SQL Conformance

This chapter attempts to outline to what extent QHB conforms to the current SQL standard. The following information is not a full statement of conformance, but it presents the main topics in as much detail as is both reasonable and useful for users.

The formal name of the SQL standard is ISO/IEC 9075 “Database Language SQL”. A revised version of the standard is released from time to time; the most recent update appearing in 2023. The 2023 version is referred to as ISO/IEC 9075:2023, or simply as SQL:2023. The versions prior to that were SQL:2016, SQL:2011, SQL:2008, SQL:2006, SQL:2003, SQL:1999, and SQL-92. Each version replaces the previous one, so claims of conformance to earlier versions have no official merit. QHB development aims for conformance with the latest official version of the standard where such conformance does not contradict traditional features or common sense. Many of the features required by the SQL standard are supported, though sometimes with slightly differing syntax or function. Further moves towards conformance can be expected over time.

SQL-92 defined three feature sets for conformance: Entry, Intermediate, and Full. Most database management systems claiming SQL standard conformance were conforming at only the Entry level, since the entire set of features in the Intermediate and Full levels was either too voluminous or in conflict with legacy behaviors.

Starting with SQL:1999, the SQL standard defines a large set of individual features rather than the ineffectively broad three levels found in SQL-92. A large subset of these features represents the “Core” features, which every conforming SQL implementation must supply. The rest of the features are purely optional.

The standard is split into a number of parts also known by a shorthand name.

  • ISO/IEC 9075-1 Framework (SQL/Framework)

  • ISO/IEC 9075-2 Foundation (SQL/Foundation)

  • ISO/IEC 9075-3 Call Level Interface (SQL/CLI)

  • ISO/IEC 9075-4 Persistent Stored Modules (SQL/PSM)

  • ISO/IEC 9075-9 Management of External Data (SQL/MED)

  • ISO/IEC 9075-10 Object Language Bindings (SQL/OLB)

  • ISO/IEC 9075-11 Information and Definition Schemas (SQL/Schemata)

  • ISO/IEC 9075-13 Routines and Types using the Java Language (SQL/JRT)

  • ISO/IEC 9075-14 XML-related specifications (SQL/XML)

  • ISO/IEC 9075-15 Multi-dimensional arrays (SQL/MDA)

  • ISO/IEC 9075-16 Property Graph Queries (SQL/PGQ)

Note that some part numbers are not (or no longer) used.

The QHB core covers parts 1, 2, 9, 11, and 14. Part 3 is covered by the ODBC driver, and part 13 is covered by the PL/Java plug-in, but exact conformance is currently not being verified for these components. There are currently no implementations of parts 4, 10, 15, and 16 for QHB.

QHB supports most of the major features of SQL:2023. Out of 177 mandatory features required for full Core conformance, QHB conforms to at least 170. In addition, there is a long list of supported optional features. It might be worth noting that at the time of writing, no current version of any database management system claims full conformance to Core SQL:2023.

In the following two sections, we provide a list of those features that QHB supports, followed by a list of the features defined in SQL:2023 which are not yet supported in QHB. Both of these lists are approximate: There might be minor details that are nonconforming for a feature that is listed as supported, and large parts of an unsupported feature might in fact be implemented. The main body of the documentation always contains the most accurate information about what does and does not work.

Note
Feature codes containing a hyphen are subfeatures. Therefore, if a particular subfeature is not supported, the main feature is listed as unsupported even if some other subfeatures are supported.



Supported Features

