php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48568 Query to SQLite fails through PDO, works otherwise
Submitted: 2009-06-16 09:48 UTC Modified: 2009-06-17 06:56 UTC
From: karsten at typo3 dot org Assigned:
Status: Closed Package: PDO related
PHP Version: 5.3.0RC3 OS: OSX 10.5.7
Private report: No CVE-ID: None
 [2009-06-16 09:48 UTC] karsten at typo3 dot org
Description:
------------
After updating to 5.3.0RC3 two unit tests started to fail which worked 
before. The same tests continue to succeed on MySQL and PostgreSQL, the 
failure only occurs with SQLite.

Reproduce code:
---------------
<?php
/*
-- put this in test.db:
CREATE TABLE "referenceproperties" (
  "parent" VARCHAR(36) NOT NULL,
  "name" TEXT NOT NULL,
  "namespace" TEXT NOT NULL DEFAULT '',
  "index" INTEGER NOT NULL DEFAULT 0,
  "value" VARCHAR(36) NOT NULL,
  PRIMARY KEY ("parent", "name", "namespace", "index")
);
CREATE TABLE "properties" (
  "parent" VARCHAR(36) NOT NULL,
  "name" TEXT NOT NULL,
  "namespace" TEXT NOT NULL DEFAULT '',
  "multivalue" BOOLEAN NOT NULL DEFAULT '0',
  "type" INTEGER NOT NULL DEFAULT 0,
  PRIMARY KEY ("parent", "name", "namespace")
);
*/

$sql = 'SELECT "properties"."parent" FROM (SELECT DISTINCT "parent" FROM "referenceproperties") AS "pv" JOIN "properties" USING ("parent")';
$databaseHandle = new \PDO('sqlite:test.db');
$databaseHandle->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$databaseHandle->prepare($sql);
?>


Expected result:
----------------
simply nothing

Actual result:
--------------
[note the doubled exception - wtf?]

kmac:~ karsten$ php test.php 
PHP Fatal error:  Uncaught exception 'PDOException' with message 
'SQLSTATE[HY000]: General error: 1 cannot join using column parent - 
column not present in both tables' in /Users/karsten/test.php:6
Stack trace:
#0 /Users/karsten/test.php(6): PDO->prepare('SELECT "propert...')
#1 {main}
  thrown in /Users/karsten/test.php on line 6

Fatal error: Uncaught exception 'PDOException' with message 
'SQLSTATE[HY000]: General error: 1 cannot join using column parent - 
column not present in both tables' in /Users/karsten/test.php:6
Stack trace:
#0 /Users/karsten/test.php(6): PDO->prepare('SELECT "propert...')
#1 {main}
  thrown in /Users/karsten/test.php on line 6


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-16 14:44 UTC] scottmac@php.net
This was a bug in libsqlite 3.6.14.2, we've updated to 3.6.15 already in CVS so it should be fixed.
 [2009-06-17 06:56 UTC] karsten at typo3 dot org
Ah, good to know. Thanks!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 13:01:30 2024 UTC