php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41860 Identifiers should be double quoted
Submitted: 2007-06-29 23:34 UTC Modified: 2007-07-03 03:34 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: brian at derocher dot org Assigned:
Status: Wont fix Package: PostgreSQL related
PHP Version: 5.2.3 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
29 - 8 = ?
Subscribe to this entry?

 
 [2007-06-29 23:34 UTC] brian at derocher dot org
Description:
------------
Quoting table names and other identifiers is needed because they are 
case-sensitive in PostgreSQL.  As Marco pointed out reserved words 
also need to be quoted.

See section 4.1.1. Identifiers and Key Words
http://www.postgresql.org/docs/8.1/static/sql-syntax.html#SQL-SYNTAX-IDENTIFIERS

I'm not sure why sniper@php.net marked bug #28020 as bodus 3 years 
ago.

Reproduce code:
---------------
$Conn = pg_connect( "dbname=db" );

pg_query( $Conn, "insert into \"caseTest\" (foo) values (2)" ); // works
//pg_query( $Conn, "insert into   caseTest   (foo) values (2)" ); // fails correctly


echo pg_insert( $Conn, 'caseTest', array( 'foo' => 1 ), PGSQL_DML_STRING );
// INSERT INTO caseTest (foo) VALUES (1);

if (pg_insert( $Conn, 'caseTest', array( 'foo' => 1 ) ))
        echo 'success';
else
        echo 'failure';


Expected result:
----------------
 INSERT INTO caseTest (foo) VALUES (1);success

db=# select * from "caseTest";
 foo
-----
   2
   1
(2 rows)

Actual result:
--------------
 INSERT INTO caseTest (foo) VALUES (1);failure

db=# select * from "caseTest";
 foo
-----
   2
(1 row)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-02 15:51 UTC] iliaa@php.net
This fix would break backwards compatibility for people relying on the 
case-insensetive behavior.
 [2007-07-03 03:34 UTC] brian at derocher dot org
pg_insert(), pg_select(), pg_delete(), and pg_update() are marked as 
EXPERIMENTAL.  Nobody should be relying on them since they are 
subject to change.  Now's the time to fix the bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 17:01:30 2024 UTC