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 1gZf2I-0002f2-GG for pgsql-bugs@arkaria.postgresql.org; Wed, 19 Dec 2018 16:49:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gZf2G-0006l4-Rn for pgsql-bugs@arkaria.postgresql.org; Wed, 19 Dec 2018 16:49:28 +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 1gZf2G-0006kw-LV for pgsql-bugs@lists.postgresql.org; Wed, 19 Dec 2018 16:49:28 +0000 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gZf29-0004Ai-Dg for pgsql-bugs@postgresql.org; Wed, 19 Dec 2018 16:49:27 +0000 Received: by mail-qt1-x843.google.com with SMTP id k12so22930430qtf.7 for ; Wed, 19 Dec 2018 08:49:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=qwiapoym3bDaN/YoB1eAByqMeztpzLOmcDn2ATU5Q1g=; b=v6Euv1c4pCtxzeCIaAdgcNQ9vy/aJPiA7FXDW0eKiHoyiXeU8CYlqLDlvj5SQV2a7G azSU0eeUNfotDlzcIyincl1/Yd8oxjA47K2ICXyHofb7mY/oEQbbMSFKlSCCPEHt5umE fT5Rehgru7VghERYNNa3Z8QfJVAqwhkO3Se08PbdHdoJZRLGkm50RH6tu+njUIh6qntl Wp7sNq/AjFN/d+QWM0ll1T45NSVS77XWfLSPiYHlssLJ3dUYv1e8B3tsCTR+l4TQ2sOO +eTv70E1D/jjo25ao+c6+uT7KGyCdBl1T2mhIWci7rd/fQ6GDxa74jHtQYUvh0i4v7bk Ma3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=qwiapoym3bDaN/YoB1eAByqMeztpzLOmcDn2ATU5Q1g=; b=ewg6xwVbASqLy4JD9QyY3siDt/HLTS6cvAD5f94omAlVF//IGKdkqQgYkrY54qhl/l hPX3e8dKeQdA/GPJ303QQC5d9TRlQnmIRqBicM0fK1dMmyaPqnSxZ/pCmAE0w5laHD4K XhcMwihdWGP0aU6DLLw81uIm0XUeuofK1NaTWW3MLxfZ0qwltN215LsG1UGc1wzQ5rKK sVkgGKgq3dMAGa0/yfk2P3Vm3dehPjUouiMUrVTac98AlQ6WMDG05EjEKuvMMBcmQswU B36c+9LzNGTJ6EFoHszoqUKAPrkjqp9FKj7TglaBAt36G+NId3Tg7HSakf6Jh9o4FCiJ HA+g== X-Gm-Message-State: AA+aEWaWdL2azZwpMQmriqRUnhRauQMy3sW56GkYsdNKB7lIKDayB4n5 loU3o/jpwAyZR/NUJ+v7jhQGLA== X-Google-Smtp-Source: AFSGD/WeOxRnNvTJvQF7l2QYaaCU+lsEaBnj/18hOYgagLQE/UFw9clSoR1IE+R8pBxU+Wyk6clLTg== X-Received: by 2002:a0c:d4f9:: with SMTP id y54mr22056808qvh.98.1545238159324; Wed, 19 Dec 2018 08:49:19 -0800 (PST) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id h31sm2192671qtk.5.2018.12.19.08.49.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Dec 2018 08:49:18 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 04FD26B9; Wed, 19 Dec 2018 13:49:17 -0300 (-03) Date: Wed, 19 Dec 2018 13:49:17 -0300 From: Alvaro Herrera To: Joshua Muzaaya Cc: pgsql-bugs@postgresql.org Subject: Re: Postgres 11 Insufficient columns in PRIMARY KEY constraint definition Message-ID: <20181219164917.r36rvypp22h7inem@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-Dec-19, Joshua Muzaaya wrote: > DETAIL: PRIMARY KEY constraint on table lacks column "sdate" which is part > of the partition key. SQL state: 0A000 > > I have a table which i am trying to create with RANGE partitioning using > the timestamp column. But my primary doesnot need to have this timestamp > column, its another column. Yeah, that won't work. > Why is postgres 11 asking me to add this > partition key in the primary key ? Implementation restrictions. We may lift it in future releases, but don't hold your breath. > The documentation lacks this or am missing something ? It seems the docs are unclear on this ... failed edits. The PRIMARY KEY part of it is clear; they say: PRIMARY KEY constraints share the restrictions that UNIQUE constraints have when placed on partitioned tables. But under UNIQUE you find this: When establishing a unique constraint for a multi-level partition hierarchy, all the columns in the partition key of the target partitioned table, as well as those of all its descendant partitioned tables, must be included in the constraint definition. in reality it doesn't matter than the hierarchy is multi-level or not -- the restriction applies to all partitioned setups. I think this may be clearer: When establishing a unique constraint on a partitioned table, all the columns in the partition key of the partitioned table must be included in the constraint definition. In case of a multi-level partition hierarchy, this applies to the set of all columns used in partition keys across the whole hierarchy. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services