ID:               36969
 Updated by:       [EMAIL PROTECTED]
 Reported By:      alan dot harder at sun dot com
-Status:           Assigned
+Status:           Bogus
 Bug Type:         PostgreSQL related
 Operating System: Debian
 PHP Version:      5.1.5
 Assigned To:      helly
 New Comment:

This is not a bug in PHP itself. As you can see below, the same thing
happens using psql (and I'm using PostgreSQL 8.2beta2). Perhaps you
should contact the Postgres guys, or perhaps distinct simply needs you
to be more specific about the type it needs to distinguish against?
$1::int works with distinct, for example.


testdb=# prepare blah as insert into test select distinct $1;
ERROR:  column "i" is of type integer but expression is of type text
HINT:  You will need to rewrite or cast the expression.

testdb=# prepare blah as insert into test select $1;         
PREPARE
testdb=#



Previous Comments:
------------------------------------------------------------------------

[2006-09-26 22:27:47] [EMAIL PROTECTED]

Assigned to the maintainer.

------------------------------------------------------------------------

[2006-08-30 18:50:24] alan dot harder at sun dot com

Tested on PHP 5.1.5.. same result.

------------------------------------------------------------------------

[2006-04-04 17:00:24] alan dot harder at sun dot com

Description:
------------
parameter given as integer but treated as text with particular sql
syntax.  remove "distinct" from the sql and it works.

Tested with PHP 5.1.2 and PHP 5.1.3-RC2

pg_version output:
array(3) { ["client"]=>  string(5) "8.1.2" ["protocol"]=>  int(3)
["server"]=>  string(6) "7.4.11" }


Reproduce code:
---------------
First in psql:
create table test (val integer);

Test code:
<?php
 $db = pg_connect('dbname=testdb');
 if (!$db) return;
 $s = pg_query_params($db, 'insert into test select distinct $1',
array(666));
 if ($s === false) {
   print pg_last_error($db);
 } else {
   print "OK\n";
 }
 pg_close($db);
?>


Expected result:
----------------
OK

Actual result:
--------------
Warning: pg_query_params() [function.pg-query-params]: Query failed:
ERROR: column "val" is of type integer but expression is of type text
HINT: You will need to rewrite or cast the expression. in
/usr/home/mindless/public_html/pgtest.php on line 5
ERROR: column "val" is of type integer but expression is of type text
HINT: You will need to rewrite or cast the expression.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=36969&edit=1

Reply via email to