Repository navigation
Conversation
The output buffer of a string or blob column was bound empty, and each value was fetched again with the reported length. MySQL's libmysqlclient converts a floating-point value to a string no longer than the buffer, so a DOUBLE value of a column typed as a string, such as a placeholder with a MySQL server, was read as an empty string. The buffer now holds 256 bytes, and only a longer value is fetched again in full. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
…vers A MySQL server reports a placeholder result column as a non-binary string at prepare time, and its actual type after the execution. Such columns now follow the type reported after the execution, as placeholder columns of type NULL do with MariaDB (#604). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
Tests whose purpose is not placeholder typing cast their placeholders, `SELECT ? + 1` expects integer64 with MySQL, and the fetch error test uses a regular table, because MySQL cannot refer to a temporary table twice in one query. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
With a MySQL server, an integer parameter gives a BIGINT column, and a NULL parameter keeps the type of the previous execution, which is a string for the first parameter set. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
A query on the same connection cancels a pending result. The comment on placeholder columns documents MySQL's typing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
…ULL (#638) With MySQL, a NULL parameter in the first set gives a string column. A later set of another type no longer errors for such a column, its values are fetched as strings. A column with a non-NULL value in the first set still errors on a type change. The tests now call MySQL's silent conversion of 'a' a known server limitation and use ASCII bytes for the blob parameter. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
…638) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
…lumn that was NULL first (#638) The override that keeps such a column a string no longer applies when a later set reports a binary type. Its bytes would otherwise be read as a string. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
…olders (#638) With MariaDB, the blob test uses the bytes 00 and ff again. With MySQL, a blob parameter gives a string column, the test uses valid UTF-8 control bytes and checks a set without NULL too. A new MySQL-only test checks that a NUL byte after a NULL first set fails the fetch instead of returning a corrupt string. The leading-NA test adds 0.1, which is not exact in binary. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
The removed test expected R's "embedded nul" error from inside the fetch, which locks in the behavior that #642 tracks. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
Superseded: A leading
|
Accepted limitationsThree review rounds. The first found two Mediums: a leading
Generated by Claude Code |
…ion columns (#638) A server counts as MariaDB when its version is 10.0 or later or its version string mentions MariaDB, so that a proxy or an overridden version string does not misroute it. Lowercasing goes through unsigned char. On MySQL, only string columns without an origin table, expressions and placeholders, have their metadata re-read per parameter set; table columns keep their type. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
…638) MariaDB servers again test a bare integer placeholder with integer results, MySQL servers keep the CAST(). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
| dbGetQuery(con, "SELECT ? AS x", params = list(NA_character_))$x, | ||
| NA_character_ | ||
| ) | ||
| expect_identical( |
There was a problem hiding this comment.
Just skip this test on MySQL.
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
| dbGetQuery(con, "SELECT ? AS x", params = list(c(1.5, NA, 2.5)))$x, | ||
| c(1.5, NA, 2.5) | ||
| ) | ||
| if (is_mariadb_server(con)) { |
There was a problem hiding this comment.
Same here: document MySQL as odd-behaving and just skip the test, assuming we can't do anything about it.
There was a problem hiding this comment.
Doing this for every test in test-dbBind-types.R that differs between the servers: they become MariaDB-only, and a new dbBind() section documents how MySQL types placeholder columns. One small test still runs on both servers, so that the empty-string bug for doubles and dates (#638) stays covered on MySQL.
We could do something about the leading NA: re-preparing the statement when a later parameter set has another type would give correct types, at the cost of a prepare per type change and more code. That is the third option in the question. Until it is decided, this PR returns strings there and documents it.
Generated by Claude Code
| out <- dbGetQuery(con, "SELECT ? AS x", params = params) | ||
| expect_identical(out$x, blob::blob(NULL, as.raw(c(0, 255)))) | ||
| } else { | ||
| # MySQL types a blob parameter as a string in the connection's charset, |
Tests of placeholder typing run with MariaDB servers only, one test checks double and date placeholders on both servers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
| con <- mariadbDefault() | ||
| on.exit(dbDisconnect(con)) | ||
|
|
||
| # At prepare time, MariaDB reports DOUBLE for `? + 1`, MySQL reports BIGINT |
There was a problem hiding this comment.
This test may be ill-formed. Can we cast instead of just assuming, or create a temporary table?
There was a problem hiding this comment.
Or perhaps use dbConnect(bigint = "integer") for this test?
…sumptions (#638) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
| ) | ||
| expect_s3_class(out$b, "blob") | ||
| expect_identical(out$y, 1L) | ||
| if (is_mariadb_server(con)) { |
There was a problem hiding this comment.
The tests below are about placeholder-only columns (? AS y next to NULL or BINARY(0), and IF(?, ?, ?)). Placeholder typing is exactly what MySQL does differently, so a cast would remove what they test. Since 518656a they are MariaDB-only, with the MySQL behavior documented in ?dbBind (5809634). The known-type test above is the one that only assumed server typing, and cf4ca65 rewrites it with a typed temporary table that runs on both servers. CI for the new head is running.
Generated by Claude Code
| sql <- "SELECT ? AS a, ? AS b" | ||
| expected <- data.frame(a = 1L, b = 2L) | ||
| } else { | ||
| sql <- "SELECT CAST(? AS CHAR) AS a, CAST(? AS CHAR) AS b" |
There was a problem hiding this comment.
For this test, the second form might be portable.
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
Keep this branch's MySQL handling of the tests and drop main's skip_if_mysql_server(), which no test uses here any more. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
|
I don't understand this PR. New PR: Reduce the problem to a reproducer in plain C against libmariadb/libmysql and MariaDB or MySQL. Attempt to find solutions in plain C first. Prepare a special GitHub workflow for testing this. Record as an experiment. |
|
Understood. Work on this PR is paused. A new PR from Generated by Claude Code |
|
The red "macos-latest (release) mysql_config" job on 702f863 (job) is not this PR's code. The MariaDB server on the macOS runner never accepted connections, so every test that connects failed with "Can't connect to MySQL server on '127.0.0.1:3306' (61)" ( Generated by Claude Code |
|
The plain-C experiment is up as #646. In short: the empty string buffer truncates converted doubles on both clients and both servers (1.5 → Generated by Claude Code |
|
Correction to my earlier comment: the red macOS job is not this PR's, but it isn't a Homebrew setup problem either. The server stops accepting connections during the #621 interrupt test in Generated by Claude Code |
|
Rebuild fix from findings. |
|
Rebuilding from the findings of #646 on a new branch from Generated by Claude Code |
|
The rebuilt fix is up as draft #656, from Generated by Claude Code |
|
Abandoning in favor of #656. |
Fixes #638.
On a MySQL 8.4 server,
SELECT ? AS xwith 1.5 returned"". Integer andDateparameters came back as character, and 23 tests failed in CI's "MySQL server" job.src/MariaRow.cpp): string and blob columns were bound with an empty buffer, then fetched again at the length the client reported. When libmysqlclient converts a DOUBLE to a string, it writes no more characters than the buffer holds, so it reported length 0 and the value came back empty. String and blob columns are now bound to a 256-byte buffer. Only longer values are fetched again in full withmysql_stmt_fetch_column(), into a separate buffer, so the bound one never moves. This applies to every column and also saves the second fetch MariaDB used to do for every non-empty string. The newtest-fetch-length.Rcovers lengths 0 to 5000 for strings and blobs.src/MariaResultPrep.cpp): MySQL reports a?column as VARCHAR when the statement is prepared, but gives the real type after execution. On a MySQL server (detected withmysql_get_server_info()), non-binary string columns now take their type from the metadata after execution, so 1.5 comes back as double and a date asDate. A real VARCHAR column stays a string. MariaDB servers are unchanged (fix: Read result types afterdbBind(), so that placeholder columns keep their values #618's handling).NAon MySQL: a column whose first parameter set is allNULLis a string there, and MySQL keeps that type. Such a column stays character, soc(NA, 0.1, 2.5)returnsc(NA, "0.1", "2.5"), see the question. Every other type change, including one to a binary type, still fails with the type-mismatch error.is_mariadb_server()helper.test-dbBind-types.Rexpects MySQL's behavior where it really differs:integer64for integer parameters, and the server's silent conversion inIF(?, ?, ?), commented as a server limitation.test-dbBind.Randtest-dbBind-completed.RuseCAST(? AS CHAR), because what they test isn't placeholder typing.test-fetch-error.Ruses a regular table, because MySQL can't reference aTEMPORARYtable twice in one query.Blob parameters on MySQL come back as strings, without a UTF-8 check, as on
main; that is #642.Tests: the local database server is down, so this was tested in CI only, with dispatched runs of the full matrix. Job status is not reliable here (a job can pass with a failing test), so each server job's log was checked for
[ FAIL 0. At 337db3d, all 26 jobs passed and the MySQL, "MariaDB server, MySQL client" and "MariaDB server + client" jobs had FAIL 0: run 46281404509. cbcc9aa only removes a test, and its run is pending.Accepted limitations
https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
Generated by Claude Code