Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 8F752475A6F for ; Mon, 29 Apr 2002 10:04:00 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 5CCEA475B08 for ; Mon, 29 Apr 2002 10:02:37 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g3TE2DF23310; Mon, 29 Apr 2002 10:02:13 -0400 (EDT) To: Christoph Haller Cc: pgsql-sql@postgresql.org Subject: Re: view on system tables upgrade II In-reply-to: <200204290824.KAA19627@rodos> References: <200204290824.KAA19627@rodos> Comments: In-reply-to Christoph Haller message dated "Mon, 29 Apr 2002 10:24:25 +0700" Date: Mon, 29 Apr 2002 10:02:12 -0400 Message-ID: <23307.1020088932@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200204/356 X-Sequence-Number: 7620 Christoph Haller 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