IdentifierCore?DescriptionComment
B012Embedded C
B021Direct SQL
B128Routine language SQL
E011CoreNumeric data types
E011-01CoreINTEGER and SMALLINT data types
E011-02CoreREAL, DOUBLE PRECISION, and FLOAT data types
E011-03CoreDECIMAL and NUMERIC data types
E011-04CoreArithmetic operators
E011-05CoreNumeric comparison
E011-06CoreImplicit casting among the numeric data types
E021CoreCharacter data types
E021-01CoreCHARACTER data type
E021-02CoreCHARACTER VARYING data type
E021-03CoreCharacter literals
E021-04CoreCHARACTER_LENGTH functiontrims trailing spaces from CHARACTER values before counting
E021-05CoreOCTET_LENGTH function
E021-06CoreSUBSTRING function
E021-07CoreCharacter concatenation
E021-08CoreUPPER and LOWER functions
E021-09CoreTRIM function
E021-10CoreImplicit casting among the character string types
E021-11CorePOSITION function
E021-12CoreCharacter comparison
E031CoreIdentifiers
E031-01CoreDelimited identifiers
E031-02CoreLower case identifiers
E031-03CoreTrailing underscore
E051CoreBasic query specification
E051-01CoreSELECT DISTINCT
E051-02CoreGROUP BY clause
E051-04CoreGROUP BY can contain columns not in <select list>
E051-05CoreSelect list items can be renamed
E051-06CoreHAVING clause
E051-07CoreQualified * in select list
E051-08CoreCorrelation names in the FROM clause
E051-09CoreRename columns in the FROM clause
E061CoreBasic predicates and search conditions
E061-01CoreComparison predicate
E061-02CoreBETWEEN predicate
E061-03CoreIN predicate with list of values
E061-04CoreLIKE predicate
E061-05CoreLIKE predicate ESCAPE clause
E061-06CoreNULL predicate
E061-07CoreQuantified comparison predicate
E061-08CoreEXISTS predicate
E061-09CoreSubqueries in comparison predicate
E061-11CoreSubqueries in IN predicate
E061-12CoreSubqueries in quantified comparison predicate
E061-13CoreCorrelated subqueries
E061-14CoreSearch condition
E071CoreBasic query expressions
E071-01CoreUNION DISTINCT table operator
E071-02CoreUNION ALL table operator
E071-03CoreEXCEPT DISTINCT table operator
E071-05CoreColumns combined via table operators need not have exactly the same data type
E071-06CoreTable operators in subqueries
E081CoreBasic Privileges
E081-01CoreSELECT privilege
E081-02CoreDELETE privilege
E081-03CoreINSERT privilege at the table level
E081-04CoreUPDATE privilege at the table level
E081-05CoreUPDATE privilege at the column level
E081-06CoreREFERENCES privilege at the table level
E081-07CoreREFERENCES privilege at the column level
E081-08CoreWITH GRANT OPTION
E081-09CoreUSAGE privilege
E081-10CoreEXECUTE privilege
E091CoreSet functions
E091-01CoreAVG
E091-02CoreCOUNT
E091-03CoreMAX
E091-04CoreMIN
E091-05CoreSUM
E091-06CoreALL quantifier
E091-07CoreDISTINCT quantifier
E101CoreBasic data manipulation
E101-01CoreINSERT statement
E101-03CoreSearched UPDATE statement
E101-04CoreSearched DELETE statement
E111CoreSingle row SELECT statement
E121CoreBasic cursor support
E121-01CoreDECLARE CURSOR
E121-02CoreORDER BY columns need not be in select list
E121-03CoreValue expressions in ORDER BY clause
E121-04CoreOPEN statement
E121-06CorePositioned UPDATE statement
E121-07CorePositioned DELETE statement
E121-08CoreCLOSE statement
E121-10CoreFETCH statement implicit NEXT
E121-17CoreWITH HOLD cursors
E131CoreNull value support (nulls in lieu of values)
E141CoreBasic integrity constraints
E141-01CoreNOT NULL constraints
E141-02CoreUNIQUE constraints of NOT NULL columns
E141-03CorePRIMARY KEY constraints
E141-04CoreBasic FOREIGN KEY constraint with the NO ACTION default for both referential delete action and referential update action
E141-06CoreCHECK constraints
E141-07CoreColumn defaults
E141-08CoreNOT NULL inferred on PRIMARY KEY
E141-10CoreNames in a foreign key can be specified in any order
E151CoreTransaction support
E151-01CoreCOMMIT statement
E151-02CoreROLLBACK statement
E152CoreBasic SET TRANSACTION statement
E152-01CoreSET TRANSACTION statement: ISOLATION LEVEL SERIALIZABLE clause
E152-02CoreSET TRANSACTION statement: READ ONLY and READ WRITE clauses
E153CoreUpdatable queries with subqueries
E161CoreSQL comments using leading double minus
E171CoreSQLSTATE support
E182CoreHost language binding
F021CoreBasic information schema
F021-01CoreCOLUMNS view
F021-02CoreTABLES view
F021-03CoreVIEWS view
F021-04CoreTABLE_CONSTRAINTS view
F021-05CoreREFERENTIAL_CONSTRAINTS view
F021-06CoreCHECK_CONSTRAINTS view
F031CoreBasic schema manipulation
F031-01CoreCREATE TABLE statement to create persistent base tables
F031-02CoreCREATE VIEW statement
F031-03CoreGRANT statement
F031-04CoreALTER TABLE statement: ADD COLUMN clause
F031-13CoreDROP TABLE statement: RESTRICT clause
F031-16CoreDROP VIEW statement: RESTRICT clause
F031-19CoreREVOKE statement: RESTRICT clause
F032CASCADE drop behavior
F033ALTER TABLE statement: DROP COLUMN clause
F034Extended REVOKE statement
F034-01REVOKE statement performed by other than the owner of a schema object
F034-02REVOKE statement: GRANT OPTION FOR clause
F034-03REVOKE statement to revoke a privilege that the grantee has WITH GRANT OPTION
F041CoreBasic joined table
F041-01CoreInner join (but not necessarily the INNER keyword)
F041-02CoreINNER keyword
F041-03CoreLEFT OUTER JOIN
F041-04CoreRIGHT OUTER JOIN
F041-05CoreOuter joins can be nested
F041-07CoreThe inner table in a left or right outer join can also be used in an inner join
F041-08CoreAll comparison operators are supported (rather than just =)
F051CoreBasic date and time
F051-01CoreDATE data type (including support of DATE literal)
F051-02CoreTIME data type (including support of TIME literal) with fractional seconds precision of at least 0
F051-03CoreTIMESTAMP data type (including support of TIMESTAMP literal) with fractional seconds precision of at least 0 and 6
F051-04CoreComparison predicate on DATE, TIME, and TIMESTAMP data types
F051-05CoreExplicit CAST between datetime types and character string types
F051-06CoreCURRENT_DATE
F051-07CoreLOCALTIME
F051-08CoreLOCALTIMESTAMP
F052Intervals and datetime arithmetic
F053OVERLAPS predicate
F081CoreUNION and EXCEPT in views
F111Isolation levels other than SERIALIZABLE
F111-01READ UNCOMMITTED isolation level
F111-02READ COMMITTED isolation level
F111-03REPEATABLE READ isolation level
F131CoreGrouped operations
F131-01CoreWHERE, GROUP BY, and HAVING clauses supported in queries with grouped views
F131-02CoreMultiple tables supported in queries with grouped views
F131-03CoreSet functions supported in queries with grouped views
F131-04CoreSubqueries with GROUP BY and HAVING clauses and grouped views
F131-05CoreSingle row SELECT with GROUP BY and HAVING clauses and grouped views
F171Multiple schemas per user
F181CoreMultiple module support
F191Referential delete actions
F200TRUNCATE TABLE statement
F201CoreCAST function
F202TRUNCATE TABLE: identity column restart option
F221CoreExplicit defaults
F222INSERT statement: DEFAULT VALUES clause
F231Privilege tables
F231-01TABLE_PRIVILEGES view
F231-02COLUMN_PRIVILEGES view
F231-03USAGE_PRIVILEGES view
F251Domain support
F261CoreCASE expression
F261-01CoreSimple CASE
F261-02CoreSearched CASE
F261-03CoreNULLIF
F261-04CoreCOALESCE
F262Extended CASE expression
F271Compound character literals
F281LIKE enhancements
F292UNIQUE null treatmentSQL:202x draft
F302INTERSECT table operator
F302-01INTERSECT DISTINCT table operator
F302-02INTERSECT ALL table operator
F304EXCEPT ALL table operator
F311CoreSchema definition statement
F311-01CoreCREATE SCHEMA
F311-02CoreCREATE TABLE for persistent base tables
F311-03CoreCREATE VIEW
F311-04CoreCREATE VIEW: WITH CHECK OPTION
F311-05CoreGRANT statement
F312MERGE statement
F313Enhanced MERGE statement
F314MERGE statement with DELETE branch
F321User authorization
F341Usage tables
F361Subprogram support
F381Extended schema manipulation
F381-01ALTER TABLE statement: ALTER COLUMN clause
F381-02ALTER TABLE statement: ADD CONSTRAINT clause
F381-03ALTER TABLE statement: DROP CONSTRAINT clause
F382Alter column data type
F383Set column not null clause
F384Drop identity property clause
F385Drop column generation expression clause
F386Set identity column generation clause
F391Long identifiers
F392Unicode escapes in identifiers
F393Unicode escapes in literals
F394Optional normal form specification
F401Extended joined table
F401-01NATURAL JOIN
F401-02FULL OUTER JOIN
F401-04CROSS JOIN
F402Named column joins for LOBs, arrays, and multisets
F404Range variable for common column names
F411Time zone specificationdifferences regarding literal interpretation
F421National character
F431Read-only scrollable cursors
F431-01FETCH with explicit NEXT
F431-02FETCH FIRST
F431-03FETCH LAST
F431-04FETCH PRIOR
F431-05FETCH ABSOLUTE
F431-06FETCH RELATIVE
F441Extended set function support
F442Mixed column references in set functions
F471CoreScalar subquery values
F481CoreExpanded NULL predicate
F491Constraint management
F501CoreFeatures and conformance views
F501-01CoreSQL_FEATURES view
F501-02CoreSQL_SIZING view
F502Enhanced documentation tables
F531Temporary tables
F555Enhanced seconds precision
F561Full value expressions
F571Truth value tests
F591Derived tables
F611Indicator data types
F641Row and table constructors
F651Catalog name qualifiers
F661Simple tables
F672Retrospective check constraints
F690Collation supportbut no character set support
F692Extended collation support
F701Referential update actions
F711ALTER domain
F731INSERT column privileges
F751View CHECK enhancements
F761Session management
F762CURRENT_CATALOG
F763CURRENT_SCHEMA
F771Connection management
F781Self-referencing operations
F791Insensitive cursors
F801Full set function
F850Top-level <order by clause> in <query expression>
F851<order by clause> in subqueries
F852Top-level <order by clause> in views
F855Nested <order by clause> in <query expression>
F856Nested <fetch first clause> in <query expression>
F857Top-level <fetch first clause> in <query expression>
F858<fetch first clause> in subqueries
F859Top-level <fetch first clause> in views
F860<fetch first row count> in <fetch first clause>
F861Top-level <result offset clause> in <query expression>
F862<result offset clause> in subqueries
F863Nested <result offset clause> in <query expression>
F864Top-level <result offset clause> in views
F865<offset row count> in <result offset clause>
F867FETCH FIRST clause: WITH TIES option
S071SQL paths in function and type name resolution
S091-01Arrays of built-in data types
S091-03Array expressions
S092Arrays of user-defined types
S095Array constructors by query
S096Optional array bounds
S098ARRAY_AGG
S111ONLY in query expressions
S201SQL-invoked routines on arrays
S201-01Array parameters
S201-02Array as result type of functions
S211User-defined cast functions
S301Enhanced UNNEST
S404TRIM_ARRAY
T031BOOLEAN data type
T071BIGINT data type
T121WITH (excluding RECURSIVE) in query expression
T122WITH (excluding RECURSIVE) in subquery
T131Recursive query
T132Recursive query in subquery
T133Enhanced cycle mark valuesSQL:202x draft
T141SIMILAR predicate
T151DISTINCT predicate
T152DISTINCT predicate with negation
T171LIKE clause in table definition
T172AS subquery clause in table definition
T173Extended LIKE clause in table definition
T174Identity columns
T177Sequence generator support: simple restart option
T178Identity columns: simple restart option
T191Referential action RESTRICT
T201Comparable data types for referential constraints
T211-01Triggers activated on UPDATE, INSERT, or DELETE of one base table
T211-02BEFORE triggers
T211-03AFTER triggers
T211-04FOR EACH ROW triggers
T211-05Ability to specify a search condition that must be true before the trigger is invoked
T211-07TRIGGER privilege
T212Enhanced trigger capability
T213INSTEAD OF triggers
T241START TRANSACTION statement
T261Chained transactions
T271Savepoints
T281SELECT privilege with column granularity
T285Enhanced derived column names
T312OVERLAY function
T321-01CoreUser-defined functions with no overloading
T321-02CoreUser-defined stored procedures with no overloading
T321-03CoreFunction invocation
T321-04CoreCALL statement
T321-05CoreRETURN statement
T321-06CoreROUTINES view
T321-07CorePARAMETERS view
T323Explicit security for external routines
T325Qualified SQL parameter references
T331Basic roles
T332Extended roles
T341Overloading of SQL-invoked functions and procedures
T351Bracketed SQL comments (/*...*/ comments)
T431Extended grouping capabilities
T432Nested and concatenated GROUPING SETS
T433Multiargument GROUPING function
T434GROUP BY DISTINCT
T441ABS and MOD functions
T461Symmetric BETWEEN predicate
T491LATERAL derived table
T501Enhanced EXISTS predicate
T521Named arguments in CALL statement
T523Default values for INOUT parameters of SQL-invoked procedures
T524Named arguments in routine invocations other than a CALL statement
T525Default values for parameters of SQL-invoked functions
T551Optional key words for default syntax
T581Regular expression substring function
T591UNIQUE constraints of possibly null columns
T611Elementary OLAP operations
T612Advanced OLAP operations
T613Sampling
T614NTILE function
T615LEAD and LAG functions
T617FIRST_VALUE and LAST_VALUE function
T620WINDOW clause: GROUPS option
T621Enhanced numeric functions
T622Trigonometric functions
T623General logarithm functions
T624Common logarithm functions
T631CoreIN predicate with one list element
T651SQL-schema statements in SQL routines
T653SQL-schema statements in external routines
T655Cyclically dependent routines
T831SQL/JSON path language: strict mode
T832SQL/JSON path language: item method
T833SQL/JSON path language: multiple subscripts
T834SQL/JSON path language: wildcard member accessor
T835SQL/JSON path language: filter expressions
T836SQL/JSON path language: starts with predicate
T837SQL/JSON path language: regex_like predicate
X010XML type
X011Arrays of XML type
X014Attributes of XML type
X016Persistent XML values
X020XMLConcat
X031XMLElement
X032XMLForest
X034XMLAgg
X035XMLAgg: ORDER BY option
X036XMLComment
X037XMLPI
X040Basic table mapping
X041Basic table mapping: nulls absent
X042Basic table mapping: null as nil
X043Basic table mapping: table as forest
X044Basic table mapping: table as element
X045Basic table mapping: with target namespace
X046Basic table mapping: data mapping
X047Basic table mapping: metadata mapping
X048Basic table mapping: base64 encoding of binary strings
X049Basic table mapping: hex encoding of binary strings
X050Advanced table mapping
X051Advanced table mapping: nulls absent
X052Advanced table mapping: null as nil
X053Advanced table mapping: table as forest
X054Advanced table mapping: table as element
X055Advanced table mapping: with target namespace
X056Advanced table mapping: data mapping
X057Advanced table mapping: metadata mapping
X058Advanced table mapping: base64 encoding of binary strings
X059Advanced table mapping: hex encoding of binary strings
X060XMLParse: character string input and CONTENT option
X061XMLParse: character string input and DOCUMENT option
X070XMLSerialize: character string serialization and CONTENT option
X071XMLSerialize: character string serialization and DOCUMENT option
X072XMLSerialize: character string serialization
X090XML document predicate
X120XML parameters in SQL routines
X121XML parameters in external routines
X221XML passing mechanism BY VALUE
X301XMLTable: derived column list option
X302XMLTable: ordinality column option
X303XMLTable: column default option
X304XMLTable: passing a context itemmust be XML DOCUMENT
X400Name and identifier mapping
X410Alter column data type: XML type

