Skip site navigation (1) Skip section navigation (2)

Recursive query syntax ambiguity

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Recursive query syntax ambiguity
Date: 2007-01-26 17:10:01
Message-ID: 87r6thaf4m.fsf@stark.xeocode.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hm, I had hoped that the DB2/ANSI syntax would only require making "WITH" a
fully reserved word, and not the other tokens it uses. Certainly for
non-recursive queries that's the case as the only other token it uses is "AS"
which is already a fully reserved word.

However to fully support the DB2/ANSI syntax we would definitely have an
ambiguity and I think we would have to make "CYCLE" a fully reserved word
which seems like a much bigger concession than "WITH". Observe the following
case:

  WITH RECURSIVE foo (x,y) AS (select 1,2) SEARCH DEPTH FIRST BY x CYCLE x,y SET ...

The parser can't search arbitrarily far checking for a SET to see if the CYCLE
is a keyword or a binary operator. Even if it could things like this would be
entirely ambiguous:

  WITH RECURSIVE foo (x,y) AS (select 1,2) SEARCH DEPTH FIRST BY x CYCLE x, y CYCLE y SET ...

I'm nowhere near actually implementing this functionality yet so there's no
pressing need for action. In fact I think the search clause is actually an
ANSIism that isn't supported by DB2 itself yet either.


-- 
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com

Responses

pgsql-hackers by date

Next:From: Simon RiggsDate: 2007-01-26 17:22:34
Subject: Re: Proposal: Snapshot cloning
Previous:From: Simon RiggsDate: 2007-01-26 17:07:37
Subject: Re: HAVING push-down

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group