view on system tables upgrade II

From: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane)
Cc: pgsql-sql(at)postgresql(dot)org
Subject: view on system tables upgrade II
Date: 2002-04-29 10:24:25
Message-ID: 200204290824.KAA19627@rodos
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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_attrdef d
WHERE d.adrelid = a.attrelid and d.adnum = a.attnum) THEN
1
ELSE
0
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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2002-04-29 14:02:12 Re: view on system tables upgrade II
Previous Message Joseph Barillari 2002-04-29 06:20:00 Temporary table weirdness