Unsupported Features

The following features defined in SQL:2023 are not implemented in this release of QHB. In a few cases, equivalent functionality is available.

IdentifierCore?DescriptionComment
B011Embedded Ada
B013Embedded COBOL
B014Embedded Fortran
B015Embedded MUMPS
B016Embedded Pascal
B017Embedded PL/I
B031Basic dynamic SQL
B032Extended dynamic SQL
B032-01<describe input statement>
B033Untyped SQL-invoked function arguments
B034Dynamic specification of cursor attributes
B035Non-extended descriptor names
B041Extensions to embedded SQL exception declarations
B051Enhanced execution rights
B111Module language Ada
B112Module language C
B113Module language COBOL
B114Module language Fortran
B115Module language MUMPS
B116Module language Pascal
B117Module language PL/I
B121Routine language Ada
B122Routine language C
B123Routine language COBOL
B124Routine language Fortran
B125Routine language MUMPS
B126Routine language Pascal
B127Routine language PL/I
B200Polymorphic table functions (PTF)
B201More than one PTF generic table parameter
B202PTF Copartitioning
B203More than one copartition specification
B204PRUNE WHEN EMPTY
B205Pass-through columns
B206PTF descriptor parameters
B207Cross products of partitionings
B208PTF component procedure interface
B209PTF extended names
B211Module language Ada: VARCHAR and NUMERIC support
B221Routine language Ada: VARCHAR and NUMERIC support
F054TIMESTAMP in DATE type precedence list
F121Basic diagnostics management
F121-01GET DIAGNOSTICS statement
F121-02SET TRANSACTION statement: DIAGNOSTICS SIZE clause
F122Enhanced diagnostics management
F123All diagnostics
F263Comma-separated predicates in simple CASE expression
F291UNIQUE predicate
F301CORRESPONDING in query expressions
F403Partitioned joined tables
F451Character set definition
F461Named character sets
F492Optional table constraint enforcement
F521Assertions
F671Subqueries in CHECKintentionally omitted
F673Reads SQL-data routine invocations in CHECK constraints
F693SQL-session and client module collations
F695Translation support
F696Additional translation documentation
F721Deferrable constraintsforeign and unique keys only
F741Referential MATCH typesno partial match yet
F812CoreBasic flagging
F813Extended flagging
F821Local table references
F831Full cursor update
F831-01Updatable scrollable cursors
F831-02Updatable ordered cursors
F841LIKE_REGEX predicateconsider regexp_like()
F842OCCURRENCES_REGEX functionconsider regexp_matches()
F843POSITION_REGEX functionconsider regexp_instr()
F844SUBSTRING_REGEX functionconsider regexp_substr()
F845TRANSLATE_REGEX functionconsider regexp_replace()
F846Octet support in regular expression operators
F847Nonconstant regular expressions
F866FETCH FIRST clause: PERCENT option
R010Row pattern recognition: FROM clause
R020Row pattern recognition: WINDOW clause
R030Row pattern recognition: full aggregate support
S011CoreDistinct data types
S011-01CoreUSER_DEFINED_TYPES view
S023Basic structured types
S024Enhanced structured types
S025Final structured types
S026Self-referencing structured types
S027Create method by specific method name
S028Permutable UDT options list
S041Basic reference types
S043Enhanced reference types
S051Create table of typepartially supported
S081Subtables
S091Basic array supportpartially supported
S091-02Arrays of distinct types
S094Arrays of reference types
S097Array element assignment
S151Type predicatesee pg_typeof()
S161Subtype treatment
S162Subtype treatment for references
S202SQL-invoked routines on multisets
S231Structured type locators
S232Array locators
S233Multiset locators
S241Transform functions
S242Alter transform statement
S251User-defined orderings
S261Specific type method
S271Basic multiset support
S272Multisets of user-defined types
S274Multisets of reference types
S275Advanced multiset support
S281Nested collection types
S291Unique constraint on entire row
S401Distinct types based on array types
S402Distinct types based on distinct types
S403ARRAY_MAX_CARDINALITY
T011Timestamp in Information Schema
T021BINARY and VARBINARY data types
T022Advanced support for BINARY and VARBINARY data types
T023Compound binary literal
T024Spaces in binary literals
T041Basic LOB data type support
T041-01BLOB data type
T041-02CLOB data type
T041-03POSITION, LENGTH, LOWER, TRIM, UPPER, and SUBSTRING functions for LOB data types
T041-04Concatenation of LOB data types
T041-05LOB locator: non-holdable
T042Extended LOB data type support
T043Multiplier T
T044Multiplier P
T051Row types
T053Explicit aliases for all-fields reference
T061UCS support
T076DECFLOAT data type
T101Enhanced nullability determination
T111Updatable joins, unions, and columns
T175Generated columnsmostly supported
T176Sequence generator supportsupported except for NEXT VALUE FOR
T180System-versioned tables
T181Application-time period tables
T211Basic trigger capability
T211-06Support for run-time rules for the interaction of triggers and constraints
T211-08Multiple triggers for the same event are executed in the order in which they were created in the catalogintentionally omitted
T231Sensitive cursors
T251SET TRANSACTION statement: LOCAL option
T272Enhanced savepoint management
T301Functional dependenciespartially supported
T321CoreBasic SQL-invoked routinespartially supported
T322Declared data type attributes
T324Explicit security for SQL routines
T326Table functions
T471Result sets return value
T472DESCRIBE CURSOR
T495Combined data change and retrievaldifferent syntax
T502Period predicates
T511Transaction counts
T522Default values for IN parameters of SQL-invoked proceduressupported except DEFAULT key word in invocation
T561Holdable locators
T571Array-returning external SQL-invoked functions
T572Multiset-returning external SQL-invoked functions
T601Local cursor references
T616Null treatment option for LEAD and LAG functions
T618NTH_VALUE functionfunction exists, but some options missing
T619Nested window functions
T625LISTAGG
T641Multiple column assignmentonly some syntax variants supported
T652SQL-dynamic statements in SQL routines
T654SQL-dynamic statements in external routines
T811Basic SQL/JSON constructor functions
T812SQL/JSON: JSON_OBJECTAGG
T813SQL/JSON: JSON_ARRAYAGG with ORDER BY
T814Colon in JSON_OBJECT or JSON_OBJECTAGG
T821Basic SQL/JSON query operators
T822SQL/JSON: IS JSON WITH UNIQUE KEYS predicate
T823SQL/JSON: PASSING clause
T824JSON_TABLE: specific PLAN clause
T825SQL/JSON: ON EMPTY and ON ERROR clauses
T826General value expression in ON ERROR or ON EMPTY clauses
T827JSON_TABLE: sibling NESTED COLUMNS clauses
T828JSON_QUERY
T829JSON_QUERY: array wrapper options
T830Enforcing unique keys in SQL/JSON constructor functions
T838JSON_TABLE: PLAN DEFAULT clause
T839Formatted cast of datetimes to/from character strings
M001Datalinks
M002Datalinks via SQL/CLI
M003Datalinks via Embedded SQL
M004Foreign data supportpartially supported
M005Foreign schema support
M006GetSQLString routine
M007TransmitRequest
M009GetOpts and GetStatistics routines
M010Foreign data wrapper supportdifferent API
M011Datalinks via Ada
M012Datalinks via C
M013Datalinks via COBOL
M014Datalinks via Fortran
M015Datalinks via MUMPS
M016Datalinks via Pascal
M017Datalinks via PL/I
M018Foreign data wrapper interface routines in Ada
M019Foreign data wrapper interface routines in Cdifferent API
M020Foreign data wrapper interface routines in COBOL
M021Foreign data wrapper interface routines in Fortran
M022Foreign data wrapper interface routines in MUMPS
M023Foreign data wrapper interface routines in Pascal
M024Foreign data wrapper interface routines in PL/I
M030SQL-server foreign data support
M031Foreign data wrapper general routines
X012Multisets of XML type
X013Distinct types of XML type
X015Fields of XML type
X025XMLCast
X030XMLDocument
X038XMLText
X065XMLParse: BLOB input and CONTENT option
X066XMLParse: BLOB input and DOCUMENT option
X068XMLSerialize: BOM
X069XMLSerialize: INDENT
X073XMLSerialize: BLOB serialization and CONTENT option
X074XMLSerialize: BLOB serialization and DOCUMENT option
X075XMLSerialize: BLOB serialization
X076XMLSerialize: VERSION
X077XMLSerialize: explicit ENCODING option
X078XMLSerialize: explicit XML declaration
X080Namespaces in XML publishing
X081Query-level XML namespace declarations
X082XML namespace declarations in DML
X083XML namespace declarations in DDL
X084XML namespace declarations in compound statements
X085Predefined namespace prefixes
X086XML namespace declarations in XMLTable
X091XML content predicate
X096XMLExistsXPath 1.0 only
X100Host language support for XML: CONTENT option
X101Host language support for XML: DOCUMENT option
X110Host language support for XML: VARCHAR mapping
X111Host language support for XML: CLOB mapping
X112Host language support for XML: BLOB mapping
X113Host language support for XML: STRIP WHITESPACE option
X114Host language support for XML: PRESERVE WHITESPACE option
X131Query-level XMLBINARY clause
X132XMLBINARY clause in DML
X133XMLBINARY clause in DDL
X134XMLBINARY clause in compound statements
X135XMLBINARY clause in subqueries
X141IS VALID predicate: data-driven case
X142IS VALID predicate: ACCORDING TO clause
X143IS VALID predicate: ELEMENT clause
X144IS VALID predicate: schema location
X145IS VALID predicate outside check constraints
X151IS VALID predicate with DOCUMENT option
X152IS VALID predicate with CONTENT option
X153IS VALID predicate with SEQUENCE option
X155IS VALID predicate: NAMESPACE without ELEMENT clause
X157IS VALID predicate: NO NAMESPACE with ELEMENT clause
X160Basic Information Schema for registered XML Schemas
X161Advanced Information Schema for registered XML Schemas
X170XML null handling options
X171NIL ON NO CONTENT option
X181XML(DOCUMENT (UNTYPED)) type
X182XML(DOCUMENT(ANY)) type
X190XML(SEQUENCE) type
X191XML(DOCUMENT(XMLSCHEMA)) type
X192XML(CONTENT(XMLSCHEMA)) type
X200XMLQuery
X201XMLQuery: RETURNING CONTENT
X202XMLQuery: RETURNING SEQUENCE
X203XMLQuery: passing a context item
X204XMLQuery: initializing an XQuery variable
X205XMLQuery: EMPTY ON EMPTY option
X206XMLQuery: NULL ON EMPTY option
X211XML 1.1 support
X222XML passing mechanism BY REFparser accepts BY REF but ignores it; passing is always BY VALUE
X231XML(CONTENT (UNTYPED)) type
X232XML(CONTENT (ANY)) type
X241RETURNING CONTENT in XML publishing
X242RETURNING SEQUENCE in XML publishing
X251Persistent XML values of XML(DOCUMENT (UNTYPED)) type
X252Persistent XML values of XML(DOCUMENT (ANY)) type
X253Persistent XML values of XML(CONTENT (UNTYPED)) type
X254Persistent XML values of XML(CONTENT (ANY)) type
X255Persistent XML values of XML(SEQUENCE) type
X256Persistent XML values of XML(DOCUMENT (XMLSCHEMA)) type
X257Persistent XML values of XML(CONTENT (XMLSCHEMA)) type
X260XML type: ELEMENT clause
X261XML type: NAMESPACE without ELEMENT clause
X263XML type: NO NAMESPACE with ELEMENT clause
X264XML type: schema location
X271XMLValidate: data-driven case
X272XMLValidate: ACCORDING TO clause
X273XMLValidate: ELEMENT clause
X274XMLValidate: schema location
X281XMLValidate with DOCUMENT option
X282XMLValidate with CONTENT option
X283XMLValidate with SEQUENCE option
X284XMLValidate: NAMESPACE without ELEMENT clause
X286XMLValidate: NO NAMESPACE with ELEMENT clause
X300XMLTableXPath 1.0 only
X305XMLTable: initializing an XQuery variable

