view on system tables upgrade II - Mailing list pgsql-sql

From Christoph Haller
Subject view on system tables upgrade II
Date
Msg-id 200204290824.KAA19627@rodos
Whole thread Raw
In response to Re: view on system tables upgrade?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: view on system tables upgrade II
List pgsql-sql
Tom Lane wrote:
>
> There's a bug in the 7.2.* pg_type table, which I found just a
> couple days ago: _timestamp has the wrong typelem.  Since your join
> assumes every datatype has an array type, it fails to find a join
> for timestamp columns.  (Should probably use an outer join there,
> rather than assuming that.) 
Sorry, but I cannot figure out where in the join 
SELECT 
upper(u.usename) AS TBL_OWNER, upper(t.typname) AS TBL_NAME, 
upper(a.attname) AS COL_NAME, a.atttypid AS COL_TYPE, 
int4larger(a.attlen, a.atttypmod - 4) AS COL_LENGTH, 
CASE WHEN a.attnotnull=true THEN 0 ELSE 1 END AS COL_NULL, a.attnum AS COL_SEQ, CASE WHEN EXISTS(SELECT adsrc FROM
pg_attrdefd WHERE d.adrelid = a.attrelid and d.adnum = a.attnum) THEN 1ELSE0 END AS COL_DEFAULT 
 
from pg_user u, pg_type t, pg_attribute a, pg_type n 
where u.usesysid = t.typowner 
and t.typrelid = a.attrelid and t.typtype = 'c' and not (t.typname ~* 'pg_') 
and n.typelem = a.atttypid 
and substr(n.typname, 1, 1) = '_' 
and a.attnum > 0 ;
I am assuming every datatype has an array type. 
Would an outer join solve the current bug? 
> 
> If you need timestamp arrays I'd suggest
> 
> UPDATE pg_type SET typelem = 1114 WHERE oid = 1115;
> 
Did the pg_attribute.atttypid resp. pg_type.typelem of timestamp change from 
1184 to 1114? 
If this bug is fixed, what would it become, 1184 or 1114? 

Regards, Christoph 


pgsql-sql by date:

Previous
From: Joseph Barillari
Date:
Subject: Temporary table weirdness
Next
From: Wayne Seward
Date:
Subject: Trying to purchase an annual subscription to the CD distribution