Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WFYcl-0002Sl-44 for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Feb 2014 00:33:23 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WFYck-0004fF-JQ for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Feb 2014 00:33:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WFYcj-0004eB-FW for pgsql-bugs@postgresql.org; Tue, 18 Feb 2014 00:33:21 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WFYcd-0001Kz-2q for pgsql-bugs@postgresql.org; Tue, 18 Feb 2014 00:33:21 +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 s1I0XDTC010304; Mon, 17 Feb 2014 19:33:13 -0500 From: Tom Lane To: pythonesque@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #9227: Error on SELECT ROW OVERLAPS ROW with single ROW argument In-reply-to: <20140215035549.24618.37927@wrigleys.postgresql.org> References: <20140215035549.24618.37927@wrigleys.postgresql.org> Comments: In-reply-to pythonesque@gmail.com message dated "Sat, 15 Feb 2014 03:55:49 +0000" Date: Mon, 17 Feb 2014 19:33:13 -0500 Message-ID: <10303.1392683593@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) 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 pythonesque@gmail.com writes: > # SELECT ROW (1) OVERLAPS ROW (2); > ERROR: XX000: unrecognized node type: 656 > LOCATION: transformExprRecurse, parse_expr.c:359 > I'm not sure why this even parses, as it's not documented to do so. I do > notice, however, that in makeOverlaps in gram.y creates a recursive list > when largs or args has only one argument, which seems wrong to me. Huh, yeah: if (list_length(largs) == 1) largs = lappend(largs, largs); else if (list_length(largs) != 2) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("wrong number of parameters on left side of OVERLAPS expression"), parser_errposition(location))); (and similarly for rargs). What this is evidently trying to do is convert (foo) overlaps ... to (foo, foo) overlaps ... which is perhaps sensible on the grounds that a point in time can be considered as a zero-width interval. However, as you say, this behavior is undocumented, and what's more I can find no support for it in any version of the SQL standard. My guess is that this code might've originally worked as intended, but it got broken when Neil Conway rewrote our List implementation, which was a darn long time ago now. A quick browse in our git history shows that OVERLAPS support was introduced in commit 64568100787a5d03d036e70b32147385a35245e2 of 2000-03-14, and the self-append-the-same-list behavior was in that version though it looked rather different. Neil's work dates to 2004. [ thinks some more ... ] Actually, even back when Lists didn't have headers, it's not immediately clear to me that this code could've worked. In the current code we end up with a List that includes itself, which surely ain't gonna work. While it would be a reasonably simple change to make this work as originally intended, I'm strongly tempted to just rip it out instead, and only support the SQL-mandated syntax. If anyone was using this undocumented feature, you'd think they'd have complained sometime in the last ten years. And making it work would really entail adding documentation and a regression test case, so it'd be substantially more effort than just killing the "list_length == 1" case. 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