Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gXAhM-00025y-27 for pgsql-bugs@arkaria.postgresql.org; Wed, 12 Dec 2018 20:01:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gXAgM-0001S6-QE for pgsql-bugs@arkaria.postgresql.org; Wed, 12 Dec 2018 20:00:34 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1gXAgM-0001OP-Cc for pgsql-bugs@lists.postgresql.org; Wed, 12 Dec 2018 20:00:34 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gXAgJ-0000Nh-BI for pgsql-bugs@postgresql.org; Wed, 12 Dec 2018 20:00:34 +0000 Received: by mail-ed1-x536.google.com with SMTP id x30so92892edx.2 for ; Wed, 12 Dec 2018 12:00:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=U1grw6R0g1SLNxPIUUUgqldUr0Cj3GFTjO1TLfSUuvE=; b=fzXK1XNwhxeTBYNaH2+nqeb0O09VHeaYbz1B1lka5N5BiV7gi4wOeAYd1Pcq6ldR1t GlialXuIecUmBLqBlTm458/XSzb/YFaegEWCPZzm6LMzoJZMkmpRUVZ4UaDMaStLNFvM NhoS3jsI5dw1sle5I8jEaNVluSUMlKXco4qRCqwRlMlrZpZahujRPqZLRE5VJ0PgiaNf ZC+2uXKWfWPB612EXdYXKbz9qnZibzusUn32h7uqwhMzzy0wa5O4mv/O7JlfR0tgxDDe cttB4iFIlifgXdswqFLcwbQGk67dKfbg6luDE+f1I1/s+zB77DAvVBMQ7E+2JB987k/X yGgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=U1grw6R0g1SLNxPIUUUgqldUr0Cj3GFTjO1TLfSUuvE=; b=gT9HRpwt6TdI0ZJBInr5PdMh4N/OMh0cK9Olrz+QosrkAeo+nw6KpAfbdMlB/oYY8p 4sHxi88jKZdlMcUGCLXg0A7by5sZFYNuao3KZOv06eHDXYs9Rbd79LQWt3RniRnxEwpj 0uWWc4VzFKLASCMEusHJXtBNhMbbvyDGXoFY498Hhi5f6BjkmPRzxJMG8dXZGdUBD2Gm wi4y1y6+jrG0r1byolRhVlHQYE9UmXEbujdOzcS3u50odyByNiFOgxNjrhxHWUNSsWHO YBaR9IsLJn2x7fIzMhEosU4f9VF7KzwZqVmAg/wNpbdvl7nhCdDgKRB09EuKs3XxM/SS tCBA== X-Gm-Message-State: AA+aEWZVMmZygInPKvfOeQZoQc5mQWd5RlYqzl+H40ROEDWPoAYyb+Lk sE1ULoBHmTIT7/cA5qWtJrqeWD6zglw= X-Google-Smtp-Source: AFSGD/Ugi8SuRW3U137YSonZrB+ao3q5xJLEfNmpSGeUIBcyLvML2YCy4l4RxazpRbQoGsMr2r1Lgw== X-Received: by 2002:a17:906:4b19:: with SMTP id y25-v6mr16079473eju.89.1544644827902; Wed, 12 Dec 2018 12:00:27 -0800 (PST) Received: from station53.ousa.org ([2.89.154.1]) by smtp.gmail.com with ESMTPSA id b49sm19560edb.73.2018.12.12.12.00.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Dec 2018 12:00:27 -0800 (PST) From: Stuart To: pgsql-bugs@postgresql.org Subject: Errors creating partitioned tables from existing using (LIKE ) after renaming table constraints Date: Wed, 12 Dec 2018 23:00:22 +0300 Message-ID: <2047094.V130LYfLq4@station53.ousa.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="nextPart14193711.1WTG35NLYi" Content-Transfer-Encoding: 7Bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --nextPart14193711.1WTG35NLYi Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="iso-8859-1" Dear team, I am using PostGreSQL 11.1, I compiled from source on openSuSE Tumbleweed. ousa_new=# SELECT version() ; version ---------------------------------------------------------------------------------------------------------------------------- PostgreSQL 11.1 on x86_64-pc-linux-gnu, compiled by gcc (SUSE Linux) 8.2.1 20181025 [gcc-8-branch revision 265488], 64-bit I imported a table definition from another database using: pg_dump -d ousa -t knowledge_vectors -s | psql ousa_new The table inherits from a hierarchy and I imported those parent tables first. I want to test partitioning so in the new db, I renamed the table and all its indexes and constraints so I can create a new table partitioned table based on this design using (like
). ousa_new=# \d+ knowledge_vectors_old Table "public.knowledge_vectors_old" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------------+-----------------------------+-----------+----------+--------------------------------+----------+--------------+------------- entry_date | timestamp(3) with time zone | | not null | now() | plain | | revision_date | timestamp(3) with time zone | | | NULL::timestamp with time zone | plain | | entered_by | text | | not null | "current_user"() | extended | | revised_by | text | | | ''::text | extended | | source_id | bigint | | | | plain | | object_id | bigint | | not null | | plain | | description | text | | | ''::text | extended | | vectors | tsvector | | not null | | extended | | Indexes: "knowledgevectorsold_pk" PRIMARY KEY, btree (object_id), tablespace "pgindex" "knowledgevectorsold_vector_idx" gin (vectors), tablespace "pgindex" Check constraints: "knowledgevectors_vectors_ck" CHECK (vectors <> ''::tsvector) Foreign-key constraints: "knowledgevectorsold_objectid_fk" FOREIGN KEY (object_id) REFERENCES knowledge(object_id) Triggers: knowledgevectors_revision_tr BEFORE UPDATE ON knowledge_vectors_old FOR EACH ROW EXECUTE PROCEDURE revised() Inherits: ousa_objects ousa_new=# alter table knowledge_vectors_old rename constraint knowledgevectors_vectors_ck to knowledgevectorsold_vectors_ck ; ALTER TABLE ousa_new=# \d+ knowledge_vectors_old Table "public.knowledge_vectors_old" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------------+-----------------------------+-----------+----------+--------------------------------+----------+--------------+------------- entry_date | timestamp(3) with time zone | | not null | now() | plain | | revision_date | timestamp(3) with time zone | | | NULL::timestamp with time zone | plain | | entered_by | text | | not null | "current_user"() | extended | | revised_by | text | | | ''::text | extended | | source_id | bigint | | | | plain | | object_id | bigint | | not null | | plain | | description | text | | | ''::text | extended | | vectors | tsvector | | not null | | extended | | Indexes: "knowledgevectorsold_pk" PRIMARY KEY, btree (object_id), tablespace "pgindex" "knowledgevectorsold_vector_idx" gin (vectors), tablespace "pgindex" Check constraints: "knowledgevectorsold_vectors_ck" CHECK (vectors <> ''::tsvector) Foreign-key constraints: "knowledgevectorsold_objectid_fk" FOREIGN KEY (object_id) REFERENCES knowledge(object_id) Triggers: knowledgevectors_revision_tr BEFORE UPDATE ON knowledge_vectors_old FOR EACH ROW EXECUTE PROCEDURE revised() Inherits: ousa_objects On my attempt to create the new partitioned table using like, I get error that the constraint by the old name doesn't exist: ousa_new=# create table knowledge_vectors (like knowledge_vectors_old INCLUDING ALL ) PARTITION BY RANGE ( object_id ) ; ERROR: constraint "knowledgevectors_vectors_ck" for table "knowledge_vectors_old" does not exist Only after I dropped the new constraint and recreated it, did the create table (like
) work. Ousa_new=# alter table knowledge_vectors_old drop constraint knowledgevectorsold_vectors_ck ; ALTER TABLE ousa_new=# alter table knowledge_vectors_old add constraint knowledgevectorsold_vectors_ck CHECK (vectors <> ''::tsvector) ; ALTER TABLE ousa_new=# \d+ knowledge_vectors_old Table "public.knowledge_vectors_old" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------------+-----------------------------+-----------+----------+--------------------------------+----------+--------------+------------- entry_date | timestamp(3) with time zone | | not null | now() | plain | | revision_date | timestamp(3) with time zone | | | NULL::timestamp with time zone | plain | | entered_by | text | | not null | "current_user"() | extended | | revised_by | text | | | ''::text | extended | | source_id | bigint | | | | plain | | object_id | bigint | | not null | | plain | | description | text | | | ''::text | extended | | vectors | tsvector | | not null | | extended | | Indexes: "knowledgevectorsold_pk" PRIMARY KEY, btree (object_id), tablespace "pgindex" "knowledgevectorsold_vector_idx" gin (vectors), tablespace "pgindex" Check constraints: "knowledgevectorsold_vectors_ck" CHECK (vectors <> ''::tsvector) Foreign-key constraints: "knowledgevectorsold_objectid_fk" FOREIGN KEY (object_id) REFERENCES knowledge(object_id) Triggers: knowledgevectors_revision_tr BEFORE UPDATE ON knowledge_vectors_old FOR EACH ROW EXECUTE PROCEDURE revised() Inherits: ousa_objects ousa_new=# create table knowledge_vectors (like knowledge_vectors_old INCLUDING ALL ) PARTITION BY RANGE ( object_id ) ; CREATE TABLE ousa_new=# \d+ knowledge_vectors Table "public.knowledge_vectors" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------------+-----------------------------+-----------+----------+--------------------------------+----------+--------------+------------- entry_date | timestamp(3) with time zone | | not null | now() | plain | | revision_date | timestamp(3) with time zone | | | NULL::timestamp with time zone | plain | | entered_by | text | | not null | "current_user"() | extended | | revised_by | text | | | ''::text | extended | | source_id | bigint | | | | plain | | object_id | bigint | | not null | | plain | | description | text | | | ''::text | extended | | vectors | tsvector | | not null | | extended | | Partition key: RANGE (object_id) Indexes: "knowledge_vectors_pkey" PRIMARY KEY, btree (object_id), tablespace "pgindex" "knowledge_vectors_vectors_idx" gin (vectors), tablespace "pgindex" Check constraints: "knowledgevectorsold_vectors_ck" CHECK (vectors <> ''::tsvector) Number of partitions: 0 The original table is: ousa# \d+ knowledge_vectors Table "public.knowledge_vectors" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------------+-----------------------------+-----------+----------+--------------------------------+----------+--------------+------------- entry_date | timestamp(3) with time zone | | not null | now() | plain | | revision_date | timestamp(3) with time zone | | | NULL::timestamp with time zone | plain | | entered_by | text | | not null | "current_user"() | extended | | revised_by | text | | | ''::text | extended | | source_id | bigint | | | | plain | | object_id | bigint | | not null | | plain | | description | text | | | ''::text | extended | | vectors | tsvector | | not null | | extended | | Indexes: "knowledgevectors_pk" PRIMARY KEY, btree (object_id), tablespace "pgindex" "knowledgevectors_vector_idx" gin (vectors), tablespace "pgindex" Check constraints: "knowledgevectors_vectors_ck" CHECK (vectors <> ''::tsvector) Triggers: knowledgevectors_revision_tr BEFORE UPDATE ON knowledge_vectors FOR EACH ROW EXECUTE PROCEDURE revised() Inherits: ousa_objects --nextPart14193711.1WTG35NLYi Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="iso-8859-1"

