ronsavage / SQL

BNF Grammars for SQL-92, SQL-99 and SQL-2003
MIT License
369 stars 93 forks source link

syntax rules #9

Closed tsatke closed 4 years ago

tsatke commented 4 years ago

The document sql-2003-2.bnf.html and many other documents on the web contain !! See Syntax Rules, but I'm not able to find them. Where do I find the definition of these rules?

jleffler commented 4 years ago

Hi Tim and Ron,

That (!! See the Syntax Rules) is literally what it says in the PDF containing the standard. And the Syntax Rules are one part of the verbiage in the standard supporting the grammar — specifying what it means. The first such place where it occurs is:

<#xref-space> ::= !! See the Syntax Rules. And if I go to the full pDF, I find 5.1 says: Information technology — Database languages — SQL — Part 2: Foundation (SQL/Foundation) Syntax Rules 1) Every character set shall contain a character that is equivalent to U+0020. Access Rules None. General Rules 1) There is a one-to-one correspondence between the symbols contained in and the symbols contained in such that, for all i, the symbol defined as the i-th alternative for corresponds to the symbol defined as the i-th alternative for . Conformance Rules None. And, in this case, that's all it has to say. Each section of the standard has sub-headings 'Function', 'Format' (containing the BNF), 'Syntax Rules', 'Access Rules', 'General Rules' (usually the biggest section), and 'Conformance Rules'. The next pair of occurrences are: ::= | ::= !! See the Syntax Rules ::= !! See the Syntax Rules That's pulled from the PDF, not the HTML. This time, we find: Syntax Rules 1) An is any character in the Unicode General Category classes “Lu”, “Ll”, “Lt”, “Lm”, “Lo”, or “Nl”. NOTE 58 — The Unicode General Category classes “Lu”, “Ll”, “Lt”, “Lm”, “Lo”, and “Nl” are assigned to Unicode characters that are, respectively, upper-case letters, lower-case letters, title-case letters, modifier letters, other letters, and letter numbers. 2) An is U+00B7, “Middle Dot”, or any character in the Unicode General Category classes “Mn”, “Mc”, “Nd”, “Pc”, or “Cf”. NOTE 59 — The Unicode General Category classes “Mn”, “Mc”, “Nd”, “Pc”, and “Cf” are assigned to Unicode characters that are, respectively, nonspacing marks, spacing combining marks, decimal numbers, connector punctuations, and formatting codes. Very detailed specification stuff — but not something you can easily put into the BNF. It belongs in the lexical analyzer, probably. Another example — not to do with characters this time: <#xref-preparable implementation-defined statement> ::= !! See the Syntax Rules. Here the further information is: 3) The Format and Syntax Rules for are implementation-defined. And another pair of them: <#xref-SQLSTATE class value> ::= <#SQLSTATE char> <#SQLSTATE char> !! See the Syntax Rules. <#xref-SQLSTATE subclass value> ::= <#SQLSTATE char> <#SQLSTATE char> <#SQLSTATE char> !! See the Syntax Rules. The Syntax Rules say: 3) In the values of and , there shall be no between the s. 4) The values of and shall correspond to class values and subclass values, respectively, specified in Table 32, “SQLSTATE class and subclass values”. Expanding on this last example, here is the copy'n'paste of the Syntax Rules through the end of the section: Syntax Rules 1) SQLWARNING, NOT FOUND, and SQLEXCEPTION correspond to SQLSTATE class values corresponding to categories W, N, and X in Table 32, “SQLSTATE class and subclass values”, respectively. ©ISO/IEC 2003 – All rights reserved Embedded SQL 1001 ISO/IEC 9075-2:2003 (E) 20.2 2) An contained in an applies to an contained in that if and only if the appears after the that has condition C in the text sequence of the and no other E that satisfies one of the following conditions appears between the and the in the text sequence of the . Let D be the contained in E. a) D is the same as C. b) D is a and belongs to the same class to which C belongs. c) D contains an , but does not contain an , and E contains the same that C contains. d) D contains the that corresponds to integrity constraint violation and C contains CONSTRAINT. 3) In the values of and , there shall be no between the s. 4) The values of and shall correspond to class values and subclass values, respectively, specified in Table 32, “SQLSTATE class and subclass values”. 5) If an specifies a , then the , , or of the shall be such that a host language GO TO statement specifying that , , or is valid at every to which the applies. NOTE 445 — If an is contained in an , then the of a should specify a that is a label_name in the containing . If an is contained in an , then the of a should specify a that is a label in the containing . If an is contained in an , then the of a should specify a that is a section-name or an unqualified paragraph-name in the containing . If an is contained in an , then the of a should be an that is the statement label of an executable statement that appears in the same program unit as the . If an is contained in an , then the of a should be a gotoargument that is the statement label of an executable statement that appears in the same . If an is contained in an , then the of a should be an that is a label. If an is contained in an , then the of a should specify either a or a . Case: — If is specified, then the should be a label constant in the containing . ISO/IEC 9075-2:2003 (E) 20.2 1002 Foundation (SQL/Foundation) ©ISO/IEC 2003 – All rights reserved — If is specified, then the should be a PL/I label variable declared in the containing . Access Rules None. General Rules 1) Immediately after the execution of an STMT in an that returns an SQLSTATE value other than successful completion: a) Let E be the set of s that are contained in the containing STMT, that applies to STMT, and that specifies a that is . b) Let CV and SCV be respectively the values of the class and subclass of the SQLSTATE value that indicates the result of the . c) If the execution of the caused the violation of one or more constraints or assertions, then: i) Let ECN be the set of s in E that specify CONSTRAINT and the of a constraint that was violated by execution of STMT. ii) If ECN contains more than one , then an implementationdependent is chosen from ECN; otherwise, the single in ECN is chosen. iii) A GO TO statement of the host language is performed, specifying the , , or of the specified in the chosen from ECN. d) Otherwise: i) Let ECS be the set of s in E that specify SQLSTATE, an , and an . ii) If ECS contains an EY that specifies an identical to CV and an identical to SCV, then a GO TO statement of the host language is performed, specifying the , , or of the specified in the EY. iii) Otherwise: 1) Let EC be the set of s in E that specify SQLSTATE and an without an . 2) If EC contains an EY that specifies an identical to CV, then a GO TO statement of the host language is performed, ©ISO/IEC 2003 – All rights reserved Embedded SQL 1003 ISO/IEC 9075-2:2003 (E) 20.2 specifying the , , or of the specified in the EY. 3) Otherwise: A) Let EX be the set of s in E that specify SQLEXCEPTION. B) If EX contains an EY and CV belongs to Category X in Table 32, “SQLSTATE class and subclass values”, then a GO TO statement of the host language is performed, specifying the , , or of the specified in the EY. C) Otherwise: I) Let EW be the set of s in E that specify SQLWARNING. II) If EW contains an EY and CV belongs to Category W in Table 32, “SQLSTATE class and subclass values”, then a GO TO statement of the host language is performed, specifying the , , or of the specified in the EY. III) Otherwise, let ENF be the set of s in E that specify NOT FOUND. If ENF contains an EY and CV belongs to Category N in Table 32, “SQLSTATE class and subclass values”, then a GO TO statement of the host language is performed, specifying the , , or of the specified in the EY. Conformance Rules 1) Without Feature B041, “Extensions to embedded SQL exception declarations”, conforming SQL language shall not contain an that contains either SQLSTATE or CONSTRAINT. 2) Without Feature F491, “Constraint management”, conforming SQL language shall not contain an that contains a . ISO/IEC 9075-2:2003 (E) 20.2 1004 Turgid prose doesn't begin to describe it. The copy'n'paste loses the indentation which makes it a bit clearer, and includes page headers and footers. And so it goes on. I'm not able to show the whole standard. It's a problem. On Sun, Dec 22, 2019 at 12:14 PM Tim Satke wrote: > The document sql-2003-2.bnf.html and many other documents on the web > contain !! See Syntax Rules, but I'm not able to find them. Where do I > find the definition of these rules? > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > , > or unsubscribe > > . > -- Jonathan Leffler #include Guardian of DBD::Informix - v2018.1031 - http://dbi.perl.org "Blessed are we who can laugh at ourselves, for we shall never cease to be amused."
ronsavage commented 4 years ago

Hi Tim

Jonathan Leffler sent me an extract of the standard regarding that text. I've updated the readme on github, and added a new file: Syntax.rules.txt.

Cheers

Ron Savage savage.net.au On 2019-12-23 06:14, Tim Satke wrote:

The document sql-2003-2.bnf.html and many other documents on the web contain !! See Syntax Rules, but I'm not able to find them. Where do I find the definition of these rules?

-- You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub [1], or unsubscribe [2].

Links:

[1] https://github.com/ronsavage/SQL/issues/9?email_source=notifications&amp;email_token=AAAFH6F74NFFZAF5VLYSI3TQZ64CVA5CNFSM4J6NDSU2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4ICGPXHQ [2] https://github.com/notifications/unsubscribe-auth/AAAFH6FT56VE73YCNSRR5SDQZ64CVANCNFSM4J6NDSUQ