Skip to content

db.mysql query and real_query with ConnectionFlag.client_multi_statements makes the Connection instance useless #18061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
einar-hjortdal opened this issue Apr 26, 2023 · 0 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@einar-hjortdal
Copy link
Contributor

Describe the bug

When creating a mysql.Connection using the ConnectionFlag.client_multi_statements, executing a query with multiple statements returns multiple resoluts.
The mysql wrapper lacks the ability to fetch all the results, because it does not wrap mysql_more_results() nor mysql_next_result().
Because these results aren't fetched, they remain allocated and the connection cannot be reused for any new statement without triggering a V panic: Commands out of sync; you can't run this command now; code: 2014
This problem forces to create independent connections whenever a query with multiple statements needs to be run.

Expected Behavior

Results should be able to be fetched and memory cleared.
The execution of a new query in the same connection should be possible.

Current Behavior

V panic: Commands out of sync; you can't run this command now; code: 2014

Reproduction Steps

file_data := os.read_file(file_path)!
mysql_conn.real_query(file_data)!
// Here one would loop through all results until no more results are available
// and then call mysql_free_result()
mysql_conn.real_query(query_string)!

Possible Solution

Wrap mysql_more_results() nor mysql_next_result().

Ideally the functions available already should include these functions and return an array of results instead, calling mysql_free_result() automatically. This is because mysql_free_result() requires an unsafe block which is no good for basic V users.

Additional Information/Context

No response

V version

Current V version: V 0.3.3 0a8a0fd, timestamp: 2023-03-25 14:38:47 +0200

Environment details (OS name and version, etc.)

V full version: V 0.3.3 ee4150f.c4b34c9
OS: linux, Linux version 5.14.0-162.23.1.el9_1.x86_64 (mockbuild@pp-el9) (gcc (GCC) 11.3.1 20220421 (Red Hat 11.3.1-2), GNU ld version 2.35.2-24.el9) #1 SMP PREEMPT_DYNAMIC Wed Apr 12 16:23:09 UTC 2023
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i3-5005U CPU @ 2.00GHz

getwd: /home/coachonko/Documents/projects/vlang/peony
vexe: /home/coachonko/.local/lib64/v/v
vexe mtime: 2023-04-26 09:47:45

vroot: OK, value: /home/coachonko/.local/lib64/v
VMODULES: OK, value: /home/coachonko/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.31.1
Git vroot status: weekly.2023.15-62-gc4b34c94
.git/config present: true

CC version: cc (GCC) 11.3.1 20220421 (Red Hat 11.3.1-2)
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3
@einar-hjortdal einar-hjortdal added the Bug This tag is applied to issues which reports bugs. label Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

1 participant