Appendix G – Errata¶
Note
You are reading a digital copy of SQL-99 Complete, Really, a book that documents the SQL-99 standard.
For more information specific to CrateDB, check out the CrateDB Reference.
This concise errata list concerns apparent errors in some of our source literature, such as the SQL standard documents or the ODBC manual. We do not intend this as a comment. Like any errata list, its sole use is to help you avoid confusion if you happen to read one of those texts. And, like any errata list, it’s ephemeral. At some time, the original documents will cease to contain these errors.
Table of Contents
SQL Foundation¶
The data type and size of
CURRENT_ROLE
is not defined, but we have assumed that it’s supposed to match the data type and size defined forCURRENT_USER
.The Standard declares that precision is the number of “significant digits”. We have to assume they don’t use the usual definition of significant.
The Standard speaks of valid datetime or interval results “according to the Gregorian calendar”. But the Gregorian calendar only validates dates. We assume they mean “based on a 24 hour clock” for times, with adjustments according to the Gregorian calendar in the case of timestamps and (where applicable) intervals.
The word “satisfies” means “is
TRUE
” when the context is theHAVING
clause, or “is notFALSE
” when the context is a constraint. But it is not clear what “satisfies” means when the context is aWHEN
clause or a view’sWITH CHECK OPTION
clause. Therefore it is not possible to be sure whether these clauses are “satisfied” if the search conditions that they refer to areUNKNOWN
.SQL3’s
BOOLEAN
data type should have four values:TRUE
,FALSE
,UNKNOWN
andNULL
.For “effect of replacing rows in base tables”, the trigger event is defined as
DELETE
. We assume thatUPDATE
is meant.The
DROP TABLE ... CASCADE
definition fails to specify that all dependent triggers will also be dropped. TheDROP TABLE ... RESTRICT
definition fails to specify that, if there are dependent triggers, the drop will fail. Since analogous statements are true forDROP VIEW
, we assume that they should also be true forDROP TABLE
.The Standard states six times that the following statement, or a slight variation thereof, is “implicit” (in column definitions etc.):
"CREATE TRIGGER BTN BEFORE DELETE ON TND FOR EACH STATEMENT SET CONSTRAINT CCN DEFERRED"
But
SET CONSTRAINT
statements are illegal within triggers.According to the Standard,
DROP TRIGGER
is legal in Core SQL; butCREATE TRIGGER
is illegal. We assume that the intent is not to includeDROP TRIGGER
in Core SQL either.In the description of <cast specification> there is a reference to an
SQLSTATE error 'Data exception - invalid interval format'
; this error does not appear in the list ofSQLSTATE
exception conditions so we haven’t been able to provide anSQLSTATE
code for it.The
ASCII_FULL
character set does not include the\0
character. This contradicts FIPS, and makes casts from bit strings difficult.The Standard’s Section 9.7 <type name determination> has no mention of
BOOLEAN
. Neither does Section 10.14.BOOLEAN
appears to have been forgotten in many places.There is an initial definition of “subtype”. The Standard’s description of UDTs is comprehensible only if this definition is ignored.
The Standard’s definition of “direct subtype” is confusing:
“A type
T(a)
is a direct subtype of a typeT(b)
ifT(a)
is a proper subtype ofT(b)
and there does not exist a typeT(c)
such thatT(c)
is a proper subtype ofT(b)
and a proper subtype ofT(a)
.”Perhaps it should read:
“A type
T(a)
is a direct subtype of a typeT(b)
ifT(a)
is a proper subtype ofT(b)
and there does not exist a typeT(c)
such thatT(c)
is a proper subtype ofT(b)
and a proper supertype ofT(a)
.”If this emendation is correct, then the terms “every direct supertype” and “every direct supertable” are misleading; more English are the terms “the direct supertype” and “the direct supertable”, passim.
The
CREATE TYPE
definition contains a contradiction:"4) If <subtype clause> is not specified, then <representation> shall be specified. 5) If <subtype clause> is not specified, then NOT FINAL shall be specified. 6) If <representation> specifies <predefined type>, then: a) ... b) FINAL shall be specified. c) <subtype clause> shall not be specified."
We have made no assumption as to the Standard’s intent here.
The
BNF
nonterminal <method specification> is defined differently in two separate sections. We have made no assumption as to which definition is the correct one.For the
NEW
statement, the Standard contains this suspicious looking grammer:"<new specification> ::= NEW <routine invocation> <new invocation> ::= <method invocation>"
<new invocation> is not used elsewhere. We assume that the definition is actually “
NEW
<method invocation>”.If this assumption is incorrect, the first syntax rule for the
NEW
statement seems like it would work only for the main option:“1) Let
RN
be the <routine name> immediately contained in the <routine invocation>. LetMN
be the <qualified identifier> immediately contained inRN
.”Possibly what is meant is:
“1) Let
RN
be the <routine name> immediately contained in the <routine invocation> or <method invocation>. LetMN
be the <qualified identifier> immediately contained inRN
.”This note looks out of place, and in any case is superseded by Note 243:
“NOTE 242 - The comparison categories of two user-defined types in the same type family must be the same.”
Possibly what is meant is:
“NOTE 242 - The comparison forms of two user-defined types in the same type family must be the same.”
The
INFORMATION_SCHEMA.ATTRIBUTES
view definition contains references toTABLE_CATALOG
andCOLUMN_DEFAULT
columns – neither of which are applicable here. We assume they should beUDT_CATALOG
andATTRIBUTE_DEFAULT
.The
DEFINITION_SCHEMA.ATTRIBUTES
base table is also defined as having two columns –TABLE_CATALOG
andTABLE_SCHEMA
– which are not applicable here. We assume they should beUDT_CATALOG
andUDT_SCHEMA
.Also, this table’s columns
USER_DEFINED_TYPE_CATALOG
,USER_DEFINED_TYPE_SCHEMA
andUSER_DEFINED_TYPE_NAME
are defined on domainINFORMATION_SCHEMA.CHARACTER_DATA
.But everywhere else, such columns are defined on domain
INFORMATION_SCHEMA.SQL_IDENTIFIER
. We assume the intent is to be consistent here as well.The
NUMERIC_PRECISION_RADIX
value for datetime / interval data types is unclear. TheGetTypeInfo
description of the ODBC 3.0 manual says: “If the data type is an approximate numeric type, this column contains the value2
to indicate thatCOLUMN_SIZE
specifies a number of bits. For exact numeric types, this column contains the value10
to indicate thatCOLUMN_SIZE
specifies a number of decimal digits. Otherwise, this column isNULL
.”The same section in the SQL/CLI document says:
"r) The value of NUM_PREC_RADIX is Case: i) If the value of PRECISION is the value of a precision, then the radix of that precision. ii) Otherwise, the null value."
While the definition of the
DEFINITION_SCHEMA.DATA_TYPE_DESCRIPTOR
base table, where this information is stored has this constraint:" CHECK ( ... DATA_TYPE IN ( 'DATE', 'TIME', 'TIMESTAMP', 'TIME WITH TIME ZONE', 'TIMESTAMP WITH TIME ZONE' ) ... AND ( NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX ) IS NOT NULL"
From the above quotes, some disagreements are visible:
The writers of ODBC thought datetime/interval radices are nullable.
The SQL/CLI writers had no idea
PRECISION
is a nonexistent column but agree that radices can be nullable if a data type has no precision.The foundation writers thought datetime/interval radices couldn’t be
NULL
.
For
GET_TYPE_INFO
, we assume the first two quotes reflect the true intent: thatNUMERIC_PRECISION_RADIX
value for datetimes and intervals isNULL
.The definition of the
INFORMATION_SCHEMA.ROLE_ROUTINE_GRANTS
view contains:"SELECT ... ROUTINE_CATALOG, ROUTINE_SCHEMA, ROUTINE_NAME ... FROM ROUTINE_PRIVILEGES"
But these three columns do not exist in the
ROUTINE_PRIVILEGES
table. We assume these columns should be omitted from the view.The definition of the
INFORMATION_SCHEMA.ROLE_USER_DEFINED_TYPE_GRANTS
view contains:"SELECT ... OBJECT_TYPE ... FROM DEFINITION_SCHEMA.USER_DEFINED_TYPE_PRIVILEGES"
But this column does not exist the in
USER_DEFINED_TYPE_PRIVILEGES
table. We assume this column should be omitted from the view.
SQL/CLI¶
The “Description of CLI item descriptors” says that
DEFERRED
is true if the octet length pointer points toSQL NULL DATA
.For
SQLGetTypeInfo
,NULL
values are returned forsql_prefix
andsql_suffix
– i.e.:NULL
is used to mean “blank string”. In other fields it means N/A.For
SQLExecute
andSQLExecute
, the general rules are ordered in such a way that input parameters will be checked for consistencyAFTER
execution. We assume that checking should take place before execution. The embedded SQL document has parameter-checking in the logical place.The
SQLDisconnect
function description contains a reference to an exception “active SQL-statement”; we assume this should read “active SQL-transaction”.The
SQLGetData
function description contains a reference toIP
andDP
, which do not exist.The
SQLSetDescField
function description suggests that it is illegal to set theSQL_DESC_TYPE
field toSQL_SMALLINT
,SQL_INTEGER
,SQL_REAL
orSQL_DOUBLE_PRECISION
(or several other legal data types). This is clearly an oversight.The
SQLSetDescField
function description fails to state that theRecordNumber
parameter should be ignored ifFieldIdentifier
isSQL_DESC_COUNT
. We assume this is the case.The
SQLGetDescRec
function description is ambiguous about the field to be used as the source for Length.For
SQLGetDiagField
, the Standard saysSQL_DIAG_MORE
is associated with a return of'Y'
or'N'
. ButSQL_DIAG_MORE
is not defined as a string.For
SQLGetLength
: exception “Invalid argument value” is undefined.For
SQLColumns
: for a <fractional seconds precision>, the value is taken fromINFORMATION_SCHEMA.COLUMNS.NUMERIC_PRECISION
. The value is actually inINFORMATION_SCHEMA.COLUMNS.DATETIME_PRECISION
and we assume this is the intent. Also: theSQL_DATA_TYPE
column has been forgotten; we assume it is included. Also: for calculatingSQL_DATETIME_SUB
, the Standard says one is supposed to useINFORMATION_SCHEMA.COLUMNS.DATA_TYPE
to look up a'Code'
– however, the information is actually in found inINFORMATION_SCHEMA.COLUMNS.INTERVAL_TYPE
; we assume this is the intent.There is an implicit assumption that
CAST
is possible between two character sets (otherwise, why bother having character set in the descriptor IDA?). ButCAST
is illegal if repertoires differ.