From: shade at nekto dot com
Operating system: Windows, FreeBSD
PHP version: 5.2.1
PHP Bug Type: PostgreSQL related
Bug description: pg_meta_data does not return fields description
Description:
------------
I found that pg_meta_data do not returns fields descriptions in result. I
explore sources and found that table's meta fteched by query, citated
below. I do not have free FreeBSD host for programming experiments, but i
upgrade a query little bit, adding ability to fetch description from
fields.
Can you use my query to add to pg_meta_data() ability to return field
descriptions?
Reproduce code:
---------------
Original code:
smart_str_appends(&querystr,
"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 = '");
tmp_name = php_addslashes((char *)table_name, strlen(table_name),
&new_len, 0 TSRMLS_CC);
smart_str_appendl(&querystr, tmp_name, new_len);
efree(tmp_name);
smart_str_appends(&querystr, "' AND a.atttypid = t.oid ORDER BY
a.attnum;");
smart_str_0(&querystr);
Changed code, that i proposes:
smart_str_appends(&querystr,
"SELECT a.attname, a.attnum, t.typname, a.attlen,
a.attnotNULL, a.atthasdef, a.attndims, d.description "
"FROM pg_class as c JOIN pg_attribute a on
(a.attrelid = c.oid) JOIN pg_type t on (a.atttypid = t.oid) "
"LEFT JOIN pg_description d on
(d.objoid=a.attrelid and d.objsubid=a.attnum and c.oid=d.objoid) "
"WHERE a.attnum > 0 AND c.relname = '");
tmp_name = php_addslashes((char *)table_name, strlen(table_name),
&new_len, 0 TSRMLS_CC);
smart_str_appendl(&querystr, tmp_name, new_len);
efree(tmp_name);
smart_str_appends(&querystr, "' ORDER BY a.attnum;");
smart_str_0(&querystr);
Expected result:
----------------
Information about table, including fields description (aka comments).
Actual result:
--------------
No any descriptions :(
--
Edit bug report at http://bugs.php.net/?id=41146&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=41146&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=41146&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=41146&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41146&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=41146&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41146&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41146&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41146&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41146&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41146&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=41146&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=41146&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41146&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41146&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41146&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41146&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41146&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41146&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41146&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41146&r=mysqlcfg