Dear team,<= /p>

&nb= sp;

I am using = PostGreSQL 11.1, I compiled from source on openSuSE Tumbleweed.

ous= a_new=3D# SELECT version() ;
= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0version
----------------------------------------= =2D------------------------------------------------------------------------= =2D----------
PostgreSQL 11.1 on x86_64-pc-linux-gnu, compiled by gcc= (SUSE Linux) 8.2.1 20181025 [gcc-8-branch revision 265488], 64-bit
<= span style=3D" font-family:'monospace';">

I imported = a table definition from another database using:

&nb= sp;

pg_dump -d = ousa -t knowledge_vectors -s | psql ousa_new

&nb= sp;

The table i= nherits from a hierarchy and I imported those parent tables first. I want = to test partitioning so in the new db, I renamed the table and all its inde= xes and constraints so I can create a new table partitioned table based on = this design using (like <table>).

&nb= sp;

ousa_new=3D= # \d+ knowledge_vectors_old

= Table "public.knowledge_vectors_old"

Column | = Type | Collation | Nullable | Default | = Storage | Stats target | Description

---------------+------------= =2D----------------+-----------+----------+--------------------------------= +----------+--------------+-------------

entry_date | timestamp(3= ) with time zone | | not null | now() | = plain | |

revision_date | timestamp(3= ) with time zone | | | NULL::timestamp with time zone | = plain | |

