Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zhg8U-0004IN-6j for pgsql-bugs@arkaria.postgresql.org; Thu, 01 Oct 2015 15:51:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zhg8T-0004dT-0U for pgsql-bugs@arkaria.postgresql.org; Thu, 01 Oct 2015 15:51:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zhg7q-0003wp-N6 for pgsql-bugs@postgresql.org; Thu, 01 Oct 2015 15:50:30 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zhg7j-000692-KZ for pgsql-bugs@postgresql.org; Thu, 01 Oct 2015 15:50:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t91FoLqq017809; Thu, 1 Oct 2015 11:50:21 -0400 From: Tom Lane To: jtc331@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #13659: Constraint names truncated without error In-reply-to: <20151001144027.348.87665@wrigleys.postgresql.org> References: <20151001144027.348.87665@wrigleys.postgresql.org> Comments: In-reply-to jtc331@gmail.com message dated "Thu, 01 Oct 2015 14:40:27 -0000" Date: Thu, 01 Oct 2015 11:50:21 -0400 Message-ID: <17808.1443714621@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org jtc331@gmail.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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs