ID:               35996
 Comment by:       miksir at maker dot ru
 Reported By:      G dot Gersdorf at tu-bs dot de
 Status:           No Feedback
 Bug Type:         PostgreSQL related
 Operating System: Linux
 PHP Version:      5.1.2
 New Comment:

I'm confirm this bug in PHP 5.2.3.
Example:
postgres=# create schema a;
postgres=# create schema b;
postgres=# create table a.test(id int, field1 text);
postgres=# create table b.test(id int, field2 text);
After use pg_meta_data('test') the following statement used:
  SELECT a.attname, a.attnum, t.typname, a.attlen,
    a.attnotNULL, a.atthasdef, a.attndims
  FROM pg_class as c, pg_attribute a, pg_type t
  WHERE a.attnum > 0 AND a.attrelid = c.oid AND
    c.relname='test' AND a.atttypid = t.oid
  ORDER BY a.attnum
Return of this SELECT:
 attname | attnum | typname | attlen | attnotnull | atthasdef |
attndims
---------+--------+---------+--------+------------+-----------+----------
 id      |      1 | int4    |      4 | f          | f         |       
0
 id      |      1 | int4    |      4 | f          | f         |       
0
 field1  |      2 | text    |     -1 | f          | f         |       
0
 field2  |      2 | text    |     -1 | f          | f         |       
0


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

[2006-01-21 01:00:03] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

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

[2006-01-13 15:56:12] [EMAIL PROTECTED]

Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.




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

[2006-01-13 15:42:23] G dot Gersdorf at tu-bs dot de

Description:
------------
If a database contains tables with the same name in different schemas,
requesting the meta data for this table returns a mix for all fields in
all that tables.

The select statement use is something like
  SELECT a.attname, a.attnum, t.typname, a.attlen,
    a.attnotNULL, a.atthasdef, a.attndims
  FROM pg_class as c, pg_attribute a, pg_type t
  WHERE a.attnum > 0 AND a.attrelid = c.oid AND
    c.relname='$table' AND a.atttypid = t.oid
  ORDER BY a.attnum

but should be something like
  SELECT a.attname, a.attnum, t.typname, a.attlen,
    a.attnotNULL, a.atthasdef, a.attndims
  FROM pg_class as c, pg_attribute a, pg_type t,
      pg_namespace n
  WHERE a.attnum > 0 AND a.attrelid = c.oid AND
    c.relname='$table' AND a.atttypid = t.oid
      AND c.relnamespace=n.oid AND n.nspname='$schema'
  ORDER BY a.attnum

where $schema='public' as default



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


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

Reply via email to