Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSnos-0005e4-TH for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Jul 2016 16:05:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bSnos-0003ce-8e for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Jul 2016 16:05:58 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bSnoF-0002tn-5l for pgsql-bugs@postgresql.org; Thu, 28 Jul 2016 16:05:19 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bSnoC-0006u8-TV for pgsql-bugs@postgresql.org; Thu, 28 Jul 2016 16:05:18 +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 u6SG5BAV019145; Thu, 28 Jul 2016 12:05:11 -0400 From: Tom Lane To: Vitaly Burovoy cc: joel.traf@magwerks.com, pgsql-bugs@postgresql.org Subject: Re: bug error message constraint "con_item_id_costelement" for table "costs" does not exist SQL state: 42704 In-reply-to: References: <20160728151154.AABE64016B@smtp.hushmail.com> Comments: In-reply-to Vitaly Burovoy message dated "Thu, 28 Jul 2016 08:43:00 -0700" Date: Thu, 28 Jul 2016 12:05:11 -0400 Message-ID: <19144.1469721911@sss.pgh.pa.us> X-Pg-Spam-Score: -3.2 (---) 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 Vitaly Burovoy writes: > On 7/28/16, joel.traf@magwerks.com wrote: >> The documentation states "create temp table mytable (including all) " >> is suppose to create all the constraints > CREATE TABLE ... (LIKE ...) > creates indexes and constraints with names as if they weren't given > (i.e. by default), so your > constraint "con_item_id_costelement" becomes > "costs_cost_item_id_cost_costelem_id_key" There's a comment in generateClonedIndexStmt about that: * We don't try to preserve the name of the source index; instead, just * let DefineIndex() choose a reasonable name. However, this isn't documented anywhere user-visible AFAICS, and it probably should be. It's rather annoying that LIKE doesn't duplicate names of constraints, especially now that we've invented ON CONFLICT and thereby made constraint names something that would be explicitly referenced in DML code. However, I'm afraid that doing so is harder than it looks because index names have to be unique within a schema. If we tried to copy constraint names we'd get a failure anytime the new table is in the same schema as the LIKE source table. 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