entered_by | text = | | not null | "current_user"() = | extended | |

revised_by | text = | | | ''::text | = extended | |

source_id | bigint = | | | | = plain | |

object_id | bigint = | | not null | | = plain | |

description | text = | | | ''::text | = extended | |

vectors | tsvector = | | not null | | = extended | |

Indexes:

"knowledgevectorsol= d_pk" PRIMARY KEY, btree (object_id), tablespace "pgindex"

"knowledgevectorsol= d_vector_idx" gin (vectors), tablespace "pgindex"

Check constraints:

"knowledgevectors_v= ectors_ck" CHECK (vectors <> ''::tsvector)

Foreign-key constraints:

"knowledgevectorsol= d_objectid_fk" FOREIGN KEY (object_id) REFERENCES knowledge(object_id)=

Triggers:

knowledgevectors_revisio= n_tr BEFORE UPDATE ON knowledge_vectors_old FOR EACH ROW EXECUTE PROCEDURE = revised()

Inherits: ousa_objects

&nb= sp;

&nb= sp;

ousa_new=3D= # alter table knowledge_vectors_old rename constraint knowledgevectors_vect= ors_ck to knowledgevectorsold_vectors_ck ;

ALTER TABLE=

&nb= sp;

ousa_new=3D= # \d+ knowledge_vectors_old

