pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Christoph Haller <ch@rodos.fzk.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: view on system tables upgrade II
Date: Mon, 29 Apr 2002 10:02:12 -0400
Message-ID: <23307.1020088932@sss.pgh.pa.us> (raw)
In-Reply-To: <200204290824.KAA19627@rodos>
References: <200204290824.KAA19627@rodos>

Christoph Haller <ch@rodos.fzk.de> writes:
> Sorry, but I cannot figure out where in the join 
> ...
> 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. 

The row "pg_type n" is the array type corresponding to the datatype of
the "pg_attribute a" row.  If there is no such array type, no join.
Since the select isn't actually doing anything with the "n" row, I'm
not sure why it's there at all.

Another thing that's slightly bizarre about this code is that it joins
attrelid to pg_type.typrelid, rather than pg_class.oid.  I'd be inclined
to write the join as

from pg_attribute a,
     pg_class c left join pg_user u on (u.usesysid = c.relowner)
where c.oid = a.attrelid and not (c.relname ~* 'pg_') and a.attnum > 0 ;

The outer join against pg_user guarantees that you won't miss tables
that have no owning user.

>> 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? 

1184 is timestamptz, 1114 is timestamp.  But both _timestamptz and
_timestamp are pointing at 1184 as their typelem.  I imagine this was
a cut-and-paste error...

			regards, tom lane



view thread (2+ messages)

Message-ID: <23307.1020088932@sss.pgh.pa.us>
Permalink:  ../23307.1020088932@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23307.1020088932@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ch@rodos.fzk.de
  Subject: Re: view on system tables upgrade II
  In-Reply-To: <23307.1020088932@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox