Re: [HACKERS] Arrays of Complex Types

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: David Fetter <david(at)fetter(dot)org>, Bruce Momjian <bruce(at)momjian(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Arrays of Complex Types
Date: 2007-04-09 14:40:49
Message-ID: 27676.1176129649@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> Regarding catalog objects, we might have to try a little harder than
> just not generating in bootstrap mode - IIRC we generate system views
> (including pg_stats) in non-bootstrap mode. Maybe we just need to exempt
> anything in the pg_catalog namespace. What would happen if a user
> created a view over pg_statistic?

Nothing:

regression=# create view vvv as select * from pg_statistic;
ERROR: column "stavalues1" has pseudo-type anyarray

which means we do have an issue for the pg_stats view. Now that I look
instead of guessing, the existing test in CheckAttributeType is not on
bootstrap mode but standalone mode:

/* Special hack for pg_statistic: allow ANYARRAY during initdb */
if (atttypid != ANYARRAYOID || IsUnderPostmaster)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("column \"%s\" has pseudo-type %s",
attname, format_type_be(atttypid))));

so for consistency we should use the same condition to suppress types
for system catalogs.

> Or maybe we should go to the heart
> of the problem and simply check for pseudo-types directly.

Actually we may have an issue already:

regression=# create table zzz (f1 pg_statistic);
CREATE TABLE

I couldn't make it misbehave in a short amount of trying:

regression=# insert into zzz values(row(0,0,0,0,0,0,0,0,0,0,0,0,0,array[1,2],null,null,null,array[12,13],null,null,null));
ERROR: ROW() column has type integer[] instead of type anyarray

but I don't feel comfortable about this at all. Maybe
CheckAttributeType should be made to recurse into composite columns.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-04-09 14:55:23 Re: CIC and deadlocks
Previous Message Andrew Dunstan 2007-04-09 14:14:41 Re: [HACKERS] Arrays of Complex Types

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2007-04-09 14:55:23 Re: CIC and deadlocks
Previous Message Andrew Dunstan 2007-04-09 14:14:41 Re: [HACKERS] Arrays of Complex Types