= Table "public.knowledge_vectors_old"

Column | = Type | Collation | Nullable | Default | = Storage | Stats target | Description

---------------+------------= =2D----------------+-----------+----------+--------------------------------= +----------+--------------+-------------

entry_date | timestamp(3= ) with time zone | | not null | now() | = plain | |

revision_date | timestamp(3= ) with time zone | | | NULL::timestamp with time zone | = plain | |

entered_by | text = | | not null | "current_user"() = | extended | |

revised_by | text = | | | ''::text | = extended | |

source_id | bigint = | | | | = plain | |

object_id | bigint = | | not null | | = plain | |

description | text = | | | ''::text | = extended | |

vectors | tsvector = | | not null | | = extended | |

Indexes:

"knowledgevectorsol= d_pk" PRIMARY KEY, btree (object_id), tablespace "pgindex"

"knowledgevectorsol= d_vector_idx" gin (vectors), tablespace "pgindex"

Check constraints:

"knowledgevectorsol= d_vectors_ck" CHECK (vectors <> ''::tsvector)

Foreign-key constraints:

"knowledgevectorsol= d_objectid_fk" FOREIGN KEY (object_id) REFERENCES knowledge(object_id)=

Triggers:

knowledgevectors_revisio= n_tr BEFORE UPDATE ON knowledge_vectors_old FOR EACH ROW EXECUTE PROCEDURE = revised()

Inherits: ousa_objects

&nb= sp;

On my attem= pt to create the new partitioned table using like, I get error that the con= straint by the old name doesn't exist:

&nb= sp;

ousa_new=3D= # create table knowledge_vectors (like knowledge_vectors_old INCLUDING ALL = ) PARTITION BY RANGE ( object_id ) ;

ERROR: con= straint "knowledgevectors_vectors_ck" for table "knowledge_v= ectors_old" does not exist

&nb= sp;

Only after = I dropped the new constraint and recreated it, did the create table (like &= lt;table>) work.

&nb= sp;

Ousa_new=3D= # alter table knowledge_vectors_old drop constraint knowledgevectorsold_vec= tors_ck ;

ALTER TABLE=

&nb= sp;

ousa_new=3D= # alter table knowledge_vectors_old add constraint knowledgevectorsold_vect= ors_ck CHECK (vectors <> ''::tsvector) ;

ALTER TABLE=

&nb= sp;

ousa_new=3D= # \d+ knowledge_vectors_old

= Table "public.knowledge_vectors_old"

Column | = Type | Collation | Nullable | Default | = Storage | Stats target | Description

