pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pythonesque@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #9227: Error on SELECT ROW OVERLAPS ROW with single ROW argument
Date: Mon, 17 Feb 2014 19:33:13 -0500
Message-ID: <10303.1392683593@sss.pgh.pa.us> (raw)
In-Reply-To: <20140215035549.24618.37927@wrigleys.postgresql.org>
References: <20140215035549.24618.37927@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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



view thread (13+ messages)  latest in thread

Message-ID: <10303.1392683593@sss.pgh.pa.us>
Permalink:  ../10303.1392683593@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10303.1392683593@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pythonesque@gmail.com
  Subject: Re: BUG #9227: Error on SELECT ROW OVERLAPS ROW with single ROW argument
  In-Reply-To: <10303.1392683593@sss.pgh.pa.us>
  References: <20140215035549.24618.37927@wrigleys.postgresql.org> <10303.1392683593@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox