public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: Tom Lane <[email protected]>
Cc: Euler Taveira <[email protected]>
Cc: [email protected]
Cc: [email protected]
Subject: Re: Synopsis of SELECT statement: UNION, INTERSECTION, EXCEPT
Date: Sun, 18 Mar 2018 14:28:26 -0700
Message-ID: <CAKFQuwayZRHgyQRrA=wYJnh6V-C3jZeumk=yfxjei=LxeBbGCA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<CAHE3wgiaV1YyQ6-v12R4bzmQoUc_5E3hBupKxHTzLXg2TOsh-g@mail.gmail.com>
	<[email protected]>

As a first step we could do something like:

​basic_select_statement is:
​

> SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
>     [ * | expression [ [ AS ] output_name ] [, ...] ]
>     [ FROM from_item [, ...] ]
>     [ WHERE condition ]
>     [ GROUP BY grouping_element [, ...] ]
>     [ HAVING condition [, ...] ]
>     [ WINDOW window_name AS ( window_definition ) [, ...] ]
>

​full_select_statement is basic_select_statement with the following
possible additional clauses tacked onto the end:

    [ ORDER BY expression [ ASC | DESC | USING operator ] [ NULLS { FIRST |
> LAST } ] [, ...] ]
>     [ LIMIT { count | ALL } ]
>     [ OFFSET start [ ROW | ROWS ] ]
>     [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ]
>     [ FOR { UPDATE | NO KEY UPDATE | SHARE | KEY SHARE } [ OF table_name
> [, ...] ] [ NOWAIT | SKIP LOCKED ] [...] ]
>
> and that's still not right because ORDER BY et al can't be attached to a
> select_stmt that's the argument of a set operation, so really we'd need
> a couple of levels of nonterminals before we get down to the basic
> "SELECT expression FROM ..." part.  Nor has the use of parentheses been
> mentioned yet.
>

​Then we can define the set clauses in terms of basic_select_stmt and
parentheses-surrounded full_select_stmt. The result of the set clause is
itself a type of basic_select_statement which can be made full by adding
one or more of the additional clauses, including ORDER BY.

David J.


view thread (8+ messages)  latest in thread

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Synopsis of SELECT statement: UNION, INTERSECTION, EXCEPT
  In-Reply-To: <CAKFQuwayZRHgyQRrA=wYJnh6V-C3jZeumk=yfxjei=LxeBbGCA@mail.gmail.com>

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

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