Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TmWMb-0005vj-Bn for pgsql-bugs@arkaria.postgresql.org; Sat, 22 Dec 2012 21:12:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TmWMa-0005QO-8a for pgsql-bugs@arkaria.postgresql.org; Sat, 22 Dec 2012 21:12:08 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TmWMY-0005QG-Dv for pgsql-bugs@postgresql.org; Sat, 22 Dec 2012 21:12:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TmWMU-0000CY-V6 for pgsql-bugs@postgresql.org; Sat, 22 Dec 2012 21:12:05 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id qBMLBlTE003839; Sat, 22 Dec 2012 16:11:47 -0500 (EST) From: Tom Lane To: Andres Freund cc: norbi@nix.hu, pgsql-bugs@postgresql.org Subject: Re: BUG #7763: "CREATE TABLE ... (LIKE ... INCLUDING INDEXES ...)" does not work with indexes on composite types In-reply-to: <20121222130618.GB15790@awork2.anarazel.de> References: <20121220201703.GA29416@awork2.anarazel.de> <20121220215053.GB29416@awork2.anarazel.de> <20121222130618.GB15790@awork2.anarazel.de> Comments: In-reply-to Andres Freund message dated "Sat, 22 Dec 2012 14:06:18 +0100" Date: Sat, 22 Dec 2012 16:11:47 -0500 Message-ID: <3838.1356210707@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 Andres Freund writes: > On 2012-12-20 22:50:54 +0100, Andres Freund wrote: >> Ok, here are two patches: >> * Add a cooked_expr member to IndexElem and use it for transformed >> expressions, including filling it directly in generateClonedIndexStmt. >> >> * Follow the pattern set by other routines in parse_expr.c and don't >> transformRowExpr the same expression twice. >> >> While the first one fixes the above bug - and I think its the right >> approach not to analyze the expression twice, the second one seems like >> a good idea anyway because as transformExpr says: >> * 1. At least one construct (BETWEEN/AND) puts the same nodes >> * into two branches of the parse tree; hence, some nodes >> * are transformed twice. >> * 2. Another way it can happen is that coercion of an operator or >> * function argument to the required type (via coerce_type()) >> * can apply transformExpr to an already-transformed subexpression. >> * An example here is "SELECT count(*) + 1.0 FROM table". >> >> There unfortunately is not sufficient padding in IndexElem to do that >> without changing its size. Not sure whether we consider that to be a big >> problem for the back branches, its nothing user code should do, but >> ... > So nobody has an idea that would avoid changing the sizeof(IndexElem)? Yeah: forget the first patch and just do the second. There are already sufficient reasons why transformExpr has to be idempotent; this is just another one. I don't really see a need to kluge up IndexElem for this. We might at some point try to clean all this up. But in the meantime I see no good reason to make LIKE INCLUDING INDEXES adhere to a higher standard than the rest of the code does, and even less reason to back-patch such a change. BTW, it sure looks to me like transformXmlExpr will get an Assert failure on an already-transformed expression ... 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