Details
-
Bug
-
Status: In Review (View Workflow)
-
Minor
-
Resolution: Unresolved
-
12.3.3
-
None
-
Linux/amd64; source revision bdf154a3638d54a4d210e2a28962927581c02ef2
Description
Source inspection of MariaDB 12.3.3 shows that a plus sign followed by an apostrophe inside an ordinary C-style comment makes mysqltest treat the apostrophe as the start of quoted text. This hides the first semicolon from delimiter processing and causes mysqltest to combine the two statements. Under --ps-protocol, the combined text is then expected to be rejected as a multi-statement prepare. This is source-supported; mysqltest itself was not available for runtime execution in the verification environment. The server-side SQL parser is not affected.
This occurs when an ordinary C-style comment contains + or ! after the comment introducer, followed by an unmatched quote-like character before the statement delimiter.
Save the following three files in an empty directory.
case.test:
SELECT 74 AS first /* arithmetic + isn't executable */; |
SELECT 75 AS second; |
case.result:
SELECT 74 AS first /* arithmetic + isn't executable */;
|
first
|
74
|
SELECT 75 AS second;
|
second
|
75
|
run.sh:
#!/usr/bin/env bash
|
set -euo pipefail |
|
|
if [[ $# -ne 1 ]]; then |
echo "usage: $0 /path/to/mariadb-source" >&2 |
exit 2 |
fi
|
|
|
src=$(realpath "$1") |
here=$(cd "$(dirname "$0")" && pwd) |
build="$here/build" |
suite="$here/mysql-test/suite/comment_boundary" |
|
|
mkdir -p "$build" "$suite/t" "$suite/r" |
cp "$here/case.test" "$suite/t/comment_boundary.test" |
cp "$here/case.result" "$suite/r/comment_boundary.result" |
|
|
cmake -S "$src" -B "$build" \ |
-DCMAKE_BUILD_TYPE=Debug \
|
-DWITHOUT_SERVER=OFF \
|
-DWITH_UNIT_TESTS=OFF
|
cmake --build "$build" --parallel --target mariadbd mysqltest |
|
|
runner="$src/mysql-test/mariadb-test-run.pl" |
common=(--mem --basedir="$build" --vardir="$here/var" --suite="$suite") |
|
|
perl "$runner" "${common[@]}" comment_boundary |
perl "$runner" "${common[@]}" --ps-protocol comment_boundary |
With CMake, a C/C++ toolchain, Perl, and MariaDB's normal build dependencies installed, run:
chmod +x run.sh |
./run.sh /path/to/mariadb-source |
Correct behavior is for both invocations to exit successfully and produce first=74 and second=75 once each as separate statements. The supplied result file is the oracle for that behavior. The frozen runtime evidence only executed the same two SELECT statements through the server-side SQL interface, where they returned 74 and 75 successfully; that control does not exercise mysqltest's lexer.
In client/mysqltest.cc, mysqltest enters R_CSTYLE_COMMENT after /* but changes to R_HINT upon any later + or Unable to render embedded object: File (}}, without requiring the character to occur at the comment introducer. In this case, the apostrophe in {{isn't}} is consequently processed as a quote, so the first semicolon is not recognized as the statement delimiter. Only {{/*+}} and {{/*) not found. at the introducer should enable special-comment processing; later characters in an ordinary comment should remain lexically inert.