Re: [HACKERS] Arrays of Complex Types

From: David Fetter <david(at)fetter(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, 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-08 23:32:22
Message-ID: 20070408233222.GA21511@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Sun, Apr 08, 2007 at 07:08:38PM -0400, Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> > One of the things that's been bothering me about this proposal is that
> > it leaves untouched and indeed greatly expands the scope of the typename
> > mangling we do. (i.e. adding an entry to pg_type with _ prepended).
>
> Yeah, that's been bothering me too. One of the problems with the patch
> as-is is that it extends the 62-instead-of-63-char limit to table names
> as well as type names.

I did this by copying some code which already creates array names, so
should that code change to do something different, the
62-instead-of-63-char thing would go away along with it. I agree that
the prepended _s are far from optimal.

> I've been thinking of proposing that we add a column to pg_type that
> points from a type to its array type (if any), ie the reverse link
> from typelem. If we had that then the parser could follow that to
> determine which type is foo[], instead of relying on the _foo naming
> convention. I don't suggest that we stop using the naming convention,
> but it would no longer be a hard-and-fast rule, just a convention.

That'd be neat :)

> In particular we could rejigger things around the edges to reduce
> the name conflict problem. For instance the rule for forming array type
> names could be "prepend _, truncate to less than 64 bytes if necessary,
> then substitute numbers at the end if needed to get something unique".
> This is not all that different from what we do now to get unique
> serial sequence names, for example.
>
> This would also open the door to supporting
>
> CREATE TYPE foo AS ARRAY OF bar

I'm sorry to keep harping on this, but I really don't see a use case
and do see foot guns both with making the array types optional and
with decoupling their names from those of their respective compound
types. When they're optional, we get all kinds of "stepping on a step
that isn't there" issues, and when they're decoupled, operations like,
"ALTER TABLE foo RENAME TO bar" have either surprising or undefined
behavior, or both.

> without having to have any restrictions about the name of foo.
> I'd still much rather do things that way for arrays of composites
> than invent a ton of pg_type entries that are mostly going to go
> unused.

I'm sure there's a better way than my first attempt.

> PS: Has anyone looked at what it will take to make the entries in an
> array-of-composite be something smaller than full tuples? It's not
> going to be anything but a toy unless you can get the per-entry
> overhead down to something sane. Perhaps the MinimalTuple
> representation would work.

Sounds neat, too :)

Cheers,
D
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter

Remember to vote!
Consider donating to PostgreSQL: http://www.postgresql.org/about/donate

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2007-04-08 23:36:17 Re: [HACKERS] Arrays of Complex Types
Previous Message Tom Lane 2007-04-08 23:08:38 Re: [HACKERS] Arrays of Complex Types

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2007-04-08 23:36:17 Re: [HACKERS] Arrays of Complex Types
Previous Message Tom Lane 2007-04-08 23:08:38 Re: [HACKERS] Arrays of Complex Types