#35996 [Opn->Fbk]: pg_meta_data should take the schema into account
| From: | tony2001@php.net | Date: | Fri, 13 Jan 2006 14:56:14 +0000 |
| Subject: | #35996 [Opn->Fbk]: pg_meta_data should take the schema into account | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-91850@lists.php.net to get a copy of this message | ||
ID: 35996
Updated by: tony2001@php.net
Reported By: G dot Gersdorf at tu-bs dot de
-Status: Open
+Status: Feedback
Bug Type: PostgreSQL related
Operating System: Linux
PHP Version: 5.1.2
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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