Re: [HACKERS] Re: [SQL] Column name's length

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Cc: Zalman Stern <zalman(at)netcom(dot)com>
Subject: Re: [HACKERS] Re: [SQL] Column name's length
Date: 1999-06-01 21:52:34
Message-ID: 23827.928273954@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

We've seen this table-name-plus-column-name-too-long problem before,
and I'm sure we're going to keep hearing about it until we fix it
somehow. Messing with NAMEDATALEN is probably not a very useful
answer for the average user, given the compatibility problems it
creates.

How about something like this: if the code finds that the names are
too long when forming an implicit index name, it truncates the names
to fit, and you are OK as long as the truncated name is unique.
For example

create table averylongtablename (averylongfieldname serial);

would truncate the input names to produce something like

averylongtable_averylongfie_key
averylongtable_averylongfie_seq

and you'd only get a failure if those indexes/sequences already existed.
(Truncating both names as shown above, not just the field name,
should reduce the probability of collisions.)

You could even imagine trying a few different possibilities in order
to find an unused name, but that worries me. I'd rather that it were
completely predictable what name would be used for a given key, and if
it depends on what already exists then it wouldn't be so predictable.
But there's nothing unpredictable about truncation to fit a known
length.

This is obviously not a 100% solution, since there's a risk of name
collisions (averylongfieldname1 and averylongfieldname2) but it's
probably a 95% solution, and it wouldn't take much work or risk.

Comments? Objections? I think I could argue that this is a bug fix
and deserves to be slipped into 6.5 ;-)

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zalman Stern 1999-06-01 23:34:59 Re: [HACKERS] Re: [SQL] Column name's length
Previous Message Tom Lane 1999-06-01 21:26:09 Re: [HACKERS] variables in psql