for Varied size datatypes (varchar, text, etc) you can get the max data length from the system table pg_attribute.atttypmod -4eg. select attnum, attname , atttypmod -4 as field_len from pg_attribute, pg_class where relname='$tablename' and attrelid=relfilenode and attnum>=1

When querying on meta data from a temp table, the meta data seems to persist even if a fresh connection is established, where the temp table no longer exists.

For example, if you create a connection and a temp table like so:$dbconn1 = pg_connect('blah blah', , PGSQL_CONNECT_FORCE_NEW);pg_exec($dbconn1,'create temp table foo as select 'foo' as namecol, 'bar' as valcol');

Then create a new connection

$dbconn2 = pg_connect('blah blah', , PGSQL_CONNECT_FORCE_NEW);

And query the meta data for table 'foo' in this new connection, it will report the facts about this table:pg_meta_data($dbconn2,'foo');

"'Array ( [foo] => Array ( [num] => 1 [type] => varchar... "

However, trying to remove this table:pg_exec($dbconn,'drop table foo');

Throws an error:pg_exec(): Query failed: ERROR: table "foo" does not exist in ...