php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42078 pg_meta_data mix tables metadata from different schemas
Submitted: 2007-07-23 11:16 UTC Modified: 2008-10-16 00:45 UTC
From: miksir at maker dot ru Assigned: helly (profile)
Status: Closed Package: PostgreSQL related
PHP Version: 5.2.3 OS: Linux
Private report: No CVE-ID: None
 [2007-07-23 11:16 UTC] miksir at maker dot ru
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.
Related to bug #35996 http://bugs.php.net/35996

Reproduce code:
---------------
mydb=# create schema a;
mydb=# create schema b;
mydb=# create table a.test(id int, field1 text);
mydb=# create table b.test(id int, field2 text);

In PHP connect to `mydb' with user `a' (search_path will be set to schema a) or with different user and say "set search_path = 'a';". Use pg_meta_data('test') for get table metadata.

Expected result:
----------------
a.test metadata:
 attname | attnum | typname | attlen | attnotnull | atthasdef |att...
---------+--------+---------+--------+------------+-----------+-----
 id      |      1 | int4    |      4 | f          | f         |    0
 field1  |      2 | text    |     -1 | f          | f         |    0


Actual result:
--------------
mix of a.test and b.test metadata:
 attname | attnum | typname | attlen | attnotnull | atthasdef |att...
---------+--------+---------+--------+------------+-----------+-----
 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-17 20:26 UTC] jani@php.net
Marcus, this ought to be simple fix. Just add an optional parameter to pass the schema with and use that if passed..?

Bug #35996 had some sort of improved query to get the metadata.
As I don't use pgsql, I don't want to mess with the code either. :)

 [2008-10-16 00:45 UTC] felipe@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 08:01:29 2024 UTC