Re: RFC for adding typmods to functions

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Subject: Re: RFC for adding typmods to functions
Date: 2009-11-18 01:15:29
Message-ID: 603c8f070911171715v456248bar891e1fe0afff457d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 17, 2009 at 7:46 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> So I guess really can't get worked up about the idea of propagating
>> this information through the type system.  Even suppose we eventually
>> take the steps you suggesting and make it so that varchar(30) ||
>> varchar(40) yields varchar(70).  What good is that?  Why would anyone
>> care?
>
> People have complained that we don't follow the spec on this.  Not many
> people, perhaps, and it's certainly arguable that fixing this will be
> far more trouble than it's worth.  But there is a constituency that
> cares --- mainly people who use client-side code that tends to fall over
> if it doesn't see a suitable maxlength attached to query result columns.
> The first example I came across in the archives was
> http://archives.postgresql.org/pgsql-sql/2002-06/msg00235.php
> [ pokes around a bit more ... ]  Hm, I don't see any *recent* examples.
> Maybe all that code has gotten fixed?  Nah ...
>
>> What would actually be really nice is the ability to have
>> parameterized types (like list-of-<some type>,
>> unordered-set-of-<type>, hash-with-keys-of-<some
>> type>-and-values-of-<some type>, function-taking-arguments-of-<various
>> types>-returning-<some type>) which would let us do all kinds of neat
>> things - but I don't see how improving support for typmods gets us any
>> closer to that.
>
> Well, we could possibly implement hacks like the current one for
> anonymous record types.  But SQL isn't intended as a language for
> manipulating arbitrary data types, and I think trying to make it
> do stuff like the above will be an exercise in masochism.

Unfortunately, I kind of agree with you. As much as I'd like to have
this, I wouldn't like it enough to seriously consider working on it at
this point.

> typmod
> is mainly intended for tweaking the properties of base types, and
> it seems fairly useful for that.

"tweaking" certainly describes how we're using it, and perhaps why
it's not worth putting a lot of effort into it. If we're going to do
a lot of work, I'd like to get something better than
slightly-improved-tweaking out of it.

...Robert

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Euler Taveira de Oliveira 2009-11-18 01:33:59 Re: Very bad FTS performance with the Polish config
Previous Message Robert Haas 2009-11-18 01:12:47 Re: Syntax for partitioning