XML Limits and Conformance to SQL/XML

Significant revisions to the XML-related specifications in ISO/IEC 9075-14 (SQL/XML) were introduced with SQL:2006. QHB's implementation of the XML data type and related functions largely follows the earlier 2003 edition, with some borrowing from later editions. In particular:

  • Where the current standard provides a family of XML data types to hold “document” or “content” in untyped or XML Schema-typed variants, and a type XML(SEQUENCE) to hold arbitrary pieces of XML content, QHB provides the single xml type, which can hold “document” or “content”. There is no equivalent of the standard's “sequence” type.

  • QHB provides two functions introduced in SQL:2006, but in variants that use the XPath 1.0 language, rather than XML Query as specified for them in the standard.

This section presents some of the resulting differences you may encounter.


Queries Are Restricted to XPath 1.0

The QHB-specific functions xpath() and xpath_exists() query XML documents using the XPath language. QHB also provides XPath-only variants of the standard functions XMLEXISTS and XMLTABLE, which officially use the XQuery language. For all of these functions, QHB relies on the libxml2 library, which provides only XPath 1.0.

There is a strong connection between the XQuery language and XPath versions 2.0 and later: any expression that is syntactically valid and executes successfully in both produces the same result (with a minor exception for expressions containing numeric character references or predefined entity references, which XQuery replaces with the corresponding character while XPath leaves them alone). But there is no such connection between these languages and XPath 1.0; it was an earlier language and differs in many respects.

