Re: BUG #13659: Constraint names truncated without error

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jtc331(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13659: Constraint names truncated without error
Date: 2015-10-01 15:50:21
Message-ID: 17808.1443714621@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

jtc331(at)gmail(dot)com writes:
> If I create the following schema:

> create table t(n integer);
> alter table t add constraint
> test_contrainst_that_has_a_very_long_name_to_trigger_the_character_limit
> check (n != 1);

> the constraint name appears to be automatically truncated without error, as
> confirmed with:

> SELECT tc.constraint_name, tc.table_name
> FROM information_schema.table_constraints AS tc
> WHERE tc.table_name = 't'

> Since PG raises errors when index names, for example, are too long, I
> believe it should do the same for constraints.

Really? I see the same type of behavior for both cases:

regression=# create table t(n integer);
CREATE TABLE
regression=# alter table t add constraint
test_contrainst_that_has_a_very_long_name_to_trigger_the_character_limit
check (n != 1);
NOTICE: identifier "test_contrainst_that_has_a_very_long_name_to_trigger_the_character_limit" will be truncated to "test_contrainst_that_has_a_very_long_name_to_trigger_the_charac"
ALTER TABLE
regression=# create index test_index_test_contrainst_that_has_a_very_long_name_to_trigger_the_character_limit on t(n);
NOTICE: identifier "test_index_test_contrainst_that_has_a_very_long_name_to_trigger_the_character_limit" will be truncated to "test_index_test_contrainst_that_has_a_very_long_name_to_trigger"
CREATE INDEX
regression=# \d+ t
Table "public.t"
Column | Type | Modifiers | Storage | Stats target | Description
--------+---------+-----------+---------+--------------+-------------
n | integer | | plain | |
Indexes:
"test_index_test_contrainst_that_has_a_very_long_name_to_trigger" btree (n)
Check constraints:
"test_contrainst_that_has_a_very_long_name_to_trigger_the_charac" CHECK (n <> 1)

Given where the identifier truncation behavior occurs, in the lexer, it
would be mildly astonishing if it didn't work the same for both cases.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2015-10-01 15:52:59 Re: BUG #13658: DELETE with syntax error in subselect deletes ALL
Previous Message Tom Lane 2015-10-01 15:46:47 Re: BUG #13655: Incorrect Syntax Error