Skip to content

Commit ab029f2

Browse files
committed
Experiment: patch Doltlite to skip WITHOUT ROWID auto-conversion
Doltlite auto-converts tables with composite/TEXT primary keys to WITHOUT ROWID, which strips the ROWID column and breaks the driver's ORDER BY ROWID tie-breaks in info-schema reads. The auto-conversion is a single tabOpts |= TF_WithoutRowid in src/build.c. Sed that line to a no-op before building so composite-PK tables take SQLite's normal rowid + unique-PK-index path, and assert at runtime that a composite-PK test table exposes a rowid.
1 parent 8a191d0 commit ab029f2

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

.github/workflows/phpunit-tests-doltlite.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ jobs:
3131
repository: dolthub/doltlite
3232
path: doltlite-src
3333

34+
- name: Disable Doltlite's auto-conversion of PK tables to WITHOUT ROWID
35+
# Experimental: Doltlite normally auto-converts tables with a
36+
# non-INTEGER / composite PK to WITHOUT ROWID, which strips `ROWID`.
37+
# The mysql-on-sqlite driver uses `ORDER BY ROWID` as a tie-break in
38+
# its info-schema reads, so that auto-conversion produces hundreds
39+
# of "no such column: ROWID" failures. We neutralize the single
40+
# assignment in src/build.c that flips TF_WithoutRowid on so those
41+
# tables take SQLite's normal rowid+unique-PK-index path.
42+
run: |
43+
FILE=doltlite-src/src/build.c
44+
BEFORE=$(grep -cF ' tabOpts |= TF_WithoutRowid;' "$FILE")
45+
if [ "$BEFORE" != "1" ]; then
46+
echo "::error::expected exactly 1 match for the auto-convert line, found $BEFORE"
47+
exit 1
48+
fi
49+
# Use @ as sed delimiter because the match contains `|=`.
50+
sed -i 's@^ tabOpts |= TF_WithoutRowid;$@ /* patched off in CI: do not auto-convert composite-PK tables */ (void)0;@' "$FILE"
51+
echo "Patched line:"
52+
grep -n 'patched off in CI' "$FILE"
53+
3454
- name: Build Doltlite shared library
3555
run: |
3656
mkdir -p build
@@ -74,7 +94,7 @@ jobs:
7494
echo "ldd pdo_sqlite:"
7595
ldd "$(php -r 'echo ini_get("extension_dir");')/pdo_sqlite.so"
7696
77-
- name: Verify Doltlite is active in PHP
97+
- name: Verify Doltlite is active in PHP and rowid patch took effect
7898
run: |
7999
VERSION=$(php -r 'echo (new PDO("sqlite::memory:"))->query("SELECT SQLITE_VERSION()")->fetch()[0];')
80100
ENGINE=$(php -r 'echo (new PDO("sqlite::memory:"))->query("SELECT doltlite_engine()")->fetch()[0];')
@@ -84,6 +104,20 @@ jobs:
84104
echo "::error::Doltlite is not active (expected doltlite_engine() = 'prolly', got '${ENGINE}')"
85105
exit 1
86106
fi
107+
# Confirm the build.c patch took effect: a composite-PK table
108+
# would normally be auto-converted to WITHOUT ROWID (no rowid
109+
# column); with the patch, rowid should be accessible.
110+
ROWID=$(php -r '
111+
$db = new PDO("sqlite::memory:");
112+
$db->exec("CREATE TABLE t (a INT, b INT, PRIMARY KEY(a, b))");
113+
$db->exec("INSERT INTO t VALUES (1, 2)");
114+
echo $db->query("SELECT rowid FROM t")->fetch()[0];
115+
' 2>&1)
116+
echo "composite-PK rowid = ${ROWID}"
117+
if ! [[ "${ROWID}" =~ ^[0-9]+$ ]]; then
118+
echo "::error::rowid-preservation patch did not take effect: ${ROWID}"
119+
exit 1
120+
fi
87121
88122
- name: Install Composer dependencies (root)
89123
uses: ramsey/composer-install@v3

0 commit comments

Comments
 (0)