Skip to content
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

Not all rows are returned when encountering an empty string in the first column #162

Closed
NeKzor opened this issue Sep 13, 2023 · 4 comments · Fixed by #163
Closed

Not all rows are returned when encountering an empty string in the first column #162

NeKzor opened this issue Sep 13, 2023 · 4 comments · Fixed by #163

Comments

@NeKzor
Copy link

NeKzor commented Sep 13, 2023

What a waste of time this was to debug just to find out that this library cannot handle simple select queries. The current workaround is to select another column that cannot contain an empty string before the column that could contain an empty string. This is a big problem when you select large amounts of data from a table and nobody would notice that the data is incomplete! I actually wonder now where the issue is...

Minimal reproducible example:

const rows = await db.query(`select '' as a`);
console.log(rows);

Actual output:

INFO connecting 127.0.0.1:3307
INFO connected to 127.0.0.1:3307
[]
INFO close connection

Here is a working example with npm:mysql2/promise:

const [rows] = await db.query(`select '' as a`);
console.log(rows);

Expected output:

[ { a: "" } ]

Used Deno version:

deno 1.36.4 (release, x86_64-unknown-linux-gnu)
v8 11.6.189.12
typescript 5.1.6

Used database images from Docker Hub:

  • mariadb:11.1
  • mariadb:11
  • mariadb:10
  • mysql:8
  • mysql:5
@NeKzor
Copy link
Author

NeKzor commented Sep 13, 2023

Oh wow, it looks like this is a regression caused by e3359d0 (PR #140).
CC @shiyuhang0 @lideming

@lideming
Copy link
Collaborator

@NeKzor Thanks for reporting this.

it looks like this is a regression caused by e3359d0 (PR #140).

You are right. The packet header byte is always 0xfe whether it's an EOF_Packet or an OK_Packet representing EOF.

@NeKzor
Copy link
Author

NeKzor commented Sep 13, 2023

Thanks for the really fast fix! It's working again in v2.12.1.

@shiyuhang0
Copy link
Contributor

Sorry for the mistake. I think mysql/mariadb may not following the https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_ok_packet.html.
I also see the replacement of eof is not that easy in go-sql-driver/mysql#1153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants