|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-07-26 05:36 UTC] leon at lost dot co dot nz
Description:
------------
Attached snippet triggers an assertion everytime:
$ php -v
PHP 5.1.0-dev (cli) (built: Jul 26 2005 15:26:09) (DEBUG)
Copyright (c) 1997-2005 The PHP Group
Zend Engine v2.1.0-dev, Copyright (c) 1998-2004 Zend Technologies
$ php bug3.php
php: /tmp/php5-200507260230/ext/pdo_sqlite/sqlite/src/auth.c:117: sqlite3AuthRead: Assertion `pExpr->op==7' failed.
Aborted
Reproduce code:
---------------
<?php
// Setup sample database
$conn = new PDO('sqlite::memory:');
$conn->exec('CREATE TABLE barrel (docid INTEGER, wordid INTEGER, position INTEGER)');
$conn->exec('CREATE TABLE documents (id INTEGER PRIMARY KEY, key TEXT UNIQUE)');
// Run problem query
$sql = "SELECT count(*) AS count, key FROM ".
"barrel, documents WHERE id == docid AND " .
"wordid == 1 GROUP BY docid ORDER BY count DESC;";
$stmt = $conn->query($sql);
$result = $stmt->fetch();
print_r($result);
?>
Expected result:
----------------
Array
(
[count] => 0
[0] => 0
[key] =>
[1] =>
)
Actual result:
--------------
php: /tmp/php5-200507260230/ext/pdo_sqlite/sqlite/src/auth.c:117: sqlite3AuthRead: Assertion `pExpr->op==7' failed.
Aborted
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 18:00:01 2025 UTC |
With all due respect, that's complete and utter nonsense. However on the postitive side, at least now I can see where you were confused. Obviously you have assumed that the error was because my choice of alias is also a function name (prehaps you should have ran the code to actually test your assumption). This turns out not to be the case. The error still occurs if I use another alias (I've also simplified the SQL to the bare minimum for you): <?php // Setup sample database $conn = new PDO('sqlite::memory:'); $conn->exec('CREATE TABLE barrel (docid INTEGER)'); // Run problem query $sql = "SELECT count(*) AS cnt FROM barrel ORDER BY cnt"; $stmt = $conn->query($sql); $result = $stmt->fetch(); print_r($result); ?> Also, the original example SQL was perfecly valid, as demonstrated by giving it to native sqlite3 command line program: $ echo "SELECT count(*) AS count,key FROM barrel, \ documents WHERE id == docid AND wordid == 3 \ GROUP BY docid ORDER BY count DESC;" | sqlite3 search.sqlite3 3|/main/library/index.html 2|/main/docs/page/printable.html 1|/main/apps/index.html ... and so on... $