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 1gXaVc-0001qS-Jh for pgsql-bugs@arkaria.postgresql.org; Thu, 13 Dec 2018 23:35:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gXaVa-0005os-P7 for pgsql-bugs@arkaria.postgresql.org; Thu, 13 Dec 2018 23:35:10 +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 1gXaVa-0005ol-GP for pgsql-bugs@lists.postgresql.org; Thu, 13 Dec 2018 23:35:10 +0000 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gXaVY-0005L3-Fv for pgsql-bugs@postgresql.org; Thu, 13 Dec 2018 23:35:10 +0000 Received: by mail-ed1-x544.google.com with SMTP id j6so3473193edp.9 for ; Thu, 13 Dec 2018 15:35:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NRNRfiFBhOMpyJB/N/g9CyL3nNZ23U+8ue4xXjB+LxI=; b=ToxtYtj9wry2NyK+RDPm/VlQWgHhzBS+2X29hkIMMiiX6ZiYMWAgZIYn5YzQJewumY QbQlVg7ggq7hbp2yxe/kJlvDhMX/f3c6T0QUWs5B3v4xkKBqFyYVz7zDg1+DQNJ1z42J UFqRug01SQMuB8qKirXBjB3VK7/wklT0XgrWmjRQhSmJCVVZSKD8OmY1coKyjFLpIrVO 5dPXtgiE79R5rjXt+gZzA5thTYnJX4D4WbxujknWi7WWbrCNhxB5aUoOkOWcf+941gyO piBDqpluUfjG4i/0QUXdGt0ggzDrt4d/jpqpz9wKB1HEJ9yoHKI58hXu6GwMqjCw0Zzs 9YIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NRNRfiFBhOMpyJB/N/g9CyL3nNZ23U+8ue4xXjB+LxI=; b=li5ol5IYa2R1PoPAcJ3cVo2udXNNz0Cd6FbnvAiXjiLcJoHe9Q98I/OTbCt3i0uEVc 46WycF93dAGr+QdPfoqFsW1Ed9hZgSpgVtz4j/ZJ5mkNPlynjdqSfqSKKZGM0BUPc+jp IxqPiCei58E8/E6ryp/ra4QKR0h+l3CbBSIUURiY4233BvNMDwf3M7meK4f4oFmI+taS AKFFNVnP/iMnwc2ntQH/gaBZvrIbgdMQnXNO1uq1Cyj85XrxgYE0JkxZ6mNgVHenurkB v82zU4EyZYiizVG9h22flEN197FkVBl5fo9UTH/T0DchJVL5xGd6MMTu9cJfORNZzFsL 9FXg== X-Gm-Message-State: AA+aEWZZeJB5GiGV/mUUgN+Q1llNigeLcmPbL+rV7SN2SKTSsoRIMY4n qTPZfylQUOyeXYcxGgCbXbEykg07QgI= X-Google-Smtp-Source: AFSGD/VWesSkdaKUhZz6CbhugYMetnrMzQojzovD5/IfQ1z1+CA/H3SSJHHXy6Zhb/SRHnmx7G1uhQ== X-Received: by 2002:a17:906:9613:: with SMTP id s19-v6mr758777ejx.109.1544744107226; Thu, 13 Dec 2018 15:35:07 -0800 (PST) Received: from station53.ousa.org ([37.106.140.58]) by smtp.gmail.com with ESMTPSA id a11sm990509edc.28.2018.12.13.15.35.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Dec 2018 15:35:06 -0800 (PST) From: Stuart To: Amit Langote Cc: pgsql-bugs@postgresql.org Subject: Re: create partitioned table with (like table INCLUDING ALL ) fails with "insufficient columns in UNIQUE constraint definition" Date: Fri, 14 Dec 2018 02:35:03 +0300 Message-ID: <39619765.ZOXDBuc6tV@station53.ousa.org> In-Reply-To: <979372cf-ac21-6b5e-7987-5033fe53c2c2@lab.ntt.co.jp> References: <1848484.oBYbUDFMh6@station53.ousa.org> <979372cf-ac21-6b5e-7987-5033fe53c2c2@lab.ntt.co.jp> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018 Zvita 13, China 12:14:33 +03 Amit Langote wrote: > On 2018/12/13 6:08, Stuart wrote: > > Dear team, > > > > Another issue found with attempting to create partitioned table from (like > > table including all). Primary key constraints don't get recognized if > > there are other unique constraints and indexes in the original table. > > Creating a non-partitioned table works ok using the same options. > > > > > > =# \d+ knowledge > > > > Table > > "public.knowl > > edge" > > > > 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 | nextval('resource_seq'::regclass) | plain > > | | description | text | > > | | ''::text | extended | > > | category_id | bigint | | | > > | plain | | producer_id > > | bigint | | not null | > > | plain | | released | date > > | | | date(now()) > > | plain | | copyprotected | date > > | | | | plain | > > | isindexed | boolean | | > > | false | plain | | > > filepath | text | | | > > ''::text | extended | | url > > | text | | | ''::text > > | extended | |> > > Indexes: > > "knowledge_pk" PRIMARY KEY, btree (object_id), tablespace "pgindex" > > "knowledge_categoryfilepathurl_un" UNIQUE, btree (category_id, > > filepath, url) WHERE filepath IS NULL AND url IS NULL, tablespace > > "pgindex" "knowledge_filepath_un" UNIQUE CONSTRAINT, btree > > (filepath), tablespace "pgindex" "knowledge_url_un" UNIQUE > > CONSTRAINT, btree (url), tablespace "pgindex"> > > Inherits: products > > > > > > =# create table knowledge_new (like knowledge INCLUDING ALL ) PARTITION BY > > RANGE ( object_id ) ; ERROR: insufficient columns in UNIQUE constraint > > definition > > DETAIL: UNIQUE constraint on table "knowledge_new" lacks column > > "object_id" which is part of the partition key. > > > > =# create table knowledge_new (like knowledge INCLUDING ALL ) PARTITION BY > > RANGE ( object_id ) ; ERROR: insufficient columns in UNIQUE constraint > > definition > > DETAIL: UNIQUE constraint on table "knowledge_new" lacks column > > "object_id" which is part of the partition key. > > > > =# alter table knowledge drop constraint knowledge_url_un ; > > ALTER TABLE > > > > =# create table knowledge_new (like knowledge INCLUDING ALL ) PARTITION BY > > RANGE ( object_id ) ; ERROR: insufficient columns in UNIQUE constraint > > definition > > DETAIL: UNIQUE constraint on table "knowledge_new" lacks column > > "object_id" which is part of the partition key. > > > > =# alter table knowledge drop constraint knowledge_filepath_un ; > > ALTER TABLE > > > > =# create table knowledge_new (like knowledge INCLUDING ALL ) PARTITION BY > > RANGE ( object_id ) ; ERROR: insufficient columns in UNIQUE constraint > > definition > > DETAIL: UNIQUE constraint on table "knowledge_new" lacks column > > "object_id" which is part of the partition key. > I don't think this is a bug. It's rather a current *limitation* of > defining UNIQUE constraints on partitioned tables that they cannot be > created without including the partition key. > > Thanks, > Amit Amit, Thanks for your response. So partitioning does not recognize a primary key constraint on the partition key as a unique constraint? Shouldn't it? Thanks, Stuart