From 63bd8f38f4b7e8ffbcbd0ea607e21041ebba2455 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 2 Jun 2020 09:36:39 +0200 Subject: Fix #79664: PDOStatement::getColumnMeta fails on empty result set As its name suggests, `sqlite3_data_count` returns the number of columns in the current row of the result set; we are interested in the number of columns regardless of the current row, so we have to use `sqlite3_column_count` instead. --- ext/pdo_sqlite/tests/bug79664.phpt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ext/pdo_sqlite/tests/bug79664.phpt (limited to 'ext/pdo_sqlite/tests') diff --git a/ext/pdo_sqlite/tests/bug79664.phpt b/ext/pdo_sqlite/tests/bug79664.phpt new file mode 100644 index 0000000000..072d107ba6 --- /dev/null +++ b/ext/pdo_sqlite/tests/bug79664.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #79664 (PDOStatement::getColumnMeta fails on empty result set) +--SKIPIF-- + +--FILE-- + PDO::ERRMODE_EXCEPTION, +]); +$stmt = $pdo->query('select 1 where 0'); +if ($stmt->columnCount()) { + var_dump($stmt->getColumnMeta(0)); +} +?> +--EXPECT-- +array(6) { + ["native_type"]=> + string(4) "null" + ["flags"]=> + array(0) { + } + ["name"]=> + string(1) "1" + ["len"]=> + int(4294967295) + ["precision"]=> + int(0) + ["pdo_type"]=> + int(2) +} -- cgit v1.2.1