---------------+------------= =2D----------------+-----------+----------+--------------------------------= +----------+--------------+-------------

entry_date | timestamp(3= ) with time zone | | not null | now() | = plain | |

revision_date | timestamp(3= ) with time zone | | | NULL::timestamp with time zone | = plain | |

entered_by | text = | | not null | "current_user"() = | extended | |

revised_by | text = | | | ''::text | = extended | |

source_id | bigint = | | | | = plain | |

object_id | bigint = | | not null | | = plain | |

description | text = | | | ''::text | = extended | |

vectors | tsvector = | | not null | | = extended | |

Indexes:

"knowledgevectorsol= d_pk" PRIMARY KEY, btree (object_id), tablespace "pgindex"

"knowledgevectorsol= d_vector_idx" gin (vectors), tablespace "pgindex"

Check constraints:

"knowledgevectorsol= d_vectors_ck" CHECK (vectors <> ''::tsvector)

Foreign-key constraints:

"knowledgevectorsol= d_objectid_fk" FOREIGN KEY (object_id) REFERENCES knowledge(object_id)=

Triggers:

knowledgevectors_revisio= n_tr BEFORE UPDATE ON knowledge_vectors_old FOR EACH ROW EXECUTE PROCEDURE = revised()

Inherits: ousa_objects

&nb= sp;

&nb= sp;

ousa_new=3D= # create table knowledge_vectors (like knowledge_vectors_old INCLUDING ALL = ) PARTITION BY RANGE ( object_id ) ;

CREATE TABL= E

&nb= sp;

ousa_new=3D= # \d+ knowledge_vectors

= Table "public.knowledge_vectors"=

Column | = Type | Collation | Nullable | Default | = Storage | Stats target | Description

---------------+------------= =2D----------------+-----------+----------+--------------------------------= +----------+--------------+-------------

entry_date | timestamp(3= ) with time zone | | not null | now() | = plain | |

revision_date | timestamp(3= ) with time zone | | | NULL::timestamp with time zone | = plain | |

entered_by | text = | | not null | "current_user"() = | extended | |

revised_by | text = | | | ''::text | = extended | |

source_id | bigint = | | | | = plain | |

object_id | bigint = | | not null | | = plain | |

description | text = | | | ''::text | = extended | |

vectors | tsvector = | | not null | | = extended | |

Partition key: RANGE (object= _id)

Indexes:

"knowledge_vectors_= pkey" PRIMARY KEY, btree (object_id), tablespace "pgindex"

"knowledge_vectors_= vectors_idx" gin (vectors), tablespace "pgindex"

Check constraints:

"knowledgevectorsol= d_vectors_ck" CHECK (vectors <> ''::tsvector)

Number of partitions: 0

&nb= sp;

&nb= sp;

The origina= l table is:

&nb= sp;

ousa# \d+ k= nowledge_vectors

= Table "public.knowledge_vectors"=

Column | = Type | Collation | Nullable | Default | = Storage | Stats target | Description

---------------+------------= =2D----------------+-----------+----------+--------------------------------= +----------+--------------+-------------

entry_date | timestamp(3= ) with time zone | | not null | now() | = plain | |

revision_date | timestamp(3= ) with time zone | | | NULL::timestamp with time zone | = plain | |

entered_by | text = | | not null | "current_user"() = | extended | |

revised_by | text = | | | ''::text | = extended | |

source_id | bigint = | | | | = plain | |

object_id | bigint = | | not null | | = plain | |

description | text = | | | ''::text | = extended | |

vectors | tsvector = | | not null | | = extended | |

Indexes:

"knowledgevectors_p= k" PRIMARY KEY, btree (object_id), tablespace "pgindex"

"knowledgevectors_v= ector_idx" gin (vectors), tablespace "pgindex"

Check constraints:

"knowledgevectors_v= ectors_ck" CHECK (vectors <> ''::tsvector)

Triggers:

knowledgevectors_revisio= n_tr BEFORE UPDATE ON knowledge_vectors FOR EACH ROW EXECUTE PROCEDURE revi= sed()

Inherits: ousa_objects

&nb= sp;

&nb= sp;

&nb= sp;

--nextPart14193711.1WTG35NLYi--