There are two categories of limitation to keep in mind: the restriction from XQuery to XPath for the functions specified in the SQL standard, and the restriction of XPath to version 1.0 for both the standard and the QHB-specific functions.


Restriction of XQuery to XPath

Features of XQuery beyond those of XPath include:

  • XQuery expressions can construct and return new XML nodes, in addition to all possible XPath values. XPath can create and return values of the atomic types (numbers, strings, and so on) but can only return XML nodes that were already present in documents supplied as input to the expression.

  • XQuery has control constructs for iteration, sorting, and grouping.

  • XQuery allows declaration and use of local functions.

Recent XPath versions begin to offer capabilities overlapping with these (such as functional-style for-each and sort, anonymous functions, and parse-xml to create a node from a string), but such features were not available before XPath 3.0.

Restriction of XPath to 1.0

For developers familiar with XQuery and XPath 2.0 or later, XPath 1.0 presents a number of differences to contend with:

  • The fundamental type of an XQuery/XPath expression, the sequence, which can contain XML nodes, atomic values, or both, does not exist in XPath 1.0. A 1.0 expression can only produce a node-set (containing zero or more XML nodes), or a single atomic value.

  • Unlike an XQuery/XPath sequence, which can contain any desired items in any desired order, an XPath 1.0 node-set has no guaranteed order and, like any set, does not allow multiple appearances of the same item.

    Note
    The libxml2 library does seem to always return node-sets to QHB with their members in the same relative order they had in the input document. Its documentation does not commit to this behavior, and an XPath 1.0 expression cannot control it.

  • While XQuery/XPath provides all of the types defined in XML Schema and many operators and functions over those types, XPath 1.0 has only node-sets and the three atomic types boolean, double, and string.

  • XPath 1.0 has no conditional operator. An XQuery/XPath expression such as if ( hat ) then hat/@size else "no hat" has no XPath 1.0 equivalent.

  • XPath 1.0 has no ordering comparison operator for strings. Both "cat" < "dog" and "cat" > "dog" are false, because each is a numeric comparison of two NaNs. In contrast, = and != do compare the strings as strings.

  • XPath 1.0 blurs the distinction between value comparisons and general comparisons as XQuery/XPath define them. Both sale/@hatsize = 7 and sale/@customer = "alice" are existentially quantified comparisons, true if there is any sale with the given value for the attribute, but sale/@taxable = false() is a value comparison to the effective boolean value of a whole node-set. It is true only if no sale has a taxable attribute at all.

  • In the XQuery/XPath data model, a document node can have either document form (i.e., exactly one top-level element, with only comments and processing instructions outside of it) or content form (with those constraints relaxed). Its equivalent in XPath 1.0, the root node, can only be in document form. This is part of the reason an xml value passed as the context item to any QHB XPath-based function must be in document form.

