From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Amit Langote <amitlangote09(at)gmail(dot)com> |
Cc: | Joshua Ma <josh(at)benchling(dot)com>, PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>, Victor Pontis <victor(at)benchling(dot)com> |
Subject: | Re: pg_restore casts check constraints differently |
Date: | 2016-03-30 14:01:35 |
Message-ID: | 395.1459346495@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
Amit Langote <amitlangote09(at)gmail(dot)com> writes:
> destdb=# ALTER TABLE c ADD CONSTRAINT p_a_check CHECK (a IN ('a', 'b', 'c'));
> destdb=# \d c
> ...
> Check constraints:
> "p_a_check" CHECK (a::text = ANY (ARRAY['a'::character varying,
> 'b'::character varying, 'c'::character varying]::text[]))
Hm. It seems like the parser is doing something weird with IN there.
If you just do a simple comparison the constant ends up as TEXT to start
with:
regression=# CREATE TABLE pp (a varchar, CHECK (a = 'a'));
regression=# \d pp
...
Check constraints:
"pp_a_check" CHECK (a::text = 'a'::text)
Or for that matter
regression=# CREATE TABLE p (a varchar, CHECK (a = any(array['a', 'b', 'c'])));
regression=# \d p
...
Check constraints:
"p_a_check" CHECK (a::text = ANY (ARRAY['a'::text, 'b'::text, 'c'::text]))
I wonder why you don't get an array of text constants in the IN case.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2016-03-30 14:19:11 | Re: Missed LIMIT clause pushdown in FDW API |
Previous Message | Adrian Klaver | 2016-03-30 13:51:52 | Re: Multixacts wraparound monitoring |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2016-03-30 14:21:29 | Re: [postgresSQL] [bug] Two or more different types of constraints with same name creates ambiguity while drooping. |
Previous Message | Marc-Olaf Jaschke | 2016-03-30 14:00:36 | Re: Missing rows with index scan when collation is not "C" (PostgreSQL 9.5) |