@@ -137,7 +137,7 @@ static void SPI_sql_row_to_xmlelement(int rownum, StringInfo result,
137137 errhint("You need to rebuild PostgreSQL using --with-libxml.")))
138138
139139
140- /* from SQL/XML:2003 section 4.7 */
140+ /* from SQL/XML:2008 section 4.9 */
141141#define NAMESPACE_XSD "http://www.w3.org/2001/XMLSchema"
142142#define NAMESPACE_XSI "http://www.w3.org/2001/XMLSchema-instance"
143143#define NAMESPACE_SQLXML "http://standards.iso.org/iso/9075/2003/sqlxml"
@@ -1200,9 +1200,9 @@ xml_parse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace,
12001200{
12011201/*
12021202 * Note, that here we try to apply DTD defaults
1203- * (XML_PARSE_DTDATTR) according to SQL/XML:10.16.7.d: 'Default
1203+ * (XML_PARSE_DTDATTR) according to SQL/XML:2008 GR 10.16.7.d: 'Default
12041204 * values defined by internal DTD are applied'. As for external
1205- * DTDs, we try to support them too, (see SQL/XML:10.16.7.e)
1205+ * DTDs, we try to support them too, (see SQL/XML:2008 GR 10.16.7.e)
12061206 */
12071207doc = xmlCtxtReadDoc (ctxt ,utf8string ,
12081208NULL ,
@@ -1490,7 +1490,7 @@ is_valid_xml_namechar(pg_wchar c)
14901490
14911491
14921492/*
1493- * Map SQL identifier to XML name; see SQL/XML:2003 section 9.1.
1493+ * Map SQL identifier to XML name; see SQL/XML:2008 section 9.1.
14941494 */
14951495char *
14961496map_sql_identifier_to_xml_name (char * ident ,bool fully_escaped ,
@@ -1570,7 +1570,7 @@ unicode_to_sqlchar(pg_wchar c)
15701570
15711571
15721572/*
1573- * Map XML name to SQL identifier; see SQL/XML:2003 section 9.17 .
1573+ * Map XML name to SQL identifier; see SQL/XML:2008 section 9.3 .
15741574 */
15751575char *
15761576map_xml_name_to_sql_identifier (char * name )
@@ -1603,16 +1603,14 @@ map_xml_name_to_sql_identifier(char *name)
16031603}
16041604
16051605/*
1606- * Map SQL value to XML value; see SQL/XML:2003 section 9.16 .
1606+ * Map SQL value to XML value; see SQL/XML:2008 section 9.8 .
16071607 *
16081608 * When xml_escape_strings is true, then certain characters in string
16091609 * values are replaced by entity references (< etc.), as specified
1610- * in SQL/XML:2003 section 9.16 GR8) ii ).This is normally what is
1610+ * in SQL/XML:2008 section 9.8 GR9) a) iii ).This is normally what is
16111611 * wanted.The false case is mainly useful when the resulting value
16121612 * is used with xmlTextWriterWriteAttribute() to write out an
1613- * attribute, because that function does the escaping itself. The SQL
1614- * standard of 2003 is somewhat buggy in this regard, so we do our
1615- * best to make sense.
1613+ * attribute, because that function does the escaping itself.
16161614 */
16171615char *
16181616map_sql_value_to_xml_value (Datum value ,Oid type ,bool xml_escape_strings )
@@ -1868,12 +1866,13 @@ _SPI_strdup(const char *s)
18681866/*
18691867 * SQL to XML mapping functions
18701868 *
1871- * What follows belowis intentionally organized so that you can read
1872- * along in the SQL/XML:2003 standard. The functions are mostly split
1873- *up and ordered they way the clauses lay out in the standards
1869+ * What follows belowwas at one point intentionally organized so that
1870+ *you can read along in the SQL/XML standard. The functions are
1871+ *mostly split up the way the clauses lay out in the standards
18741872 * document, and the identifiers are also aligned with the standard
1875- * text. (SQL/XML:2006 appears to be ordered differently,
1876- * unfortunately.)
1873+ * text. Unfortunately, SQL/XML:2006 reordered the clauses
1874+ * differently than SQL/XML:2003, so the order below doesn't make much
1875+ * sense anymore.
18771876 *
18781877 * There are many things going on there:
18791878 *
@@ -1902,8 +1901,8 @@ _SPI_strdup(const char *s)
19021901
19031902
19041903/*
1905- * Visibility of objects for XML mappings; see SQL/XML:2003 section
1906- * 4.8.5 .
1904+ * Visibility of objects for XML mappings; see SQL/XML:2008 section
1905+ * 4.10.8 .
19071906 */
19081907
19091908/*
@@ -1972,8 +1971,8 @@ database_get_xml_visible_tables(void)
19721971
19731972
19741973/*
1975- * Map SQL table to XML and/or XML Schema document; see SQL/XML:2003
1976- * section 9.3 .
1974+ * Map SQL table to XML and/or XML Schema document; see SQL/XML:2008
1975+ * section 9.11 .
19771976 */
19781977
19791978static StringInfo
@@ -2269,8 +2268,8 @@ query_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
22692268
22702269
22712270/*
2272- * Map SQL schema to XML and/or XML Schema document; see SQL/XML:2003
2273- *section 9.4 .
2271+ * Map SQL schema to XML and/or XML Schema document; see SQL/XML:2008
2272+ *sections 9.13, 9.14 .
22742273 */
22752274
22762275static StringInfo
@@ -2446,8 +2445,8 @@ schema_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
24462445
24472446
24482447/*
2449- * Map SQL database to XML and/or XML Schema document; see SQL/XML:2003
2450- *section 9.5 .
2448+ * Map SQL database to XML and/or XML Schema document; see SQL/XML:2008
2449+ *sections 9.16, 9.17 .
24512450 */
24522451
24532452static StringInfo
@@ -2578,7 +2577,7 @@ database_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
25782577
25792578
25802579/*
2581- * Map a multi-part SQL name to an XML name; see SQL/XML:2003 section
2580+ * Map a multi-part SQL name to an XML name; see SQL/XML:2008 section
25822581 * 9.2.
25832582 */
25842583static char *
@@ -2606,11 +2605,11 @@ map_multipart_sql_identifier_to_xml_name(char *a, char *b, char *c, char *d)
26062605
26072606
26082607/*
2609- * Map an SQL table to an XML Schema document; see SQL/XML:2003
2610- * section 9.3 .
2608+ * Map an SQL table to an XML Schema document; see SQL/XML:2008
2609+ * section 9.11 .
26112610 *
2612- * Map an SQL table to XML Schema data types; see SQL/XML:2003 section
2613- * 9.6 .
2611+ * Map an SQL table to XML Schema data types; see SQL/XML:2008 section
2612+ * 9.9 .
26142613 */
26152614static const char *
26162615map_sql_table_to_xmlschema (TupleDesc tupdesc ,Oid relid ,bool nulls ,
@@ -2712,8 +2711,8 @@ map_sql_table_to_xmlschema(TupleDesc tupdesc, Oid relid, bool nulls,
27122711
27132712
27142713/*
2715- * Map an SQL schema to XML Schema data types; see SQL/XML section
2716- *9.7 .
2714+ * Map an SQL schema to XML Schema data types; see SQL/XML:2008
2715+ *section 9.12 .
27172716 */
27182717static const char *
27192718map_sql_schema_to_xmlschema_types (Oid nspid ,List * relid_list ,bool nulls ,
@@ -2785,8 +2784,8 @@ map_sql_schema_to_xmlschema_types(Oid nspid, List *relid_list, bool nulls,
27852784
27862785
27872786/*
2788- * Map an SQL catalog to XML Schema data types; see SQL/XML section
2789- *9.8 .
2787+ * Map an SQL catalog to XML Schema data types; see SQL/XML:2008
2788+ *section 9.15 .
27902789 */
27912790static const char *
27922791map_sql_catalog_to_xmlschema_types (List * nspid_list ,bool nulls ,
@@ -2843,7 +2842,7 @@ map_sql_catalog_to_xmlschema_types(List *nspid_list, bool nulls,
28432842
28442843
28452844/*
2846- * Map an SQL data type to an XML name; see SQL/XML:2003 section 9.9 .
2845+ * Map an SQL data type to an XML name; see SQL/XML:2008 section 9.4 .
28472846 */
28482847static const char *
28492848map_sql_type_to_xml_name (Oid typeoid ,int typmod )
@@ -2948,7 +2947,7 @@ map_sql_type_to_xml_name(Oid typeoid, int typmod)
29482947
29492948/*
29502949 * Map a collection of SQL data types to XML Schema data types; see
2951- * SQL/XML:2002 section 9.10 .
2950+ * SQL/XML:2008 section 9.7 .
29522951 */
29532952static const char *
29542953map_sql_typecoll_to_xmlschema_types (List * tupdesc_list )
@@ -2997,12 +2996,12 @@ map_sql_typecoll_to_xmlschema_types(List *tupdesc_list)
29972996
29982997
29992998/*
3000- * Map an SQL data type to a named XML Schema data type; see SQL/XML
3001- * sections 9.11 and 9.15 .
2999+ * Map an SQL data type to a named XML Schema data type; see
3000+ *SQL/XML:2008 sections 9.5 and 9.6 .
30023001 *
3003- * (The distinction between 9.11 and 9.15 is basically that 9.15 adds
3002+ * (The distinction between 9.5 and 9.6 is basically that 9.6 adds
30043003 * a name attribute, which this function does.The name-less version
3005- * 9.11 doesn't appear to be required anywhere.)
3004+ * 9.5 doesn't appear to be required anywhere.)
30063005 */
30073006static const char *
30083007map_sql_type_to_xmlschema_type (Oid typeoid ,int typmod )
@@ -3179,7 +3178,7 @@ map_sql_type_to_xmlschema_type(Oid typeoid, int typmod)
31793178
31803179/*
31813180 * Map an SQL row to an XML element, taking the row from the active
3182- * SPI cursor.See also SQL/XML:2003 section 9.12 .
3181+ * SPI cursor.See also SQL/XML:2008 section 9.10 .
31833182 */
31843183static void
31853184SPI_sql_row_to_xmlelement (int rownum ,StringInfo result ,char * tablename ,