The differences highlighted here are not all of them. In XQuery and the 2.0 and later versions of XPath, there is an XPath 1.0 compatibility mode, and the W3C lists of function library changes and language changes applied in that mode offer a more complete (but still not exhaustive) account of the differences. The compatibility mode cannot make the later languages exactly equivalent to XPath 1.0.


Mappings between SQL and XML Data Types and Values

In SQL:2006 and later, both directions of conversion between standard SQL data types and the XML Schema types are specified precisely. However, the rules are expressed using the types and semantics of XQuery/XPath, and have no direct application to the different data model of XPath 1.0.

When QHB maps SQL data values to XML (as in xmlelement), or XML to SQL (as in the output columns of xmltable), except for a few cases treated specially, QHB simply assumes that the XML data type's XPath 1.0 string form will be valid as the text-input form of the SQL datatype, and conversely. This rule has the virtue of simplicity while producing, for many data types, results similar to the mappings specified in the standard.

Where interoperability with other systems is a concern, for some data types, it may be necessary to use data type formatting functions (such as those in Section Data Type Formatting Functions) explicitly to produce the standard mappings.


Incidental Limits of the Implementation

This section concerns limits that are not inherent in the libxml2 library, but apply to the current implementation in QHB.

Only BY VALUE Passing Mechanism Is Supported

