Skip to content

Commit 60b4b76

Browse files
committed
Patch Doltlite to keep composite-PK tables as rowid tables
Doltlite silently sets TF_WithoutRowid on every table declared with a primary key, so `SELECT rowid FROM t` fails with "no such column: rowid". The mysql-on-sqlite driver uses `ORDER BY ROWID` as a stable tie-break when reading its internal information_schema tables, so dropping rowid breaks info-schema lookups across the board. Patch by sed: replace the single `tabOpts |= TF_WithoutRowid;` line in src/build.c with a no-op, leaving table creation otherwise untouched. Verified with a PHP one-liner that a composite-PK table still returns a rowid.
1 parent af14bb3 commit 60b4b76

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

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

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

34+
- name: Patch Doltlite for mysql-on-sqlite compatibility
35+
# Narrow, verifiable source-level patches applied before build:
36+
#
37+
# 1) src/build.c — neutralize the auto-conversion of composite/TEXT-PK
38+
# tables to WITHOUT ROWID, so the driver's `ORDER BY ROWID`
39+
# tie-breaks in info-schema reads keep working.
40+
run: |
41+
BUILD=doltlite-src/src/build.c
42+
43+
# --- Patch 1: disable WITHOUT ROWID auto-conversion ---
44+
N=$(grep -cF ' tabOpts |= TF_WithoutRowid;' "$BUILD")
45+
if [ "$N" != "1" ]; then
46+
echo "::error::build.c patch: expected exactly 1 match, found $N"; exit 1
47+
fi
48+
sed -i 's@^ tabOpts |= TF_WithoutRowid;$@ /* patched off in CI: do not auto-convert composite-PK tables */ (void)0;@' "$BUILD"
49+
50+
echo "--- Patched lines ---"
51+
grep -n 'patched off in CI' "$BUILD"
52+
3453
- name: Build Doltlite shared library
3554
run: |
3655
mkdir -p build
@@ -74,7 +93,7 @@ jobs:
7493
echo "ldd pdo_sqlite:"
7594
ldd "$(php -r 'echo ini_get("extension_dir");')/pdo_sqlite.so"
7695
77-
- name: Verify Doltlite is active
96+
- name: Verify Doltlite is active and patches took effect
7897
run: |
7998
VERSION=$(php -r 'echo (new PDO("sqlite::memory:"))->query("SELECT SQLITE_VERSION()")->fetch()[0];')
8099
ENGINE=$(php -r 'echo (new PDO("sqlite::memory:"))->query("SELECT doltlite_engine()")->fetch()[0];')
@@ -84,6 +103,19 @@ jobs:
84103
echo "::error::Doltlite is not active (expected doltlite_engine() = 'prolly', got '${ENGINE}')"
85104
exit 1
86105
fi
106+
# 1) build.c patch: composite-PK tables keep rowid accessible
107+
# instead of auto-converting to WITHOUT ROWID.
108+
ROWID=$(php -r '
109+
$db = new PDO("sqlite::memory:");
110+
$db->exec("CREATE TABLE t (a INT, b INT, PRIMARY KEY(a, b))");
111+
$db->exec("INSERT INTO t VALUES (1, 2)");
112+
echo $db->query("SELECT rowid FROM t")->fetch()[0];
113+
' 2>&1)
114+
echo "composite-PK rowid = ${ROWID}"
115+
if ! [[ "${ROWID}" =~ ^[0-9]+$ ]]; then
116+
echo "::error::rowid-preservation patch did not take effect: ${ROWID}"
117+
exit 1
118+
fi
87119
88120
- name: Install Composer dependencies (root)
89121
uses: ramsey/composer-install@v3

0 commit comments

Comments
 (0)