From e2a0aa3c59d700d0ecdd177dd9d91e0bd6e104db Mon Sep 17 00:00:00 2001 From: Roman Konz Date: Sat, 2 May 2026 00:19:26 +0200 Subject: [PATCH] fix: route hasIndex() through information_schema (#89) MysqliDriver::hasIndex() executed `SHOW INDEX ... WHERE Key_name = ?` through the prepared-statement protocol, which Dolt rejects. The table name was also interpolated into the SQL string unfiltered. Replace with a parameterised SELECT against information_schema.statistics, binding both the table and index name. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/Driver/MysqliDriver.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Driver/MysqliDriver.php b/src/Driver/MysqliDriver.php index 2801720a..4b3c8ecd 100755 --- a/src/Driver/MysqliDriver.php +++ b/src/Driver/MysqliDriver.php @@ -444,7 +444,17 @@ public function createIndex(string $table, string $name, array $columns, bool $u #[Override] public function hasIndex(string $table, string $name): bool { - $index = iterator_to_array($this->getPArray("SHOW INDEX FROM $table WHERE Key_name = ?", [$name]), false); + $index = iterator_to_array( + $this->getPArray( + 'SELECT 1 FROM information_schema.statistics + WHERE table_schema = DATABASE() + AND table_name = ? + AND index_name = ? + LIMIT 1', + [$table, $name], + ), + false, + ); return count($index) > 0; }