diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index cf2033249b5d1b537094a0d0cb6202aca8efd4e0..a94a457cac6f4e15471775880e8a21b2fc6f061d 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -137,7 +137,7 @@ static void SPI_sql_row_to_xmlelement(int rownum, StringInfo result,
 			 errhint("You need to rebuild PostgreSQL using --with-libxml.")))
 
 
-/* from SQL/XML:2003 section 4.7 */
+/* from SQL/XML:2008 section 4.9 */
 #define NAMESPACE_XSD "http://www.w3.org/2001/XMLSchema"
 #define NAMESPACE_XSI "http://www.w3.org/2001/XMLSchema-instance"
 #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,
 		{
 			/*
 			 * Note, that here we try to apply DTD defaults
-			 * (XML_PARSE_DTDATTR) according to SQL/XML:10.16.7.d: 'Default
+			 * (XML_PARSE_DTDATTR) according to SQL/XML:2008 GR 10.16.7.d: 'Default
 			 * values defined by internal DTD are applied'. As for external
-			 * DTDs, we try to support them too, (see SQL/XML:10.16.7.e)
+			 * DTDs, we try to support them too, (see SQL/XML:2008 GR 10.16.7.e)
 			 */
 			doc = xmlCtxtReadDoc(ctxt, utf8string,
 								 NULL,
@@ -1490,7 +1490,7 @@ is_valid_xml_namechar(pg_wchar c)
 
 
 /*
- * Map SQL identifier to XML name; see SQL/XML:2003 section 9.1.
+ * Map SQL identifier to XML name; see SQL/XML:2008 section 9.1.
  */
 char *
 map_sql_identifier_to_xml_name(char *ident, bool fully_escaped,
@@ -1570,7 +1570,7 @@ unicode_to_sqlchar(pg_wchar c)
 
 
 /*
- * Map XML name to SQL identifier; see SQL/XML:2003 section 9.17.
+ * Map XML name to SQL identifier; see SQL/XML:2008 section 9.3.
  */
 char *
 map_xml_name_to_sql_identifier(char *name)
@@ -1603,16 +1603,14 @@ map_xml_name_to_sql_identifier(char *name)
 }
 
 /*
- * Map SQL value to XML value; see SQL/XML:2003 section 9.16.
+ * Map SQL value to XML value; see SQL/XML:2008 section 9.8.
  *
  * When xml_escape_strings is true, then certain characters in string
  * values are replaced by entity references (< etc.), as specified
- * in SQL/XML:2003 section 9.16 GR 8) ii).	This is normally what is
+ * in SQL/XML:2008 section 9.8 GR 9) a) iii).	This is normally what is
  * wanted.	The false case is mainly useful when the resulting value
  * is used with xmlTextWriterWriteAttribute() to write out an
- * attribute, because that function does the escaping itself.  The SQL
- * standard of 2003 is somewhat buggy in this regard, so we do our
- * best to make sense.
+ * attribute, because that function does the escaping itself.
  */
 char *
 map_sql_value_to_xml_value(Datum value, Oid type, bool xml_escape_strings)
@@ -1868,12 +1866,13 @@ _SPI_strdup(const char *s)
 /*
  * SQL to XML mapping functions
  *
- * What follows below is intentionally organized so that you can read
- * along in the SQL/XML:2003 standard.	The functions are mostly split
- * up and ordered they way the clauses lay out in the standards
+ * What follows below was at one point intentionally organized so that
+ * you can read along in the SQL/XML standard. The functions are
+ * mostly split up the way the clauses lay out in the standards
  * document, and the identifiers are also aligned with the standard
- * text.  (SQL/XML:2006 appears to be ordered differently,
- * unfortunately.)
+ * text.  Unfortunately, SQL/XML:2006 reordered the clauses
+ * differently than SQL/XML:2003, so the order below doesn't make much
+ * sense anymore.
  *
  * There are many things going on there:
  *
@@ -1902,8 +1901,8 @@ _SPI_strdup(const char *s)
 
 
 /*
- * Visibility of objects for XML mappings; see SQL/XML:2003 section
- * 4.8.5.
+ * Visibility of objects for XML mappings; see SQL/XML:2008 section
+ * 4.10.8.
  */
 
 /*
@@ -1972,8 +1971,8 @@ database_get_xml_visible_tables(void)
 
 
 /*
- * Map SQL table to XML and/or XML Schema document; see SQL/XML:2003
- * section 9.3.
+ * Map SQL table to XML and/or XML Schema document; see SQL/XML:2008
+ * section 9.11.
  */
 
 static StringInfo
@@ -2269,8 +2268,8 @@ query_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
 
 
 /*
- * Map SQL schema to XML and/or XML Schema document; see SQL/XML:2003
- * section 9.4.
+ * Map SQL schema to XML and/or XML Schema document; see SQL/XML:2008
+ * sections 9.13, 9.14.
  */
 
 static StringInfo
@@ -2446,8 +2445,8 @@ schema_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
 
 
 /*
- * Map SQL database to XML and/or XML Schema document; see SQL/XML:2003
- * section 9.5.
+ * Map SQL database to XML and/or XML Schema document; see SQL/XML:2008
+ * sections 9.16, 9.17.
  */
 
 static StringInfo
@@ -2578,7 +2577,7 @@ database_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
 
 
 /*
- * Map a multi-part SQL name to an XML name; see SQL/XML:2003 section
+ * Map a multi-part SQL name to an XML name; see SQL/XML:2008 section
  * 9.2.
  */
 static char *
@@ -2606,11 +2605,11 @@ map_multipart_sql_identifier_to_xml_name(char *a, char *b, char *c, char *d)
 
 
 /*
- * Map an SQL table to an XML Schema document; see SQL/XML:2003
- * section 9.3.
+ * Map an SQL table to an XML Schema document; see SQL/XML:2008
+ * section 9.11.
  *
- * Map an SQL table to XML Schema data types; see SQL/XML:2003 section
- * 9.6.
+ * Map an SQL table to XML Schema data types; see SQL/XML:2008 section
+ * 9.9.
  */
 static const char *
 map_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,
 
 
 /*
- * Map an SQL schema to XML Schema data types; see SQL/XML section
- * 9.7.
+ * Map an SQL schema to XML Schema data types; see SQL/XML:2008
+ * section 9.12.
  */
 static const char *
 map_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,
 
 
 /*
- * Map an SQL catalog to XML Schema data types; see SQL/XML section
- * 9.8.
+ * Map an SQL catalog to XML Schema data types; see SQL/XML:2008
+ * section 9.15.
  */
 static const char *
 map_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,
 
 
 /*
- * Map an SQL data type to an XML name; see SQL/XML:2003 section 9.9.
+ * Map an SQL data type to an XML name; see SQL/XML:2008 section 9.4.
  */
 static const char *
 map_sql_type_to_xml_name(Oid typeoid, int typmod)
@@ -2948,7 +2947,7 @@ map_sql_type_to_xml_name(Oid typeoid, int typmod)
 
 /*
  * Map a collection of SQL data types to XML Schema data types; see
- * SQL/XML:2002 section 9.10.
+ * SQL/XML:2008 section 9.7.
  */
 static const char *
 map_sql_typecoll_to_xmlschema_types(List *tupdesc_list)
@@ -2997,12 +2996,12 @@ map_sql_typecoll_to_xmlschema_types(List *tupdesc_list)
 
 
 /*
- * Map an SQL data type to a named XML Schema data type; see SQL/XML
- * sections 9.11 and 9.15.
+ * Map an SQL data type to a named XML Schema data type; see
+ * SQL/XML:2008 sections 9.5 and 9.6.
  *
- * (The distinction between 9.11 and 9.15 is basically that 9.15 adds
+ * (The distinction between 9.5 and 9.6 is basically that 9.6 adds
  * a name attribute, which this function does.	The name-less version
- * 9.11 doesn't appear to be required anywhere.)
+ * 9.5 doesn't appear to be required anywhere.)
  */
 static const char *
 map_sql_type_to_xmlschema_type(Oid typeoid, int typmod)
@@ -3179,7 +3178,7 @@ map_sql_type_to_xmlschema_type(Oid typeoid, int typmod)
 
 /*
  * Map an SQL row to an XML element, taking the row from the active
- * SPI cursor.	See also SQL/XML:2003 section 9.12.
+ * SPI cursor.	See also SQL/XML:2008 section 9.10.
  */
 static void
 SPI_sql_row_to_xmlelement(int rownum, StringInfo result, char *tablename,