The SQL standard defines two passing mechanisms that apply when passing an XML argument from SQL to an XML function or receiving a result: BY REF, in which a particular XML value retains its node identity, and BY VALUE, in which the content of the XML is passed but node identity is not preserved. A mechanism can be specified before a list of parameters, as the default mechanism for all of them, or after any parameter, to override the default.

To illustrate the difference, if x is an XML value, these two queries in an SQL:2006 environment would produce true and false, respectively:

SELECT XMLQUERY(’$a is $b’ PASSING BY REF x AS a, x AS b NULL ON EMPTY);

SELECT XMLQUERY(’$a is $b’ PASSING BY VALUE x AS a, x AS b NULL ON EMPTY);

QHB will accept BY VALUE or BY REF in an XMLEXISTS or XMLTABLE construct, but it ignores them. The xml data type holds a character- string serialized representation, so there is no node identity to preserve, and passing is always effectively BY VALUE.

Cannot Pass Named Parameters to Queries

The XPath-based functions support passing one parameter to serve as the XPath expression's context item, but do not support passing additional values to be available to the expression as named parameters.

No XML(SEQUENCE) Type

The QHB xml data type can only hold a value in DOCUMENT or CONTENT form. An XQuery/XPath expression context item must be a single XML node or atomic value, but XPath 1.0 further restricts it to be only an XML node, and has no node type allowing CONTENT. The upshot is that a well-formed DOCUMENT is the only form of XML value that QHB can supply as an XPath context item.