diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index fd6910ddbe..80e7d72ce0 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1412,6 +1412,18 @@
        the column is null.
       </para></entry>
      </row>
+
+     <row>
+      <entry role="catalog_table_entry"><para role="column_definition">
+       <structfield>attisunexpanded</structfield> <type>bool</type>
+      </para>
+      <para>
+       This column is not expanded in the resulting target list of a
+       <literal>SELECT *</literal> or in an <literal>INSERT</literal> without
+       destination column list.  An unexpanded column can still be used, but it
+       must be explicitly referenced.
+      </para></entry>
+     </row>
     </tbody>
    </tgroup>
   </table>
diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 94f745aed0..c23938428f 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -377,6 +377,207 @@ CREATE TABLE people (
   </para>
  </sect1>
 
+ <sect1 id="ddl-unexpanded-columns">
+  <title>Unexpanded Columns</title>
+
+  <indexterm zone="ddl-unexpanded-columns">
+   <primary>Unexpanded column</primary>
+  </indexterm>
+
+  <para>
+  An unexpanded column is just like a normal column except that it is not available
+  unless it is explicitly referenced.  Columns with the <literal>UNEXEPANDED</literal>
+  attribute will not be part of the star expansion such that <literal>SELECT * FROM</literal> table doesn't
+  return a value for the columns.  The same behavior applies to the <literal>COPY ... TO</literal>
+  statements when no columns are specified.
+  In order to be used, unexpanded columns must be explicitly included in the query.
+  Unexpanded column can always be referenced explicitly wherever a column name can
+  be specified, for example in a <literal>JOIN</literal>, a <literal>GROUP BY</literal>
+  or an <literal>ORDER BY</literal> clause.
+  </para>
+  <para>
+  When inserting data into a table, an <literal>INSERT</literal> statement without a target column
+  list does not expect values for any unexpanded columns.  In such cases, if the
+  input includes a value for a unexpanded column, that value does not have a target
+  column and an error is returned.  Because an <literal>INSERT</literal> statement without a
+  column list does not include values for unexpanded columns, any columns that are
+  defined as hidden and <literal>NOT NULL</literal> must have a default value.
+  The same behavior with unexpanded column applies to the <literal>COPY ... FROM</literal>
+  statements when no destination columns are specified.
+  </para>
+  <para>
+  The <command>ALTER TABLE</command> statement can be used to set the unexpanded attribute
+  to a column or to remove it.
+<programlisting>
+ALTER TABLE people ALTER COLUMN rowid <emphasis>SET UNEXPANDED</emphasis>;
+ALTER TABLE people ALTER COLUMN rowid <emphasis>DROP UNEXPANDED</emphasis>;
+</programlisting>
+  </para>
+
+  <para>
+  If a table is created using a <command>CREATE TABLE</command> statement with
+  the LIKE clause, any unexpanded columns in the source table is copied to the
+  new table but by default the unexpanded attribute is not set.
+<programlisting>
+CREATE TABLE foo (LIKE t1);
+</programlisting>
+  To copied the <literal>UNEXPANDED</literal> attribute it must be explicitely
+  included.
+<programlisting>
+CREATE TABLE foo (LIKE t1 <emphasis>INCLUDING UNEXPANDED</emphasis>);
+</programlisting>
+  </para>
+
+  <para>
+  Since <literal>SELECT *</literal> does not return the unexpanded columns,
+  new tables or views created in this manner will have no trace of the
+  unexpanded columns.  If explicitely referenced in the <literal>SELECT</literal>
+  statement, the columns will be brought into the view/new table, but the
+  <literal>UNEXPANDED</literal> attribute will not.
+<programlisting>
+db=# \d+ t1
+                     Table "public.t1"
+ Column |  Type   | Collation | Nullable |  Expanded  | Default 
+--------+---------+-----------+----------+------------+---------
+ col1   | integer |           |          | unexpanded | 13
+ col2   | text    |           | not null |            | 
+
+test=# CREATE TABLE t2 AS SELECT * FROM t1;
+SELECT 2
+db=# \d t2
+                    Table "public.t2"
+ Column | Type | Collation | Nullable | Expanded | Default 
+--------+------+-----------+----------+--------+---------
+ col2   | text |           |          |        | 
+
+test=# CREATE TABLE t3 AS SELECT col1, col2 FROM t1;
+SELECT 2
+db=# \d t2
+                    Table "public.t2"
+ Column |  Type   | Collation | Nullable | Expanded | Default 
+--------+---------+-----------+----------+----------+---------
+ col1   | integer |           |          |          | 13
+ col2   | text    |           |          |          | 
+</programlisting>
+  </para>
+
+  <para>
+   Several other points apply to the definition of unexpanded columns and tables
+   involving such columns:
+   <itemizedlist>
+    <listitem>
+     <para>
+      Unexpanded columns are also supported in created temporary or unlogged tables
+      but not in foreign table.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+     Unexpanded columns support the usual column attributes as well as all
+     constraints.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+     An unexpanded column can be explicitly referenced in a
+     <command>CREATE INDEX</command> statement or <command>ALTER TABLE</command>
+     statement.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+     Foreign key constraints can be defined on unexpanded columns and unexpanded columns
+     can be referenced in foreign key constraints.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+     Virtual columns can be flagged unexpanded as well as identity columns.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+     A table can be partitioned by an unexpanded column.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+    User-defined types can not contain unexpanded attributes.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+     A table must have at least one expanded column.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+     Unexpanded column are inherited.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+     Changing a column's unexpanded attribute after defining a view that
+     references the column does not change the view behavior. 
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+     The unexpanded column attribute has no effect when the whole-row or star is used in a function. For example:
+<programlisting>
+SELECT row_to_json(t) FROM htest0 t;
+       row_to_json
+--------------------------
+ {"a":1,"b":"one"}
+ {"a":2,"b":"two"}
+
+SELECT row_to_json(t.*) FROM htest0 t;
+       row_to_json
+--------------------------
+ {"a":1,"b":"one"}
+ {"a":2,"b":"two"}
+</programlisting>
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+     Insert without column list with values retrieved from a query using the
+     wild-card star (<literal>INSERT INTO t2 SELECT * FROM t1;</literal>) will
+     not include unexpanded columns from the selected table.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+     The unexpanded column will not be part of the values returned by a
+     <literal>RETURNING *</literal>. For example:
+<programlisting>
+CREATE TABLE htest1 (a bigserial PRIMARY KEY, b text);
+ALTER TABLE htest1 ALTER COLUMN a SET UNEXPANDED;
+INSERT INTO htest1 VALUES ('htest1 one');
+SELECT a, b FROM htest1;
+ a |     b 
+---+------------
+ 1 | htest1 one
+
+WITH cte AS (
+   DELETE FROM htest1 RETURNING *
+) SELECT * FROM cte;
+     b      
+------------
+ htest1 one
+     </para>
+    </listitem>
+   </itemizedlist>
+  </para>
+
+  <para>
+  Information about whether a column is expanded or not is available from
+  the <structfield>attisunexpanded</structfield> column of the
+  <link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>
+  catalog table.
+  </para>
+ </sect1>
+
  <sect1 id="ddl-constraints">
   <title>Constraints</title>
 
diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index 81291577f8..940a6066ab 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -46,6 +46,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
     ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET DEFAULT <replaceable class="parameter">expression</replaceable>
     ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> DROP DEFAULT
     ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> { SET | DROP } NOT NULL
+    ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> { SET | DROP } UNEXPANDED
     ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> DROP EXPRESSION [ IF EXISTS ]
     ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> ADD GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ( <replaceable>sequence_options</replaceable> ) ]
     ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> { SET GENERATED { ALWAYS | BY DEFAULT } | SET <replaceable>sequence_option</replaceable> | RESTART [ [ WITH ] <replaceable class="parameter">restart</replaceable> ] } [...]
@@ -245,6 +246,26 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
+   <varlistentry>
+    <term><literal>SET</literal>/<literal>DROP UNEXPANDED</literal></term>
+    <listitem>
+     <para>
+      When a column is defined with the <literal>UNEXPANDED</literal> attribute,
+      it is not available unless it is explicitly referenced. For example,
+      if a SELECT * FROM table is executed, unexpanded columns are not returned
+      in the resulting rows. Same, if an INSERT statement without a target
+      columns list is executed it does not expect values for any unexpanded columns.
+      An unexpanded column can always be referenced explicitly wherever a column
+      name can be specified, for example in an ORDER BY or a JOIN clause.
+      (See <xref linkend="ddl-unexpanded-columns"/> for more information on unexpanded column).
+     </para>
+     <para>
+      The unexpansion behavior will only apply in subsequent SELECT or INSERT commands;
+      it does not cause running queries behavior to change. 
+     </para>
+    </listitem>
+   </varlistentry>
+
    <varlistentry>
     <term><literal>DROP EXPRESSION [ IF EXISTS ]</literal></term>
     <listitem>
diff --git a/doc/src/sgml/ref/create_index.sgml b/doc/src/sgml/ref/create_index.sgml
index cc484d5b39..d24bb67ddc 100644
--- a/doc/src/sgml/ref/create_index.sgml
+++ b/doc/src/sgml/ref/create_index.sgml
@@ -635,7 +635,7 @@ postgres=# \d tab
        Table "public.tab"
  Column |  Type   | Collation | Nullable | Default 
 --------+---------+-----------+----------+---------
- col    | integer |           |          | 
+ col    | integer |           |          |
 Indexes:
     "idx" btree (col) INVALID
 </programlisting>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 473a0a4aeb..bb69830e93 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -87,7 +87,7 @@ class="parameter">referential_action</replaceable> ] [ ON UPDATE <replaceable cl
 
 <phrase>and <replaceable class="parameter">like_option</replaceable> is:</phrase>
 
-{ INCLUDING | EXCLUDING } { COMMENTS | COMPRESSION | CONSTRAINTS | DEFAULTS | GENERATED | IDENTITY | INDEXES | STATISTICS | STORAGE | ALL }
+{ INCLUDING | EXCLUDING } { COMMENTS | COMPRESSION | CONSTRAINTS | DEFAULTS | GENERATED | UNEXPANDED | IDENTITY | INDEXES | STATISTICS | STORAGE | ALL }
 
 <phrase>and <replaceable class="parameter">partition_bound_spec</replaceable> is:</phrase>
 
@@ -676,6 +676,20 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
+       <varlistentry>
+        <term><literal>INCLUDING UNEXPANDED</literal></term>
+        <listitem>
+
+   <varlistentry>
+    <term><literal>HIDDEN</literal></term>
+    <listitem>
+         <para>
+          Any unexpanded attribute of copied column definitions will be
+          copied.  By default, new columns will be part of the star expansion.
+         </para>
+        </listitem>
+       </varlistentry>
+
        <varlistentry>
         <term><literal>INCLUDING IDENTITY</literal></term>
         <listitem>
@@ -1349,7 +1363,6 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
      </para>
     </listitem>
    </varlistentry>
-
   </variablelist>
 
   <refsect2 id="sql-createtable-storage-parameters" xreflabel="Storage Parameters">
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 14e0a4dbe3..3b495bcd20 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -4908,7 +4908,7 @@ testdb=&gt; <userinput>\d my_table</userinput>
  Column |  Type   | Collation | Nullable | Default
 --------+---------+-----------+----------+---------
  first  | integer |           | not null | 0
- second | text    |           |          | 
+ second | text    |           |          |
 </programlisting>
   Now we change the prompt to something more interesting:
 <programlisting>
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index 4c63bd4dc6..c6b6a05448 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -133,6 +133,7 @@ CreateTupleDescCopy(TupleDesc tupdesc)
 		att->atthasmissing = false;
 		att->attidentity = '\0';
 		att->attgenerated = '\0';
+		att->attisunexpanded = false;
 	}
 
 	/* We can copy the tuple type identification, too */
@@ -463,6 +464,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
 			return false;
 		if (attr1->attcollation != attr2->attcollation)
 			return false;
+		if (attr1->attisunexpanded != attr2->attisunexpanded)
+			return false;
 		/* variable-length fields are not even present... */
 	}
 
@@ -644,6 +647,7 @@ TupleDescInitEntry(TupleDesc desc,
 	att->attstorage = typeForm->typstorage;
 	att->attcompression = InvalidCompressionMethod;
 	att->attcollation = typeForm->typcollation;
+	att->attisunexpanded = false;
 
 	ReleaseSysCache(tuple);
 }
@@ -691,6 +695,7 @@ TupleDescInitBuiltinEntry(TupleDesc desc,
 	att->attisdropped = false;
 	att->attislocal = true;
 	att->attinhcount = 0;
+	att->attisunexpanded = false;
 	/* attacl, attoptions and attfdwoptions are not present in tupledescs */
 
 	att->atttypid = oidtypeid;
@@ -839,6 +844,7 @@ BuildDescForRelation(List *schema)
 		has_not_null |= entry->is_not_null;
 		att->attislocal = entry->is_local;
 		att->attinhcount = entry->inhcount;
+		att->attisunexpanded = entry->is_unexpanded;
 	}
 
 	if (has_not_null)
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 5898203972..514adf0a58 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -789,7 +789,9 @@ InsertPgAttributeTuples(Relation pg_attribute_rel,
 		slot[slotCount]->tts_values[Anum_pg_attribute_attisdropped - 1] = BoolGetDatum(attrs->attisdropped);
 		slot[slotCount]->tts_values[Anum_pg_attribute_attislocal - 1] = BoolGetDatum(attrs->attislocal);
 		slot[slotCount]->tts_values[Anum_pg_attribute_attinhcount - 1] = Int32GetDatum(attrs->attinhcount);
+		slot[slotCount]->tts_values[Anum_pg_attribute_attisunexpanded - 1] = BoolGetDatum(attrs->attisunexpanded);
 		slot[slotCount]->tts_values[Anum_pg_attribute_attcollation - 1] = ObjectIdGetDatum(attrs->attcollation);
+
 		if (attoptions && attoptions[natts] != (Datum) 0)
 			slot[slotCount]->tts_values[Anum_pg_attribute_attoptions - 1] = attoptions[natts];
 		else
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 53f4853141..42c54ffade 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -637,7 +637,7 @@ ProcessCopyOptions(ParseState *pstate,
  *
  * The input attnamelist is either the user-specified column list,
  * or NIL if there was none (in which case we want all the non-dropped
- * columns).
+ * and not hidden columns).
  *
  * We don't include generated columns in the generated full list and we don't
  * allow them to be specified explicitly.  They don't make sense for COPY
@@ -659,7 +659,7 @@ CopyGetAttnums(TupleDesc tupDesc, Relation rel, List *attnamelist)
 
 		for (i = 0; i < attr_count; i++)
 		{
-			if (TupleDescAttr(tupDesc, i)->attisdropped)
+			if (TupleDescAttr(tupDesc, i)->attisdropped || TupleDescAttr(tupDesc, i)->attisunexpanded)
 				continue;
 			if (TupleDescAttr(tupDesc, i)->attgenerated)
 				continue;
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index ff97b618e6..93542b4049 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -602,6 +602,10 @@ static void refuseDupeIndexAttach(Relation parentIdx, Relation partIdx,
 static List *GetParentedForeignKeyRefs(Relation partition);
 static void ATDetachCheckNoForeignKeyRefs(Relation partition);
 static char GetAttributeCompression(Oid atttypid, char *compression);
+static ObjectAddress ATExecDropUnexpanded(Relation rel, const char *colName,
+									  LOCKMODE lockmode);
+static ObjectAddress ATExecSetUnexpanded(Relation rel, const char *colName,
+									  LOCKMODE lockmode);
 
 
 /* ----------------------------------------------------------------
@@ -647,6 +651,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
 	LOCKMODE	parentLockmode;
 	const char *accessMethod = NULL;
 	Oid			accessMethodId = InvalidOid;
+	bool	   has_visible_col = false;
 
 	/*
 	 * Truncate relname to appropriate length (probably a waste of time, as
@@ -897,11 +902,25 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
 		if (colDef->generated)
 			attr->attgenerated = colDef->generated;
 
+		if (colDef->is_unexpanded)
+			attr->attisunexpanded = true;
+		else
+			has_visible_col = true;
+
 		if (colDef->compression)
 			attr->attcompression = GetAttributeCompression(attr->atttypid,
 														   colDef->compression);
 	}
 
+	/*
+	 * Verify that we have at least one visible column
+	 * when there is hidden ones
+	 */
+	if (attnum > 0 && !has_visible_col)
+		ereport(ERROR,
+				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+				 errmsg("a table must have at least one visible column")));
+
 	/*
 	 * If the statement hasn't specified an access method, but we're defining
 	 * a type of relation that needs one, use the default.
@@ -2340,6 +2359,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
 					coldef->cooked_default = restdef->cooked_default;
 					coldef->constraints = restdef->constraints;
 					coldef->is_from_type = false;
+					coldef->is_unexpanded = restdef->is_unexpanded;
 					schema = list_delete_nth_cell(schema, restpos);
 				}
 				else
@@ -2565,6 +2585,8 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
 							(errcode(ERRCODE_DATATYPE_MISMATCH),
 							 errmsg("inherited column \"%s\" has a generation conflict",
 									attributeName)));
+				/* Merge of UNEXPANDED attribute = OR 'em together */
+				def->is_unexpanded |= attribute->attisunexpanded;
 			}
 			else
 			{
@@ -2592,6 +2614,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
 						pstrdup(GetCompressionMethodName(attribute->attcompression));
 				else
 					def->compression = NULL;
+				def->is_unexpanded = attribute->attisunexpanded;
 				inhSchema = lappend(inhSchema, def);
 				newattmap->attnums[parent_attno - 1] = ++child_attno;
 			}
@@ -2857,6 +2880,8 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
 				def->is_local = true;
 				/* Merge of NOT NULL constraints = OR 'em together */
 				def->is_not_null |= newdef->is_not_null;
+				/* Merge of UNEXPANDED attribute = OR 'em together */
+				def->is_unexpanded |= newdef->is_unexpanded;
 
 				/*
 				 * Check for conflicts related to generated columns.
@@ -2951,6 +2976,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
 				{
 					found = true;
 					coldef->is_not_null |= restdef->is_not_null;
+					coldef->is_unexpanded |= restdef->is_unexpanded;
 
 					/*
 					 * Override the parent's default value for this column
@@ -4173,6 +4199,8 @@ AlterTableGetLockLevel(List *cmds)
 			case AT_SetIdentity:
 			case AT_DropExpression:
 			case AT_SetCompression:
+			case AT_DropUnexpanded:
+			case AT_SetUnexpanded:
 				cmd_lockmode = AccessExclusiveLock;
 				break;
 
@@ -4461,6 +4489,16 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
 			/* This command never recurses */
 			pass = AT_PASS_DROP;
 			break;
+		case AT_SetUnexpanded:
+			ATSimplePermissions(cmd->subtype, rel, ATT_TABLE);
+			/* No command-specific prep needed */
+			pass = AT_PASS_MISC;
+			break;
+		case AT_DropUnexpanded:
+			ATSimplePermissions(cmd->subtype, rel, ATT_TABLE);
+			/* This command never recurses */
+			pass = AT_PASS_DROP;
+			break;
 		case AT_DropNotNull:	/* ALTER COLUMN DROP NOT NULL */
 			ATSimplePermissions(cmd->subtype, rel, ATT_TABLE | ATT_FOREIGN_TABLE);
 			ATPrepDropNotNull(rel, recurse, recursing);
@@ -4859,6 +4897,12 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
 		case AT_DropIdentity:
 			address = ATExecDropIdentity(rel, cmd->name, cmd->missing_ok, lockmode);
 			break;
+		case AT_SetUnexpanded:		/* ALTER COLUMN SET UNEXPANDED  */
+			address = ATExecSetUnexpanded(rel, cmd->name, lockmode);
+			break;
+		case AT_DropUnexpanded:		/* ALTER COLUMN DROP UNEXPANDED  */
+			address = ATExecDropUnexpanded(rel, cmd->name, lockmode);
+			break;
 		case AT_DropNotNull:	/* ALTER COLUMN DROP NOT NULL */
 			address = ATExecDropNotNull(rel, cmd->name, lockmode);
 			break;
@@ -6101,6 +6145,10 @@ alter_table_type_to_string(AlterTableType cmdtype)
 			return "ALTER COLUMN ... DROP IDENTITY";
 		case AT_ReAddStatistics:
 			return NULL;		/* not real grammar */
+		case AT_DropUnexpanded:
+			return "ALTER COLUMN ... DROP UNEXPANDED";
+		case AT_SetUnexpanded:
+			return "ALTER COLUMN ... SET UNEXPANDED";
 	}
 
 	return NULL;
@@ -6722,6 +6770,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
 	attribute.attisdropped = false;
 	attribute.attislocal = colDef->is_local;
 	attribute.attinhcount = colDef->inhcount;
+	attribute.attisunexpanded = colDef->is_unexpanded;
 	attribute.attcollation = collOid;
 
 	/* attribute.attacl is handled by InsertPgAttributeTuples() */
@@ -7067,6 +7116,184 @@ ATPrepDropNotNull(Relation rel, bool recurse, bool recursing)
 	}
 }
 
+/*
+ * Return the address of the modified column.  If the column was already
+ * part of star expansion, InvalidObjectAddress is returned.
+ */
+static ObjectAddress
+ATExecDropUnexpanded(Relation rel, const char *colName, LOCKMODE lockmode)
+{
+	HeapTuple	tuple;
+	Form_pg_attribute attTup;
+	AttrNumber	attnum;
+	Relation	attr_rel;
+	ObjectAddress address;
+
+	/*
+	 * lookup the attribute
+	 */
+	attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
+
+	tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
+	if (!HeapTupleIsValid(tuple))
+		ereport(ERROR,
+				(errcode(ERRCODE_UNDEFINED_COLUMN),
+				 errmsg("column \"%s\" of relation \"%s\" does not exist",
+						colName, RelationGetRelationName(rel))));
+	attTup = (Form_pg_attribute) GETSTRUCT(tuple);
+	attnum = attTup->attnum;
+
+	/* Prevent them from altering a system attribute */
+	if (attnum <= 0)
+		ereport(ERROR,
+				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+				 errmsg("cannot alter system column \"%s\"",
+						colName)));
+
+	/* If rel is partition, shouldn't drop UNEXPANDED if parent has the same */
+	if (rel->rd_rel->relispartition)
+	{
+		Oid		parentId = get_partition_parent(RelationGetRelid(rel), false);
+		Relation	parent = table_open(parentId, AccessShareLock);
+		TupleDesc	tupDesc = RelationGetDescr(parent);
+		AttrNumber	parent_attnum;
+
+		parent_attnum = get_attnum(parentId, colName);
+		if (TupleDescAttr(tupDesc, parent_attnum - 1)->attisunexpanded)
+			ereport(ERROR,
+					(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
+					 errmsg("column \"%s\" is marked UNEXPANDED in parent table",
+							colName)));
+		table_close(parent, AccessShareLock);
+	}
+
+	/*
+	 * Okay, actually perform the catalog change ... if needed
+	 */
+	if (attTup->attisunexpanded)
+	{
+		attTup->attisunexpanded = false;
+
+		CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple);
+
+		ObjectAddressSubSet(address, RelationRelationId,
+							RelationGetRelid(rel), attnum);
+	}
+	else
+		address = InvalidObjectAddress;
+
+	InvokeObjectPostAlterHook(RelationRelationId,
+							  RelationGetRelid(rel), attnum);
+
+	table_close(attr_rel, RowExclusiveLock);
+
+	return address;
+}
+
+/*
+ * Return the address of the modified column.  If the column was already
+ * UNEXPANDED, InvalidObjectAddress is returned.
+ */
+static ObjectAddress
+ATExecSetUnexpanded(Relation rel, const char *colName, LOCKMODE lockmode)
+{
+	HeapTuple	tuple;
+	AttrNumber	attnum;
+	Relation	attr_rel;
+	ObjectAddress   address;
+	SysScanDesc     scan;
+
+
+	if (rel->rd_rel->reloftype)
+		ereport(ERROR,
+				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
+				 errmsg("cannot set UNEXPANDED attribute on a column of a typed table")));
+
+	attr_rel = table_open(AttributeRelationId, RowExclusiveLock);
+
+	/*
+	 * lookup the attribute
+	 */
+	tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
+
+	if (!HeapTupleIsValid(tuple))
+		ereport(ERROR,
+				(errcode(ERRCODE_UNDEFINED_COLUMN),
+				 errmsg("column \"%s\" of relation \"%s\" does not exist",
+						colName, RelationGetRelationName(rel))));
+
+	attnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attnum;
+
+	/* Prevent them from altering a system attribute */
+	if (attnum <= 0)
+		ereport(ERROR,
+				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+				 errmsg("cannot alter system column \"%s\"",
+						colName)));
+
+	/*
+	 * Okay, actually perform the catalog change ... if needed
+	 */
+	if (!((Form_pg_attribute) GETSTRUCT(tuple))->attisunexpanded)
+	{
+		bool            has_expanded_cols = false;
+		HeapTuple	chk_tuple;
+		ScanKeyData     key[1];
+		((Form_pg_attribute) GETSTRUCT(tuple))->attisunexpanded = true;
+
+		/*
+		 * Look if we will have at least one other column that is
+		 * expanded, we do not allow all columns of a relation to
+		 * be unexpanded.
+		 */
+		ScanKeyInit(&key[0],
+					Anum_pg_attribute_attrelid,
+					BTEqualStrategyNumber, F_OIDEQ,
+					ObjectIdGetDatum(rel->rd_rel->oid));
+
+		scan = systable_beginscan(attr_rel, AttributeRelidNumIndexId, true,
+								  NULL, 1, key);
+
+		while ((chk_tuple = systable_getnext(scan)) != NULL)
+		{
+			Form_pg_attribute attr = (Form_pg_attribute) GETSTRUCT(chk_tuple);
+			if (attr->attnum <= 0 || attr->attisdropped || attr->attnum == attnum)
+				continue;
+			if (!attr->attisunexpanded)
+			{
+				has_expanded_cols = true;
+				break;
+			}
+
+		}
+
+		/* Clean up after the scan */
+		systable_endscan(scan);
+
+		if (!has_expanded_cols)
+			ereport(ERROR,
+					(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+					 errmsg("relation \"%s\" can not have all columns unexpanded",
+							RelationGetRelationName(rel))));
+
+		/* Now we can update the catalog */
+		CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple);
+
+		ObjectAddressSubSet(address, RelationRelationId,
+							RelationGetRelid(rel), attnum);
+
+	}
+	else
+		address = InvalidObjectAddress;
+
+	InvokeObjectPostAlterHook(RelationRelationId,
+							RelationGetRelid(rel), attnum);
+
+	table_close(attr_rel, RowExclusiveLock);
+
+	return address;
+}
+
 /*
  * Return the address of the modified column.  If the column was already
  * nullable, InvalidObjectAddress is returned.
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 08f1bf1031..34b7a69ff9 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -713,7 +713,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 	TREAT TRIGGER TRIM TRUE_P
 	TRUNCATE TRUSTED TYPE_P TYPES_P
 
-	UESCAPE UNBOUNDED UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN
+	UESCAPE UNBOUNDED UNCOMMITTED UNENCRYPTED UNEXPANDED UNION UNIQUE UNKNOWN
 	UNLISTEN UNLOGGED UNTIL UPDATE USER USING
 
 	VACUUM VALID VALIDATE VALIDATOR VALUE_P VALUES VARCHAR VARIADIC VARYING
@@ -2232,6 +2232,22 @@ alter_table_cmd:
 					n->name = $3;
 					$$ = (Node *)n;
 				}
+			/* ALTER TABLE <name> ALTER [COLUMN] <colname> DROP UNEXPANDED */
+			| ALTER opt_column ColId DROP UNEXPANDED
+				{
+					AlterTableCmd *n = makeNode(AlterTableCmd);
+					n->subtype = AT_DropUnexpanded;
+					n->name = $3;
+					$$ = (Node *)n;
+				}
+			/* ALTER TABLE <name> ALTER [COLUMN] <colname> SET UNEXPANDED */
+			| ALTER opt_column ColId SET UNEXPANDED
+				{
+					AlterTableCmd *n = makeNode(AlterTableCmd);
+					n->subtype = AT_SetUnexpanded;
+					n->name = $3;
+					$$ = (Node *)n;
+				}
 			/* ALTER TABLE <name> ALTER [COLUMN] <colname> DROP EXPRESSION */
 			| ALTER opt_column ColId DROP EXPRESSION
 				{
@@ -3486,6 +3502,7 @@ columnDef:	ColId Typename opt_column_compression create_generic_options ColQualL
 					n->fdwoptions = $4;
 					SplitColQualList($5, &n->constraints, &n->collClause,
 									 yyscanner);
+					n->is_unexpanded = false;
 					n->location = @1;
 					$$ = (Node *)n;
 				}
@@ -3506,6 +3523,7 @@ columnOptions:	ColId ColQualList
 					n->collOid = InvalidOid;
 					SplitColQualList($2, &n->constraints, &n->collClause,
 									 yyscanner);
+					n->is_unexpanded = false;
 					n->location = @1;
 					$$ = (Node *)n;
 				}
@@ -3770,6 +3788,7 @@ TableLikeOption:
 				| INDEXES			{ $$ = CREATE_TABLE_LIKE_INDEXES; }
 				| STATISTICS		{ $$ = CREATE_TABLE_LIKE_STATISTICS; }
 				| STORAGE			{ $$ = CREATE_TABLE_LIKE_STORAGE; }
+				| UNEXPANDED		{ $$ = CREATE_TABLE_LIKE_UNEXPANDED; }
 				| ALL				{ $$ = CREATE_TABLE_LIKE_ALL; }
 		;
 
@@ -15770,6 +15789,7 @@ unreserved_keyword:
 			| UNBOUNDED
 			| UNCOMMITTED
 			| UNENCRYPTED
+			| UNEXPANDED
 			| UNKNOWN
 			| UNLISTEN
 			| UNLOGGED
@@ -16371,6 +16391,7 @@ bare_label_keyword:
 			| UNBOUNDED
 			| UNCOMMITTED
 			| UNENCRYPTED
+			| UNEXPANDED
 			| UNIQUE
 			| UNKNOWN
 			| UNLISTEN
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index c5c3f26ecf..40c99fb3aa 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -1256,6 +1256,12 @@ buildNSItemFromTupleDesc(RangeTblEntry *rte, Index rtindex, TupleDesc tupdesc)
 		nscolumns[varattno].p_varcollid = attr->attcollation;
 		nscolumns[varattno].p_varnosyn = rtindex;
 		nscolumns[varattno].p_varattnosyn = varattno + 1;
+		/*
+		 * For an hidden column, the entry will not
+		 * be included in star expansion.
+		 */
+		if (attr->attisunexpanded)
+			nscolumns[varattno].p_dontexpand = true;
 	}
 
 	/* ... and build the nsitem */
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index 6e8fbc4780..69172200e3 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -1029,7 +1029,7 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
 
 			attr = TupleDescAttr(pstate->p_target_relation->rd_att, i);
 
-			if (attr->attisdropped)
+			if (attr->attisdropped || attr->attisunexpanded)
 				continue;
 
 			col = makeNode(ResTarget);
@@ -1304,7 +1304,6 @@ ExpandAllTables(ParseState *pstate, int location)
 		Assert(!nsitem->p_lateral_only);
 		/* Remember we found a p_cols_visible item */
 		found_table = true;
-
 		target = list_concat(target,
 							 expandNSItemAttrs(pstate,
 											   nsitem,
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 313d7b6ff0..6a06749119 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -1084,6 +1084,12 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
 		else
 			def->storage = 0;
 
+		/* Likewise, copy hidden if requested */
+		if (table_like_clause->options & CREATE_TABLE_LIKE_UNEXPANDED)
+			def->is_unexpanded = attribute->attisunexpanded;
+		else
+			def->is_unexpanded = false;
+
 		/* Likewise, copy compression if requested */
 		if ((table_like_clause->options & CREATE_TABLE_LIKE_COMPRESSION) != 0
 			&& CompressionMethodIsValid(attribute->attcompression))
@@ -1482,6 +1488,7 @@ transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
 		n->collOid = attr->attcollation;
 		n->constraints = NIL;
 		n->location = -1;
+		n->is_unexpanded = false;
 		cxt->columns = lappend(cxt->columns, n);
 	}
 	DecrTupleDescRefCount(tupdesc);
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 13d9994af3..d82478d377 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -3450,6 +3450,7 @@ RelationBuildLocalRelation(const char *relname,
 		datt->attidentity = satt->attidentity;
 		datt->attgenerated = satt->attgenerated;
 		datt->attnotnull = satt->attnotnull;
+		datt->attisunexpanded = satt->attisunexpanded;
 		has_not_null |= satt->attnotnull;
 	}
 
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index a485fb2d07..21564b27a9 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -8712,6 +8712,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
 	int			i_attoptions;
 	int			i_attcollation;
 	int			i_attcompression;
+	int			i_attisunexpanded;
 	int			i_attfdwoptions;
 	int			i_attmissingval;
 	int			i_atthasdef;
@@ -8788,6 +8789,13 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
 			appendPQExpBuffer(q,
 							  "'' AS attcompression,\n");
 
+		if (fout->remoteVersion >= 150000)
+			appendPQExpBuffer(q,
+							  "a.attisunexpanded,\n");
+		else
+			appendPQExpBuffer(q,
+							  "'f' AS attisunexpanded,\n");
+
 		if (fout->remoteVersion >= 90200)
 			appendPQExpBufferStr(q,
 								 "pg_catalog.array_to_string(ARRAY("
@@ -8851,6 +8859,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
 		tbinfo->attoptions = (char **) pg_malloc(ntups * sizeof(char *));
 		tbinfo->attcollation = (Oid *) pg_malloc(ntups * sizeof(Oid));
 		tbinfo->attcompression = (char *) pg_malloc(ntups * sizeof(char));
+		tbinfo->attisunexpanded = (bool *) pg_malloc(ntups * sizeof(bool));
 		tbinfo->attfdwoptions = (char **) pg_malloc(ntups * sizeof(char *));
 		tbinfo->attmissingval = (char **) pg_malloc(ntups * sizeof(char *));
 		tbinfo->notnull = (bool *) pg_malloc(ntups * sizeof(bool));
@@ -8875,6 +8884,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
 		i_attoptions = PQfnumber(res, "attoptions");
 		i_attcollation = PQfnumber(res, "attcollation");
 		i_attcompression = PQfnumber(res, "attcompression");
+		i_attisunexpanded = PQfnumber(res, "attisunexpanded");
 		i_attfdwoptions = PQfnumber(res, "attfdwoptions");
 		i_attmissingval = PQfnumber(res, "attmissingval");
 		i_atthasdef = PQfnumber(res, "atthasdef");
@@ -8901,6 +8911,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
 			tbinfo->attoptions[j] = pg_strdup(PQgetvalue(res, j, i_attoptions));
 			tbinfo->attcollation[j] = atooid(PQgetvalue(res, j, i_attcollation));
 			tbinfo->attcompression[j] = *(PQgetvalue(res, j, i_attcompression));
+			tbinfo->attisunexpanded[j] = (PQgetvalue(res, j, i_attisunexpanded)[0] == 't');
 			tbinfo->attfdwoptions[j] = pg_strdup(PQgetvalue(res, j, i_attfdwoptions));
 			tbinfo->attmissingval[j] = pg_strdup(PQgetvalue(res, j, i_attmissingval));
 			tbinfo->attrdefs[j] = NULL; /* fix below */
@@ -16454,6 +16465,16 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
 								  foreign, qualrelname,
 								  fmtId(tbinfo->attnames[j]));
 
+			/*
+			 * Dump per-column unexpanded information. We only issue an ALTER
+			 * TABLE statement if the attisunexpanded entry for this column is
+			 * true (i.e. it's not the default value)
+			 */
+			if (tbinfo->attisunexpanded[j] >= 0)
+				appendPQExpBuffer(q, "ALTER %sTABLE ONLY %s ALTER COLUMN %s SET UNEXPANDED;\n",
+								  foreign, qualrelname,
+								  fmtId(tbinfo->attnames[j]));
+
 			/*
 			 * Dump per-column statistics information. We only issue an ALTER
 			 * TABLE statement if the attstattarget entry for this column is
@@ -16547,6 +16568,7 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
 								  qualrelname,
 								  fmtId(tbinfo->attnames[j]),
 								  tbinfo->attfdwoptions[j]);
+
 		}						/* end loop over columns */
 
 		if (ftoptions)
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 29af845ece..c2d7ab7cd4 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -321,6 +321,7 @@ typedef struct _tableInfo
 	char	  **attoptions;		/* per-attribute options */
 	Oid		   *attcollation;	/* per-attribute collation selection */
 	char	   *attcompression; /* per-attribute compression method */
+	bool	   *attisunexpanded;	/* hidden column */
 	char	  **attfdwoptions;	/* per-attribute fdw options */
 	char	  **attmissingval;	/* per attribute missing value */
 	bool	   *notnull;		/* NOT NULL constraints on attributes */
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index a33d77c0ef..13b99bbf28 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -1629,6 +1629,7 @@ describeOneTableDetails(const char *schemaname,
 				atttype_col = -1,
 				attrdef_col = -1,
 				attnotnull_col = -1,
+				attisunexpanded_col = -1,
 				attcoll_col = -1,
 				attidentity_col = -1,
 				attgenerated_col = -1,
@@ -2092,6 +2093,14 @@ describeOneTableDetails(const char *schemaname,
 			appendPQExpBufferStr(&buf, ",\n  pg_catalog.col_description(a.attrelid, a.attnum)");
 			attdescr_col = cols++;
 		}
+
+		/* column visibility in a SELECT *, if relevant to relkind */
+		if (tableinfo.relkind == RELKIND_RELATION ||
+			tableinfo.relkind == RELKIND_PARTITIONED_TABLE)
+		{
+			appendPQExpBufferStr(&buf, ",\n  a.attisunexpanded AS attisunexpanded");
+			attisunexpanded_col = cols++;
+		}
 	}
 
 	appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_attribute a");
@@ -2184,6 +2193,8 @@ describeOneTableDetails(const char *schemaname,
 		headers[cols++] = gettext_noop("Nullable");
 		headers[cols++] = gettext_noop("Default");
 	}
+	if (attisunexpanded_col >= 0)
+		headers[cols++] = gettext_noop("Expanded");
 	if (isindexkey_col >= 0)
 		headers[cols++] = gettext_noop("Key?");
 	if (indexdef_col >= 0)
@@ -2216,7 +2227,7 @@ describeOneTableDetails(const char *schemaname,
 		/* Type */
 		printTableAddCell(&cont, PQgetvalue(res, i, atttype_col), false, false);
 
-		/* Collation, Nullable, Default */
+		/* Collation, Nullable, Unexpanded, Default */
 		if (show_column_details)
 		{
 			char	   *identity;
@@ -2229,7 +2240,6 @@ describeOneTableDetails(const char *schemaname,
 			printTableAddCell(&cont,
 							  strcmp(PQgetvalue(res, i, attnotnull_col), "t") == 0 ? "not null" : "",
 							  false, false);
-
 			identity = PQgetvalue(res, i, attidentity_col);
 			generated = PQgetvalue(res, i, attgenerated_col);
 
@@ -2259,6 +2269,12 @@ describeOneTableDetails(const char *schemaname,
 		if (fdwopts_col >= 0)
 			printTableAddCell(&cont, PQgetvalue(res, i, fdwopts_col), false, false);
 
+		/* Column unexpanded in SELECT *, if relevant */
+		if (attisunexpanded_col >= 0)
+			printTableAddCell(&cont,
+						  strcmp(PQgetvalue(res, i, attisunexpanded_col), "t") == 0 ? "unexpanded" : "",
+						  false, false);
+
 		/* Storage mode, if relevant */
 		if (attstorage_col >= 0)
 		{
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index ecae9df8ed..46e449088c 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2160,7 +2160,7 @@ psql_completion(const char *text, int start, int end)
 	/* ALTER TABLE ALTER [COLUMN] <foo> SET */
 	else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET") ||
 			 Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET"))
-		COMPLETE_WITH("(", "COMPRESSION", "DEFAULT", "NOT NULL", "STATISTICS", "STORAGE");
+		COMPLETE_WITH("(", "COMPRESSION", "DEFAULT", "NOT NULL", "STATISTICS", "STORAGE", "UNEXPANDED");
 	/* ALTER TABLE ALTER [COLUMN] <foo> SET ( */
 	else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "(") ||
 			 Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "("))
@@ -2178,7 +2178,7 @@ psql_completion(const char *text, int start, int end)
 	/* ALTER TABLE ALTER [COLUMN] <foo> DROP */
 	else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "DROP") ||
 			 Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "DROP"))
-		COMPLETE_WITH("DEFAULT", "EXPRESSION", "IDENTITY", "NOT NULL");
+		COMPLETE_WITH("DEFAULT", "EXPRESSION", "IDENTITY", "NOT NULL", "UNEXPANDED");
 	else if (Matches("ALTER", "TABLE", MatchAny, "CLUSTER"))
 		COMPLETE_WITH("ON");
 	else if (Matches("ALTER", "TABLE", MatchAny, "CLUSTER", "ON"))
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index 5c1ec9313e..0ca6fb0978 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -167,8 +167,15 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
 	/* Number of times inherited from direct parent relation(s) */
 	int32		attinhcount BKI_DEFAULT(0);
 
+	/*
+	 * This flag specifies whether this column is expendable in
+	 * a SELECT *, an INSERT without column list, or not. It is true when
+	 * a column is defined with the HIDDEN attribute, false otherwise.
+	 */
+	bool		attisunexpanded BKI_DEFAULT(f);
+
 	/* attribute's collation, if any */
-	Oid			attcollation BKI_LOOKUP_OPT(pg_collation);
+	Oid		attcollation BKI_LOOKUP_OPT(pg_collation);
 
 #ifdef CATALOG_VARLEN			/* variable-length fields start here */
 	/* NOTE: The following fields are not present in tuple descriptors. */
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 3138877553..a786338f6a 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -686,6 +686,8 @@ typedef struct ColumnDef
 	List	   *constraints;	/* other constraints on column */
 	List	   *fdwoptions;		/* per-column FDW options */
 	int			location;		/* parse location, or -1 if none/unknown */
+	bool	is_unexpanded;		/* column is not included in star expansion?
+						   				(unexpanded column) */
 } ColumnDef;
 
 /*
@@ -710,6 +712,7 @@ typedef enum TableLikeOption
 	CREATE_TABLE_LIKE_INDEXES = 1 << 6,
 	CREATE_TABLE_LIKE_STATISTICS = 1 << 7,
 	CREATE_TABLE_LIKE_STORAGE = 1 << 8,
+	CREATE_TABLE_LIKE_UNEXPANDED = 1 << 9,
 	CREATE_TABLE_LIKE_ALL = PG_INT32_MAX
 } TableLikeOption;
 
@@ -1946,7 +1949,9 @@ typedef enum AlterTableType
 	AT_AddIdentity,				/* ADD IDENTITY */
 	AT_SetIdentity,				/* SET identity column options */
 	AT_DropIdentity,			/* DROP IDENTITY */
-	AT_ReAddStatistics			/* internal to commands/tablecmds.c */
+	AT_ReAddStatistics,			/* internal to commands/tablecmds.c */
+	AT_DropUnexpanded,			/* alter column drop unexpanded */
+	AT_SetUnexpanded			/* alter column set unexpanded */
 } AlterTableType;
 
 typedef struct ReplicaIdentityStmt
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
index f836acf876..230af7aa11 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -434,6 +434,7 @@ PG_KEYWORD("uescape", UESCAPE, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("unbounded", UNBOUNDED, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("uncommitted", UNCOMMITTED, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("unencrypted", UNENCRYPTED, UNRESERVED_KEYWORD, BARE_LABEL)
+PG_KEYWORD("unexpanded", UNEXPANDED, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("union", UNION, RESERVED_KEYWORD, AS_LABEL)
 PG_KEYWORD("unique", UNIQUE, RESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("unknown", UNKNOWN, UNRESERVED_KEYWORD, BARE_LABEL)
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 4bee0c1173..665373d93e 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -2199,11 +2199,11 @@ where oid = 'test_storage'::regclass;
 create index test_storage_idx on test_storage (b, a);
 alter table test_storage alter column a set storage external;
 \d+ test_storage
-                                Table "public.test_storage"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | external |              | 
- b      | integer |           |          | 0       | plain    |              | 
+                                     Table "public.test_storage"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | external |              | 
+ b      | integer |           |          | 0       |          | plain    |              | 
 Indexes:
     "test_storage_idx" btree (b, a)
 
@@ -4187,10 +4187,10 @@ DROP TABLE part_rpd;
 -- works fine
 ALTER TABLE range_parted2 DETACH PARTITION part_rp CONCURRENTLY;
 \d+ range_parted2
-                         Partitioned table "public.range_parted2"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- a      | integer |           |          |         | plain   |              | 
+                              Partitioned table "public.range_parted2"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ a      | integer |           |          |         |          | plain   |              | 
 Partition key: RANGE (a)
 Number of partitions: 0
 
diff --git a/src/test/regress/expected/char.out b/src/test/regress/expected/char.out
index d515b3ce34..6c917c0b68 100644
--- a/src/test/regress/expected/char.out
+++ b/src/test/regress/expected/char.out
@@ -63,12 +63,11 @@ SELECT c.*
    WHERE c.f1 < 'a';
  f1 
 ----
- A
  1
  2
  3
   
-(5 rows)
+(4 rows)
 
 SELECT c.*
    FROM CHAR_TBL c
@@ -76,20 +75,20 @@ SELECT c.*
  f1 
 ----
  a
- A
  1
  2
  3
   
-(6 rows)
+(5 rows)
 
 SELECT c.*
    FROM CHAR_TBL c
    WHERE c.f1 > 'a';
  f1 
 ----
+ A
  c
-(1 row)
+(2 rows)
 
 SELECT c.*
    FROM CHAR_TBL c
@@ -97,8 +96,9 @@ SELECT c.*
  f1 
 ----
  a
+ A
  c
-(2 rows)
+(3 rows)
 
 DROP TABLE CHAR_TBL;
 --
diff --git a/src/test/regress/expected/collate.icu.utf8.out b/src/test/regress/expected/collate.icu.utf8.out
index 70133df804..a6a33b39ab 100644
--- a/src/test/regress/expected/collate.icu.utf8.out
+++ b/src/test/regress/expected/collate.icu.utf8.out
@@ -7,1953 +7,3 @@ SELECT getdatabaseencoding() <> 'UTF8' OR
        AS skip_test \gset
 \if :skip_test
 \quit
-\endif
-SET client_encoding TO UTF8;
-CREATE SCHEMA collate_tests;
-SET search_path = collate_tests;
-CREATE TABLE collate_test1 (
-    a int,
-    b text COLLATE "en-x-icu" NOT NULL
-);
-\d collate_test1
-        Table "collate_tests.collate_test1"
- Column |  Type   | Collation | Nullable | Default 
---------+---------+-----------+----------+---------
- a      | integer |           |          | 
- b      | text    | en-x-icu  | not null | 
-
-CREATE TABLE collate_test_fail (
-    a int,
-    b text COLLATE "ja_JP.eucjp-x-icu"
-);
-ERROR:  collation "ja_JP.eucjp-x-icu" for encoding "UTF8" does not exist
-LINE 3:     b text COLLATE "ja_JP.eucjp-x-icu"
-                   ^
-CREATE TABLE collate_test_fail (
-    a int,
-    b text COLLATE "foo-x-icu"
-);
-ERROR:  collation "foo-x-icu" for encoding "UTF8" does not exist
-LINE 3:     b text COLLATE "foo-x-icu"
-                   ^
-CREATE TABLE collate_test_fail (
-    a int COLLATE "en-x-icu",
-    b text
-);
-ERROR:  collations are not supported by type integer
-LINE 2:     a int COLLATE "en-x-icu",
-                  ^
-CREATE TABLE collate_test_like (
-    LIKE collate_test1
-);
-\d collate_test_like
-      Table "collate_tests.collate_test_like"
- Column |  Type   | Collation | Nullable | Default 
---------+---------+-----------+----------+---------
- a      | integer |           |          | 
- b      | text    | en-x-icu  | not null | 
-
-CREATE TABLE collate_test2 (
-    a int,
-    b text COLLATE "sv-x-icu"
-);
-CREATE TABLE collate_test3 (
-    a int,
-    b text COLLATE "C"
-);
-INSERT INTO collate_test1 VALUES (1, 'abc'), (2, 'äbc'), (3, 'bbc'), (4, 'ABC');
-INSERT INTO collate_test2 SELECT * FROM collate_test1;
-INSERT INTO collate_test3 SELECT * FROM collate_test1;
-SELECT * FROM collate_test1 WHERE b >= 'bbc';
- a |  b  
----+-----
- 3 | bbc
-(1 row)
-
-SELECT * FROM collate_test2 WHERE b >= 'bbc';
- a |  b  
----+-----
- 2 | äbc
- 3 | bbc
-(2 rows)
-
-SELECT * FROM collate_test3 WHERE b >= 'bbc';
- a |  b  
----+-----
- 2 | äbc
- 3 | bbc
-(2 rows)
-
-SELECT * FROM collate_test3 WHERE b >= 'BBC';
- a |  b  
----+-----
- 1 | abc
- 2 | äbc
- 3 | bbc
-(3 rows)
-
-SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc';
- a |  b  
----+-----
- 2 | äbc
- 3 | bbc
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b >= 'bbc' COLLATE "C";
- a |  b  
----+-----
- 2 | äbc
- 3 | bbc
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "C";
- a |  b  
----+-----
- 2 | äbc
- 3 | bbc
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "en-x-icu";
-ERROR:  collation mismatch between explicit collations "C" and "en-x-icu"
-LINE 1: ...* FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "e...
-                                                             ^
-CREATE DOMAIN testdomain_sv AS text COLLATE "sv-x-icu";
-CREATE DOMAIN testdomain_i AS int COLLATE "sv-x-icu"; -- fails
-ERROR:  collations are not supported by type integer
-CREATE TABLE collate_test4 (
-    a int,
-    b testdomain_sv
-);
-INSERT INTO collate_test4 SELECT * FROM collate_test1;
-SELECT a, b FROM collate_test4 ORDER BY b;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-CREATE TABLE collate_test5 (
-    a int,
-    b testdomain_sv COLLATE "en-x-icu"
-);
-INSERT INTO collate_test5 SELECT * FROM collate_test1;
-SELECT a, b FROM collate_test5 ORDER BY b;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT a, b FROM collate_test1 ORDER BY b;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT a, b FROM collate_test2 ORDER BY b;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, b FROM collate_test3 ORDER BY b;
- a |  b  
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
- a |  b  
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
--- star expansion
-SELECT * FROM collate_test1 ORDER BY b;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT * FROM collate_test2 ORDER BY b;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT * FROM collate_test3 ORDER BY b;
- a |  b  
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
--- constant expression folding
-SELECT 'bbc' COLLATE "en-x-icu" > 'äbc' COLLATE "en-x-icu" AS "true";
- true 
-------
- t
-(1 row)
-
-SELECT 'bbc' COLLATE "sv-x-icu" > 'äbc' COLLATE "sv-x-icu" AS "false";
- false 
--------
- f
-(1 row)
-
--- upper/lower
-CREATE TABLE collate_test10 (
-    a int,
-    x text COLLATE "en-x-icu",
-    y text COLLATE "tr-x-icu"
-);
-INSERT INTO collate_test10 VALUES (1, 'hij', 'hij'), (2, 'HIJ', 'HIJ');
-SELECT a, lower(x), lower(y), upper(x), upper(y), initcap(x), initcap(y) FROM collate_test10;
- a | lower | lower | upper | upper | initcap | initcap 
----+-------+-------+-------+-------+---------+---------
- 1 | hij   | hij   | HIJ   | HİJ   | Hij     | Hij
- 2 | hij   | hıj   | HIJ   | HIJ   | Hij     | Hıj
-(2 rows)
-
-SELECT a, lower(x COLLATE "C"), lower(y COLLATE "C") FROM collate_test10;
- a | lower | lower 
----+-------+-------
- 1 | hij   | hij
- 2 | hij   | hij
-(2 rows)
-
-SELECT a, x, y FROM collate_test10 ORDER BY lower(y), a;
- a |  x  |  y  
----+-----+-----
- 2 | HIJ | HIJ
- 1 | hij | hij
-(2 rows)
-
--- LIKE/ILIKE
-SELECT * FROM collate_test1 WHERE b LIKE 'abc';
- a |  b  
----+-----
- 1 | abc
-(1 row)
-
-SELECT * FROM collate_test1 WHERE b LIKE 'abc%';
- a |  b  
----+-----
- 1 | abc
-(1 row)
-
-SELECT * FROM collate_test1 WHERE b LIKE '%bc%';
- a |  b  
----+-----
- 1 | abc
- 2 | äbc
- 3 | bbc
-(3 rows)
-
-SELECT * FROM collate_test1 WHERE b ILIKE 'abc';
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b ILIKE 'abc%';
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b ILIKE '%bc%';
- a |  b  
----+-----
- 1 | abc
- 2 | äbc
- 3 | bbc
- 4 | ABC
-(4 rows)
-
-SELECT 'Türkiye' COLLATE "en-x-icu" ILIKE '%KI%' AS "true";
- true 
-------
- t
-(1 row)
-
-SELECT 'Türkiye' COLLATE "tr-x-icu" ILIKE '%KI%' AS "false";
- false 
--------
- f
-(1 row)
-
-SELECT 'bıt' ILIKE 'BIT' COLLATE "en-x-icu" AS "false";
- false 
--------
- f
-(1 row)
-
-SELECT 'bıt' ILIKE 'BIT' COLLATE "tr-x-icu" AS "true";
- true 
-------
- t
-(1 row)
-
--- The following actually exercises the selectivity estimation for ILIKE.
-SELECT relname FROM pg_class WHERE relname ILIKE 'abc%';
- relname 
----------
-(0 rows)
-
--- regular expressions
-SELECT * FROM collate_test1 WHERE b ~ '^abc$';
- a |  b  
----+-----
- 1 | abc
-(1 row)
-
-SELECT * FROM collate_test1 WHERE b ~ '^abc';
- a |  b  
----+-----
- 1 | abc
-(1 row)
-
-SELECT * FROM collate_test1 WHERE b ~ 'bc';
- a |  b  
----+-----
- 1 | abc
- 2 | äbc
- 3 | bbc
-(3 rows)
-
-SELECT * FROM collate_test1 WHERE b ~* '^abc$';
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b ~* '^abc';
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b ~* 'bc';
- a |  b  
----+-----
- 1 | abc
- 2 | äbc
- 3 | bbc
- 4 | ABC
-(4 rows)
-
-CREATE TABLE collate_test6 (
-    a int,
-    b text COLLATE "en-x-icu"
-);
-INSERT INTO collate_test6 VALUES (1, 'abc'), (2, 'ABC'), (3, '123'), (4, 'ab1'),
-                                 (5, 'a1!'), (6, 'a c'), (7, '!.;'), (8, '   '),
-                                 (9, 'äbç'), (10, 'ÄBÇ');
-SELECT b,
-       b ~ '^[[:alpha:]]+$' AS is_alpha,
-       b ~ '^[[:upper:]]+$' AS is_upper,
-       b ~ '^[[:lower:]]+$' AS is_lower,
-       b ~ '^[[:digit:]]+$' AS is_digit,
-       b ~ '^[[:alnum:]]+$' AS is_alnum,
-       b ~ '^[[:graph:]]+$' AS is_graph,
-       b ~ '^[[:print:]]+$' AS is_print,
-       b ~ '^[[:punct:]]+$' AS is_punct,
-       b ~ '^[[:space:]]+$' AS is_space
-FROM collate_test6;
-  b  | is_alpha | is_upper | is_lower | is_digit | is_alnum | is_graph | is_print | is_punct | is_space 
------+----------+----------+----------+----------+----------+----------+----------+----------+----------
- abc | t        | f        | t        | f        | t        | t        | t        | f        | f
- ABC | t        | t        | f        | f        | t        | t        | t        | f        | f
- 123 | f        | f        | f        | t        | t        | t        | t        | f        | f
- ab1 | f        | f        | f        | f        | t        | t        | t        | f        | f
- a1! | f        | f        | f        | f        | f        | t        | t        | f        | f
- a c | f        | f        | f        | f        | f        | f        | t        | f        | f
- !.; | f        | f        | f        | f        | f        | t        | t        | t        | f
-     | f        | f        | f        | f        | f        | f        | t        | f        | t
- äbç | t        | f        | t        | f        | t        | t        | t        | f        | f
- ÄBÇ | t        | t        | f        | f        | t        | t        | t        | f        | f
-(10 rows)
-
-SELECT 'Türkiye' COLLATE "en-x-icu" ~* 'KI' AS "true";
- true 
-------
- t
-(1 row)
-
-SELECT 'Türkiye' COLLATE "tr-x-icu" ~* 'KI' AS "true";  -- true with ICU
- true 
-------
- t
-(1 row)
-
-SELECT 'bıt' ~* 'BIT' COLLATE "en-x-icu" AS "false";
- false 
--------
- f
-(1 row)
-
-SELECT 'bıt' ~* 'BIT' COLLATE "tr-x-icu" AS "false";  -- false with ICU
- false 
--------
- f
-(1 row)
-
--- The following actually exercises the selectivity estimation for ~*.
-SELECT relname FROM pg_class WHERE relname ~* '^abc';
- relname 
----------
-(0 rows)
-
-/* not run by default because it requires tr_TR system locale
--- to_char
-
-SET lc_time TO 'tr_TR';
-SELECT to_char(date '2010-04-01', 'DD TMMON YYYY');
-SELECT to_char(date '2010-04-01', 'DD TMMON YYYY' COLLATE "tr-x-icu");
-*/
--- backwards parsing
-CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc';
-CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
-CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10;
-SELECT table_name, view_definition FROM information_schema.views
-  WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name |                             view_definition                              
-------------+--------------------------------------------------------------------------
- collview1  |  SELECT collate_test1.a,                                                +
-            |     collate_test1.b                                                     +
-            |    FROM collate_test1                                                   +
-            |   WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2  |  SELECT collate_test1.a,                                                +
-            |     collate_test1.b                                                     +
-            |    FROM collate_test1                                                   +
-            |   ORDER BY (collate_test1.b COLLATE "C");
- collview3  |  SELECT collate_test10.a,                                               +
-            |     lower(((collate_test10.x || collate_test10.x) COLLATE "C")) AS lower+
-            |    FROM collate_test10;
-(3 rows)
-
--- collation propagation in various expression types
-SELECT a, coalesce(b, 'foo') FROM collate_test1 ORDER BY 2;
- a | coalesce 
----+----------
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT a, coalesce(b, 'foo') FROM collate_test2 ORDER BY 2;
- a | coalesce 
----+----------
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, coalesce(b, 'foo') FROM collate_test3 ORDER BY 2;
- a | coalesce 
----+----------
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, lower(coalesce(x, 'foo')), lower(coalesce(y, 'foo')) FROM collate_test10;
- a | lower | lower 
----+-------+-------
- 1 | hij   | hij
- 2 | hij   | hıj
-(2 rows)
-
-SELECT a, b, greatest(b, 'CCC') FROM collate_test1 ORDER BY 3;
- a |  b  | greatest 
----+-----+----------
- 1 | abc | CCC
- 2 | äbc | CCC
- 3 | bbc | CCC
- 4 | ABC | CCC
-(4 rows)
-
-SELECT a, b, greatest(b, 'CCC') FROM collate_test2 ORDER BY 3;
- a |  b  | greatest 
----+-----+----------
- 1 | abc | CCC
- 3 | bbc | CCC
- 4 | ABC | CCC
- 2 | äbc | äbc
-(4 rows)
-
-SELECT a, b, greatest(b, 'CCC') FROM collate_test3 ORDER BY 3;
- a |  b  | greatest 
----+-----+----------
- 4 | ABC | CCC
- 1 | abc | abc
- 3 | bbc | bbc
- 2 | äbc | äbc
-(4 rows)
-
-SELECT a, x, y, lower(greatest(x, 'foo')), lower(greatest(y, 'foo')) FROM collate_test10;
- a |  x  |  y  | lower | lower 
----+-----+-----+-------+-------
- 1 | hij | hij | hij   | hij
- 2 | HIJ | HIJ | hij   | hıj
-(2 rows)
-
-SELECT a, nullif(b, 'abc') FROM collate_test1 ORDER BY 2;
- a | nullif 
----+--------
- 4 | ABC
- 2 | äbc
- 3 | bbc
- 1 | 
-(4 rows)
-
-SELECT a, nullif(b, 'abc') FROM collate_test2 ORDER BY 2;
- a | nullif 
----+--------
- 4 | ABC
- 3 | bbc
- 2 | äbc
- 1 | 
-(4 rows)
-
-SELECT a, nullif(b, 'abc') FROM collate_test3 ORDER BY 2;
- a | nullif 
----+--------
- 4 | ABC
- 3 | bbc
- 2 | äbc
- 1 | 
-(4 rows)
-
-SELECT a, lower(nullif(x, 'foo')), lower(nullif(y, 'foo')) FROM collate_test10;
- a | lower | lower 
----+-------+-------
- 1 | hij   | hij
- 2 | hij   | hıj
-(2 rows)
-
-SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2;
- a |  b   
----+------
- 4 | ABC
- 2 | äbc
- 1 | abcd
- 3 | bbc
-(4 rows)
-
-SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2;
- a |  b   
----+------
- 4 | ABC
- 1 | abcd
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test3 ORDER BY 2;
- a |  b   
----+------
- 4 | ABC
- 1 | abcd
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-CREATE DOMAIN testdomain AS text;
-SELECT a, b::testdomain FROM collate_test1 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT a, b::testdomain FROM collate_test2 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, b::testdomain FROM collate_test3 ORDER BY 2;
- a |  b  
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, b::testdomain_sv FROM collate_test3 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, lower(x::testdomain), lower(y::testdomain) FROM collate_test10;
- a | lower | lower 
----+-------+-------
- 1 | hij   | hij
- 2 | hij   | hıj
-(2 rows)
-
-SELECT min(b), max(b) FROM collate_test1;
- min | max 
------+-----
- abc | bbc
-(1 row)
-
-SELECT min(b), max(b) FROM collate_test2;
- min | max 
------+-----
- abc | äbc
-(1 row)
-
-SELECT min(b), max(b) FROM collate_test3;
- min | max 
------+-----
- ABC | äbc
-(1 row)
-
-SELECT array_agg(b ORDER BY b) FROM collate_test1;
-     array_agg     
--------------------
- {abc,ABC,äbc,bbc}
-(1 row)
-
-SELECT array_agg(b ORDER BY b) FROM collate_test2;
-     array_agg     
--------------------
- {abc,ABC,bbc,äbc}
-(1 row)
-
-SELECT array_agg(b ORDER BY b) FROM collate_test3;
-     array_agg     
--------------------
- {ABC,abc,bbc,äbc}
-(1 row)
-
-SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 1 | abc
- 4 | ABC
- 4 | ABC
- 2 | äbc
- 2 | äbc
- 3 | bbc
- 3 | bbc
-(8 rows)
-
-SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, b FROM collate_test3 WHERE a < 4 INTERSECT SELECT a, b FROM collate_test3 WHERE a > 1 ORDER BY 2;
- a |  b  
----+-----
- 3 | bbc
- 2 | äbc
-(2 rows)
-
-SELECT a, b FROM collate_test3 EXCEPT SELECT a, b FROM collate_test3 WHERE a < 2 ORDER BY 2;
- a |  b  
----+-----
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(3 rows)
-
-SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 ORDER BY 2; -- fail
-ERROR:  could not determine which collation to use for string comparison
-HINT:  Use the COLLATE clause to set the collation explicitly.
-SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3; -- ok
- a |  b  
----+-----
- 1 | abc
- 2 | äbc
- 3 | bbc
- 4 | ABC
- 1 | abc
- 2 | äbc
- 3 | bbc
- 4 | ABC
-(8 rows)
-
-SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2; -- fail
-ERROR:  collation mismatch between implicit collations "en-x-icu" and "C"
-LINE 1: SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collat...
-                                                       ^
-HINT:  You can choose the collation by applying the COLLATE clause to one or both expressions.
-SELECT a, b COLLATE "C" FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2; -- ok
- a |  b  
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test3 ORDER BY 2; -- fail
-ERROR:  collation mismatch between implicit collations "en-x-icu" and "C"
-LINE 1: ...ELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM col...
-                                                             ^
-HINT:  You can choose the collation by applying the COLLATE clause to one or both expressions.
-SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test3 ORDER BY 2; -- fail
-ERROR:  collation mismatch between implicit collations "en-x-icu" and "C"
-LINE 1: SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM colla...
-                                                        ^
-HINT:  You can choose the collation by applying the COLLATE clause to one or both expressions.
-CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3; -- fail
-ERROR:  no collation was derived for column "b" with collatable type text
-HINT:  Use the COLLATE clause to set the collation explicitly.
--- ideally this would be a parse-time error, but for now it must be run-time:
-select x < y from collate_test10; -- fail
-ERROR:  could not determine which collation to use for string comparison
-HINT:  Use the COLLATE clause to set the collation explicitly.
-select x || y from collate_test10; -- ok, because || is not collation aware
- ?column? 
-----------
- hijhij
- HIJHIJ
-(2 rows)
-
-select x, y from collate_test10 order by x || y; -- not so ok
-ERROR:  collation mismatch between implicit collations "en-x-icu" and "tr-x-icu"
-LINE 1: select x, y from collate_test10 order by x || y;
-                                                      ^
-HINT:  You can choose the collation by applying the COLLATE clause to one or both expressions.
--- collation mismatch between recursive and non-recursive term
-WITH RECURSIVE foo(x) AS
-   (SELECT x FROM (VALUES('a' COLLATE "en-x-icu"),('b')) t(x)
-   UNION ALL
-   SELECT (x || 'c') COLLATE "de-x-icu" FROM foo WHERE length(x) < 10)
-SELECT * FROM foo;
-ERROR:  recursive query "foo" column 1 has collation "en-x-icu" in non-recursive term but collation "de-x-icu" overall
-LINE 2:    (SELECT x FROM (VALUES('a' COLLATE "en-x-icu"),('b')) t(x...
-                   ^
-HINT:  Use the COLLATE clause to set the collation of the non-recursive term.
--- casting
-SELECT CAST('42' AS text COLLATE "C");
-ERROR:  syntax error at or near "COLLATE"
-LINE 1: SELECT CAST('42' AS text COLLATE "C");
-                                 ^
-SELECT a, CAST(b AS varchar) FROM collate_test1 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
- a |  b  
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
--- propagation of collation in SQL functions (inlined and non-inlined cases)
--- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
-    AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
-    AS $$ select $1 < $2 limit 1 $$;
-CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
-    AS $$ begin return $1 < $2; end $$;
-SELECT a.b AS a, b.b AS b, a.b < b.b AS lt,
-       mylt(a.b, b.b), mylt_noninline(a.b, b.b), mylt_plpgsql(a.b, b.b)
-FROM collate_test1 a, collate_test1 b
-ORDER BY a.b, b.b;
-  a  |  b  | lt | mylt | mylt_noninline | mylt_plpgsql 
------+-----+----+------+----------------+--------------
- abc | abc | f  | f    | f              | f
- abc | ABC | t  | t    | t              | t
- abc | äbc | t  | t    | t              | t
- abc | bbc | t  | t    | t              | t
- ABC | abc | f  | f    | f              | f
- ABC | ABC | f  | f    | f              | f
- ABC | äbc | t  | t    | t              | t
- ABC | bbc | t  | t    | t              | t
- äbc | abc | f  | f    | f              | f
- äbc | ABC | f  | f    | f              | f
- äbc | äbc | f  | f    | f              | f
- äbc | bbc | t  | t    | t              | t
- bbc | abc | f  | f    | f              | f
- bbc | ABC | f  | f    | f              | f
- bbc | äbc | f  | f    | f              | f
- bbc | bbc | f  | f    | f              | f
-(16 rows)
-
-SELECT a.b AS a, b.b AS b, a.b < b.b COLLATE "C" AS lt,
-       mylt(a.b, b.b COLLATE "C"), mylt_noninline(a.b, b.b COLLATE "C"),
-       mylt_plpgsql(a.b, b.b COLLATE "C")
-FROM collate_test1 a, collate_test1 b
-ORDER BY a.b, b.b;
-  a  |  b  | lt | mylt | mylt_noninline | mylt_plpgsql 
------+-----+----+------+----------------+--------------
- abc | abc | f  | f    | f              | f
- abc | ABC | f  | f    | f              | f
- abc | äbc | t  | t    | t              | t
- abc | bbc | t  | t    | t              | t
- ABC | abc | t  | t    | t              | t
- ABC | ABC | f  | f    | f              | f
- ABC | äbc | t  | t    | t              | t
- ABC | bbc | t  | t    | t              | t
- äbc | abc | f  | f    | f              | f
- äbc | ABC | f  | f    | f              | f
- äbc | äbc | f  | f    | f              | f
- äbc | bbc | f  | f    | f              | f
- bbc | abc | f  | f    | f              | f
- bbc | ABC | f  | f    | f              | f
- bbc | äbc | t  | t    | t              | t
- bbc | bbc | f  | f    | f              | f
-(16 rows)
-
--- collation override in plpgsql
-CREATE FUNCTION mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$
-declare
-  xx text := x;
-  yy text := y;
-begin
-  return xx < yy;
-end
-$$;
-SELECT mylt2('a', 'B' collate "en-x-icu") as t, mylt2('a', 'B' collate "C") as f;
- t | f 
----+---
- t | f
-(1 row)
-
-CREATE OR REPLACE FUNCTION
-  mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$
-declare
-  xx text COLLATE "POSIX" := x;
-  yy text := y;
-begin
-  return xx < yy;
-end
-$$;
-SELECT mylt2('a', 'B') as f;
- f 
----
- f
-(1 row)
-
-SELECT mylt2('a', 'B' collate "C") as fail; -- conflicting collations
-ERROR:  could not determine which collation to use for string comparison
-HINT:  Use the COLLATE clause to set the collation explicitly.
-CONTEXT:  PL/pgSQL function mylt2(text,text) line 6 at RETURN
-SELECT mylt2('a', 'B' collate "POSIX") as f;
- f 
----
- f
-(1 row)
-
--- polymorphism
-SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1;
- unnest 
---------
- abc
- ABC
- äbc
- bbc
-(4 rows)
-
-SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1;
- unnest 
---------
- abc
- ABC
- bbc
- äbc
-(4 rows)
-
-SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1;
- unnest 
---------
- ABC
- abc
- bbc
- äbc
-(4 rows)
-
-CREATE FUNCTION dup (anyelement) RETURNS anyelement
-    AS 'select $1' LANGUAGE sql;
-SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
- a | dup 
----+-----
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT a, dup(b) FROM collate_test2 ORDER BY 2;
- a | dup 
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, dup(b) FROM collate_test3 ORDER BY 2;
- a | dup 
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
--- indexes
-CREATE INDEX collate_test1_idx1 ON collate_test1 (b);
-CREATE INDEX collate_test1_idx2 ON collate_test1 (b COLLATE "C");
-CREATE INDEX collate_test1_idx3 ON collate_test1 ((b COLLATE "C")); -- this is different grammatically
-CREATE INDEX collate_test1_idx4 ON collate_test1 (((b||'foo') COLLATE "POSIX"));
-CREATE INDEX collate_test1_idx5 ON collate_test1 (a COLLATE "C"); -- fail
-ERROR:  collations are not supported by type integer
-CREATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "C")); -- fail
-ERROR:  collations are not supported by type integer
-LINE 1: ...ATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "C...
-                                                             ^
-SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1;
-      relname       |                                                  pg_get_indexdef                                                  
---------------------+-------------------------------------------------------------------------------------------------------------------
- collate_test1_idx1 | CREATE INDEX collate_test1_idx1 ON collate_tests.collate_test1 USING btree (b)
- collate_test1_idx2 | CREATE INDEX collate_test1_idx2 ON collate_tests.collate_test1 USING btree (b COLLATE "C")
- collate_test1_idx3 | CREATE INDEX collate_test1_idx3 ON collate_tests.collate_test1 USING btree (b COLLATE "C")
- collate_test1_idx4 | CREATE INDEX collate_test1_idx4 ON collate_tests.collate_test1 USING btree (((b || 'foo'::text)) COLLATE "POSIX")
-(4 rows)
-
-set enable_seqscan = off;
-explain (costs off)
-select * from collate_test1 where b ilike 'abc';
-          QUERY PLAN           
--------------------------------
- Seq Scan on collate_test1
-   Filter: (b ~~* 'abc'::text)
-(2 rows)
-
-select * from collate_test1 where b ilike 'abc';
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
-(2 rows)
-
-explain (costs off)
-select * from collate_test1 where b ilike 'ABC';
-          QUERY PLAN           
--------------------------------
- Seq Scan on collate_test1
-   Filter: (b ~~* 'ABC'::text)
-(2 rows)
-
-select * from collate_test1 where b ilike 'ABC';
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
-(2 rows)
-
-reset enable_seqscan;
--- schema manipulation commands
-CREATE ROLE regress_test_role;
-CREATE SCHEMA test_schema;
--- We need to do this this way to cope with varying names for encodings:
-do $$
-BEGIN
-  EXECUTE 'CREATE COLLATION test0 (provider = icu, locale = ' ||
-          quote_literal(current_setting('lc_collate')) || ');';
-END
-$$;
-CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
-ERROR:  collation "test0" already exists
-do $$
-BEGIN
-  EXECUTE 'CREATE COLLATION test1 (provider = icu, lc_collate = ' ||
-          quote_literal(current_setting('lc_collate')) ||
-          ', lc_ctype = ' ||
-          quote_literal(current_setting('lc_ctype')) || ');';
-END
-$$;
-CREATE COLLATION test3 (provider = icu, lc_collate = 'en_US.utf8'); -- fail, need lc_ctype
-ERROR:  parameter "lc_ctype" must be specified
-CREATE COLLATION testx (provider = icu, locale = 'nonsense'); /* never fails with ICU */  DROP COLLATION testx;
-CREATE COLLATION test4 FROM nonsense;
-ERROR:  collation "nonsense" for encoding "UTF8" does not exist
-CREATE COLLATION test5 FROM test0;
-SELECT collname FROM pg_collation WHERE collname LIKE 'test%' ORDER BY 1;
- collname 
-----------
- test0
- test1
- test5
-(3 rows)
-
-ALTER COLLATION test1 RENAME TO test11;
-ALTER COLLATION test0 RENAME TO test11; -- fail
-ERROR:  collation "test11" already exists in schema "collate_tests"
-ALTER COLLATION test1 RENAME TO test22; -- fail
-ERROR:  collation "test1" for encoding "UTF8" does not exist
-ALTER COLLATION test11 OWNER TO regress_test_role;
-ALTER COLLATION test11 OWNER TO nonsense;
-ERROR:  role "nonsense" does not exist
-ALTER COLLATION test11 SET SCHEMA test_schema;
-COMMENT ON COLLATION test0 IS 'US English';
-SELECT collname, nspname, obj_description(pg_collation.oid, 'pg_collation')
-    FROM pg_collation JOIN pg_namespace ON (collnamespace = pg_namespace.oid)
-    WHERE collname LIKE 'test%'
-    ORDER BY 1;
- collname |    nspname    | obj_description 
-----------+---------------+-----------------
- test0    | collate_tests | US English
- test11   | test_schema   | 
- test5    | collate_tests | 
-(3 rows)
-
-DROP COLLATION test0, test_schema.test11, test5;
-DROP COLLATION test0; -- fail
-ERROR:  collation "test0" for encoding "UTF8" does not exist
-DROP COLLATION IF EXISTS test0;
-NOTICE:  collation "test0" does not exist, skipping
-SELECT collname FROM pg_collation WHERE collname LIKE 'test%';
- collname 
-----------
-(0 rows)
-
-DROP SCHEMA test_schema;
-DROP ROLE regress_test_role;
--- ALTER
-ALTER COLLATION "en-x-icu" REFRESH VERSION;
-NOTICE:  version has not changed
--- dependencies
-CREATE COLLATION test0 FROM "C";
-CREATE TABLE collate_dep_test1 (a int, b text COLLATE test0);
-CREATE DOMAIN collate_dep_dom1 AS text COLLATE test0;
-CREATE TYPE collate_dep_test2 AS (x int, y text COLLATE test0);
-CREATE VIEW collate_dep_test3 AS SELECT text 'foo' COLLATE test0 AS foo;
-CREATE TABLE collate_dep_test4t (a int, b text);
-CREATE INDEX collate_dep_test4i ON collate_dep_test4t (b COLLATE test0);
-DROP COLLATION test0 RESTRICT; -- fail
-ERROR:  cannot drop collation test0 because other objects depend on it
-DETAIL:  column b of table collate_dep_test1 depends on collation test0
-type collate_dep_dom1 depends on collation test0
-column y of composite type collate_dep_test2 depends on collation test0
-view collate_dep_test3 depends on collation test0
-index collate_dep_test4i depends on collation test0
-HINT:  Use DROP ... CASCADE to drop the dependent objects too.
-DROP COLLATION test0 CASCADE;
-NOTICE:  drop cascades to 5 other objects
-DETAIL:  drop cascades to column b of table collate_dep_test1
-drop cascades to type collate_dep_dom1
-drop cascades to column y of composite type collate_dep_test2
-drop cascades to view collate_dep_test3
-drop cascades to index collate_dep_test4i
-\d collate_dep_test1
-      Table "collate_tests.collate_dep_test1"
- Column |  Type   | Collation | Nullable | Default 
---------+---------+-----------+----------+---------
- a      | integer |           |          | 
-
-\d collate_dep_test2
- Composite type "collate_tests.collate_dep_test2"
- Column |  Type   | Collation | Nullable | Default 
---------+---------+-----------+----------+---------
- x      | integer |           |          | 
-
-DROP TABLE collate_dep_test1, collate_dep_test4t;
-DROP TYPE collate_dep_test2;
--- test range types and collations
-create type textrange_c as range(subtype=text, collation="C");
-create type textrange_en_us as range(subtype=text, collation="en-x-icu");
-select textrange_c('A','Z') @> 'b'::text;
- ?column? 
-----------
- f
-(1 row)
-
-select textrange_en_us('A','Z') @> 'b'::text;
- ?column? 
-----------
- t
-(1 row)
-
-drop type textrange_c;
-drop type textrange_en_us;
--- test ICU collation customization
--- test the attributes handled by icu_set_collation_attributes()
-CREATE COLLATION testcoll_ignore_accents (provider = icu, locale = '@colStrength=primary;colCaseLevel=yes');
-SELECT 'aaá' > 'AAA' COLLATE "und-x-icu", 'aaá' < 'AAA' COLLATE testcoll_ignore_accents;
- ?column? | ?column? 
-----------+----------
- t        | t
-(1 row)
-
-CREATE COLLATION testcoll_backwards (provider = icu, locale = '@colBackwards=yes');
-SELECT 'coté' < 'côte' COLLATE "und-x-icu", 'coté' > 'côte' COLLATE testcoll_backwards;
- ?column? | ?column? 
-----------+----------
- t        | t
-(1 row)
-
-CREATE COLLATION testcoll_lower_first (provider = icu, locale = '@colCaseFirst=lower');
-CREATE COLLATION testcoll_upper_first (provider = icu, locale = '@colCaseFirst=upper');
-SELECT 'aaa' < 'AAA' COLLATE testcoll_lower_first, 'aaa' > 'AAA' COLLATE testcoll_upper_first;
- ?column? | ?column? 
-----------+----------
- t        | t
-(1 row)
-
-CREATE COLLATION testcoll_shifted (provider = icu, locale = '@colAlternate=shifted');
-SELECT 'de-luge' < 'deanza' COLLATE "und-x-icu", 'de-luge' > 'deanza' COLLATE testcoll_shifted;
- ?column? | ?column? 
-----------+----------
- t        | t
-(1 row)
-
-CREATE COLLATION testcoll_numeric (provider = icu, locale = '@colNumeric=yes');
-SELECT 'A-21' > 'A-123' COLLATE "und-x-icu", 'A-21' < 'A-123' COLLATE testcoll_numeric;
- ?column? | ?column? 
-----------+----------
- t        | t
-(1 row)
-
-CREATE COLLATION testcoll_error1 (provider = icu, locale = '@colNumeric=lower');
-ERROR:  could not open collator for locale "@colNumeric=lower": U_ILLEGAL_ARGUMENT_ERROR
--- test that attributes not handled by icu_set_collation_attributes()
--- (handled by ucol_open() directly) also work
-CREATE COLLATION testcoll_de_phonebook (provider = icu, locale = 'de@collation=phonebook');
-SELECT 'Goldmann' < 'Götz' COLLATE "de-x-icu", 'Goldmann' > 'Götz' COLLATE testcoll_de_phonebook;
- ?column? | ?column? 
-----------+----------
- t        | t
-(1 row)
-
--- nondeterministic collations
-CREATE COLLATION ctest_det (provider = icu, locale = '', deterministic = true);
-CREATE COLLATION ctest_nondet (provider = icu, locale = '', deterministic = false);
-CREATE TABLE test6 (a int, b text);
--- same string in different normal forms
-INSERT INTO test6 VALUES (1, U&'\00E4bc');
-INSERT INTO test6 VALUES (2, U&'\0061\0308bc');
-SELECT * FROM test6;
- a |  b  
----+-----
- 1 | äbc
- 2 | äbc
-(2 rows)
-
-SELECT * FROM test6 WHERE b = 'äbc' COLLATE ctest_det;
- a |  b  
----+-----
- 1 | äbc
-(1 row)
-
-SELECT * FROM test6 WHERE b = 'äbc' COLLATE ctest_nondet;
- a |  b  
----+-----
- 1 | äbc
- 2 | äbc
-(2 rows)
-
--- same with arrays
-CREATE TABLE test6a (a int, b text[]);
-INSERT INTO test6a VALUES (1, ARRAY[U&'\00E4bc']);
-INSERT INTO test6a VALUES (2, ARRAY[U&'\0061\0308bc']);
-SELECT * FROM test6a;
- a |   b   
----+-------
- 1 | {äbc}
- 2 | {äbc}
-(2 rows)
-
-SELECT * FROM test6a WHERE b = ARRAY['äbc'] COLLATE ctest_det;
- a |   b   
----+-------
- 1 | {äbc}
-(1 row)
-
-SELECT * FROM test6a WHERE b = ARRAY['äbc'] COLLATE ctest_nondet;
- a |   b   
----+-------
- 1 | {äbc}
- 2 | {äbc}
-(2 rows)
-
-CREATE COLLATION case_sensitive (provider = icu, locale = '');
-CREATE COLLATION case_insensitive (provider = icu, locale = '@colStrength=secondary', deterministic = false);
-SELECT 'abc' <= 'ABC' COLLATE case_sensitive, 'abc' >= 'ABC' COLLATE case_sensitive;
- ?column? | ?column? 
-----------+----------
- t        | f
-(1 row)
-
-SELECT 'abc' <= 'ABC' COLLATE case_insensitive, 'abc' >= 'ABC' COLLATE case_insensitive;
- ?column? | ?column? 
-----------+----------
- t        | t
-(1 row)
-
-CREATE TABLE test1cs (x text COLLATE case_sensitive);
-CREATE TABLE test2cs (x text COLLATE case_sensitive);
-CREATE TABLE test3cs (x text COLLATE case_sensitive);
-INSERT INTO test1cs VALUES ('abc'), ('def'), ('ghi');
-INSERT INTO test2cs VALUES ('ABC'), ('ghi');
-INSERT INTO test3cs VALUES ('abc'), ('ABC'), ('def'), ('ghi');
-SELECT x FROM test3cs WHERE x = 'abc';
-  x  
------
- abc
-(1 row)
-
-SELECT x FROM test3cs WHERE x <> 'abc';
-  x  
------
- ABC
- def
- ghi
-(3 rows)
-
-SELECT x FROM test3cs WHERE x LIKE 'a%';
-  x  
------
- abc
-(1 row)
-
-SELECT x FROM test3cs WHERE x ILIKE 'a%';
-  x  
------
- abc
- ABC
-(2 rows)
-
-SELECT x FROM test3cs WHERE x SIMILAR TO 'a%';
-  x  
------
- abc
-(1 row)
-
-SELECT x FROM test3cs WHERE x ~ 'a';
-  x  
------
- abc
-(1 row)
-
-SELECT x FROM test1cs UNION SELECT x FROM test2cs ORDER BY x;
-  x  
------
- abc
- ABC
- def
- ghi
-(4 rows)
-
-SELECT x FROM test2cs UNION SELECT x FROM test1cs ORDER BY x;
-  x  
------
- abc
- ABC
- def
- ghi
-(4 rows)
-
-SELECT x FROM test1cs INTERSECT SELECT x FROM test2cs;
-  x  
------
- ghi
-(1 row)
-
-SELECT x FROM test2cs INTERSECT SELECT x FROM test1cs;
-  x  
------
- ghi
-(1 row)
-
-SELECT x FROM test1cs EXCEPT SELECT x FROM test2cs;
-  x  
------
- abc
- def
-(2 rows)
-
-SELECT x FROM test2cs EXCEPT SELECT x FROM test1cs;
-  x  
------
- ABC
-(1 row)
-
-SELECT DISTINCT x FROM test3cs ORDER BY x;
-  x  
------
- abc
- ABC
- def
- ghi
-(4 rows)
-
-SELECT count(DISTINCT x) FROM test3cs;
- count 
--------
-     4
-(1 row)
-
-SELECT x, count(*) FROM test3cs GROUP BY x ORDER BY x;
-  x  | count 
------+-------
- abc |     1
- ABC |     1
- def |     1
- ghi |     1
-(4 rows)
-
-SELECT x, row_number() OVER (ORDER BY x), rank() OVER (ORDER BY x) FROM test3cs ORDER BY x;
-  x  | row_number | rank 
------+------------+------
- abc |          1 |    1
- ABC |          2 |    2
- def |          3 |    3
- ghi |          4 |    4
-(4 rows)
-
-CREATE UNIQUE INDEX ON test1cs (x);  -- ok
-INSERT INTO test1cs VALUES ('ABC');  -- ok
-CREATE UNIQUE INDEX ON test3cs (x);  -- ok
-SELECT string_to_array('ABC,DEF,GHI' COLLATE case_sensitive, ',', 'abc');
- string_to_array 
------------------
- {ABC,DEF,GHI}
-(1 row)
-
-SELECT string_to_array('ABCDEFGHI' COLLATE case_sensitive, NULL, 'b');
-   string_to_array   
----------------------
- {A,B,C,D,E,F,G,H,I}
-(1 row)
-
-CREATE TABLE test1ci (x text COLLATE case_insensitive);
-CREATE TABLE test2ci (x text COLLATE case_insensitive);
-CREATE TABLE test3ci (x text COLLATE case_insensitive);
-CREATE INDEX ON test3ci (x text_pattern_ops);  -- error
-ERROR:  nondeterministic collations are not supported for operator class "text_pattern_ops"
-INSERT INTO test1ci VALUES ('abc'), ('def'), ('ghi');
-INSERT INTO test2ci VALUES ('ABC'), ('ghi');
-INSERT INTO test3ci VALUES ('abc'), ('ABC'), ('def'), ('ghi');
-SELECT x FROM test3ci WHERE x = 'abc';
-  x  
------
- abc
- ABC
-(2 rows)
-
-SELECT x FROM test3ci WHERE x <> 'abc';
-  x  
------
- def
- ghi
-(2 rows)
-
-SELECT x FROM test3ci WHERE x LIKE 'a%';
-ERROR:  nondeterministic collations are not supported for LIKE
-SELECT x FROM test3ci WHERE x ILIKE 'a%';
-ERROR:  nondeterministic collations are not supported for ILIKE
-SELECT x FROM test3ci WHERE x SIMILAR TO 'a%';
-ERROR:  nondeterministic collations are not supported for regular expressions
-SELECT x FROM test3ci WHERE x ~ 'a';
-ERROR:  nondeterministic collations are not supported for regular expressions
-SELECT x FROM test1ci UNION SELECT x FROM test2ci ORDER BY x;
-  x  
------
- abc
- def
- ghi
-(3 rows)
-
-SELECT x FROM test2ci UNION SELECT x FROM test1ci ORDER BY x;
-  x  
------
- ABC
- def
- ghi
-(3 rows)
-
-SELECT x FROM test1ci INTERSECT SELECT x FROM test2ci ORDER BY x;
-  x  
------
- abc
- ghi
-(2 rows)
-
-SELECT x FROM test2ci INTERSECT SELECT x FROM test1ci ORDER BY x;
-  x  
------
- ABC
- ghi
-(2 rows)
-
-SELECT x FROM test1ci EXCEPT SELECT x FROM test2ci;
-  x  
------
- def
-(1 row)
-
-SELECT x FROM test2ci EXCEPT SELECT x FROM test1ci;
- x 
----
-(0 rows)
-
-SELECT DISTINCT x FROM test3ci ORDER BY x;
-  x  
------
- abc
- def
- ghi
-(3 rows)
-
-SELECT count(DISTINCT x) FROM test3ci;
- count 
--------
-     3
-(1 row)
-
-SELECT x, count(*) FROM test3ci GROUP BY x ORDER BY x;
-  x  | count 
------+-------
- abc |     2
- def |     1
- ghi |     1
-(3 rows)
-
-SELECT x, row_number() OVER (ORDER BY x), rank() OVER (ORDER BY x) FROM test3ci ORDER BY x;
-  x  | row_number | rank 
------+------------+------
- abc |          1 |    1
- ABC |          2 |    1
- def |          3 |    3
- ghi |          4 |    4
-(4 rows)
-
-CREATE UNIQUE INDEX ON test1ci (x);  -- ok
-INSERT INTO test1ci VALUES ('ABC');  -- error
-ERROR:  duplicate key value violates unique constraint "test1ci_x_idx"
-DETAIL:  Key (x)=(ABC) already exists.
-CREATE UNIQUE INDEX ON test3ci (x);  -- error
-ERROR:  could not create unique index "test3ci_x_idx"
-DETAIL:  Key (x)=(abc) is duplicated.
-SELECT string_to_array('ABC,DEF,GHI' COLLATE case_insensitive, ',', 'abc');
-ERROR:  nondeterministic collations are not supported for substring searches
-SELECT string_to_array('ABCDEFGHI' COLLATE case_insensitive, NULL, 'b');
-    string_to_array     
-------------------------
- {A,NULL,C,D,E,F,G,H,I}
-(1 row)
-
--- bpchar
-CREATE TABLE test1bpci (x char(3) COLLATE case_insensitive);
-CREATE TABLE test2bpci (x char(3) COLLATE case_insensitive);
-CREATE TABLE test3bpci (x char(3) COLLATE case_insensitive);
-CREATE INDEX ON test3bpci (x bpchar_pattern_ops);  -- error
-ERROR:  nondeterministic collations are not supported for operator class "bpchar_pattern_ops"
-INSERT INTO test1bpci VALUES ('abc'), ('def'), ('ghi');
-INSERT INTO test2bpci VALUES ('ABC'), ('ghi');
-INSERT INTO test3bpci VALUES ('abc'), ('ABC'), ('def'), ('ghi');
-SELECT x FROM test3bpci WHERE x = 'abc';
-  x  
------
- abc
- ABC
-(2 rows)
-
-SELECT x FROM test3bpci WHERE x <> 'abc';
-  x  
------
- def
- ghi
-(2 rows)
-
-SELECT x FROM test3bpci WHERE x LIKE 'a%';
-ERROR:  nondeterministic collations are not supported for LIKE
-SELECT x FROM test3bpci WHERE x ILIKE 'a%';
-ERROR:  nondeterministic collations are not supported for ILIKE
-SELECT x FROM test3bpci WHERE x SIMILAR TO 'a%';
-ERROR:  nondeterministic collations are not supported for regular expressions
-SELECT x FROM test3bpci WHERE x ~ 'a';
-ERROR:  nondeterministic collations are not supported for regular expressions
-SELECT x FROM test1bpci UNION SELECT x FROM test2bpci ORDER BY x;
-  x  
------
- abc
- def
- ghi
-(3 rows)
-
-SELECT x FROM test2bpci UNION SELECT x FROM test1bpci ORDER BY x;
-  x  
------
- ABC
- def
- ghi
-(3 rows)
-
-SELECT x FROM test1bpci INTERSECT SELECT x FROM test2bpci ORDER BY x;
-  x  
------
- abc
- ghi
-(2 rows)
-
-SELECT x FROM test2bpci INTERSECT SELECT x FROM test1bpci ORDER BY x;
-  x  
------
- ABC
- ghi
-(2 rows)
-
-SELECT x FROM test1bpci EXCEPT SELECT x FROM test2bpci;
-  x  
------
- def
-(1 row)
-
-SELECT x FROM test2bpci EXCEPT SELECT x FROM test1bpci;
- x 
----
-(0 rows)
-
-SELECT DISTINCT x FROM test3bpci ORDER BY x;
-  x  
------
- abc
- def
- ghi
-(3 rows)
-
-SELECT count(DISTINCT x) FROM test3bpci;
- count 
--------
-     3
-(1 row)
-
-SELECT x, count(*) FROM test3bpci GROUP BY x ORDER BY x;
-  x  | count 
------+-------
- abc |     2
- def |     1
- ghi |     1
-(3 rows)
-
-SELECT x, row_number() OVER (ORDER BY x), rank() OVER (ORDER BY x) FROM test3bpci ORDER BY x;
-  x  | row_number | rank 
------+------------+------
- abc |          1 |    1
- ABC |          2 |    1
- def |          3 |    3
- ghi |          4 |    4
-(4 rows)
-
-CREATE UNIQUE INDEX ON test1bpci (x);  -- ok
-INSERT INTO test1bpci VALUES ('ABC');  -- error
-ERROR:  duplicate key value violates unique constraint "test1bpci_x_idx"
-DETAIL:  Key (x)=(ABC) already exists.
-CREATE UNIQUE INDEX ON test3bpci (x);  -- error
-ERROR:  could not create unique index "test3bpci_x_idx"
-DETAIL:  Key (x)=(abc) is duplicated.
-SELECT string_to_array('ABC,DEF,GHI'::char(11) COLLATE case_insensitive, ',', 'abc');
-ERROR:  nondeterministic collations are not supported for substring searches
-SELECT string_to_array('ABCDEFGHI'::char(9) COLLATE case_insensitive, NULL, 'b');
-    string_to_array     
-------------------------
- {A,NULL,C,D,E,F,G,H,I}
-(1 row)
-
--- This tests the issue described in match_pattern_prefix().  In the
--- absence of that check, the case_insensitive tests below would
--- return no rows where they should logically return one.
-CREATE TABLE test4c (x text COLLATE "C");
-INSERT INTO test4c VALUES ('abc');
-CREATE INDEX ON test4c (x);
-SET enable_seqscan = off;
-SELECT x FROM test4c WHERE x LIKE 'ABC' COLLATE case_sensitive;  -- ok, no rows
- x 
----
-(0 rows)
-
-SELECT x FROM test4c WHERE x LIKE 'ABC%' COLLATE case_sensitive;  -- ok, no rows
- x 
----
-(0 rows)
-
-SELECT x FROM test4c WHERE x LIKE 'ABC' COLLATE case_insensitive;  -- error
-ERROR:  nondeterministic collations are not supported for LIKE
-SELECT x FROM test4c WHERE x LIKE 'ABC%' COLLATE case_insensitive;  -- error
-ERROR:  nondeterministic collations are not supported for LIKE
-RESET enable_seqscan;
--- Unicode special case: different variants of Greek lower case sigma.
--- A naive implementation like citext that just does lower(x) =
--- lower(y) will do the wrong thing here, because lower('Σ') is 'σ'
--- but upper('ς') is 'Σ'.
-SELECT 'ὀδυσσεύς' = 'ὈΔΥΣΣΕΎΣ' COLLATE case_sensitive;
- ?column? 
-----------
- f
-(1 row)
-
-SELECT 'ὀδυσσεύς' = 'ὈΔΥΣΣΕΎΣ' COLLATE case_insensitive;
- ?column? 
-----------
- t
-(1 row)
-
--- name vs. text comparison operators
-SELECT relname FROM pg_class WHERE relname = 'PG_CLASS'::text COLLATE case_insensitive;
- relname  
-----------
- pg_class
-(1 row)
-
-SELECT relname FROM pg_class WHERE 'PG_CLASS'::text = relname COLLATE case_insensitive;
- relname  
-----------
- pg_class
-(1 row)
-
-SELECT typname FROM pg_type WHERE typname LIKE 'int_' AND typname <> 'INT2'::text
-  COLLATE case_insensitive ORDER BY typname;
- typname 
----------
- int4
- int8
-(2 rows)
-
-SELECT typname FROM pg_type WHERE typname LIKE 'int_' AND 'INT2'::text <> typname
-  COLLATE case_insensitive ORDER BY typname;
- typname 
----------
- int4
- int8
-(2 rows)
-
--- test case adapted from subselect.sql
-CREATE TEMP TABLE outer_text (f1 text COLLATE case_insensitive, f2 text);
-INSERT INTO outer_text VALUES ('a', 'a');
-INSERT INTO outer_text VALUES ('b', 'a');
-INSERT INTO outer_text VALUES ('A', NULL);
-INSERT INTO outer_text VALUES ('B', NULL);
-CREATE TEMP TABLE inner_text (c1 text COLLATE case_insensitive, c2 text);
-INSERT INTO inner_text VALUES ('a', NULL);
-SELECT * FROM outer_text WHERE (f1, f2) NOT IN (SELECT * FROM inner_text);
- f1 | f2 
-----+----
- b  | a
- B  | 
-(2 rows)
-
--- accents
-CREATE COLLATION ignore_accents (provider = icu, locale = '@colStrength=primary;colCaseLevel=yes', deterministic = false);
-CREATE TABLE test4 (a int, b text);
-INSERT INTO test4 VALUES (1, 'cote'), (2, 'côte'), (3, 'coté'), (4, 'côté');
-SELECT * FROM test4 WHERE b = 'cote';
- a |  b   
----+------
- 1 | cote
-(1 row)
-
-SELECT * FROM test4 WHERE b = 'cote' COLLATE ignore_accents;
- a |  b   
----+------
- 1 | cote
- 2 | côte
- 3 | coté
- 4 | côté
-(4 rows)
-
-SELECT * FROM test4 WHERE b = 'Cote' COLLATE ignore_accents;  -- still case-sensitive
- a | b 
----+---
-(0 rows)
-
-SELECT * FROM test4 WHERE b = 'Cote' COLLATE case_insensitive;
- a |  b   
----+------
- 1 | cote
-(1 row)
-
--- foreign keys (should use collation of primary key)
--- PK is case-sensitive, FK is case-insensitive
-CREATE TABLE test10pk (x text COLLATE case_sensitive PRIMARY KEY);
-INSERT INTO test10pk VALUES ('abc'), ('def'), ('ghi');
-CREATE TABLE test10fk (x text COLLATE case_insensitive REFERENCES test10pk (x) ON UPDATE CASCADE ON DELETE CASCADE);
-INSERT INTO test10fk VALUES ('abc');  -- ok
-INSERT INTO test10fk VALUES ('ABC');  -- error
-ERROR:  insert or update on table "test10fk" violates foreign key constraint "test10fk_x_fkey"
-DETAIL:  Key (x)=(ABC) is not present in table "test10pk".
-INSERT INTO test10fk VALUES ('xyz');  -- error
-ERROR:  insert or update on table "test10fk" violates foreign key constraint "test10fk_x_fkey"
-DETAIL:  Key (x)=(xyz) is not present in table "test10pk".
-SELECT * FROM test10pk;
-  x  
------
- abc
- def
- ghi
-(3 rows)
-
-SELECT * FROM test10fk;
-  x  
------
- abc
-(1 row)
-
--- restrict update even though the values are "equal" in the FK table
-UPDATE test10fk SET x = 'ABC' WHERE x = 'abc';  -- error
-ERROR:  insert or update on table "test10fk" violates foreign key constraint "test10fk_x_fkey"
-DETAIL:  Key (x)=(ABC) is not present in table "test10pk".
-SELECT * FROM test10fk;
-  x  
------
- abc
-(1 row)
-
-DELETE FROM test10pk WHERE x = 'abc';
-SELECT * FROM test10pk;
-  x  
------
- def
- ghi
-(2 rows)
-
-SELECT * FROM test10fk;
- x 
----
-(0 rows)
-
--- PK is case-insensitive, FK is case-sensitive
-CREATE TABLE test11pk (x text COLLATE case_insensitive PRIMARY KEY);
-INSERT INTO test11pk VALUES ('abc'), ('def'), ('ghi');
-CREATE TABLE test11fk (x text COLLATE case_sensitive REFERENCES test11pk (x) ON UPDATE CASCADE ON DELETE CASCADE);
-INSERT INTO test11fk VALUES ('abc');  -- ok
-INSERT INTO test11fk VALUES ('ABC');  -- ok
-INSERT INTO test11fk VALUES ('xyz');  -- error
-ERROR:  insert or update on table "test11fk" violates foreign key constraint "test11fk_x_fkey"
-DETAIL:  Key (x)=(xyz) is not present in table "test11pk".
-SELECT * FROM test11pk;
-  x  
------
- abc
- def
- ghi
-(3 rows)
-
-SELECT * FROM test11fk;
-  x  
------
- abc
- ABC
-(2 rows)
-
--- cascade update even though the values are "equal" in the PK table
-UPDATE test11pk SET x = 'ABC' WHERE x = 'abc';
-SELECT * FROM test11fk;
-  x  
------
- ABC
- ABC
-(2 rows)
-
-DELETE FROM test11pk WHERE x = 'abc';
-SELECT * FROM test11pk;
-  x  
------
- def
- ghi
-(2 rows)
-
-SELECT * FROM test11fk;
- x 
----
-(0 rows)
-
--- partitioning
-CREATE TABLE test20 (a int, b text COLLATE case_insensitive) PARTITION BY LIST (b);
-CREATE TABLE test20_1 PARTITION OF test20 FOR VALUES IN ('abc');
-INSERT INTO test20 VALUES (1, 'abc');
-INSERT INTO test20 VALUES (2, 'ABC');
-SELECT * FROM test20_1;
- a |  b  
----+-----
- 1 | abc
- 2 | ABC
-(2 rows)
-
-CREATE TABLE test21 (a int, b text COLLATE case_insensitive) PARTITION BY RANGE (b);
-CREATE TABLE test21_1 PARTITION OF test21 FOR VALUES FROM ('ABC') TO ('DEF');
-INSERT INTO test21 VALUES (1, 'abc');
-INSERT INTO test21 VALUES (2, 'ABC');
-SELECT * FROM test21_1;
- a |  b  
----+-----
- 1 | abc
- 2 | ABC
-(2 rows)
-
-CREATE TABLE test22 (a int, b text COLLATE case_sensitive) PARTITION BY HASH (b);
-CREATE TABLE test22_0 PARTITION OF test22 FOR VALUES WITH (MODULUS 2, REMAINDER 0);
-CREATE TABLE test22_1 PARTITION OF test22 FOR VALUES WITH (MODULUS 2, REMAINDER 1);
-INSERT INTO test22 VALUES (1, 'def');
-INSERT INTO test22 VALUES (2, 'DEF');
--- they end up in different partitions
-SELECT (SELECT count(*) FROM test22_0) = (SELECT count(*) FROM test22_1);
- ?column? 
-----------
- t
-(1 row)
-
--- same with arrays
-CREATE TABLE test22a (a int, b text[] COLLATE case_sensitive) PARTITION BY HASH (b);
-CREATE TABLE test22a_0 PARTITION OF test22a FOR VALUES WITH (MODULUS 2, REMAINDER 0);
-CREATE TABLE test22a_1 PARTITION OF test22a FOR VALUES WITH (MODULUS 2, REMAINDER 1);
-INSERT INTO test22a VALUES (1, ARRAY['def']);
-INSERT INTO test22a VALUES (2, ARRAY['DEF']);
--- they end up in different partitions
-SELECT (SELECT count(*) FROM test22a_0) = (SELECT count(*) FROM test22a_1);
- ?column? 
-----------
- t
-(1 row)
-
-CREATE TABLE test23 (a int, b text COLLATE case_insensitive) PARTITION BY HASH (b);
-CREATE TABLE test23_0 PARTITION OF test23 FOR VALUES WITH (MODULUS 2, REMAINDER 0);
-CREATE TABLE test23_1 PARTITION OF test23 FOR VALUES WITH (MODULUS 2, REMAINDER 1);
-INSERT INTO test23 VALUES (1, 'def');
-INSERT INTO test23 VALUES (2, 'DEF');
--- they end up in the same partition (but it's platform-dependent which one)
-SELECT (SELECT count(*) FROM test23_0) <> (SELECT count(*) FROM test23_1);
- ?column? 
-----------
- t
-(1 row)
-
--- same with arrays
-CREATE TABLE test23a (a int, b text[] COLLATE case_insensitive) PARTITION BY HASH (b);
-CREATE TABLE test23a_0 PARTITION OF test23a FOR VALUES WITH (MODULUS 2, REMAINDER 0);
-CREATE TABLE test23a_1 PARTITION OF test23a FOR VALUES WITH (MODULUS 2, REMAINDER 1);
-INSERT INTO test23a VALUES (1, ARRAY['def']);
-INSERT INTO test23a VALUES (2, ARRAY['DEF']);
--- they end up in the same partition (but it's platform-dependent which one)
-SELECT (SELECT count(*) FROM test23a_0) <> (SELECT count(*) FROM test23a_1);
- ?column? 
-----------
- t
-(1 row)
-
-CREATE TABLE test30 (a int, b char(3) COLLATE case_insensitive) PARTITION BY LIST (b);
-CREATE TABLE test30_1 PARTITION OF test30 FOR VALUES IN ('abc');
-INSERT INTO test30 VALUES (1, 'abc');
-INSERT INTO test30 VALUES (2, 'ABC');
-SELECT * FROM test30_1;
- a |  b  
----+-----
- 1 | abc
- 2 | ABC
-(2 rows)
-
-CREATE TABLE test31 (a int, b char(3) COLLATE case_insensitive) PARTITION BY RANGE (b);
-CREATE TABLE test31_1 PARTITION OF test31 FOR VALUES FROM ('ABC') TO ('DEF');
-INSERT INTO test31 VALUES (1, 'abc');
-INSERT INTO test31 VALUES (2, 'ABC');
-SELECT * FROM test31_1;
- a |  b  
----+-----
- 1 | abc
- 2 | ABC
-(2 rows)
-
-CREATE TABLE test32 (a int, b char(3) COLLATE case_sensitive) PARTITION BY HASH (b);
-CREATE TABLE test32_0 PARTITION OF test32 FOR VALUES WITH (MODULUS 2, REMAINDER 0);
-CREATE TABLE test32_1 PARTITION OF test32 FOR VALUES WITH (MODULUS 2, REMAINDER 1);
-INSERT INTO test32 VALUES (1, 'def');
-INSERT INTO test32 VALUES (2, 'DEF');
--- they end up in different partitions
-SELECT (SELECT count(*) FROM test32_0) = (SELECT count(*) FROM test32_1);
- ?column? 
-----------
- t
-(1 row)
-
-CREATE TABLE test33 (a int, b char(3) COLLATE case_insensitive) PARTITION BY HASH (b);
-CREATE TABLE test33_0 PARTITION OF test33 FOR VALUES WITH (MODULUS 2, REMAINDER 0);
-CREATE TABLE test33_1 PARTITION OF test33 FOR VALUES WITH (MODULUS 2, REMAINDER 1);
-INSERT INTO test33 VALUES (1, 'def');
-INSERT INTO test33 VALUES (2, 'DEF');
--- they end up in the same partition (but it's platform-dependent which one)
-SELECT (SELECT count(*) FROM test33_0) <> (SELECT count(*) FROM test33_1);
- ?column? 
-----------
- t
-(1 row)
-
--- cleanup
-RESET search_path;
-SET client_min_messages TO warning;
-DROP SCHEMA collate_tests CASCADE;
-RESET client_min_messages;
--- leave a collation for pg_upgrade test
-CREATE COLLATION coll_icu_upgrade FROM "und-x-icu";
diff --git a/src/test/regress/expected/collate.linux.utf8.out b/src/test/regress/expected/collate.linux.utf8.out
index f06ae543e4..ede5fdb5dc 100644
--- a/src/test/regress/expected/collate.linux.utf8.out
+++ b/src/test/regress/expected/collate.linux.utf8.out
@@ -9,1152 +9,3 @@ SELECT getdatabaseencoding() <> 'UTF8' OR
        AS skip_test \gset
 \if :skip_test
 \quit
-\endif
-SET client_encoding TO UTF8;
-CREATE SCHEMA collate_tests;
-SET search_path = collate_tests;
-CREATE TABLE collate_test1 (
-    a int,
-    b text COLLATE "en_US" NOT NULL
-);
-\d collate_test1
-        Table "collate_tests.collate_test1"
- Column |  Type   | Collation | Nullable | Default 
---------+---------+-----------+----------+---------
- a      | integer |           |          | 
- b      | text    | en_US     | not null | 
-
-CREATE TABLE collate_test_fail (
-    a int,
-    b text COLLATE "ja_JP.eucjp"
-);
-ERROR:  collation "ja_JP.eucjp" for encoding "UTF8" does not exist
-LINE 3:     b text COLLATE "ja_JP.eucjp"
-                   ^
-CREATE TABLE collate_test_fail (
-    a int,
-    b text COLLATE "foo"
-);
-ERROR:  collation "foo" for encoding "UTF8" does not exist
-LINE 3:     b text COLLATE "foo"
-                   ^
-CREATE TABLE collate_test_fail (
-    a int COLLATE "en_US",
-    b text
-);
-ERROR:  collations are not supported by type integer
-LINE 2:     a int COLLATE "en_US",
-                  ^
-CREATE TABLE collate_test_like (
-    LIKE collate_test1
-);
-\d collate_test_like
-      Table "collate_tests.collate_test_like"
- Column |  Type   | Collation | Nullable | Default 
---------+---------+-----------+----------+---------
- a      | integer |           |          | 
- b      | text    | en_US     | not null | 
-
-CREATE TABLE collate_test2 (
-    a int,
-    b text COLLATE "sv_SE"
-);
-CREATE TABLE collate_test3 (
-    a int,
-    b text COLLATE "C"
-);
-INSERT INTO collate_test1 VALUES (1, 'abc'), (2, 'äbc'), (3, 'bbc'), (4, 'ABC');
-INSERT INTO collate_test2 SELECT * FROM collate_test1;
-INSERT INTO collate_test3 SELECT * FROM collate_test1;
-SELECT * FROM collate_test1 WHERE b >= 'bbc';
- a |  b  
----+-----
- 3 | bbc
-(1 row)
-
-SELECT * FROM collate_test2 WHERE b >= 'bbc';
- a |  b  
----+-----
- 2 | äbc
- 3 | bbc
-(2 rows)
-
-SELECT * FROM collate_test3 WHERE b >= 'bbc';
- a |  b  
----+-----
- 2 | äbc
- 3 | bbc
-(2 rows)
-
-SELECT * FROM collate_test3 WHERE b >= 'BBC';
- a |  b  
----+-----
- 1 | abc
- 2 | äbc
- 3 | bbc
-(3 rows)
-
-SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc';
- a |  b  
----+-----
- 2 | äbc
- 3 | bbc
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b >= 'bbc' COLLATE "C";
- a |  b  
----+-----
- 2 | äbc
- 3 | bbc
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "C";
- a |  b  
----+-----
- 2 | äbc
- 3 | bbc
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "en_US";
-ERROR:  collation mismatch between explicit collations "C" and "en_US"
-LINE 1: ...* FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "e...
-                                                             ^
-CREATE DOMAIN testdomain_sv AS text COLLATE "sv_SE";
-CREATE DOMAIN testdomain_i AS int COLLATE "sv_SE"; -- fails
-ERROR:  collations are not supported by type integer
-CREATE TABLE collate_test4 (
-    a int,
-    b testdomain_sv
-);
-INSERT INTO collate_test4 SELECT * FROM collate_test1;
-SELECT a, b FROM collate_test4 ORDER BY b;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-CREATE TABLE collate_test5 (
-    a int,
-    b testdomain_sv COLLATE "en_US"
-);
-INSERT INTO collate_test5 SELECT * FROM collate_test1;
-SELECT a, b FROM collate_test5 ORDER BY b;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT a, b FROM collate_test1 ORDER BY b;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT a, b FROM collate_test2 ORDER BY b;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, b FROM collate_test3 ORDER BY b;
- a |  b  
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
- a |  b  
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
--- star expansion
-SELECT * FROM collate_test1 ORDER BY b;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT * FROM collate_test2 ORDER BY b;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT * FROM collate_test3 ORDER BY b;
- a |  b  
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
--- constant expression folding
-SELECT 'bbc' COLLATE "en_US" > 'äbc' COLLATE "en_US" AS "true";
- true 
-------
- t
-(1 row)
-
-SELECT 'bbc' COLLATE "sv_SE" > 'äbc' COLLATE "sv_SE" AS "false";
- false 
--------
- f
-(1 row)
-
--- upper/lower
-CREATE TABLE collate_test10 (
-    a int,
-    x text COLLATE "en_US",
-    y text COLLATE "tr_TR"
-);
-INSERT INTO collate_test10 VALUES (1, 'hij', 'hij'), (2, 'HIJ', 'HIJ');
-SELECT a, lower(x), lower(y), upper(x), upper(y), initcap(x), initcap(y) FROM collate_test10;
- a | lower | lower | upper | upper | initcap | initcap 
----+-------+-------+-------+-------+---------+---------
- 1 | hij   | hij   | HIJ   | HİJ   | Hij     | Hij
- 2 | hij   | hıj   | HIJ   | HIJ   | Hij     | Hıj
-(2 rows)
-
-SELECT a, lower(x COLLATE "C"), lower(y COLLATE "C") FROM collate_test10;
- a | lower | lower 
----+-------+-------
- 1 | hij   | hij
- 2 | hij   | hij
-(2 rows)
-
-SELECT a, x, y FROM collate_test10 ORDER BY lower(y), a;
- a |  x  |  y  
----+-----+-----
- 2 | HIJ | HIJ
- 1 | hij | hij
-(2 rows)
-
--- LIKE/ILIKE
-SELECT * FROM collate_test1 WHERE b LIKE 'abc';
- a |  b  
----+-----
- 1 | abc
-(1 row)
-
-SELECT * FROM collate_test1 WHERE b LIKE 'abc%';
- a |  b  
----+-----
- 1 | abc
-(1 row)
-
-SELECT * FROM collate_test1 WHERE b LIKE '%bc%';
- a |  b  
----+-----
- 1 | abc
- 2 | äbc
- 3 | bbc
-(3 rows)
-
-SELECT * FROM collate_test1 WHERE b ILIKE 'abc';
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b ILIKE 'abc%';
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b ILIKE '%bc%';
- a |  b  
----+-----
- 1 | abc
- 2 | äbc
- 3 | bbc
- 4 | ABC
-(4 rows)
-
-SELECT 'Türkiye' COLLATE "en_US" ILIKE '%KI%' AS "true";
- true 
-------
- t
-(1 row)
-
-SELECT 'Türkiye' COLLATE "tr_TR" ILIKE '%KI%' AS "false";
- false 
--------
- f
-(1 row)
-
-SELECT 'bıt' ILIKE 'BIT' COLLATE "en_US" AS "false";
- false 
--------
- f
-(1 row)
-
-SELECT 'bıt' ILIKE 'BIT' COLLATE "tr_TR" AS "true";
- true 
-------
- t
-(1 row)
-
--- The following actually exercises the selectivity estimation for ILIKE.
-SELECT relname FROM pg_class WHERE relname ILIKE 'abc%';
- relname 
----------
-(0 rows)
-
--- regular expressions
-SELECT * FROM collate_test1 WHERE b ~ '^abc$';
- a |  b  
----+-----
- 1 | abc
-(1 row)
-
-SELECT * FROM collate_test1 WHERE b ~ '^abc';
- a |  b  
----+-----
- 1 | abc
-(1 row)
-
-SELECT * FROM collate_test1 WHERE b ~ 'bc';
- a |  b  
----+-----
- 1 | abc
- 2 | äbc
- 3 | bbc
-(3 rows)
-
-SELECT * FROM collate_test1 WHERE b ~* '^abc$';
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b ~* '^abc';
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
-(2 rows)
-
-SELECT * FROM collate_test1 WHERE b ~* 'bc';
- a |  b  
----+-----
- 1 | abc
- 2 | äbc
- 3 | bbc
- 4 | ABC
-(4 rows)
-
-CREATE TABLE collate_test6 (
-    a int,
-    b text COLLATE "en_US"
-);
-INSERT INTO collate_test6 VALUES (1, 'abc'), (2, 'ABC'), (3, '123'), (4, 'ab1'),
-                                 (5, 'a1!'), (6, 'a c'), (7, '!.;'), (8, '   '),
-                                 (9, 'äbç'), (10, 'ÄBÇ');
-SELECT b,
-       b ~ '^[[:alpha:]]+$' AS is_alpha,
-       b ~ '^[[:upper:]]+$' AS is_upper,
-       b ~ '^[[:lower:]]+$' AS is_lower,
-       b ~ '^[[:digit:]]+$' AS is_digit,
-       b ~ '^[[:alnum:]]+$' AS is_alnum,
-       b ~ '^[[:graph:]]+$' AS is_graph,
-       b ~ '^[[:print:]]+$' AS is_print,
-       b ~ '^[[:punct:]]+$' AS is_punct,
-       b ~ '^[[:space:]]+$' AS is_space
-FROM collate_test6;
-  b  | is_alpha | is_upper | is_lower | is_digit | is_alnum | is_graph | is_print | is_punct | is_space 
------+----------+----------+----------+----------+----------+----------+----------+----------+----------
- abc | t        | f        | t        | f        | t        | t        | t        | f        | f
- ABC | t        | t        | f        | f        | t        | t        | t        | f        | f
- 123 | f        | f        | f        | t        | t        | t        | t        | f        | f
- ab1 | f        | f        | f        | f        | t        | t        | t        | f        | f
- a1! | f        | f        | f        | f        | f        | t        | t        | f        | f
- a c | f        | f        | f        | f        | f        | f        | t        | f        | f
- !.; | f        | f        | f        | f        | f        | t        | t        | t        | f
-     | f        | f        | f        | f        | f        | f        | t        | f        | t
- äbç | t        | f        | t        | f        | t        | t        | t        | f        | f
- ÄBÇ | t        | t        | f        | f        | t        | t        | t        | f        | f
-(10 rows)
-
-SELECT 'Türkiye' COLLATE "en_US" ~* 'KI' AS "true";
- true 
-------
- t
-(1 row)
-
-SELECT 'Türkiye' COLLATE "tr_TR" ~* 'KI' AS "false";
- false 
--------
- f
-(1 row)
-
-SELECT 'bıt' ~* 'BIT' COLLATE "en_US" AS "false";
- false 
--------
- f
-(1 row)
-
-SELECT 'bıt' ~* 'BIT' COLLATE "tr_TR" AS "true";
- true 
-------
- t
-(1 row)
-
--- The following actually exercises the selectivity estimation for ~*.
-SELECT relname FROM pg_class WHERE relname ~* '^abc';
- relname 
----------
-(0 rows)
-
--- to_char
-SET lc_time TO 'tr_TR';
-SELECT to_char(date '2010-02-01', 'DD TMMON YYYY');
-   to_char   
--------------
- 01 ŞUB 2010
-(1 row)
-
-SELECT to_char(date '2010-02-01', 'DD TMMON YYYY' COLLATE "tr_TR");
-   to_char   
--------------
- 01 ŞUB 2010
-(1 row)
-
-SELECT to_char(date '2010-04-01', 'DD TMMON YYYY');
-   to_char   
--------------
- 01 NIS 2010
-(1 row)
-
-SELECT to_char(date '2010-04-01', 'DD TMMON YYYY' COLLATE "tr_TR");
-   to_char   
--------------
- 01 NİS 2010
-(1 row)
-
--- to_date
-SELECT to_date('01 ŞUB 2010', 'DD TMMON YYYY');
-  to_date   
-------------
- 02-01-2010
-(1 row)
-
-SELECT to_date('01 Şub 2010', 'DD TMMON YYYY');
-  to_date   
-------------
- 02-01-2010
-(1 row)
-
-SELECT to_date('1234567890ab 2010', 'TMMONTH YYYY'); -- fail
-ERROR:  invalid value "1234567890ab" for "MONTH"
-DETAIL:  The given value did not match any of the allowed values for this field.
--- backwards parsing
-CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc';
-CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
-CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10;
-SELECT table_name, view_definition FROM information_schema.views
-  WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name |                             view_definition                              
-------------+--------------------------------------------------------------------------
- collview1  |  SELECT collate_test1.a,                                                +
-            |     collate_test1.b                                                     +
-            |    FROM collate_test1                                                   +
-            |   WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2  |  SELECT collate_test1.a,                                                +
-            |     collate_test1.b                                                     +
-            |    FROM collate_test1                                                   +
-            |   ORDER BY (collate_test1.b COLLATE "C");
- collview3  |  SELECT collate_test10.a,                                               +
-            |     lower(((collate_test10.x || collate_test10.x) COLLATE "C")) AS lower+
-            |    FROM collate_test10;
-(3 rows)
-
--- collation propagation in various expression types
-SELECT a, coalesce(b, 'foo') FROM collate_test1 ORDER BY 2;
- a | coalesce 
----+----------
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT a, coalesce(b, 'foo') FROM collate_test2 ORDER BY 2;
- a | coalesce 
----+----------
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, coalesce(b, 'foo') FROM collate_test3 ORDER BY 2;
- a | coalesce 
----+----------
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, lower(coalesce(x, 'foo')), lower(coalesce(y, 'foo')) FROM collate_test10;
- a | lower | lower 
----+-------+-------
- 1 | hij   | hij
- 2 | hij   | hıj
-(2 rows)
-
-SELECT a, b, greatest(b, 'CCC') FROM collate_test1 ORDER BY 3;
- a |  b  | greatest 
----+-----+----------
- 1 | abc | CCC
- 2 | äbc | CCC
- 3 | bbc | CCC
- 4 | ABC | CCC
-(4 rows)
-
-SELECT a, b, greatest(b, 'CCC') FROM collate_test2 ORDER BY 3;
- a |  b  | greatest 
----+-----+----------
- 1 | abc | CCC
- 3 | bbc | CCC
- 4 | ABC | CCC
- 2 | äbc | äbc
-(4 rows)
-
-SELECT a, b, greatest(b, 'CCC') FROM collate_test3 ORDER BY 3;
- a |  b  | greatest 
----+-----+----------
- 4 | ABC | CCC
- 1 | abc | abc
- 3 | bbc | bbc
- 2 | äbc | äbc
-(4 rows)
-
-SELECT a, x, y, lower(greatest(x, 'foo')), lower(greatest(y, 'foo')) FROM collate_test10;
- a |  x  |  y  | lower | lower 
----+-----+-----+-------+-------
- 1 | hij | hij | hij   | hij
- 2 | HIJ | HIJ | hij   | hıj
-(2 rows)
-
-SELECT a, nullif(b, 'abc') FROM collate_test1 ORDER BY 2;
- a | nullif 
----+--------
- 4 | ABC
- 2 | äbc
- 3 | bbc
- 1 | 
-(4 rows)
-
-SELECT a, nullif(b, 'abc') FROM collate_test2 ORDER BY 2;
- a | nullif 
----+--------
- 4 | ABC
- 3 | bbc
- 2 | äbc
- 1 | 
-(4 rows)
-
-SELECT a, nullif(b, 'abc') FROM collate_test3 ORDER BY 2;
- a | nullif 
----+--------
- 4 | ABC
- 3 | bbc
- 2 | äbc
- 1 | 
-(4 rows)
-
-SELECT a, lower(nullif(x, 'foo')), lower(nullif(y, 'foo')) FROM collate_test10;
- a | lower | lower 
----+-------+-------
- 1 | hij   | hij
- 2 | hij   | hıj
-(2 rows)
-
-SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2;
- a |  b   
----+------
- 4 | ABC
- 2 | äbc
- 1 | abcd
- 3 | bbc
-(4 rows)
-
-SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2;
- a |  b   
----+------
- 4 | ABC
- 1 | abcd
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test3 ORDER BY 2;
- a |  b   
----+------
- 4 | ABC
- 1 | abcd
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-CREATE DOMAIN testdomain AS text;
-SELECT a, b::testdomain FROM collate_test1 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT a, b::testdomain FROM collate_test2 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, b::testdomain FROM collate_test3 ORDER BY 2;
- a |  b  
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, b::testdomain_sv FROM collate_test3 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, lower(x::testdomain), lower(y::testdomain) FROM collate_test10;
- a | lower | lower 
----+-------+-------
- 1 | hij   | hij
- 2 | hij   | hıj
-(2 rows)
-
-SELECT min(b), max(b) FROM collate_test1;
- min | max 
------+-----
- abc | bbc
-(1 row)
-
-SELECT min(b), max(b) FROM collate_test2;
- min | max 
------+-----
- abc | äbc
-(1 row)
-
-SELECT min(b), max(b) FROM collate_test3;
- min | max 
------+-----
- ABC | äbc
-(1 row)
-
-SELECT array_agg(b ORDER BY b) FROM collate_test1;
-     array_agg     
--------------------
- {abc,ABC,äbc,bbc}
-(1 row)
-
-SELECT array_agg(b ORDER BY b) FROM collate_test2;
-     array_agg     
--------------------
- {abc,ABC,bbc,äbc}
-(1 row)
-
-SELECT array_agg(b ORDER BY b) FROM collate_test3;
-     array_agg     
--------------------
- {ABC,abc,bbc,äbc}
-(1 row)
-
-SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 1 | abc
- 4 | ABC
- 4 | ABC
- 2 | äbc
- 2 | äbc
- 3 | bbc
- 3 | bbc
-(8 rows)
-
-SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, b FROM collate_test3 WHERE a < 4 INTERSECT SELECT a, b FROM collate_test3 WHERE a > 1 ORDER BY 2;
- a |  b  
----+-----
- 3 | bbc
- 2 | äbc
-(2 rows)
-
-SELECT a, b FROM collate_test3 EXCEPT SELECT a, b FROM collate_test3 WHERE a < 2 ORDER BY 2;
- a |  b  
----+-----
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(3 rows)
-
-SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 ORDER BY 2; -- fail
-ERROR:  could not determine which collation to use for string comparison
-HINT:  Use the COLLATE clause to set the collation explicitly.
-SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3; -- ok
- a |  b  
----+-----
- 1 | abc
- 2 | äbc
- 3 | bbc
- 4 | ABC
- 1 | abc
- 2 | äbc
- 3 | bbc
- 4 | ABC
-(8 rows)
-
-SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2; -- fail
-ERROR:  collation mismatch between implicit collations "en_US" and "C"
-LINE 1: SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collat...
-                                                       ^
-HINT:  You can choose the collation by applying the COLLATE clause to one or both expressions.
-SELECT a, b COLLATE "C" FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2; -- ok
- a |  b  
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test3 ORDER BY 2; -- fail
-ERROR:  collation mismatch between implicit collations "en_US" and "C"
-LINE 1: ...ELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM col...
-                                                             ^
-HINT:  You can choose the collation by applying the COLLATE clause to one or both expressions.
-SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test3 ORDER BY 2; -- fail
-ERROR:  collation mismatch between implicit collations "en_US" and "C"
-LINE 1: SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM colla...
-                                                        ^
-HINT:  You can choose the collation by applying the COLLATE clause to one or both expressions.
-CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3; -- fail
-ERROR:  no collation was derived for column "b" with collatable type text
-HINT:  Use the COLLATE clause to set the collation explicitly.
--- ideally this would be a parse-time error, but for now it must be run-time:
-select x < y from collate_test10; -- fail
-ERROR:  could not determine which collation to use for string comparison
-HINT:  Use the COLLATE clause to set the collation explicitly.
-select x || y from collate_test10; -- ok, because || is not collation aware
- ?column? 
-----------
- hijhij
- HIJHIJ
-(2 rows)
-
-select x, y from collate_test10 order by x || y; -- not so ok
-ERROR:  collation mismatch between implicit collations "en_US" and "tr_TR"
-LINE 1: select x, y from collate_test10 order by x || y;
-                                                      ^
-HINT:  You can choose the collation by applying the COLLATE clause to one or both expressions.
--- collation mismatch between recursive and non-recursive term
-WITH RECURSIVE foo(x) AS
-   (SELECT x FROM (VALUES('a' COLLATE "en_US"),('b')) t(x)
-   UNION ALL
-   SELECT (x || 'c') COLLATE "de_DE" FROM foo WHERE length(x) < 10)
-SELECT * FROM foo;
-ERROR:  recursive query "foo" column 1 has collation "en_US" in non-recursive term but collation "de_DE" overall
-LINE 2:    (SELECT x FROM (VALUES('a' COLLATE "en_US"),('b')) t(x)
-                   ^
-HINT:  Use the COLLATE clause to set the collation of the non-recursive term.
--- casting
-SELECT CAST('42' AS text COLLATE "C");
-ERROR:  syntax error at or near "COLLATE"
-LINE 1: SELECT CAST('42' AS text COLLATE "C");
-                                 ^
-SELECT a, CAST(b AS varchar) FROM collate_test1 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2;
- a |  b  
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
- a |  b  
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
--- propagation of collation in SQL functions (inlined and non-inlined cases)
--- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
-    AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
-    AS $$ select $1 < $2 limit 1 $$;
-CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
-    AS $$ begin return $1 < $2; end $$;
-SELECT a.b AS a, b.b AS b, a.b < b.b AS lt,
-       mylt(a.b, b.b), mylt_noninline(a.b, b.b), mylt_plpgsql(a.b, b.b)
-FROM collate_test1 a, collate_test1 b
-ORDER BY a.b, b.b;
-  a  |  b  | lt | mylt | mylt_noninline | mylt_plpgsql 
------+-----+----+------+----------------+--------------
- abc | abc | f  | f    | f              | f
- abc | ABC | t  | t    | t              | t
- abc | äbc | t  | t    | t              | t
- abc | bbc | t  | t    | t              | t
- ABC | abc | f  | f    | f              | f
- ABC | ABC | f  | f    | f              | f
- ABC | äbc | t  | t    | t              | t
- ABC | bbc | t  | t    | t              | t
- äbc | abc | f  | f    | f              | f
- äbc | ABC | f  | f    | f              | f
- äbc | äbc | f  | f    | f              | f
- äbc | bbc | t  | t    | t              | t
- bbc | abc | f  | f    | f              | f
- bbc | ABC | f  | f    | f              | f
- bbc | äbc | f  | f    | f              | f
- bbc | bbc | f  | f    | f              | f
-(16 rows)
-
-SELECT a.b AS a, b.b AS b, a.b < b.b COLLATE "C" AS lt,
-       mylt(a.b, b.b COLLATE "C"), mylt_noninline(a.b, b.b COLLATE "C"),
-       mylt_plpgsql(a.b, b.b COLLATE "C")
-FROM collate_test1 a, collate_test1 b
-ORDER BY a.b, b.b;
-  a  |  b  | lt | mylt | mylt_noninline | mylt_plpgsql 
------+-----+----+------+----------------+--------------
- abc | abc | f  | f    | f              | f
- abc | ABC | f  | f    | f              | f
- abc | äbc | t  | t    | t              | t
- abc | bbc | t  | t    | t              | t
- ABC | abc | t  | t    | t              | t
- ABC | ABC | f  | f    | f              | f
- ABC | äbc | t  | t    | t              | t
- ABC | bbc | t  | t    | t              | t
- äbc | abc | f  | f    | f              | f
- äbc | ABC | f  | f    | f              | f
- äbc | äbc | f  | f    | f              | f
- äbc | bbc | f  | f    | f              | f
- bbc | abc | f  | f    | f              | f
- bbc | ABC | f  | f    | f              | f
- bbc | äbc | t  | t    | t              | t
- bbc | bbc | f  | f    | f              | f
-(16 rows)
-
--- collation override in plpgsql
-CREATE FUNCTION mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$
-declare
-  xx text := x;
-  yy text := y;
-begin
-  return xx < yy;
-end
-$$;
-SELECT mylt2('a', 'B' collate "en_US") as t, mylt2('a', 'B' collate "C") as f;
- t | f 
----+---
- t | f
-(1 row)
-
-CREATE OR REPLACE FUNCTION
-  mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$
-declare
-  xx text COLLATE "POSIX" := x;
-  yy text := y;
-begin
-  return xx < yy;
-end
-$$;
-SELECT mylt2('a', 'B') as f;
- f 
----
- f
-(1 row)
-
-SELECT mylt2('a', 'B' collate "C") as fail; -- conflicting collations
-ERROR:  could not determine which collation to use for string comparison
-HINT:  Use the COLLATE clause to set the collation explicitly.
-CONTEXT:  PL/pgSQL function mylt2(text,text) line 6 at RETURN
-SELECT mylt2('a', 'B' collate "POSIX") as f;
- f 
----
- f
-(1 row)
-
--- polymorphism
-SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1;
- unnest 
---------
- abc
- ABC
- äbc
- bbc
-(4 rows)
-
-SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1;
- unnest 
---------
- abc
- ABC
- bbc
- äbc
-(4 rows)
-
-SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1;
- unnest 
---------
- ABC
- abc
- bbc
- äbc
-(4 rows)
-
-CREATE FUNCTION dup (anyelement) RETURNS anyelement
-    AS 'select $1' LANGUAGE sql;
-SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
- a | dup 
----+-----
- 1 | abc
- 4 | ABC
- 2 | äbc
- 3 | bbc
-(4 rows)
-
-SELECT a, dup(b) FROM collate_test2 ORDER BY 2;
- a | dup 
----+-----
- 1 | abc
- 4 | ABC
- 3 | bbc
- 2 | äbc
-(4 rows)
-
-SELECT a, dup(b) FROM collate_test3 ORDER BY 2;
- a | dup 
----+-----
- 4 | ABC
- 1 | abc
- 3 | bbc
- 2 | äbc
-(4 rows)
-
--- indexes
-CREATE INDEX collate_test1_idx1 ON collate_test1 (b);
-CREATE INDEX collate_test1_idx2 ON collate_test1 (b COLLATE "C");
-CREATE INDEX collate_test1_idx3 ON collate_test1 ((b COLLATE "C")); -- this is different grammatically
-CREATE INDEX collate_test1_idx4 ON collate_test1 (((b||'foo') COLLATE "POSIX"));
-CREATE INDEX collate_test1_idx5 ON collate_test1 (a COLLATE "C"); -- fail
-ERROR:  collations are not supported by type integer
-CREATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "C")); -- fail
-ERROR:  collations are not supported by type integer
-LINE 1: ...ATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "C...
-                                                             ^
-SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1;
-      relname       |                                                  pg_get_indexdef                                                  
---------------------+-------------------------------------------------------------------------------------------------------------------
- collate_test1_idx1 | CREATE INDEX collate_test1_idx1 ON collate_tests.collate_test1 USING btree (b)
- collate_test1_idx2 | CREATE INDEX collate_test1_idx2 ON collate_tests.collate_test1 USING btree (b COLLATE "C")
- collate_test1_idx3 | CREATE INDEX collate_test1_idx3 ON collate_tests.collate_test1 USING btree (b COLLATE "C")
- collate_test1_idx4 | CREATE INDEX collate_test1_idx4 ON collate_tests.collate_test1 USING btree (((b || 'foo'::text)) COLLATE "POSIX")
-(4 rows)
-
--- schema manipulation commands
-CREATE ROLE regress_test_role;
-CREATE SCHEMA test_schema;
--- We need to do this this way to cope with varying names for encodings:
-do $$
-BEGIN
-  EXECUTE 'CREATE COLLATION test0 (locale = ' ||
-          quote_literal(current_setting('lc_collate')) || ');';
-END
-$$;
-CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
-ERROR:  collation "test0" already exists
-CREATE COLLATION IF NOT EXISTS test0 FROM "C"; -- ok, skipped
-NOTICE:  collation "test0" already exists, skipping
-CREATE COLLATION IF NOT EXISTS test0 (locale = 'foo'); -- ok, skipped
-NOTICE:  collation "test0" for encoding "UTF8" already exists, skipping
-do $$
-BEGIN
-  EXECUTE 'CREATE COLLATION test1 (lc_collate = ' ||
-          quote_literal(current_setting('lc_collate')) ||
-          ', lc_ctype = ' ||
-          quote_literal(current_setting('lc_ctype')) || ');';
-END
-$$;
-CREATE COLLATION test3 (lc_collate = 'en_US.utf8'); -- fail, need lc_ctype
-ERROR:  parameter "lc_ctype" must be specified
-CREATE COLLATION testx (locale = 'nonsense'); -- fail
-ERROR:  could not create locale "nonsense": No such file or directory
-DETAIL:  The operating system could not find any locale data for the locale name "nonsense".
-CREATE COLLATION test4 FROM nonsense;
-ERROR:  collation "nonsense" for encoding "UTF8" does not exist
-CREATE COLLATION test5 FROM test0;
-SELECT collname FROM pg_collation WHERE collname LIKE 'test%' ORDER BY 1;
- collname 
-----------
- test0
- test1
- test5
-(3 rows)
-
-ALTER COLLATION test1 RENAME TO test11;
-ALTER COLLATION test0 RENAME TO test11; -- fail
-ERROR:  collation "test11" for encoding "UTF8" already exists in schema "collate_tests"
-ALTER COLLATION test1 RENAME TO test22; -- fail
-ERROR:  collation "test1" for encoding "UTF8" does not exist
-ALTER COLLATION test11 OWNER TO regress_test_role;
-ALTER COLLATION test11 OWNER TO nonsense;
-ERROR:  role "nonsense" does not exist
-ALTER COLLATION test11 SET SCHEMA test_schema;
-COMMENT ON COLLATION test0 IS 'US English';
-SELECT collname, nspname, obj_description(pg_collation.oid, 'pg_collation')
-    FROM pg_collation JOIN pg_namespace ON (collnamespace = pg_namespace.oid)
-    WHERE collname LIKE 'test%'
-    ORDER BY 1;
- collname |    nspname    | obj_description 
-----------+---------------+-----------------
- test0    | collate_tests | US English
- test11   | test_schema   | 
- test5    | collate_tests | 
-(3 rows)
-
-DROP COLLATION test0, test_schema.test11, test5;
-DROP COLLATION test0; -- fail
-ERROR:  collation "test0" for encoding "UTF8" does not exist
-DROP COLLATION IF EXISTS test0;
-NOTICE:  collation "test0" does not exist, skipping
-SELECT collname FROM pg_collation WHERE collname LIKE 'test%';
- collname 
-----------
-(0 rows)
-
-DROP SCHEMA test_schema;
-DROP ROLE regress_test_role;
--- ALTER
-ALTER COLLATION "en_US" REFRESH VERSION;
-NOTICE:  version has not changed
--- dependencies
-CREATE COLLATION test0 FROM "C";
-CREATE TABLE collate_dep_test1 (a int, b text COLLATE test0);
-CREATE DOMAIN collate_dep_dom1 AS text COLLATE test0;
-CREATE TYPE collate_dep_test2 AS (x int, y text COLLATE test0);
-CREATE VIEW collate_dep_test3 AS SELECT text 'foo' COLLATE test0 AS foo;
-CREATE TABLE collate_dep_test4t (a int, b text);
-CREATE INDEX collate_dep_test4i ON collate_dep_test4t (b COLLATE test0);
-DROP COLLATION test0 RESTRICT; -- fail
-ERROR:  cannot drop collation test0 because other objects depend on it
-DETAIL:  column b of table collate_dep_test1 depends on collation test0
-type collate_dep_dom1 depends on collation test0
-column y of composite type collate_dep_test2 depends on collation test0
-view collate_dep_test3 depends on collation test0
-index collate_dep_test4i depends on collation test0
-HINT:  Use DROP ... CASCADE to drop the dependent objects too.
-DROP COLLATION test0 CASCADE;
-NOTICE:  drop cascades to 5 other objects
-DETAIL:  drop cascades to column b of table collate_dep_test1
-drop cascades to type collate_dep_dom1
-drop cascades to column y of composite type collate_dep_test2
-drop cascades to view collate_dep_test3
-drop cascades to index collate_dep_test4i
-\d collate_dep_test1
-      Table "collate_tests.collate_dep_test1"
- Column |  Type   | Collation | Nullable | Default 
---------+---------+-----------+----------+---------
- a      | integer |           |          | 
-
-\d collate_dep_test2
- Composite type "collate_tests.collate_dep_test2"
- Column |  Type   | Collation | Nullable | Default 
---------+---------+-----------+----------+---------
- x      | integer |           |          | 
-
-DROP TABLE collate_dep_test1, collate_dep_test4t;
-DROP TYPE collate_dep_test2;
--- test range types and collations
-create type textrange_c as range(subtype=text, collation="C");
-create type textrange_en_us as range(subtype=text, collation="en_US");
-select textrange_c('A','Z') @> 'b'::text;
- ?column? 
-----------
- f
-(1 row)
-
-select textrange_en_us('A','Z') @> 'b'::text;
- ?column? 
-----------
- t
-(1 row)
-
-drop type textrange_c;
-drop type textrange_en_us;
--- nondeterministic collations
--- (not supported with libc provider)
-CREATE COLLATION ctest_det (locale = 'en_US.utf8', deterministic = true);
-CREATE COLLATION ctest_nondet (locale = 'en_US.utf8', deterministic = false);
-ERROR:  nondeterministic collations not supported with this provider
--- cleanup
-SET client_min_messages TO warning;
-DROP SCHEMA collate_tests CASCADE;
diff --git a/src/test/regress/expected/compression.out b/src/test/regress/expected/compression.out
index 4c997e2602..ea393e86d5 100644
--- a/src/test/regress/expected/compression.out
+++ b/src/test/regress/expected/compression.out
@@ -6,21 +6,22 @@ CREATE TABLE cmdata(f1 text COMPRESSION pglz);
 CREATE INDEX idx ON cmdata(f1);
 INSERT INTO cmdata VALUES(repeat('1234567890', 1000));
 \d+ cmdata
-                                        Table "public.cmdata"
- Column | Type | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+------+-----------+----------+---------+----------+-------------+--------------+-------------
- f1     | text |           |          |         | extended | pglz        |              | 
+                                              Table "public.cmdata"
+ Column | Type | Collation | Nullable | Default | Expanded | Storage  | Compression | Stats target | Description 
+--------+------+-----------+----------+---------+----------+----------+-------------+--------------+-------------
+ f1     | text |           |          |         |          | extended | pglz        |              | 
 Indexes:
     "idx" btree (f1)
 
 CREATE TABLE cmdata1(f1 TEXT COMPRESSION lz4);
+ERROR:  compression method lz4 not supported
+DETAIL:  This functionality requires the server to be built with lz4 support.
+HINT:  You need to rebuild PostgreSQL using --with-lz4.
 INSERT INTO cmdata1 VALUES(repeat('1234567890', 1004));
+ERROR:  relation "cmdata1" does not exist
+LINE 1: INSERT INTO cmdata1 VALUES(repeat('1234567890', 1004));
+                    ^
 \d+ cmdata1
-                                        Table "public.cmdata1"
- Column | Type | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+------+-----------+----------+---------+----------+-------------+--------------+-------------
- f1     | text |           |          |         | extended | lz4         |              | 
-
 -- verify stored compression method in the data
 SELECT pg_column_compression(f1) FROM cmdata;
  pg_column_compression 
@@ -29,11 +30,9 @@ SELECT pg_column_compression(f1) FROM cmdata;
 (1 row)
 
 SELECT pg_column_compression(f1) FROM cmdata1;
- pg_column_compression 
------------------------
- lz4
-(1 row)
-
+ERROR:  relation "cmdata1" does not exist
+LINE 1: SELECT pg_column_compression(f1) FROM cmdata1;
+                                              ^
 -- decompress data slice
 SELECT SUBSTR(f1, 200, 5) FROM cmdata;
  substr 
@@ -42,18 +41,16 @@ SELECT SUBSTR(f1, 200, 5) FROM cmdata;
 (1 row)
 
 SELECT SUBSTR(f1, 2000, 50) FROM cmdata1;
-                       substr                       
-----------------------------------------------------
- 01234567890123456789012345678901234567890123456789
-(1 row)
-
+ERROR:  relation "cmdata1" does not exist
+LINE 1: SELECT SUBSTR(f1, 2000, 50) FROM cmdata1;
+                                         ^
 -- copy with table creation
 SELECT * INTO cmmove1 FROM cmdata;
 \d+ cmmove1
-                                        Table "public.cmmove1"
- Column | Type | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+------+-----------+----------+---------+----------+-------------+--------------+-------------
- f1     | text |           |          |         | extended |             |              | 
+                                             Table "public.cmmove1"
+ Column | Type | Collation | Nullable | Default | Expanded | Storage  | Compression | Stats target | Description 
+--------+------+-----------+----------+---------+----------+----------+-------------+--------------+-------------
+ f1     | text |           |          |         |          | extended |             |              | 
 
 SELECT pg_column_compression(f1) FROM cmmove1;
  pg_column_compression 
@@ -65,22 +62,23 @@ SELECT pg_column_compression(f1) FROM cmmove1;
 CREATE TABLE cmmove3(f1 text COMPRESSION pglz);
 INSERT INTO cmmove3 SELECT * FROM cmdata;
 INSERT INTO cmmove3 SELECT * FROM cmdata1;
+ERROR:  relation "cmdata1" does not exist
+LINE 1: INSERT INTO cmmove3 SELECT * FROM cmdata1;
+                                          ^
 SELECT pg_column_compression(f1) FROM cmmove3;
  pg_column_compression 
 -----------------------
  pglz
- lz4
-(2 rows)
+(1 row)
 
 -- test LIKE INCLUDING COMPRESSION
 CREATE TABLE cmdata2 (LIKE cmdata1 INCLUDING COMPRESSION);
+ERROR:  relation "cmdata1" does not exist
+LINE 1: CREATE TABLE cmdata2 (LIKE cmdata1 INCLUDING COMPRESSION);
+                                   ^
 \d+ cmdata2
-                                        Table "public.cmdata2"
- Column | Type | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+------+-----------+----------+---------+----------+-------------+--------------+-------------
- f1     | text |           |          |         | extended | lz4         |              | 
-
 DROP TABLE cmdata2;
+ERROR:  table "cmdata2" does not exist
 -- try setting compression for incompressible data type
 CREATE TABLE cmdata2 (f1 int COMPRESSION pglz);
 ERROR:  column data type integer does not support compression
@@ -94,10 +92,13 @@ SELECT pg_column_compression(f1) FROM cmmove2;
 (1 row)
 
 UPDATE cmmove2 SET f1 = cmdata1.f1 FROM cmdata1;
+ERROR:  relation "cmdata1" does not exist
+LINE 1: UPDATE cmmove2 SET f1 = cmdata1.f1 FROM cmdata1;
+                                                ^
 SELECT pg_column_compression(f1) FROM cmmove2;
  pg_column_compression 
 -----------------------
- lz4
+ pglz
 (1 row)
 
 -- test externally stored compressed data
@@ -112,20 +113,17 @@ SELECT pg_column_compression(f1) FROM cmdata2;
 (1 row)
 
 INSERT INTO cmdata1 SELECT large_val() || repeat('a', 4000);
+ERROR:  relation "cmdata1" does not exist
+LINE 1: INSERT INTO cmdata1 SELECT large_val() || repeat('a', 4000);
+                    ^
 SELECT pg_column_compression(f1) FROM cmdata1;
- pg_column_compression 
------------------------
- lz4
- lz4
-(2 rows)
-
+ERROR:  relation "cmdata1" does not exist
+LINE 1: SELECT pg_column_compression(f1) FROM cmdata1;
+                                              ^
 SELECT SUBSTR(f1, 200, 5) FROM cmdata1;
- substr 
---------
- 01234
- 8f14e
-(2 rows)
-
+ERROR:  relation "cmdata1" does not exist
+LINE 1: SELECT SUBSTR(f1, 200, 5) FROM cmdata1;
+                                       ^
 SELECT SUBSTR(f1, 200, 5) FROM cmdata2;
  substr 
 --------
@@ -136,41 +134,41 @@ DROP TABLE cmdata2;
 --test column type update varlena/non-varlena
 CREATE TABLE cmdata2 (f1 int);
 \d+ cmdata2
-                                         Table "public.cmdata2"
- Column |  Type   | Collation | Nullable | Default | Storage | Compression | Stats target | Description 
---------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
- f1     | integer |           |          |         | plain   |             |              | 
+                                              Table "public.cmdata2"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Compression | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+-------------+--------------+-------------
+ f1     | integer |           |          |         |          | plain   |             |              | 
 
 ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar;
 \d+ cmdata2
-                                              Table "public.cmdata2"
- Column |       Type        | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+-------------------+-----------+----------+---------+----------+-------------+--------------+-------------
- f1     | character varying |           |          |         | extended |             |              | 
+                                                    Table "public.cmdata2"
+ Column |       Type        | Collation | Nullable | Default | Expanded | Storage  | Compression | Stats target | Description 
+--------+-------------------+-----------+----------+---------+----------+----------+-------------+--------------+-------------
+ f1     | character varying |           |          |         |          | extended |             |              | 
 
 ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE int USING f1::integer;
 \d+ cmdata2
-                                         Table "public.cmdata2"
- Column |  Type   | Collation | Nullable | Default | Storage | Compression | Stats target | Description 
---------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
- f1     | integer |           |          |         | plain   |             |              | 
+                                              Table "public.cmdata2"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Compression | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+-------------+--------------+-------------
+ f1     | integer |           |          |         |          | plain   |             |              | 
 
 --changing column storage should not impact the compression method
 --but the data should not be compressed
 ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar;
 ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION pglz;
 \d+ cmdata2
-                                              Table "public.cmdata2"
- Column |       Type        | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+-------------------+-----------+----------+---------+----------+-------------+--------------+-------------
- f1     | character varying |           |          |         | extended | pglz        |              | 
+                                                    Table "public.cmdata2"
+ Column |       Type        | Collation | Nullable | Default | Expanded | Storage  | Compression | Stats target | Description 
+--------+-------------------+-----------+----------+---------+----------+----------+-------------+--------------+-------------
+ f1     | character varying |           |          |         |          | extended | pglz        |              | 
 
 ALTER TABLE cmdata2 ALTER COLUMN f1 SET STORAGE plain;
 \d+ cmdata2
-                                              Table "public.cmdata2"
- Column |       Type        | Collation | Nullable | Default | Storage | Compression | Stats target | Description 
---------+-------------------+-----------+----------+---------+---------+-------------+--------------+-------------
- f1     | character varying |           |          |         | plain   | pglz        |              | 
+                                                   Table "public.cmdata2"
+ Column |       Type        | Collation | Nullable | Default | Expanded | Storage | Compression | Stats target | Description 
+--------+-------------------+-----------+----------+---------+----------+---------+-------------+--------------+-------------
+ f1     | character varying |           |          |         |          | plain   | pglz        |              | 
 
 INSERT INTO cmdata2 VALUES (repeat('123456789', 800));
 SELECT pg_column_compression(f1) FROM cmdata2;
@@ -181,53 +179,48 @@ SELECT pg_column_compression(f1) FROM cmdata2;
 
 -- test compression with materialized view
 CREATE MATERIALIZED VIEW compressmv(x) AS SELECT * FROM cmdata1;
+ERROR:  relation "cmdata1" does not exist
+LINE 1: ...TE MATERIALIZED VIEW compressmv(x) AS SELECT * FROM cmdata1;
+                                                               ^
 \d+ compressmv
-                                Materialized view "public.compressmv"
- Column | Type | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+------+-----------+----------+---------+----------+-------------+--------------+-------------
- x      | text |           |          |         | extended |             |              | 
-View definition:
- SELECT cmdata1.f1 AS x
-   FROM cmdata1;
-
 SELECT pg_column_compression(f1) FROM cmdata1;
- pg_column_compression 
------------------------
- lz4
- lz4
-(2 rows)
-
+ERROR:  relation "cmdata1" does not exist
+LINE 1: SELECT pg_column_compression(f1) FROM cmdata1;
+                                              ^
 SELECT pg_column_compression(x) FROM compressmv;
- pg_column_compression 
------------------------
- lz4
- lz4
-(2 rows)
-
+ERROR:  relation "compressmv" does not exist
+LINE 1: SELECT pg_column_compression(x) FROM compressmv;
+                                             ^
 -- test compression with partition
 CREATE TABLE cmpart(f1 text COMPRESSION lz4) PARTITION BY HASH(f1);
+ERROR:  compression method lz4 not supported
+DETAIL:  This functionality requires the server to be built with lz4 support.
+HINT:  You need to rebuild PostgreSQL using --with-lz4.
 CREATE TABLE cmpart1 PARTITION OF cmpart FOR VALUES WITH (MODULUS 2, REMAINDER 0);
+ERROR:  relation "cmpart" does not exist
 CREATE TABLE cmpart2(f1 text COMPRESSION pglz);
 ALTER TABLE cmpart ATTACH PARTITION cmpart2 FOR VALUES WITH (MODULUS 2, REMAINDER 1);
+ERROR:  relation "cmpart" does not exist
 INSERT INTO cmpart VALUES (repeat('123456789', 1004));
+ERROR:  relation "cmpart" does not exist
+LINE 1: INSERT INTO cmpart VALUES (repeat('123456789', 1004));
+                    ^
 INSERT INTO cmpart VALUES (repeat('123456789', 4004));
+ERROR:  relation "cmpart" does not exist
+LINE 1: INSERT INTO cmpart VALUES (repeat('123456789', 4004));
+                    ^
 SELECT pg_column_compression(f1) FROM cmpart1;
- pg_column_compression 
------------------------
- lz4
-(1 row)
-
+ERROR:  relation "cmpart1" does not exist
+LINE 1: SELECT pg_column_compression(f1) FROM cmpart1;
+                                              ^
 SELECT pg_column_compression(f1) FROM cmpart2;
  pg_column_compression 
 -----------------------
- pglz
-(1 row)
+(0 rows)
 
 -- test compression with inheritance, error
 CREATE TABLE cminh() INHERITS(cmdata, cmdata1);
-NOTICE:  merging multiple inherited definitions of column "f1"
-ERROR:  column "f1" has a compression method conflict
-DETAIL:  pglz versus lz4
+ERROR:  relation "cmdata1" does not exist
 CREATE TABLE cminh(f1 TEXT COMPRESSION lz4) INHERITS(cmdata);
 NOTICE:  merging column "f1" with inherited definition
 ERROR:  column "f1" has a compression method conflict
@@ -235,20 +228,25 @@ DETAIL:  pglz versus lz4
 -- test default_toast_compression GUC
 SET default_toast_compression = '';
 ERROR:  invalid value for parameter "default_toast_compression": ""
-HINT:  Available values: pglz, lz4.
+HINT:  Available values: pglz.
 SET default_toast_compression = 'I do not exist compression';
 ERROR:  invalid value for parameter "default_toast_compression": "I do not exist compression"
-HINT:  Available values: pglz, lz4.
+HINT:  Available values: pglz.
 SET default_toast_compression = 'lz4';
+ERROR:  invalid value for parameter "default_toast_compression": "lz4"
+HINT:  Available values: pglz.
 SET default_toast_compression = 'pglz';
 -- test alter compression method
 ALTER TABLE cmdata ALTER COLUMN f1 SET COMPRESSION lz4;
+ERROR:  compression method lz4 not supported
+DETAIL:  This functionality requires the server to be built with lz4 support.
+HINT:  You need to rebuild PostgreSQL using --with-lz4.
 INSERT INTO cmdata VALUES (repeat('123456789', 4004));
 \d+ cmdata
-                                        Table "public.cmdata"
- Column | Type | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+------+-----------+----------+---------+----------+-------------+--------------+-------------
- f1     | text |           |          |         | extended | lz4         |              | 
+                                              Table "public.cmdata"
+ Column | Type | Collation | Nullable | Default | Expanded | Storage  | Compression | Stats target | Description 
+--------+------+-----------+----------+---------+----------+----------+-------------+--------------+-------------
+ f1     | text |           |          |         |          | extended | pglz        |              | 
 Indexes:
     "idx" btree (f1)
 
@@ -256,53 +254,51 @@ SELECT pg_column_compression(f1) FROM cmdata;
  pg_column_compression 
 -----------------------
  pglz
- lz4
+ pglz
 (2 rows)
 
 ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION default;
 \d+ cmdata2
-                                              Table "public.cmdata2"
- Column |       Type        | Collation | Nullable | Default | Storage | Compression | Stats target | Description 
---------+-------------------+-----------+----------+---------+---------+-------------+--------------+-------------
- f1     | character varying |           |          |         | plain   |             |              | 
+                                                   Table "public.cmdata2"
+ Column |       Type        | Collation | Nullable | Default | Expanded | Storage | Compression | Stats target | Description 
+--------+-------------------+-----------+----------+---------+----------+---------+-------------+--------------+-------------
+ f1     | character varying |           |          |         |          | plain   |             |              | 
 
 -- test alter compression method for materialized views
 ALTER MATERIALIZED VIEW compressmv ALTER COLUMN x SET COMPRESSION lz4;
+ERROR:  relation "compressmv" does not exist
 \d+ compressmv
-                                Materialized view "public.compressmv"
- Column | Type | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+------+-----------+----------+---------+----------+-------------+--------------+-------------
- x      | text |           |          |         | extended | lz4         |              | 
-View definition:
- SELECT cmdata1.f1 AS x
-   FROM cmdata1;
-
 -- test alter compression method for partitioned tables
 ALTER TABLE cmpart1 ALTER COLUMN f1 SET COMPRESSION pglz;
+ERROR:  relation "cmpart1" does not exist
 ALTER TABLE cmpart2 ALTER COLUMN f1 SET COMPRESSION lz4;
+ERROR:  compression method lz4 not supported
+DETAIL:  This functionality requires the server to be built with lz4 support.
+HINT:  You need to rebuild PostgreSQL using --with-lz4.
 -- new data should be compressed with the current compression method
 INSERT INTO cmpart VALUES (repeat('123456789', 1004));
+ERROR:  relation "cmpart" does not exist
+LINE 1: INSERT INTO cmpart VALUES (repeat('123456789', 1004));
+                    ^
 INSERT INTO cmpart VALUES (repeat('123456789', 4004));
+ERROR:  relation "cmpart" does not exist
+LINE 1: INSERT INTO cmpart VALUES (repeat('123456789', 4004));
+                    ^
 SELECT pg_column_compression(f1) FROM cmpart1;
- pg_column_compression 
------------------------
- lz4
- pglz
-(2 rows)
-
+ERROR:  relation "cmpart1" does not exist
+LINE 1: SELECT pg_column_compression(f1) FROM cmpart1;
+                                              ^
 SELECT pg_column_compression(f1) FROM cmpart2;
  pg_column_compression 
 -----------------------
- pglz
- lz4
-(2 rows)
+(0 rows)
 
 -- VACUUM FULL does not recompress
 SELECT pg_column_compression(f1) FROM cmdata;
  pg_column_compression 
 -----------------------
  pglz
- lz4
+ pglz
 (2 rows)
 
 VACUUM FULL cmdata;
@@ -310,15 +306,22 @@ SELECT pg_column_compression(f1) FROM cmdata;
  pg_column_compression 
 -----------------------
  pglz
- lz4
+ pglz
 (2 rows)
 
 -- test expression index
 DROP TABLE cmdata2;
 CREATE TABLE cmdata2 (f1 TEXT COMPRESSION pglz, f2 TEXT COMPRESSION lz4);
+ERROR:  compression method lz4 not supported
+DETAIL:  This functionality requires the server to be built with lz4 support.
+HINT:  You need to rebuild PostgreSQL using --with-lz4.
 CREATE UNIQUE INDEX idx1 ON cmdata2 ((f1 || f2));
+ERROR:  relation "cmdata2" does not exist
 INSERT INTO cmdata2 VALUES((SELECT array_agg(md5(g::TEXT))::TEXT FROM
 generate_series(1, 50) g), VERSION());
+ERROR:  relation "cmdata2" does not exist
+LINE 1: INSERT INTO cmdata2 VALUES((SELECT array_agg(md5(g::TEXT))::...
+                    ^
 -- check data is ok
 SELECT length(f1) FROM cmdata;
  length 
@@ -328,12 +331,9 @@ SELECT length(f1) FROM cmdata;
 (2 rows)
 
 SELECT length(f1) FROM cmdata1;
- length 
---------
-  10040
-  12449
-(2 rows)
-
+ERROR:  relation "cmdata1" does not exist
+LINE 1: SELECT length(f1) FROM cmdata1;
+                               ^
 SELECT length(f1) FROM cmmove1;
  length 
 --------
@@ -350,8 +350,7 @@ SELECT length(f1) FROM cmmove3;
  length 
 --------
   10000
-  10040
-(2 rows)
+(1 row)
 
 CREATE TABLE badcompresstbl (a text COMPRESSION I_Do_Not_Exist_Compression); -- fails
 ERROR:  invalid compression method "i_do_not_exist_compression"
diff --git a/src/test/regress/expected/compression_1.out b/src/test/regress/expected/compression_1.out
index 1ce2962d55..9214b6b99f 100644
--- a/src/test/regress/expected/compression_1.out
+++ b/src/test/regress/expected/compression_1.out
@@ -6,10 +6,10 @@ CREATE TABLE cmdata(f1 text COMPRESSION pglz);
 CREATE INDEX idx ON cmdata(f1);
 INSERT INTO cmdata VALUES(repeat('1234567890', 1000));
 \d+ cmdata
-                                        Table "public.cmdata"
- Column | Type | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+------+-----------+----------+---------+----------+-------------+--------------+-------------
- f1     | text |           |          |         | extended | pglz        |              | 
+                                             Table "public.cmdata"
+ Column | Type | Collation | Nullable | Default | Visible | Storage  | Compression | Stats target | Description 
+--------+------+-----------+----------+---------+---------+----------+-------------+--------------+-------------
+ f1     | text |           |          |         |         | extended | pglz        |              | 
 Indexes:
     "idx" btree (f1)
 
@@ -47,10 +47,10 @@ LINE 1: SELECT SUBSTR(f1, 2000, 50) FROM cmdata1;
 -- copy with table creation
 SELECT * INTO cmmove1 FROM cmdata;
 \d+ cmmove1
-                                        Table "public.cmmove1"
- Column | Type | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+------+-----------+----------+---------+----------+-------------+--------------+-------------
- f1     | text |           |          |         | extended |             |              | 
+                                             Table "public.cmmove1"
+ Column | Type | Collation | Nullable | Default | Visible | Storage  | Compression | Stats target | Description 
+--------+------+-----------+----------+---------+---------+----------+-------------+--------------+-------------
+ f1     | text |           |          |         |         | extended |             |              | 
 
 SELECT pg_column_compression(f1) FROM cmmove1;
  pg_column_compression 
@@ -134,41 +134,41 @@ DROP TABLE cmdata2;
 --test column type update varlena/non-varlena
 CREATE TABLE cmdata2 (f1 int);
 \d+ cmdata2
-                                         Table "public.cmdata2"
- Column |  Type   | Collation | Nullable | Default | Storage | Compression | Stats target | Description 
---------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
- f1     | integer |           |          |         | plain   |             |              | 
+                                              Table "public.cmdata2"
+ Column |  Type   | Collation | Nullable | Default | Visible | Storage | Compression | Stats target | Description 
+--------+---------+-----------+----------+---------+---------+---------+-------------+--------------+-------------
+ f1     | integer |           |          |         |         | plain   |             |              | 
 
 ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar;
 \d+ cmdata2
-                                              Table "public.cmdata2"
- Column |       Type        | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+-------------------+-----------+----------+---------+----------+-------------+--------------+-------------
- f1     | character varying |           |          |         | extended |             |              | 
+                                                   Table "public.cmdata2"
+ Column |       Type        | Collation | Nullable | Default | Visible | Storage  | Compression | Stats target | Description 
+--------+-------------------+-----------+----------+---------+---------+----------+-------------+--------------+-------------
+ f1     | character varying |           |          |         |         | extended |             |              | 
 
 ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE int USING f1::integer;
 \d+ cmdata2
-                                         Table "public.cmdata2"
- Column |  Type   | Collation | Nullable | Default | Storage | Compression | Stats target | Description 
---------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
- f1     | integer |           |          |         | plain   |             |              | 
+                                              Table "public.cmdata2"
+ Column |  Type   | Collation | Nullable | Default | Visible | Storage | Compression | Stats target | Description 
+--------+---------+-----------+----------+---------+---------+---------+-------------+--------------+-------------
+ f1     | integer |           |          |         |         | plain   |             |              | 
 
 --changing column storage should not impact the compression method
 --but the data should not be compressed
 ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar;
 ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION pglz;
 \d+ cmdata2
-                                              Table "public.cmdata2"
- Column |       Type        | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+-------------------+-----------+----------+---------+----------+-------------+--------------+-------------
- f1     | character varying |           |          |         | extended | pglz        |              | 
+                                                   Table "public.cmdata2"
+ Column |       Type        | Collation | Nullable | Default | Visible | Storage  | Compression | Stats target | Description 
+--------+-------------------+-----------+----------+---------+---------+----------+-------------+--------------+-------------
+ f1     | character varying |           |          |         |         | extended | pglz        |              | 
 
 ALTER TABLE cmdata2 ALTER COLUMN f1 SET STORAGE plain;
 \d+ cmdata2
-                                              Table "public.cmdata2"
- Column |       Type        | Collation | Nullable | Default | Storage | Compression | Stats target | Description 
---------+-------------------+-----------+----------+---------+---------+-------------+--------------+-------------
- f1     | character varying |           |          |         | plain   | pglz        |              | 
+                                                   Table "public.cmdata2"
+ Column |       Type        | Collation | Nullable | Default | Visible | Storage | Compression | Stats target | Description 
+--------+-------------------+-----------+----------+---------+---------+---------+-------------+--------------+-------------
+ f1     | character varying |           |          |         |         | plain   | pglz        |              | 
 
 INSERT INTO cmdata2 VALUES (repeat('123456789', 800));
 SELECT pg_column_compression(f1) FROM cmdata2;
@@ -243,10 +243,10 @@ DETAIL:  This functionality requires the server to be built with lz4 support.
 HINT:  You need to rebuild PostgreSQL using --with-lz4.
 INSERT INTO cmdata VALUES (repeat('123456789', 4004));
 \d+ cmdata
-                                        Table "public.cmdata"
- Column | Type | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
---------+------+-----------+----------+---------+----------+-------------+--------------+-------------
- f1     | text |           |          |         | extended | pglz        |              | 
+                                             Table "public.cmdata"
+ Column | Type | Collation | Nullable | Default | Visible | Storage  | Compression | Stats target | Description 
+--------+------+-----------+----------+---------+---------+----------+-------------+--------------+-------------
+ f1     | text |           |          |         |         | extended | pglz        |              | 
 Indexes:
     "idx" btree (f1)
 
@@ -259,10 +259,10 @@ SELECT pg_column_compression(f1) FROM cmdata;
 
 ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION default;
 \d+ cmdata2
-                                              Table "public.cmdata2"
- Column |       Type        | Collation | Nullable | Default | Storage | Compression | Stats target | Description 
---------+-------------------+-----------+----------+---------+---------+-------------+--------------+-------------
- f1     | character varying |           |          |         | plain   |             |              | 
+                                                   Table "public.cmdata2"
+ Column |       Type        | Collation | Nullable | Default | Visible | Storage | Compression | Stats target | Description 
+--------+-------------------+-----------+----------+---------+---------+---------+-------------+--------------+-------------
+ f1     | character varying |           |          |         |         | plain   |             |              | 
 
 -- test alter compression method for materialized views
 ALTER MATERIALIZED VIEW compressmv ALTER COLUMN x SET COMPRESSION lz4;
diff --git a/src/test/regress/expected/copy2.out b/src/test/regress/expected/copy2.out
index 5f3685e9ef..517a7abbfa 100644
--- a/src/test/regress/expected/copy2.out
+++ b/src/test/regress/expected/copy2.out
@@ -513,10 +513,10 @@ begin
 end $$ language plpgsql immutable;
 alter table check_con_tbl add check (check_con_function(check_con_tbl.*));
 \d+ check_con_tbl
-                               Table "public.check_con_tbl"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- f1     | integer |           |          |         | plain   |              | 
+                                    Table "public.check_con_tbl"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ f1     | integer |           |          |         |          | plain   |              | 
 Check constraints:
     "check_con_tbl_check" CHECK (check_con_function(check_con_tbl.*))
 
diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out
index a958b84979..70fd168543 100644
--- a/src/test/regress/expected/create_table.out
+++ b/src/test/regress/expected/create_table.out
@@ -498,11 +498,11 @@ Partition key: RANGE (a oid_ops, plusone(b), c, d COLLATE "C")
 Number of partitions: 0
 
 \d+ partitioned2
-                          Partitioned table "public.partitioned2"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | integer |           |          |         | plain    |              | 
- b      | text    |           |          |         | extended |              | 
+                               Partitioned table "public.partitioned2"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | integer |           |          |         |          | plain    |              | 
+ b      | text    |           |          |         |          | extended |              | 
 Partition key: RANGE (((a + 1)), substr(b, 1, 5))
 Number of partitions: 0
 
@@ -511,11 +511,11 @@ ERROR:  no partition of relation "partitioned2" found for row
 DETAIL:  Partition key of the failing row contains ((a + 1), substr(b, 1, 5)) = (2, hello).
 CREATE TABLE part2_1 PARTITION OF partitioned2 FOR VALUES FROM (-1, 'aaaaa') TO (100, 'ccccc');
 \d+ part2_1
-                                  Table "public.part2_1"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | integer |           |          |         | plain    |              | 
- b      | text    |           |          |         | extended |              | 
+                                        Table "public.part2_1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | integer |           |          |         |          | plain    |              | 
+ b      | text    |           |          |         |          | extended |              | 
 Partition of: partitioned2 FOR VALUES FROM ('-1', 'aaaaa') TO (100, 'ccccc')
 Partition constraint: (((a + 1) IS NOT NULL) AND (substr(b, 1, 5) IS NOT NULL) AND (((a + 1) > '-1'::integer) OR (((a + 1) = '-1'::integer) AND (substr(b, 1, 5) >= 'aaaaa'::text))) AND (((a + 1) < 100) OR (((a + 1) = 100) AND (substr(b, 1, 5) < 'ccccc'::text))))
 
@@ -552,11 +552,11 @@ select * from partitioned where partitioned = '(1,2)'::partitioned;
 (2 rows)
 
 \d+ partitioned1
-                               Table "public.partitioned1"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- a      | integer |           |          |         | plain   |              | 
- b      | integer |           |          |         | plain   |              | 
+                                     Table "public.partitioned1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ a      | integer |           |          |         |          | plain   |              | 
+ b      | integer |           |          |         |          | plain   |              | 
 Partition of: partitioned FOR VALUES IN ('(1,2)')
 Partition constraint: (((partitioned1.*)::partitioned IS DISTINCT FROM NULL) AND ((partitioned1.*)::partitioned = '(1,2)'::partitioned))
 
@@ -609,10 +609,10 @@ CREATE TABLE part_p2 PARTITION OF list_parted FOR VALUES IN (2);
 CREATE TABLE part_p3 PARTITION OF list_parted FOR VALUES IN ((2+1));
 CREATE TABLE part_null PARTITION OF list_parted FOR VALUES IN (null);
 \d+ list_parted
-                          Partitioned table "public.list_parted"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- a      | integer |           |          |         | plain   |              | 
+                               Partitioned table "public.list_parted"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ a      | integer |           |          |         |          | plain   |              | 
 Partition key: LIST (a)
 Partitions: part_null FOR VALUES IN (NULL),
             part_p1 FOR VALUES IN (1),
@@ -1057,21 +1057,21 @@ create table test_part_coll_cast2 partition of test_part_coll_posix for values f
 drop table test_part_coll_posix;
 -- Partition bound in describe output
 \d+ part_b
-                                   Table "public.part_b"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | extended |              | 
- b      | integer |           | not null | 1       | plain    |              | 
+                                        Table "public.part_b"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | extended |              | 
+ b      | integer |           | not null | 1       |          | plain    |              | 
 Partition of: parted FOR VALUES IN ('b')
 Partition constraint: ((a IS NOT NULL) AND (a = 'b'::text))
 
 -- Both partition bound and partition key in describe output
 \d+ part_c
-                             Partitioned table "public.part_c"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | extended |              | 
- b      | integer |           | not null | 0       | plain    |              | 
+                                  Partitioned table "public.part_c"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | extended |              | 
+ b      | integer |           | not null | 0       |          | plain    |              | 
 Partition of: parted FOR VALUES IN ('c')
 Partition constraint: ((a IS NOT NULL) AND (a = 'c'::text))
 Partition key: RANGE (b)
@@ -1079,11 +1079,11 @@ Partitions: part_c_1_10 FOR VALUES FROM (1) TO (10)
 
 -- a level-2 partition's constraint will include the parent's expressions
 \d+ part_c_1_10
-                                Table "public.part_c_1_10"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | extended |              | 
- b      | integer |           | not null | 0       | plain    |              | 
+                                      Table "public.part_c_1_10"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | extended |              | 
+ b      | integer |           | not null | 0       |          | plain    |              | 
 Partition of: part_c FOR VALUES FROM (1) TO (10)
 Partition constraint: ((a IS NOT NULL) AND (a = 'c'::text) AND (b IS NOT NULL) AND (b >= 1) AND (b < 10))
 
@@ -1112,46 +1112,46 @@ Number of partitions: 4 (Use \d+ to list them.)
 CREATE TABLE range_parted4 (a int, b int, c int) PARTITION BY RANGE (abs(a), abs(b), c);
 CREATE TABLE unbounded_range_part PARTITION OF range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (MAXVALUE, MAXVALUE, MAXVALUE);
 \d+ unbounded_range_part
-                           Table "public.unbounded_range_part"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- a      | integer |           |          |         | plain   |              | 
- b      | integer |           |          |         | plain   |              | 
- c      | integer |           |          |         | plain   |              | 
+                                 Table "public.unbounded_range_part"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ a      | integer |           |          |         |          | plain   |              | 
+ b      | integer |           |          |         |          | plain   |              | 
+ c      | integer |           |          |         |          | plain   |              | 
 Partition of: range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (MAXVALUE, MAXVALUE, MAXVALUE)
 Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL))
 
 DROP TABLE unbounded_range_part;
 CREATE TABLE range_parted4_1 PARTITION OF range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (1, MAXVALUE, MAXVALUE);
 \d+ range_parted4_1
-                              Table "public.range_parted4_1"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- a      | integer |           |          |         | plain   |              | 
- b      | integer |           |          |         | plain   |              | 
- c      | integer |           |          |         | plain   |              | 
+                                   Table "public.range_parted4_1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ a      | integer |           |          |         |          | plain   |              | 
+ b      | integer |           |          |         |          | plain   |              | 
+ c      | integer |           |          |         |          | plain   |              | 
 Partition of: range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (1, MAXVALUE, MAXVALUE)
 Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL) AND (abs(a) <= 1))
 
 CREATE TABLE range_parted4_2 PARTITION OF range_parted4 FOR VALUES FROM (3, 4, 5) TO (6, 7, MAXVALUE);
 \d+ range_parted4_2
-                              Table "public.range_parted4_2"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- a      | integer |           |          |         | plain   |              | 
- b      | integer |           |          |         | plain   |              | 
- c      | integer |           |          |         | plain   |              | 
+                                   Table "public.range_parted4_2"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ a      | integer |           |          |         |          | plain   |              | 
+ b      | integer |           |          |         |          | plain   |              | 
+ c      | integer |           |          |         |          | plain   |              | 
 Partition of: range_parted4 FOR VALUES FROM (3, 4, 5) TO (6, 7, MAXVALUE)
 Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL) AND ((abs(a) > 3) OR ((abs(a) = 3) AND (abs(b) > 4)) OR ((abs(a) = 3) AND (abs(b) = 4) AND (c >= 5))) AND ((abs(a) < 6) OR ((abs(a) = 6) AND (abs(b) <= 7))))
 
 CREATE TABLE range_parted4_3 PARTITION OF range_parted4 FOR VALUES FROM (6, 8, MINVALUE) TO (9, MAXVALUE, MAXVALUE);
 \d+ range_parted4_3
-                              Table "public.range_parted4_3"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- a      | integer |           |          |         | plain   |              | 
- b      | integer |           |          |         | plain   |              | 
- c      | integer |           |          |         | plain   |              | 
+                                   Table "public.range_parted4_3"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ a      | integer |           |          |         |          | plain   |              | 
+ b      | integer |           |          |         |          | plain   |              | 
+ c      | integer |           |          |         |          | plain   |              | 
 Partition of: range_parted4 FOR VALUES FROM (6, 8, MINVALUE) TO (9, MAXVALUE, MAXVALUE)
 Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL) AND ((abs(a) > 6) OR ((abs(a) = 6) AND (abs(b) >= 8))) AND (abs(a) <= 9))
 
@@ -1183,11 +1183,11 @@ SELECT obj_description('parted_col_comment'::regclass);
 (1 row)
 
 \d+ parted_col_comment
-                        Partitioned table "public.parted_col_comment"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target |  Description  
---------+---------+-----------+----------+---------+----------+--------------+---------------
- a      | integer |           |          |         | plain    |              | Partition key
- b      | text    |           |          |         | extended |              | 
+                             Partitioned table "public.parted_col_comment"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target |  Description  
+--------+---------+-----------+----------+---------+----------+----------+--------------+---------------
+ a      | integer |           |          |         |          | plain    |              | Partition key
+ b      | text    |           |          |         |          | extended |              | 
 Partition key: LIST (a)
 Number of partitions: 0
 
@@ -1196,10 +1196,10 @@ DROP TABLE parted_col_comment;
 CREATE TABLE arrlp (a int[]) PARTITION BY LIST (a);
 CREATE TABLE arrlp12 PARTITION OF arrlp FOR VALUES IN ('{1}', '{2}');
 \d+ arrlp12
-                                   Table "public.arrlp12"
- Column |   Type    | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+-----------+-----------+----------+---------+----------+--------------+-------------
- a      | integer[] |           |          |         | extended |              | 
+                                         Table "public.arrlp12"
+ Column |   Type    | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+-----------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | integer[] |           |          |         |          | extended |              | 
 Partition of: arrlp FOR VALUES IN ('{1}', '{2}')
 Partition constraint: ((a IS NOT NULL) AND ((a = '{1}'::integer[]) OR (a = '{2}'::integer[])))
 
@@ -1209,10 +1209,10 @@ create table boolspart (a bool) partition by list (a);
 create table boolspart_t partition of boolspart for values in (true);
 create table boolspart_f partition of boolspart for values in (false);
 \d+ boolspart
-                           Partitioned table "public.boolspart"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- a      | boolean |           |          |         | plain   |              | 
+                                Partitioned table "public.boolspart"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ a      | boolean |           |          |         |          | plain   |              | 
 Partition key: LIST (a)
 Partitions: boolspart_f FOR VALUES IN (false),
             boolspart_t FOR VALUES IN (true)
diff --git a/src/test/regress/expected/create_table_like.out b/src/test/regress/expected/create_table_like.out
index 0ed94f1d2f..99f44dc342 100644
--- a/src/test/regress/expected/create_table_like.out
+++ b/src/test/regress/expected/create_table_like.out
@@ -327,32 +327,32 @@ CREATE TABLE ctlt4 (a text, c text);
 ALTER TABLE ctlt4 ALTER COLUMN c SET STORAGE EXTERNAL;
 CREATE TABLE ctlt12_storage (LIKE ctlt1 INCLUDING STORAGE, LIKE ctlt2 INCLUDING STORAGE);
 \d+ ctlt12_storage
-                             Table "public.ctlt12_storage"
- Column | Type | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+------+-----------+----------+---------+----------+--------------+-------------
- a      | text |           | not null |         | main     |              | 
- b      | text |           |          |         | extended |              | 
- c      | text |           |          |         | external |              | 
+                                   Table "public.ctlt12_storage"
+ Column | Type | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text |           | not null |         |          | main     |              | 
+ b      | text |           |          |         |          | extended |              | 
+ c      | text |           |          |         |          | external |              | 
 
 CREATE TABLE ctlt12_comments (LIKE ctlt1 INCLUDING COMMENTS, LIKE ctlt2 INCLUDING COMMENTS);
 \d+ ctlt12_comments
-                             Table "public.ctlt12_comments"
- Column | Type | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+------+-----------+----------+---------+----------+--------------+-------------
- a      | text |           | not null |         | extended |              | A
- b      | text |           |          |         | extended |              | B
- c      | text |           |          |         | extended |              | C
+                                  Table "public.ctlt12_comments"
+ Column | Type | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text |           | not null |         |          | extended |              | A
+ b      | text |           |          |         |          | extended |              | B
+ c      | text |           |          |         |          | extended |              | C
 
 CREATE TABLE ctlt1_inh (LIKE ctlt1 INCLUDING CONSTRAINTS INCLUDING COMMENTS) INHERITS (ctlt1);
 NOTICE:  merging column "a" with inherited definition
 NOTICE:  merging column "b" with inherited definition
 NOTICE:  merging constraint "ctlt1_a_check" with inherited definition
 \d+ ctlt1_inh
-                                Table "public.ctlt1_inh"
- Column | Type | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+------+-----------+----------+---------+----------+--------------+-------------
- a      | text |           | not null |         | main     |              | A
- b      | text |           |          |         | extended |              | B
+                                     Table "public.ctlt1_inh"
+ Column | Type | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text |           | not null |         |          | main     |              | A
+ b      | text |           |          |         |          | extended |              | B
 Check constraints:
     "ctlt1_a_check" CHECK (length(a) > 2)
 Inherits: ctlt1
@@ -366,12 +366,12 @@ SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_con
 CREATE TABLE ctlt13_inh () INHERITS (ctlt1, ctlt3);
 NOTICE:  merging multiple inherited definitions of column "a"
 \d+ ctlt13_inh
-                               Table "public.ctlt13_inh"
- Column | Type | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+------+-----------+----------+---------+----------+--------------+-------------
- a      | text |           | not null |         | main     |              | 
- b      | text |           |          |         | extended |              | 
- c      | text |           |          |         | external |              | 
+                                     Table "public.ctlt13_inh"
+ Column | Type | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text |           | not null |         |          | main     |              | 
+ b      | text |           |          |         |          | extended |              | 
+ c      | text |           |          |         |          | external |              | 
 Check constraints:
     "ctlt1_a_check" CHECK (length(a) > 2)
     "ctlt3_a_check" CHECK (length(a) < 5)
@@ -382,12 +382,12 @@ Inherits: ctlt1,
 CREATE TABLE ctlt13_like (LIKE ctlt3 INCLUDING CONSTRAINTS INCLUDING INDEXES INCLUDING COMMENTS INCLUDING STORAGE) INHERITS (ctlt1);
 NOTICE:  merging column "a" with inherited definition
 \d+ ctlt13_like
-                               Table "public.ctlt13_like"
- Column | Type | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+------+-----------+----------+---------+----------+--------------+-------------
- a      | text |           | not null |         | main     |              | A3
- b      | text |           |          |         | extended |              | 
- c      | text |           |          |         | external |              | C
+                                    Table "public.ctlt13_like"
+ Column | Type | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text |           | not null |         |          | main     |              | A3
+ b      | text |           |          |         |          | extended |              | 
+ c      | text |           |          |         |          | external |              | C
 Indexes:
     "ctlt13_like_expr_idx" btree ((a || c))
 Check constraints:
@@ -404,11 +404,11 @@ SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_con
 
 CREATE TABLE ctlt_all (LIKE ctlt1 INCLUDING ALL);
 \d+ ctlt_all
-                                Table "public.ctlt_all"
- Column | Type | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+------+-----------+----------+---------+----------+--------------+-------------
- a      | text |           | not null |         | main     |              | A
- b      | text |           |          |         | extended |              | B
+                                      Table "public.ctlt_all"
+ Column | Type | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text |           | not null |         |          | main     |              | A
+ b      | text |           |          |         |          | extended |              | B
 Indexes:
     "ctlt_all_pkey" PRIMARY KEY, btree (a)
     "ctlt_all_b_idx" btree (b)
@@ -444,11 +444,11 @@ DETAIL:  MAIN versus EXTENDED
 -- Check that LIKE isn't confused by a system catalog of the same name
 CREATE TABLE pg_attrdef (LIKE ctlt1 INCLUDING ALL);
 \d+ public.pg_attrdef
-                               Table "public.pg_attrdef"
- Column | Type | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+------+-----------+----------+---------+----------+--------------+-------------
- a      | text |           | not null |         | main     |              | A
- b      | text |           |          |         | extended |              | B
+                                     Table "public.pg_attrdef"
+ Column | Type | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text |           | not null |         |          | main     |              | A
+ b      | text |           |          |         |          | extended |              | B
 Indexes:
     "pg_attrdef_pkey" PRIMARY KEY, btree (a)
     "pg_attrdef_b_idx" btree (b)
@@ -466,11 +466,11 @@ CREATE SCHEMA ctl_schema;
 SET LOCAL search_path = ctl_schema, public;
 CREATE TABLE ctlt1 (LIKE ctlt1 INCLUDING ALL);
 \d+ ctlt1
-                                Table "ctl_schema.ctlt1"
- Column | Type | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+------+-----------+----------+---------+----------+--------------+-------------
- a      | text |           | not null |         | main     |              | A
- b      | text |           |          |         | extended |              | B
+                                     Table "ctl_schema.ctlt1"
+ Column | Type | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text |           | not null |         |          | main     |              | A
+ b      | text |           |          |         |          | extended |              | B
 Indexes:
     "ctlt1_pkey" PRIMARY KEY, btree (a)
     "ctlt1_b_idx" btree (b)
diff --git a/src/test/regress/expected/domain.out b/src/test/regress/expected/domain.out
index 411d5c003e..b5a412948f 100644
--- a/src/test/regress/expected/domain.out
+++ b/src/test/regress/expected/domain.out
@@ -266,10 +266,10 @@ explain (verbose, costs off)
 create rule silly as on delete to dcomptable do instead
   update dcomptable set d1.r = (d1).r - 1, d1.i = (d1).i + 1 where (d1).i > 0;
 \d+ dcomptable
-                                  Table "public.dcomptable"
- Column |   Type    | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+-----------+-----------+----------+---------+----------+--------------+-------------
- d1     | dcomptype |           |          |         | extended |              | 
+                                       Table "public.dcomptable"
+ Column |   Type    | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+-----------+-----------+----------+---------+----------+----------+--------------+-------------
+ d1     | dcomptype |           |          |         |          | extended |              | 
 Indexes:
     "dcomptable_d1_key" UNIQUE CONSTRAINT, btree (d1)
 Rules:
@@ -403,10 +403,10 @@ create rule silly as on delete to dcomptable do instead
   update dcomptable set d1[1].r = d1[1].r - 1, d1[1].i = d1[1].i + 1
     where d1[1].i > 0;
 \d+ dcomptable
-                                  Table "public.dcomptable"
- Column |    Type    | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+------------+-----------+----------+---------+----------+--------------+-------------
- d1     | dcomptypea |           |          |         | extended |              | 
+                                        Table "public.dcomptable"
+ Column |    Type    | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+------------+-----------+----------+---------+----------+----------+--------------+-------------
+ d1     | dcomptypea |           |          |         |          | extended |              | 
 Indexes:
     "dcomptable_d1_key" UNIQUE CONSTRAINT, btree (d1)
 Rules:
diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out
index 426080ae39..2ee5f64469 100644
--- a/src/test/regress/expected/foreign_data.out
+++ b/src/test/regress/expected/foreign_data.out
@@ -1389,12 +1389,12 @@ CREATE TABLE fd_pt1 (
 CREATE FOREIGN TABLE ft2 () INHERITS (fd_pt1)
   SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value');
 \d+ fd_pt1
-                                   Table "public.fd_pt1"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    |              | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                        Table "public.fd_pt1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    |              | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Child tables: ft2
 
 \d+ ft2
@@ -1410,12 +1410,12 @@ Inherits: fd_pt1
 
 DROP FOREIGN TABLE ft2;
 \d+ fd_pt1
-                                   Table "public.fd_pt1"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    |              | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                        Table "public.fd_pt1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    |              | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 
 CREATE FOREIGN TABLE ft2 (
 	c1 integer NOT NULL,
@@ -1434,12 +1434,12 @@ FDW options: (delimiter ',', quote '"', "be quoted" 'value')
 
 ALTER FOREIGN TABLE ft2 INHERIT fd_pt1;
 \d+ fd_pt1
-                                   Table "public.fd_pt1"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    |              | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                        Table "public.fd_pt1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    |              | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Child tables: ft2
 
 \d+ ft2
@@ -1477,12 +1477,12 @@ Child tables: ct3,
               ft3
 
 \d+ ct3
-                                    Table "public.ct3"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    |              | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                          Table "public.ct3"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    |              | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Inherits: ft2
 
 \d+ ft3
@@ -1502,17 +1502,17 @@ ALTER TABLE fd_pt1 ADD COLUMN c6 integer;
 ALTER TABLE fd_pt1 ADD COLUMN c7 integer NOT NULL;
 ALTER TABLE fd_pt1 ADD COLUMN c8 integer;
 \d+ fd_pt1
-                                   Table "public.fd_pt1"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    |              | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
- c4     | integer |           |          |         | plain    |              | 
- c5     | integer |           |          | 0       | plain    |              | 
- c6     | integer |           |          |         | plain    |              | 
- c7     | integer |           | not null |         | plain    |              | 
- c8     | integer |           |          |         | plain    |              | 
+                                        Table "public.fd_pt1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    |              | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
+ c4     | integer |           |          |         |          | plain    |              | 
+ c5     | integer |           |          | 0       |          | plain    |              | 
+ c6     | integer |           |          |         |          | plain    |              | 
+ c7     | integer |           | not null |         |          | plain    |              | 
+ c8     | integer |           |          |         |          | plain    |              | 
 Child tables: ft2
 
 \d+ ft2
@@ -1534,17 +1534,17 @@ Child tables: ct3,
               ft3
 
 \d+ ct3
-                                    Table "public.ct3"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    |              | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
- c4     | integer |           |          |         | plain    |              | 
- c5     | integer |           |          | 0       | plain    |              | 
- c6     | integer |           |          |         | plain    |              | 
- c7     | integer |           | not null |         | plain    |              | 
- c8     | integer |           |          |         | plain    |              | 
+                                          Table "public.ct3"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    |              | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
+ c4     | integer |           |          |         |          | plain    |              | 
+ c5     | integer |           |          | 0       |          | plain    |              | 
+ c6     | integer |           |          |         |          | plain    |              | 
+ c7     | integer |           | not null |         |          | plain    |              | 
+ c8     | integer |           |          |         |          | plain    |              | 
 Inherits: ft2
 
 \d+ ft3
@@ -1576,17 +1576,17 @@ ALTER TABLE fd_pt1 ALTER COLUMN c1 SET (n_distinct = 100);
 ALTER TABLE fd_pt1 ALTER COLUMN c8 SET STATISTICS -1;
 ALTER TABLE fd_pt1 ALTER COLUMN c8 SET STORAGE EXTERNAL;
 \d+ fd_pt1
-                                   Table "public.fd_pt1"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    | 10000        | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
- c4     | integer |           |          | 0       | plain    |              | 
- c5     | integer |           |          |         | plain    |              | 
- c6     | integer |           | not null |         | plain    |              | 
- c7     | integer |           |          |         | plain    |              | 
- c8     | text    |           |          |         | external |              | 
+                                        Table "public.fd_pt1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    | 10000        | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
+ c4     | integer |           |          | 0       |          | plain    |              | 
+ c5     | integer |           |          |         |          | plain    |              | 
+ c6     | integer |           | not null |         |          | plain    |              | 
+ c7     | integer |           |          |         |          | plain    |              | 
+ c8     | text    |           |          |         |          | external |              | 
 Child tables: ft2
 
 \d+ ft2
@@ -1614,12 +1614,12 @@ ALTER TABLE fd_pt1 DROP COLUMN c6;
 ALTER TABLE fd_pt1 DROP COLUMN c7;
 ALTER TABLE fd_pt1 DROP COLUMN c8;
 \d+ fd_pt1
-                                   Table "public.fd_pt1"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    | 10000        | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                        Table "public.fd_pt1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    | 10000        | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Child tables: ft2
 
 \d+ ft2
@@ -1651,12 +1651,12 @@ SELECT relname, conname, contype, conislocal, coninhcount, connoinherit
 
 -- child does not inherit NO INHERIT constraints
 \d+ fd_pt1
-                                   Table "public.fd_pt1"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    | 10000        | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                        Table "public.fd_pt1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    | 10000        | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Check constraints:
     "fd_pt1chk1" CHECK (c1 > 0) NO INHERIT
     "fd_pt1chk2" CHECK (c2 <> ''::text)
@@ -1698,12 +1698,12 @@ ALTER FOREIGN TABLE ft2 ADD CONSTRAINT fd_pt1chk2 CHECK (c2 <> '');
 ALTER FOREIGN TABLE ft2 INHERIT fd_pt1;
 -- child does not inherit NO INHERIT constraints
 \d+ fd_pt1
-                                   Table "public.fd_pt1"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    | 10000        | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                        Table "public.fd_pt1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    | 10000        | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Check constraints:
     "fd_pt1chk1" CHECK (c1 > 0) NO INHERIT
     "fd_pt1chk2" CHECK (c2 <> ''::text)
@@ -1729,12 +1729,12 @@ ALTER TABLE fd_pt1 DROP CONSTRAINT fd_pt1chk2 CASCADE;
 INSERT INTO fd_pt1 VALUES (1, 'fd_pt1'::text, '1994-01-01'::date);
 ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk3 CHECK (c2 <> '') NOT VALID;
 \d+ fd_pt1
-                                   Table "public.fd_pt1"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    | 10000        | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                        Table "public.fd_pt1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    | 10000        | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Check constraints:
     "fd_pt1chk3" CHECK (c2 <> ''::text) NOT VALID
 Child tables: ft2
@@ -1756,12 +1756,12 @@ Inherits: fd_pt1
 -- VALIDATE CONSTRAINT need do nothing on foreign tables
 ALTER TABLE fd_pt1 VALIDATE CONSTRAINT fd_pt1chk3;
 \d+ fd_pt1
-                                   Table "public.fd_pt1"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    | 10000        | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                        Table "public.fd_pt1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    | 10000        | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Check constraints:
     "fd_pt1chk3" CHECK (c2 <> ''::text)
 Child tables: ft2
@@ -1787,12 +1787,12 @@ ALTER TABLE fd_pt1 RENAME COLUMN c3 TO f3;
 -- changes name of a constraint recursively
 ALTER TABLE fd_pt1 RENAME CONSTRAINT fd_pt1chk3 TO f2_check;
 \d+ fd_pt1
-                                   Table "public.fd_pt1"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- f1     | integer |           | not null |         | plain    | 10000        | 
- f2     | text    |           |          |         | extended |              | 
- f3     | date    |           |          |         | plain    |              | 
+                                        Table "public.fd_pt1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ f1     | integer |           | not null |         |          | plain    | 10000        | 
+ f2     | text    |           |          |         |          | extended |              | 
+ f3     | date    |           |          |         |          | plain    |              | 
 Check constraints:
     "f2_check" CHECK (f2 <> ''::text)
 Child tables: ft2
@@ -1851,12 +1851,12 @@ CREATE TABLE fd_pt2 (
 CREATE FOREIGN TABLE fd_pt2_1 PARTITION OF fd_pt2 FOR VALUES IN (1)
   SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value');
 \d+ fd_pt2
-                             Partitioned table "public.fd_pt2"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    |              | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                  Partitioned table "public.fd_pt2"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    |              | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Partition key: LIST (c1)
 Partitions: fd_pt2_1 FOR VALUES IN (1)
 
@@ -1896,12 +1896,12 @@ ERROR:  table "fd_pt2_1" contains column "c4" not found in parent "fd_pt2"
 DETAIL:  The new partition may contain only the columns present in parent.
 DROP FOREIGN TABLE fd_pt2_1;
 \d+ fd_pt2
-                             Partitioned table "public.fd_pt2"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    |              | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                  Partitioned table "public.fd_pt2"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    |              | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Partition key: LIST (c1)
 Number of partitions: 0
 
@@ -1923,12 +1923,12 @@ FDW options: (delimiter ',', quote '"', "be quoted" 'value')
 -- no attach partition validation occurs for foreign tables
 ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1);
 \d+ fd_pt2
-                             Partitioned table "public.fd_pt2"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    |              | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                  Partitioned table "public.fd_pt2"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    |              | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Partition key: LIST (c1)
 Partitions: fd_pt2_1 FOR VALUES IN (1)
 
@@ -1951,12 +1951,12 @@ ERROR:  cannot add column to a partition
 ALTER TABLE fd_pt2_1 ALTER c3 SET NOT NULL;
 ALTER TABLE fd_pt2_1 ADD CONSTRAINT p21chk CHECK (c2 <> '');
 \d+ fd_pt2
-                             Partitioned table "public.fd_pt2"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    |              | 
- c2     | text    |           |          |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                  Partitioned table "public.fd_pt2"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    |              | 
+ c2     | text    |           |          |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Partition key: LIST (c1)
 Partitions: fd_pt2_1 FOR VALUES IN (1)
 
@@ -1981,12 +1981,12 @@ ERROR:  column "c1" is marked NOT NULL in parent table
 ALTER TABLE fd_pt2 DETACH PARTITION fd_pt2_1;
 ALTER TABLE fd_pt2 ALTER c2 SET NOT NULL;
 \d+ fd_pt2
-                             Partitioned table "public.fd_pt2"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    |              | 
- c2     | text    |           | not null |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                  Partitioned table "public.fd_pt2"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    |              | 
+ c2     | text    |           | not null |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Partition key: LIST (c1)
 Number of partitions: 0
 
@@ -2009,12 +2009,12 @@ ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1);
 ALTER TABLE fd_pt2 DETACH PARTITION fd_pt2_1;
 ALTER TABLE fd_pt2 ADD CONSTRAINT fd_pt2chk1 CHECK (c1 > 0);
 \d+ fd_pt2
-                             Partitioned table "public.fd_pt2"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- c1     | integer |           | not null |         | plain    |              | 
- c2     | text    |           | not null |         | extended |              | 
- c3     | date    |           |          |         | plain    |              | 
+                                  Partitioned table "public.fd_pt2"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ c1     | integer |           | not null |         |          | plain    |              | 
+ c2     | text    |           | not null |         |          | extended |              | 
+ c3     | date    |           |          |         |          | plain    |              | 
 Partition key: LIST (c1)
 Check constraints:
     "fd_pt2chk1" CHECK (c1 > 0)
diff --git a/src/test/regress/expected/identity.out b/src/test/regress/expected/identity.out
index 99811570b7..bcb246456a 100644
--- a/src/test/regress/expected/identity.out
+++ b/src/test/regress/expected/identity.out
@@ -498,14 +498,14 @@ TABLE itest8;
 (2 rows)
 
 \d+ itest8
-                                               Table "public.itest8"
- Column |  Type   | Collation | Nullable |             Default              | Storage | Stats target | Description 
---------+---------+-----------+----------+----------------------------------+---------+--------------+-------------
- f1     | integer |           |          |                                  | plain   |              | 
- f2     | integer |           | not null | generated always as identity     | plain   |              | 
- f3     | integer |           | not null | generated by default as identity | plain   |              | 
- f4     | bigint  |           | not null | generated always as identity     | plain   |              | 
- f5     | bigint  |           |          |                                  | plain   |              | 
+                                                    Table "public.itest8"
+ Column |  Type   | Collation | Nullable |             Default              | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+----------------------------------+----------+---------+--------------+-------------
+ f1     | integer |           |          |                                  |          | plain   |              | 
+ f2     | integer |           | not null | generated always as identity     |          | plain   |              | 
+ f3     | integer |           | not null | generated by default as identity |          | plain   |              | 
+ f4     | bigint  |           | not null | generated always as identity     |          | plain   |              | 
+ f5     | bigint  |           |          |                                  |          | plain   |              | 
 
 \d itest8_f2_seq
                    Sequence "public.itest8_f2_seq"
diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out
index 2d49e765de..6c7ba8612b 100644
--- a/src/test/regress/expected/inherit.out
+++ b/src/test/regress/expected/inherit.out
@@ -1050,13 +1050,13 @@ ALTER TABLE inhts RENAME aa TO aaa;      -- to be failed
 ERROR:  cannot rename inherited column "aa"
 ALTER TABLE inhts RENAME d TO dd;
 \d+ inhts
-                                   Table "public.inhts"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- aa     | integer |           |          |         | plain   |              | 
- b      | integer |           |          |         | plain   |              | 
- c      | integer |           |          |         | plain   |              | 
- dd     | integer |           |          |         | plain   |              | 
+                                        Table "public.inhts"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ aa     | integer |           |          |         |          | plain   |              | 
+ b      | integer |           |          |         |          | plain   |              | 
+ c      | integer |           |          |         |          | plain   |              | 
+ dd     | integer |           |          |         |          | plain   |              | 
 Inherits: inht1,
           inhs1
 
@@ -1069,14 +1069,14 @@ NOTICE:  merging multiple inherited definitions of column "aa"
 NOTICE:  merging multiple inherited definitions of column "b"
 ALTER TABLE inht1 RENAME aa TO aaa;
 \d+ inht4
-                                   Table "public.inht4"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- aaa    | integer |           |          |         | plain   |              | 
- b      | integer |           |          |         | plain   |              | 
- x      | integer |           |          |         | plain   |              | 
- y      | integer |           |          |         | plain   |              | 
- z      | integer |           |          |         | plain   |              | 
+                                        Table "public.inht4"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ aaa    | integer |           |          |         |          | plain   |              | 
+ b      | integer |           |          |         |          | plain   |              | 
+ x      | integer |           |          |         |          | plain   |              | 
+ y      | integer |           |          |         |          | plain   |              | 
+ z      | integer |           |          |         |          | plain   |              | 
 Inherits: inht2,
           inht3
 
@@ -1086,14 +1086,14 @@ ALTER TABLE inht1 RENAME aaa TO aaaa;
 ALTER TABLE inht1 RENAME b TO bb;                -- to be failed
 ERROR:  cannot rename inherited column "b"
 \d+ inhts
-                                   Table "public.inhts"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- aaaa   | integer |           |          |         | plain   |              | 
- b      | integer |           |          |         | plain   |              | 
- x      | integer |           |          |         | plain   |              | 
- c      | integer |           |          |         | plain   |              | 
- d      | integer |           |          |         | plain   |              | 
+                                        Table "public.inhts"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ aaaa   | integer |           |          |         |          | plain   |              | 
+ b      | integer |           |          |         |          | plain   |              | 
+ x      | integer |           |          |         |          | plain   |              | 
+ c      | integer |           |          |         |          | plain   |              | 
+ d      | integer |           |          |         |          | plain   |              | 
 Inherits: inht2,
           inhs1
 
@@ -1133,33 +1133,33 @@ drop cascades to table inht4
 CREATE TABLE test_constraints (id int, val1 varchar, val2 int, UNIQUE(val1, val2));
 CREATE TABLE test_constraints_inh () INHERITS (test_constraints);
 \d+ test_constraints
-                                   Table "public.test_constraints"
- Column |       Type        | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+-------------------+-----------+----------+---------+----------+--------------+-------------
- id     | integer           |           |          |         | plain    |              | 
- val1   | character varying |           |          |         | extended |              | 
- val2   | integer           |           |          |         | plain    |              | 
+                                        Table "public.test_constraints"
+ Column |       Type        | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+-------------------+-----------+----------+---------+----------+----------+--------------+-------------
+ id     | integer           |           |          |         |          | plain    |              | 
+ val1   | character varying |           |          |         |          | extended |              | 
+ val2   | integer           |           |          |         |          | plain    |              | 
 Indexes:
     "test_constraints_val1_val2_key" UNIQUE CONSTRAINT, btree (val1, val2)
 Child tables: test_constraints_inh
 
 ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key;
 \d+ test_constraints
-                                   Table "public.test_constraints"
- Column |       Type        | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+-------------------+-----------+----------+---------+----------+--------------+-------------
- id     | integer           |           |          |         | plain    |              | 
- val1   | character varying |           |          |         | extended |              | 
- val2   | integer           |           |          |         | plain    |              | 
+                                        Table "public.test_constraints"
+ Column |       Type        | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+-------------------+-----------+----------+---------+----------+----------+--------------+-------------
+ id     | integer           |           |          |         |          | plain    |              | 
+ val1   | character varying |           |          |         |          | extended |              | 
+ val2   | integer           |           |          |         |          | plain    |              | 
 Child tables: test_constraints_inh
 
 \d+ test_constraints_inh
-                                 Table "public.test_constraints_inh"
- Column |       Type        | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+-------------------+-----------+----------+---------+----------+--------------+-------------
- id     | integer           |           |          |         | plain    |              | 
- val1   | character varying |           |          |         | extended |              | 
- val2   | integer           |           |          |         | plain    |              | 
+                                      Table "public.test_constraints_inh"
+ Column |       Type        | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+-------------------+-----------+----------+---------+----------+----------+--------------+-------------
+ id     | integer           |           |          |         |          | plain    |              | 
+ val1   | character varying |           |          |         |          | extended |              | 
+ val2   | integer           |           |          |         |          | plain    |              | 
 Inherits: test_constraints
 
 DROP TABLE test_constraints_inh;
@@ -1170,27 +1170,27 @@ CREATE TABLE test_ex_constraints (
 );
 CREATE TABLE test_ex_constraints_inh () INHERITS (test_ex_constraints);
 \d+ test_ex_constraints
-                           Table "public.test_ex_constraints"
- Column |  Type  | Collation | Nullable | Default | Storage | Stats target | Description 
---------+--------+-----------+----------+---------+---------+--------------+-------------
- c      | circle |           |          |         | plain   |              | 
+                                 Table "public.test_ex_constraints"
+ Column |  Type  | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+--------+-----------+----------+---------+----------+---------+--------------+-------------
+ c      | circle |           |          |         |          | plain   |              | 
 Indexes:
     "test_ex_constraints_c_excl" EXCLUDE USING gist (c WITH &&)
 Child tables: test_ex_constraints_inh
 
 ALTER TABLE test_ex_constraints DROP CONSTRAINT test_ex_constraints_c_excl;
 \d+ test_ex_constraints
-                           Table "public.test_ex_constraints"
- Column |  Type  | Collation | Nullable | Default | Storage | Stats target | Description 
---------+--------+-----------+----------+---------+---------+--------------+-------------
- c      | circle |           |          |         | plain   |              | 
+                                 Table "public.test_ex_constraints"
+ Column |  Type  | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+--------+-----------+----------+---------+----------+---------+--------------+-------------
+ c      | circle |           |          |         |          | plain   |              | 
 Child tables: test_ex_constraints_inh
 
 \d+ test_ex_constraints_inh
-                         Table "public.test_ex_constraints_inh"
- Column |  Type  | Collation | Nullable | Default | Storage | Stats target | Description 
---------+--------+-----------+----------+---------+---------+--------------+-------------
- c      | circle |           |          |         | plain   |              | 
+                               Table "public.test_ex_constraints_inh"
+ Column |  Type  | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+--------+-----------+----------+---------+----------+---------+--------------+-------------
+ c      | circle |           |          |         |          | plain   |              | 
 Inherits: test_ex_constraints
 
 DROP TABLE test_ex_constraints_inh;
@@ -1200,37 +1200,37 @@ CREATE TABLE test_primary_constraints(id int PRIMARY KEY);
 CREATE TABLE test_foreign_constraints(id1 int REFERENCES test_primary_constraints(id));
 CREATE TABLE test_foreign_constraints_inh () INHERITS (test_foreign_constraints);
 \d+ test_primary_constraints
-                         Table "public.test_primary_constraints"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- id     | integer |           | not null |         | plain   |              | 
+                               Table "public.test_primary_constraints"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ id     | integer |           | not null |         |          | plain   |              | 
 Indexes:
     "test_primary_constraints_pkey" PRIMARY KEY, btree (id)
 Referenced by:
     TABLE "test_foreign_constraints" CONSTRAINT "test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id)
 
 \d+ test_foreign_constraints
-                         Table "public.test_foreign_constraints"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- id1    | integer |           |          |         | plain   |              | 
+                               Table "public.test_foreign_constraints"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ id1    | integer |           |          |         |          | plain   |              | 
 Foreign-key constraints:
     "test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id)
 Child tables: test_foreign_constraints_inh
 
 ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey;
 \d+ test_foreign_constraints
-                         Table "public.test_foreign_constraints"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- id1    | integer |           |          |         | plain   |              | 
+                               Table "public.test_foreign_constraints"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ id1    | integer |           |          |         |          | plain   |              | 
 Child tables: test_foreign_constraints_inh
 
 \d+ test_foreign_constraints_inh
-                       Table "public.test_foreign_constraints_inh"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- id1    | integer |           |          |         | plain   |              | 
+                             Table "public.test_foreign_constraints_inh"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ id1    | integer |           |          |         |          | plain   |              | 
 Inherits: test_foreign_constraints
 
 DROP TABLE test_foreign_constraints_inh;
diff --git a/src/test/regress/expected/insert.out b/src/test/regress/expected/insert.out
index 5063a3dc22..717b6c6467 100644
--- a/src/test/regress/expected/insert.out
+++ b/src/test/regress/expected/insert.out
@@ -163,11 +163,11 @@ create rule irule3 as on insert to inserttest2 do also
   insert into inserttest (f4[1].if1, f4[1].if2[2])
   select new.f1, new.f2;
 \d+ inserttest2
-                                Table "public.inserttest2"
- Column |  Type  | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+--------+-----------+----------+---------+----------+--------------+-------------
- f1     | bigint |           |          |         | plain    |              | 
- f2     | text   |           |          |         | extended |              | 
+                                     Table "public.inserttest2"
+ Column |  Type  | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+--------+-----------+----------+---------+----------+----------+--------------+-------------
+ f1     | bigint |           |          |         |          | plain    |              | 
+ f2     | text   |           |          |         |          | extended |              | 
 Rules:
     irule1 AS
     ON INSERT TO inserttest2 DO  INSERT INTO inserttest (f3.if2[1], f3.if2[2])
@@ -469,11 +469,11 @@ from hash_parted order by part;
 -- test \d+ output on a table which has both partitioned and unpartitioned
 -- partitions
 \d+ list_parted
-                          Partitioned table "public.list_parted"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | extended |              | 
- b      | integer |           |          |         | plain    |              | 
+                                Partitioned table "public.list_parted"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | extended |              | 
+ b      | integer |           |          |         |          | plain    |              | 
 Partition key: LIST (lower(a))
 Partitions: part_aa_bb FOR VALUES IN ('aa', 'bb'),
             part_cc_dd FOR VALUES IN ('cc', 'dd'),
@@ -491,10 +491,10 @@ drop table hash_parted;
 create table list_parted (a int) partition by list (a);
 create table part_default partition of list_parted default;
 \d+ part_default
-                               Table "public.part_default"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- a      | integer |           |          |         | plain   |              | 
+                                     Table "public.part_default"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ a      | integer |           |          |         |          | plain   |              | 
 Partition of: list_parted DEFAULT
 No partition constraint
 
@@ -874,11 +874,11 @@ create table mcrparted6_common_ge_10 partition of mcrparted for values from ('co
 create table mcrparted7_gt_common_lt_d partition of mcrparted for values from ('common', maxvalue) to ('d', minvalue);
 create table mcrparted8_ge_d partition of mcrparted for values from ('d', minvalue) to (maxvalue, maxvalue);
 \d+ mcrparted
-                           Partitioned table "public.mcrparted"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | extended |              | 
- b      | integer |           |          |         | plain    |              | 
+                                 Partitioned table "public.mcrparted"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | extended |              | 
+ b      | integer |           |          |         |          | plain    |              | 
 Partition key: RANGE (a, b)
 Partitions: mcrparted1_lt_b FOR VALUES FROM (MINVALUE, MINVALUE) TO ('b', MINVALUE),
             mcrparted2_b FOR VALUES FROM ('b', MINVALUE) TO ('c', MINVALUE),
@@ -890,74 +890,74 @@ Partitions: mcrparted1_lt_b FOR VALUES FROM (MINVALUE, MINVALUE) TO ('b', MINVAL
             mcrparted8_ge_d FOR VALUES FROM ('d', MINVALUE) TO (MAXVALUE, MAXVALUE)
 
 \d+ mcrparted1_lt_b
-                              Table "public.mcrparted1_lt_b"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | extended |              | 
- b      | integer |           |          |         | plain    |              | 
+                                    Table "public.mcrparted1_lt_b"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | extended |              | 
+ b      | integer |           |          |         |          | plain    |              | 
 Partition of: mcrparted FOR VALUES FROM (MINVALUE, MINVALUE) TO ('b', MINVALUE)
 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a < 'b'::text))
 
 \d+ mcrparted2_b
-                                Table "public.mcrparted2_b"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | extended |              | 
- b      | integer |           |          |         | plain    |              | 
+                                     Table "public.mcrparted2_b"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | extended |              | 
+ b      | integer |           |          |         |          | plain    |              | 
 Partition of: mcrparted FOR VALUES FROM ('b', MINVALUE) TO ('c', MINVALUE)
 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a >= 'b'::text) AND (a < 'c'::text))
 
 \d+ mcrparted3_c_to_common
-                           Table "public.mcrparted3_c_to_common"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | extended |              | 
- b      | integer |           |          |         | plain    |              | 
+                                Table "public.mcrparted3_c_to_common"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | extended |              | 
+ b      | integer |           |          |         |          | plain    |              | 
 Partition of: mcrparted FOR VALUES FROM ('c', MINVALUE) TO ('common', MINVALUE)
 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a >= 'c'::text) AND (a < 'common'::text))
 
 \d+ mcrparted4_common_lt_0
-                           Table "public.mcrparted4_common_lt_0"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | extended |              | 
- b      | integer |           |          |         | plain    |              | 
+                                Table "public.mcrparted4_common_lt_0"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | extended |              | 
+ b      | integer |           |          |         |          | plain    |              | 
 Partition of: mcrparted FOR VALUES FROM ('common', MINVALUE) TO ('common', 0)
 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a = 'common'::text) AND (b < 0))
 
 \d+ mcrparted5_common_0_to_10
-                         Table "public.mcrparted5_common_0_to_10"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | extended |              | 
- b      | integer |           |          |         | plain    |              | 
+                               Table "public.mcrparted5_common_0_to_10"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | extended |              | 
+ b      | integer |           |          |         |          | plain    |              | 
 Partition of: mcrparted FOR VALUES FROM ('common', 0) TO ('common', 10)
 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a = 'common'::text) AND (b >= 0) AND (b < 10))
 
 \d+ mcrparted6_common_ge_10
-                          Table "public.mcrparted6_common_ge_10"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | extended |              | 
- b      | integer |           |          |         | plain    |              | 
+                                Table "public.mcrparted6_common_ge_10"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | extended |              | 
+ b      | integer |           |          |         |          | plain    |              | 
 Partition of: mcrparted FOR VALUES FROM ('common', 10) TO ('common', MAXVALUE)
 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a = 'common'::text) AND (b >= 10))
 
 \d+ mcrparted7_gt_common_lt_d
-                         Table "public.mcrparted7_gt_common_lt_d"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | extended |              | 
- b      | integer |           |          |         | plain    |              | 
+                               Table "public.mcrparted7_gt_common_lt_d"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | extended |              | 
+ b      | integer |           |          |         |          | plain    |              | 
 Partition of: mcrparted FOR VALUES FROM ('common', MAXVALUE) TO ('d', MINVALUE)
 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a > 'common'::text) AND (a < 'd'::text))
 
 \d+ mcrparted8_ge_d
-                              Table "public.mcrparted8_ge_d"
- Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------+----------+--------------+-------------
- a      | text    |           |          |         | extended |              | 
- b      | integer |           |          |         | plain    |              | 
+                                    Table "public.mcrparted8_ge_d"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text    |           |          |         |          | extended |              | 
+ b      | integer |           |          |         |          | plain    |              | 
 Partition of: mcrparted FOR VALUES FROM ('d', MINVALUE) TO (MAXVALUE, MAXVALUE)
 Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a >= 'd'::text))
 
diff --git a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out
index 930ce8597a..6678d2fce0 100644
--- a/src/test/regress/expected/psql.out
+++ b/src/test/regress/expected/psql.out
@@ -2813,34 +2813,34 @@ CREATE TABLE tbl_heap(f1 int, f2 char(100)) using heap;
 CREATE VIEW view_heap_psql AS SELECT f1 from tbl_heap_psql;
 CREATE MATERIALIZED VIEW mat_view_heap_psql USING heap_psql AS SELECT f1 from tbl_heap_psql;
 \d+ tbl_heap_psql
-                              Table "tableam_display.tbl_heap_psql"
- Column |      Type      | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+----------------+-----------+----------+---------+----------+--------------+-------------
- f1     | integer        |           |          |         | plain    |              | 
- f2     | character(100) |           |          |         | extended |              | 
+                                    Table "tableam_display.tbl_heap_psql"
+ Column |      Type      | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+----------------+-----------+----------+---------+----------+----------+--------------+-------------
+ f1     | integer        |           |          |         |          | plain    |              | 
+ f2     | character(100) |           |          |         |          | extended |              | 
 
 \d+ tbl_heap
-                                 Table "tableam_display.tbl_heap"
- Column |      Type      | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+----------------+-----------+----------+---------+----------+--------------+-------------
- f1     | integer        |           |          |         | plain    |              | 
- f2     | character(100) |           |          |         | extended |              | 
+                                      Table "tableam_display.tbl_heap"
+ Column |      Type      | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+----------------+-----------+----------+---------+----------+----------+--------------+-------------
+ f1     | integer        |           |          |         |          | plain    |              | 
+ f2     | character(100) |           |          |         |          | extended |              | 
 
 \set HIDE_TABLEAM off
 \d+ tbl_heap_psql
-                              Table "tableam_display.tbl_heap_psql"
- Column |      Type      | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+----------------+-----------+----------+---------+----------+--------------+-------------
- f1     | integer        |           |          |         | plain    |              | 
- f2     | character(100) |           |          |         | extended |              | 
+                                    Table "tableam_display.tbl_heap_psql"
+ Column |      Type      | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+----------------+-----------+----------+---------+----------+----------+--------------+-------------
+ f1     | integer        |           |          |         |          | plain    |              | 
+ f2     | character(100) |           |          |         |          | extended |              | 
 Access method: heap_psql
 
 \d+ tbl_heap
-                                 Table "tableam_display.tbl_heap"
- Column |      Type      | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+----------------+-----------+----------+---------+----------+--------------+-------------
- f1     | integer        |           |          |         | plain    |              | 
- f2     | character(100) |           |          |         | extended |              | 
+                                      Table "tableam_display.tbl_heap"
+ Column |      Type      | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+----------------+-----------+----------+---------+----------+----------+--------------+-------------
+ f1     | integer        |           |          |         |          | plain    |              | 
+ f2     | character(100) |           |          |         |          | extended |              | 
 Access method: heap
 
 -- AM is displayed for tables, indexes and materialized views.
diff --git a/src/test/regress/expected/publication.out b/src/test/regress/expected/publication.out
index 82bce9be09..c57eca23b6 100644
--- a/src/test/regress/expected/publication.out
+++ b/src/test/regress/expected/publication.out
@@ -76,11 +76,11 @@ SELECT pubname, puballtables FROM pg_publication WHERE pubname = 'testpub_forall
 (1 row)
 
 \d+ testpub_tbl2
-                                                Table "public.testpub_tbl2"
- Column |  Type   | Collation | Nullable |                 Default                  | Storage  | Stats target | Description 
---------+---------+-----------+----------+------------------------------------------+----------+--------------+-------------
- id     | integer |           | not null | nextval('testpub_tbl2_id_seq'::regclass) | plain    |              | 
- data   | text    |           |          |                                          | extended |              | 
+                                                      Table "public.testpub_tbl2"
+ Column |  Type   | Collation | Nullable |                 Default                  | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+------------------------------------------+----------+----------+--------------+-------------
+ id     | integer |           | not null | nextval('testpub_tbl2_id_seq'::regclass) |          | plain    |              | 
+ data   | text    |           |          |                                          |          | extended |              | 
 Indexes:
     "testpub_tbl2_pkey" PRIMARY KEY, btree (id)
 Publications:
@@ -213,22 +213,22 @@ ALTER PUBLICATION testpub_default SET TABLE testpub_tbl1;
 ALTER PUBLICATION testpub_default ADD TABLE pub_test.testpub_nopk;
 ALTER PUBLICATION testpib_ins_trunct ADD TABLE pub_test.testpub_nopk, testpub_tbl1;
 \d+ pub_test.testpub_nopk
-                              Table "pub_test.testpub_nopk"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- foo    | integer |           |          |         | plain   |              | 
- bar    | integer |           |          |         | plain   |              | 
+                                    Table "pub_test.testpub_nopk"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ foo    | integer |           |          |         |          | plain   |              | 
+ bar    | integer |           |          |         |          | plain   |              | 
 Publications:
     "testpib_ins_trunct"
     "testpub_default"
     "testpub_fortbl"
 
 \d+ testpub_tbl1
-                                                Table "public.testpub_tbl1"
- Column |  Type   | Collation | Nullable |                 Default                  | Storage  | Stats target | Description 
---------+---------+-----------+----------+------------------------------------------+----------+--------------+-------------
- id     | integer |           | not null | nextval('testpub_tbl1_id_seq'::regclass) | plain    |              | 
- data   | text    |           |          |                                          | extended |              | 
+                                                      Table "public.testpub_tbl1"
+ Column |  Type   | Collation | Nullable |                 Default                  | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+------------------------------------------+----------+----------+--------------+-------------
+ id     | integer |           | not null | nextval('testpub_tbl1_id_seq'::regclass) |          | plain    |              | 
+ data   | text    |           |          |                                          |          | extended |              | 
 Indexes:
     "testpub_tbl1_pkey" PRIMARY KEY, btree (id)
 Publications:
@@ -250,11 +250,11 @@ ALTER PUBLICATION testpub_default DROP TABLE testpub_tbl1, pub_test.testpub_nopk
 ALTER PUBLICATION testpub_default DROP TABLE pub_test.testpub_nopk;
 ERROR:  relation "testpub_nopk" is not part of the publication
 \d+ testpub_tbl1
-                                                Table "public.testpub_tbl1"
- Column |  Type   | Collation | Nullable |                 Default                  | Storage  | Stats target | Description 
---------+---------+-----------+----------+------------------------------------------+----------+--------------+-------------
- id     | integer |           | not null | nextval('testpub_tbl1_id_seq'::regclass) | plain    |              | 
- data   | text    |           |          |                                          | extended |              | 
+                                                      Table "public.testpub_tbl1"
+ Column |  Type   | Collation | Nullable |                 Default                  | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+------------------------------------------+----------+----------+--------------+-------------
+ id     | integer |           | not null | nextval('testpub_tbl1_id_seq'::regclass) |          | plain    |              | 
+ data   | text    |           |          |                                          |          | extended |              | 
 Indexes:
     "testpub_tbl1_pkey" PRIMARY KEY, btree (id)
 Publications:
diff --git a/src/test/regress/expected/replica_identity.out b/src/test/regress/expected/replica_identity.out
index 79002197a7..f1decc955a 100644
--- a/src/test/regress/expected/replica_identity.out
+++ b/src/test/regress/expected/replica_identity.out
@@ -153,13 +153,13 @@ SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass;
 (1 row)
 
 \d+ test_replica_identity
-                                                Table "public.test_replica_identity"
- Column |  Type   | Collation | Nullable |                      Default                      | Storage  | Stats target | Description 
---------+---------+-----------+----------+---------------------------------------------------+----------+--------------+-------------
- id     | integer |           | not null | nextval('test_replica_identity_id_seq'::regclass) | plain    |              | 
- keya   | text    |           | not null |                                                   | extended |              | 
- keyb   | text    |           | not null |                                                   | extended |              | 
- nonkey | text    |           |          |                                                   | extended |              | 
+                                                      Table "public.test_replica_identity"
+ Column |  Type   | Collation | Nullable |                      Default                      | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------------------------------------------------+----------+----------+--------------+-------------
+ id     | integer |           | not null | nextval('test_replica_identity_id_seq'::regclass) |          | plain    |              | 
+ keya   | text    |           | not null |                                                   |          | extended |              | 
+ keyb   | text    |           | not null |                                                   |          | extended |              | 
+ nonkey | text    |           |          |                                                   |          | extended |              | 
 Indexes:
     "test_replica_identity_pkey" PRIMARY KEY, btree (id)
     "test_replica_identity_expr" UNIQUE, btree (keya, keyb, (3))
diff --git a/src/test/regress/expected/rowsecurity.out b/src/test/regress/expected/rowsecurity.out
index 89397e41f0..39646c2b98 100644
--- a/src/test/regress/expected/rowsecurity.out
+++ b/src/test/regress/expected/rowsecurity.out
@@ -938,14 +938,14 @@ CREATE POLICY pp1 ON part_document AS PERMISSIVE
 CREATE POLICY pp1r ON part_document AS RESTRICTIVE TO regress_rls_dave
     USING (cid < 55);
 \d+ part_document
-                    Partitioned table "regress_rls_schema.part_document"
- Column  |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
----------+---------+-----------+----------+---------+----------+--------------+-------------
- did     | integer |           |          |         | plain    |              | 
- cid     | integer |           |          |         | plain    |              | 
- dlevel  | integer |           | not null |         | plain    |              | 
- dauthor | name    |           |          |         | plain    |              | 
- dtitle  | text    |           |          |         | extended |              | 
+                         Partitioned table "regress_rls_schema.part_document"
+ Column  |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+---------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ did     | integer |           |          |         |          | plain    |              | 
+ cid     | integer |           |          |         |          | plain    |              | 
+ dlevel  | integer |           | not null |         |          | plain    |              | 
+ dauthor | name    |           |          |         |          | plain    |              | 
+ dtitle  | text    |           |          |         |          | extended |              | 
 Partition key: RANGE (cid)
 Policies:
     POLICY "pp1"
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index 2fa00a3c29..a6c4f04609 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -3167,11 +3167,11 @@ select * from rules_log;
 
 create rule r3 as on delete to rules_src do notify rules_src_deletion;
 \d+ rules_src
-                                 Table "public.rules_src"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- f1     | integer |           |          |         | plain   |              | 
- f2     | integer |           |          |         | plain   |              | 
+                                      Table "public.rules_src"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ f1     | integer |           |          |         |          | plain   |              | 
+ f2     | integer |           |          |         |          | plain   |              | 
 Rules:
     r1 AS
     ON UPDATE TO rules_src DO  INSERT INTO rules_log (f1, f2, tag) VALUES (old.f1,old.f2,'old'::text), (new.f1,new.f2,'new'::text)
@@ -3187,11 +3187,11 @@ Rules:
 create rule r4 as on insert to rules_src do instead insert into rules_log AS trgt SELECT NEW.* RETURNING trgt.f1, trgt.f2;
 create rule r5 as on update to rules_src do instead UPDATE rules_log AS trgt SET tag = 'updated' WHERE trgt.f1 = new.f1;
 \d+ rules_src
-                                 Table "public.rules_src"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- f1     | integer |           |          |         | plain   |              | 
- f2     | integer |           |          |         | plain   |              | 
+                                      Table "public.rules_src"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ f1     | integer |           |          |         |          | plain   |              | 
+ f2     | integer |           |          |         |          | plain   |              | 
 Rules:
     r1 AS
     ON UPDATE TO rules_src DO  INSERT INTO rules_log (f1, f2, tag) VALUES (old.f1,old.f2,'old'::text), (new.f1,new.f2,'new'::text)
@@ -3218,11 +3218,11 @@ create rule rr as on update to rule_t1 do instead UPDATE rule_dest trgt
   SET (f2[1], f1, tag) = (SELECT new.f2, new.f1, 'updated'::varchar)
   WHERE trgt.f1 = new.f1 RETURNING new.*;
 \d+ rule_t1
-                                  Table "public.rule_t1"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- f1     | integer |           |          |         | plain   |              | 
- f2     | integer |           |          |         | plain   |              | 
+                                       Table "public.rule_t1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ f1     | integer |           |          |         |          | plain   |              | 
+ f2     | integer |           |          |         |          | plain   |              | 
 Rules:
     rr AS
     ON UPDATE TO rule_t1 DO INSTEAD  UPDATE rule_dest trgt SET (f2[1], f1, tag) = ( SELECT new.f2,
diff --git a/src/test/regress/expected/select_having.out b/src/test/regress/expected/select_having.out
index 3950c0b404..7087fb1c0c 100644
--- a/src/test/regress/expected/select_having.out
+++ b/src/test/regress/expected/select_having.out
@@ -26,8 +26,8 @@ SELECT b, c FROM test_having
 	GROUP BY b, c HAVING b = 3 ORDER BY b, c;
  b |    c     
 ---+----------
- 3 | BBBB    
  3 | bbbb    
+ 3 | BBBB    
 (2 rows)
 
 SELECT lower(c), count(c) FROM test_having
@@ -45,8 +45,8 @@ SELECT c, max(a) FROM test_having
 	ORDER BY c;
     c     | max 
 ----------+-----
- XXXX     |   0
  bbbb     |   5
+ XXXX     |   0
 (2 rows)
 
 -- test degenerate cases involving HAVING without GROUP BY
diff --git a/src/test/regress/expected/select_implicit.out b/src/test/regress/expected/select_implicit.out
index 27c07de92c..7a353d0862 100644
--- a/src/test/regress/expected/select_implicit.out
+++ b/src/test/regress/expected/select_implicit.out
@@ -22,11 +22,11 @@ SELECT c, count(*) FROM test_missing_target GROUP BY test_missing_target.c ORDER
     c     | count 
 ----------+-------
  ABAB     |     2
+ bbbb     |     1
  BBBB     |     2
+ cccc     |     2
  CCCC     |     2
  XXXX     |     1
- bbbb     |     1
- cccc     |     2
 (6 rows)
 
 --   w/o existing GROUP BY target using a relation name in GROUP BY clause
@@ -34,11 +34,11 @@ SELECT count(*) FROM test_missing_target GROUP BY test_missing_target.c ORDER BY
  count 
 -------
      2
+     1
      2
      2
-     1
-     1
      2
+     1
 (6 rows)
 
 --   w/o existing GROUP BY target and w/o existing a different ORDER BY target
@@ -106,11 +106,11 @@ SELECT c, count(*) FROM test_missing_target GROUP BY 1 ORDER BY 1;
     c     | count 
 ----------+-------
  ABAB     |     2
+ bbbb     |     1
  BBBB     |     2
+ cccc     |     2
  CCCC     |     2
  XXXX     |     1
- bbbb     |     1
- cccc     |     2
 (6 rows)
 
 --   group using reference number out of range
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out
index c60ba45aba..5d14d46318 100644
--- a/src/test/regress/expected/stats_ext.out
+++ b/src/test/regress/expected/stats_ext.out
@@ -151,11 +151,11 @@ SELECT stxname, stxdndistinct, stxddependencies, stxdmcv
 
 ALTER STATISTICS ab1_a_b_stats SET STATISTICS -1;
 \d+ ab1
-                                    Table "public.ab1"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- a      | integer |           |          |         | plain   |              | 
- b      | integer |           |          |         | plain   |              | 
+                                         Table "public.ab1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ a      | integer |           |          |         |          | plain   |              | 
+ b      | integer |           |          |         |          | plain   |              | 
 Statistics objects:
     "public.ab1_a_b_stats" ON a, b FROM ab1
 
diff --git a/src/test/regress/expected/triggers.out b/src/test/regress/expected/triggers.out
index 5d124cf96f..eb19bb50b1 100644
--- a/src/test/regress/expected/triggers.out
+++ b/src/test/regress/expected/triggers.out
@@ -3476,10 +3476,10 @@ create trigger parenttrig after insert on child
 for each row execute procedure f();
 alter trigger parenttrig on parent rename to anothertrig;
 \d+ child
-                                   Table "public.child"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- a      | integer |           |          |         | plain   |              | 
+                                        Table "public.child"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ a      | integer |           |          |         |          | plain   |              | 
 Triggers:
     parenttrig AFTER INSERT ON child FOR EACH ROW EXECUTE FUNCTION f()
 Inherits: parent
diff --git a/src/test/regress/expected/unexpanded.out b/src/test/regress/expected/unexpanded.out
new file mode 100644
index 0000000000..9ed1a66eb2
--- /dev/null
+++ b/src/test/regress/expected/unexpanded.out
@@ -0,0 +1,577 @@
+-- sanity check of system catalog
+SELECT attrelid, attname, attisunexpanded FROM pg_attribute WHERE attisunexpanded;
+ attrelid | attname | attisunexpanded 
+----------+---------+-----------------
+(0 rows)
+
+CREATE TABLE htest0 (a int PRIMARY KEY, b text NOT NULL);
+ALTER TABLE htest0 ALTER COLUMN b SET UNEXPANDED;
+INSERT INTO htest0 (a, b) VALUES (1, 'htest0 one');
+INSERT INTO htest0 (a, b) VALUES (2, 'htest0 two');
+-- we do not allow that all columns of a relation be unexpanded
+ALTER TABLE htest0 ALTER COLUMN a SET UNEXPANDED; -- error
+ERROR:  relation "htest0" can not have all columns unexpanded
+CREATE TABLE htest1 (a bigserial PRIMARY KEY, b text);
+ALTER TABLE htest1 ALTER COLUMN a SET UNEXPANDED;
+-- Insert without named column must not include the unexpanded column
+INSERT INTO htest1 VALUES ('htest1 one');
+INSERT INTO htest1 VALUES ('htest1 two');
+-- INSERT + SELECT * should handle the unexpanded column
+CREATE TABLE htest1_1 (a bigserial PRIMARY KEY, b text);
+ALTER TABLE htest1_1 ALTER COLUMN a SET UNEXPANDED;
+INSERT INTO htest1_1 VALUES ('htest1 one');
+WITH cte AS (
+	DELETE FROM htest1_1 RETURNING *
+) SELECT * FROM cte;
+     b      
+------------
+ htest1 one
+(1 row)
+
+INSERT INTO htest1_1 SELECT * FROM htest0;
+SELECT a, b FROM htest1_1;
+ a | b 
+---+---
+ 2 | 1
+ 3 | 2
+(2 rows)
+
+DROP TABLE htest1_1;
+SELECT attrelid::regclass, attname, attisunexpanded FROM pg_attribute WHERE attisunexpanded;
+ attrelid | attname | attisunexpanded 
+----------+---------+-----------------
+ htest0   | b       | t
+ htest1   | a       | t
+(2 rows)
+
+\d+ htest1
+                                                      Table "public.htest1"
+ Column |  Type  | Collation | Nullable |              Default              |  Expanded  | Storage  | Stats target | Description 
+--------+--------+-----------+----------+-----------------------------------+------------+----------+--------------+-------------
+ a      | bigint |           | not null | nextval('htest1_a_seq'::regclass) | unexpanded | plain    |              | 
+ b      | text   |           |          |                                   |            | extended |              | 
+Indexes:
+    "htest1_pkey" PRIMARY KEY, btree (a)
+
+-- DROP/SET unexpanded attribute
+ALTER TABLE htest0 ALTER COLUMN b DROP UNEXPANDED;
+\d+ htest0
+                                        Table "public.htest0"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | integer |           | not null |         |          | plain    |              | 
+ b      | text    |           | not null |         |          | extended |              | 
+Indexes:
+    "htest0_pkey" PRIMARY KEY, btree (a)
+
+ALTER TABLE htest0 ALTER COLUMN b SET UNEXPANDED;
+-- Hidden column are not expandable and must not be returned
+SELECT * FROM htest0; -- return only column a
+ a 
+---
+ 1
+ 2
+(2 rows)
+
+SELECT t.* FROM htest1 t; -- return only column b
+     b      
+------------
+ htest1 one
+ htest1 two
+(2 rows)
+
+-- the whole-row syntax do not take care of the unexpanded attribute
+SELECT t FROM htest1 t; -- return column a and b
+        t         
+------------------
+ (1,"htest1 one")
+ (2,"htest1 two")
+(2 rows)
+
+-- CTEs based on SELECT * only have visible column returned
+WITH foo AS (SELECT * FROM htest1) SELECT * FROM foo; -- Only column b is returned here
+     b      
+------------
+ htest1 one
+ htest1 two
+(2 rows)
+
+-- Use of wildcard or whole-row in a function do not apply the unexpanded attribute
+SELECT row_to_json(t.*) FROM htest0 t;
+       row_to_json        
+--------------------------
+ {"a":1,"b":"htest0 one"}
+ {"a":2,"b":"htest0 two"}
+(2 rows)
+
+SELECT row_to_json(t) FROM htest0 t;
+       row_to_json        
+--------------------------
+ {"a":1,"b":"htest0 one"}
+ {"a":2,"b":"htest0 two"}
+(2 rows)
+
+-- inheritance, the unexpanded attribute is inherited
+CREATE TABLE htest1_1 () INHERITS (htest1);
+SELECT * FROM htest1_1;
+ b 
+---
+(0 rows)
+
+\d htest1_1
+                          Table "public.htest1_1"
+ Column |  Type  | Collation | Nullable |              Default              
+--------+--------+-----------+----------+-----------------------------------
+ a      | bigint |           | not null | nextval('htest1_a_seq'::regclass)
+ b      | text   |           |          | 
+Inherits: htest1
+
+INSERT INTO htest1_1 VALUES ('htest1 three');
+SELECT * FROM htest1_1;
+      b       
+--------------
+ htest1 three
+(1 row)
+
+SELECT * FROM htest1;
+      b       
+--------------
+ htest1 one
+ htest1 two
+ htest1 three
+(3 rows)
+
+-- unexpanded column must be explicitely named to be returned
+SELECT a,b FROM htest1_1;
+ a |      b       
+---+--------------
+ 3 | htest1 three
+(1 row)
+
+SELECT a,b FROM htest1;
+ a |      b       
+---+--------------
+ 1 | htest1 one
+ 2 | htest1 two
+ 3 | htest1 three
+(3 rows)
+
+DROP TABLE htest1_1;
+-- Default CREATE TABLE ... LIKE includes unexpanded columns, and they are not uinexpanded in the new table.
+CREATE TABLE htest_like1 (LIKE htest1);
+\d+ htest_like1
+                                     Table "public.htest_like1"
+ Column |  Type  | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+--------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | bigint |           | not null |         |          | plain    |              | 
+ b      | text   |           |          |         |          | extended |              | 
+
+-- CREATE TABLE ... LIKE includes unexpanded columns, and they are unexpanded if requested
+CREATE TABLE htest_like2 (LIKE htest1 INCLUDING UNEXPANDED);
+\d+ htest_like2
+                                      Table "public.htest_like2"
+ Column |  Type  | Collation | Nullable | Default |  Expanded  | Storage  | Stats target | Description 
+--------+--------+-----------+----------+---------+------------+----------+--------------+-------------
+ a      | bigint |           | not null |         | unexpanded | plain    |              | 
+ b      | text   |           |          |         |            | extended |              | 
+
+CREATE TABLE htest_like3 (LIKE htest1 INCLUDING ALL);
+\d+ htest_like3
+                                                   Table "public.htest_like3"
+ Column |  Type  | Collation | Nullable |              Default              |  Expanded  | Storage  | Stats target | Description 
+--------+--------+-----------+----------+-----------------------------------+------------+----------+--------------+-------------
+ a      | bigint |           | not null | nextval('htest1_a_seq'::regclass) | unexpanded | plain    |              | 
+ b      | text   |           |          |                                   |            | extended |              | 
+Indexes:
+    "htest_like3_pkey" PRIMARY KEY, btree (a)
+
+DROP TABLE htest_like1, htest_like2, htest_like3;
+-- Insert without named column with and a not null unexpanded column must have a default value
+INSERT INTO htest0 VALUES (3); -- error
+ERROR:  null value in column "b" of relation "htest0" violates not-null constraint
+DETAIL:  Failing row contains (3, null).
+ALTER TABLE htest0 ALTER COLUMN b SET DEFAULT 'unknown';
+INSERT INTO htest0 VALUES (3);
+-- Same with COPY
+COPY htest0 TO stdout;
+1
+2
+3
+COPY htest0 (a, b) TO stdout;
+1	htest0 one
+2	htest0 two
+3	unknown
+COPY htest0 FROM stdin;
+SELECT a,b FROM htest0;
+ a |     b      
+---+------------
+ 1 | htest0 one
+ 2 | htest0 two
+ 3 | unknown
+ 4 | unknown
+ 5 | unknown
+(5 rows)
+
+-- same but with drop/add the column between unexpanded columns (virtual columns can be made unexpanded)
+CREATE TABLE htest2 (a serial, b int, c int GENERATED ALWAYS AS (a * 2) STORED);
+ALTER TABLE htest2 ALTER COLUMN a SET UNEXPANDED;
+ALTER TABLE htest2 ALTER COLUMN c SET UNEXPANDED;
+SELECT * FROM htest2;
+ b 
+---
+(0 rows)
+
+INSERT INTO htest2 VALUES (2);
+SELECT a,b,c FROM htest2;
+ a | b | c 
+---+---+---
+ 1 | 2 | 2
+(1 row)
+
+ALTER TABLE htest2 DROP COLUMN b;
+ALTER TABLE htest2 ADD COLUMN b int;
+INSERT INTO htest2 VALUES (4);
+SELECT a,b,c FROM htest2;
+ a | b | c 
+---+---+---
+ 1 |   | 2
+ 2 | 4 | 4
+(2 rows)
+
+DROP TABLE htest2 CASCADE;
+-- a table can NOT have all columns unexpanded
+CREATE TABLE htest3 (a serial, b int);
+ALTER TABLE htest3
+    ALTER COLUMN a SET UNEXPANDED,
+    ALTER COLUMN b SET UNEXPANDED; -- error
+ERROR:  relation "htest3" can not have all columns unexpanded
+DROP TABLE htest3;
+-- inheritance with an additional single unexpanded column is possible
+CREATE TABLE htest3 (a serial, b int);
+ALTER TABLE htest3 ALTER COLUMN a SET UNEXPANDED;
+SELECT * FROM htest3;
+ b 
+---
+(0 rows)
+
+CREATE TABLE htest3_1 (c int) INHERITS (htest3);
+ALTER TABLE htest3_1 ALTER COLUMN c SET UNEXPANDED;
+SELECT * FROM htest3_1;
+ b 
+---
+(0 rows)
+
+\d+ htest3_1
+                                                     Table "public.htest3_1"
+ Column |  Type   | Collation | Nullable |              Default              |  Expanded  | Storage | Stats target | Description 
+--------+---------+-----------+----------+-----------------------------------+------------+---------+--------------+-------------
+ a      | integer |           | not null | nextval('htest3_a_seq'::regclass) | unexpanded | plain   |              | 
+ b      | integer |           |          |                                   |            | plain   |              | 
+ c      | integer |           |          |                                   | unexpanded | plain   |              | 
+Inherits: htest3
+
+DROP TABLE htest3_1, htest3;
+-- Ordering do not include the unexpanded column
+CREATE TABLE t1 (col1 integer NOT NULL, col2 integer);
+ALTER TABLE t1 ALTER COLUMN col1 SET UNEXPANDED;
+INSERT INTO t1 (col1, col2) VALUES (1, 6), (3, 4);
+SELECT * FROM t1 ORDER BY 1 DESC;
+ col2 
+------
+    6
+    4
+(2 rows)
+
+SELECT col1,col2 FROM t1 ORDER BY 2 DESC;
+ col1 | col2 
+------+------
+    1 |    6
+    3 |    4
+(2 rows)
+
+-- unless it is called explicitly
+SELECT * FROM t1 ORDER BY col1 DESC;
+ col2 
+------
+    4
+    6
+(2 rows)
+
+DROP TABLE t1;
+-- A table can be partitioned by an unexpanded column
+CREATE TABLE measurement (
+	city_id         int not null,
+	logdate         date not null,
+	peaktemp        int,
+	unitsales       int
+) PARTITION BY RANGE (logdate);
+ALTER TABLE measurement ALTER COLUMN logdate SET UNEXPANDED;
+CREATE TABLE measurement_y2006m02 PARTITION OF measurement
+    FOR VALUES FROM ('2021-01-01') TO ('2021-03-01');
+CREATE TABLE measurement_y2006m03 PARTITION OF measurement
+    FOR VALUES FROM ('2021-03-01') TO ('2021-05-01');
+INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-02-28', 34, 4);
+INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-04-12', 42, 6);
+EXPLAIN VERBOSE SELECT * FROM measurement;
+                                             QUERY PLAN                                             
+----------------------------------------------------------------------------------------------------
+ Append  (cost=0.00..75.50 rows=3700 width=12)
+   ->  Seq Scan on public.measurement_y2006m02 measurement_1  (cost=0.00..28.50 rows=1850 width=12)
+         Output: measurement_1.city_id, measurement_1.peaktemp, measurement_1.unitsales
+   ->  Seq Scan on public.measurement_y2006m03 measurement_2  (cost=0.00..28.50 rows=1850 width=12)
+         Output: measurement_2.city_id, measurement_2.peaktemp, measurement_2.unitsales
+(5 rows)
+
+SELECT * FROM measurement;
+ city_id | peaktemp | unitsales 
+---------+----------+-----------
+       1 |       34 |         4
+       1 |       42 |         6
+(2 rows)
+
+SELECT city_id, logdate, peaktemp, unitsales FROM measurement;
+ city_id |  logdate   | peaktemp | unitsales 
+---------+------------+----------+-----------
+       1 | 02-28-2021 |       34 |         4
+       1 | 04-12-2021 |       42 |         6
+(2 rows)
+
+DROP TABLE measurement CASCADE;
+-- Same but unitsales is unexpanded instead of the partition key
+CREATE TABLE measurement (
+	city_id         int not null,
+	logdate         date not null,
+	peaktemp        int,
+	unitsales       int
+) PARTITION BY RANGE (logdate);
+ALTER TABLE measurement ALTER COLUMN unitsales SET UNEXPANDED;
+CREATE TABLE measurement_y2006m02 PARTITION OF measurement
+    FOR VALUES FROM ('2021-01-01') TO ('2021-03-01');
+CREATE TABLE measurement_y2006m03 PARTITION OF measurement
+    FOR VALUES FROM ('2021-03-01') TO ('2021-05-01');
+INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-02-28', 34, 4);
+INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-04-12', 42, 6);
+EXPLAIN VERBOSE SELECT * FROM measurement;
+                                             QUERY PLAN                                             
+----------------------------------------------------------------------------------------------------
+ Append  (cost=0.00..75.50 rows=3700 width=12)
+   ->  Seq Scan on public.measurement_y2006m02 measurement_1  (cost=0.00..28.50 rows=1850 width=12)
+         Output: measurement_1.city_id, measurement_1.logdate, measurement_1.peaktemp
+   ->  Seq Scan on public.measurement_y2006m03 measurement_2  (cost=0.00..28.50 rows=1850 width=12)
+         Output: measurement_2.city_id, measurement_2.logdate, measurement_2.peaktemp
+(5 rows)
+
+SELECT * FROM measurement;
+ city_id |  logdate   | peaktemp 
+---------+------------+----------
+       1 | 02-28-2021 |       34
+       1 | 04-12-2021 |       42
+(2 rows)
+
+SELECT city_id, logdate, peaktemp, unitsales FROM measurement;
+ city_id |  logdate   | peaktemp | unitsales 
+---------+------------+----------+-----------
+       1 | 02-28-2021 |       34 |         4
+       1 | 04-12-2021 |       42 |         6
+(2 rows)
+
+SELECT * FROM measurement_y2006m03;
+ city_id |  logdate   | peaktemp 
+---------+------------+----------
+       1 | 04-12-2021 |       42
+(1 row)
+
+DROP TABLE measurement CASCADE;
+-- Temporary tables can have invisible columns too.
+CREATE TEMPORARY TABLE htest_tmp (col1 integer NOT NULL, col2 integer);
+ALTER TABLE htest_tmp ALTER COLUMN col1 SET UNEXPANDED;
+INSERT INTO htest_tmp (col1, col2) VALUES (1, 6), (3, 4);
+SELECT * FROM htest_tmp ORDER BY 1 DESC;
+ col2 
+------
+    6
+    4
+(2 rows)
+
+DROP TABLE htest_tmp;
+-- A table can use a composite type as an unexpanded column
+CREATE TYPE compfoo AS (f1 int, f2 text);
+CREATE TABLE htest4 (
+    a int,
+    b compfoo
+);
+ALTER TABLE htest4 ALTER COLUMN b SET UNEXPANDED;
+SELECT * FROM htest4;
+ a 
+---
+(0 rows)
+
+DROP TABLE htest4;
+DROP TYPE compfoo;
+-- Foreign key constraints can be defined on unexpanded columns, or unexpanded columns can be referenced.
+CREATE TABLE t1 (col1 integer UNIQUE, col2 integer);
+ALTER TABLE t1 ALTER COLUMN col1 SET UNEXPANDED;
+CREATE TABLE t2 (col1 integer PRIMARY KEY, col2 integer);
+ALTER TABLE t2 ALTER COLUMN col1 SET UNEXPANDED;
+ALTER TABLE t1 ADD CONSTRAINT fk_t1_col1 FOREIGN KEY (col1) REFERENCES t2(col1);
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_col1 FOREIGN KEY (col1) REFERENCES t1(col1);
+DROP TABLE t1, t2 CASCADE;
+-- CHECK constraints can be defined on invisible columns.
+CREATE TABLE t1 (col1 integer CHECK (col1 > 2), col2 integer NOT NULL);
+ALTER TABLE t1 ALTER COLUMN col1 SET UNEXPANDED;
+INSERT INTO t1 (col1, col2) VALUES (1, 6); -- error
+ERROR:  new row for relation "t1" violates check constraint "t1_col1_check"
+DETAIL:  Failing row contains (1, 6).
+INSERT INTO t1 (col1, col2) VALUES (3, 6);
+-- An index can reference a unexpanded column
+CREATE INDEX ON t1 (col1);
+ALTER TABLE t1
+  ALTER COLUMN col1 TYPE bigint,
+  ALTER COLUMN col1 DROP UNEXPANDED,
+  ALTER COLUMN col2 SET UNEXPANDED;
+\d+ t1
+                                           Table "public.t1"
+ Column |  Type   | Collation | Nullable | Default |  Expanded  | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+------------+---------+--------------+-------------
+ col1   | bigint  |           |          |         |            | plain   |              | 
+ col2   | integer |           | not null |         | unexpanded | plain   |              | 
+Indexes:
+    "t1_col1_idx" btree (col1)
+Check constraints:
+    "t1_col1_check" CHECK (col1 > 2)
+
+DROP TABLE t1;
+-- View must not include the unexpanded column when not explicitly listed
+CREATE VIEW viewt1 AS SELECT * FROM htest1;
+\d viewt1
+              View "public.viewt1"
+ Column | Type | Collation | Nullable | Default 
+--------+------+-----------+----------+---------
+ b      | text |           |          | 
+
+SELECT * FROM viewt1;
+     b      
+------------
+ htest1 one
+ htest1 two
+(2 rows)
+
+-- If the unexpanded attribute on the column is removed the view result must not change
+ALTER TABLE htest1 ALTER COLUMN a DROP UNEXPANDED;
+SELECT * FROM viewt1;
+     b      
+------------
+ htest1 one
+ htest1 two
+(2 rows)
+
+ALTER TABLE htest1 ALTER COLUMN a SET UNEXPANDED;
+DROP VIEW viewt1;
+-- Materialized view must include the unexpanded column when explicitly listed
+-- but the column is not unexpanded in the materialized view.
+CREATE VIEW viewt1 AS SELECT a, b FROM htest1;
+\d viewt1
+               View "public.viewt1"
+ Column |  Type  | Collation | Nullable | Default 
+--------+--------+-----------+----------+---------
+ a      | bigint |           |          | 
+ b      | text   |           |          | 
+
+SELECT * FROM viewt1;
+ a |     b      
+---+------------
+ 1 | htest1 one
+ 2 | htest1 two
+(2 rows)
+
+-- Materialized view must not include the unexpanded column when not explicitly listed
+CREATE MATERIALIZED VIEW mviewt1 AS SELECT * FROM htest1;
+\d mviewt1
+       Materialized view "public.mviewt1"
+ Column | Type | Collation | Nullable | Default 
+--------+------+-----------+----------+---------
+ b      | text |           |          | 
+
+REFRESH MATERIALIZED VIEW mviewt1;
+SELECT * FROM mviewt1;
+     b      
+------------
+ htest1 one
+ htest1 two
+(2 rows)
+
+DROP MATERIALIZED VIEW mviewt1;
+-- Materialized view must include the unexpanded column when explicitly listed
+-- but the column is not unexpanded in the materialized view.
+CREATE MATERIALIZED VIEW mviewt1 AS SELECT a, b FROM htest1;
+\d mviewt1
+        Materialized view "public.mviewt1"
+ Column |  Type  | Collation | Nullable | Default 
+--------+--------+-----------+----------+---------
+ a      | bigint |           |          | 
+ b      | text   |           |          | 
+
+REFRESH MATERIALIZED VIEW mviewt1;
+SELECT * FROM mviewt1;
+ a |     b      
+---+------------
+ 1 | htest1 one
+ 2 | htest1 two
+(2 rows)
+
+-- typed tables with unexpanded column is not supported
+CREATE TYPE htest_type AS (f1 integer, f2 text, f3 bigint);
+CREATE TABLE htest28 OF htest_type (f1 WITH OPTIONS DEFAULT 3);
+ALTER TABLE htest28 ALTER COLUMN f1 SET UNEXPANDED; -- error
+ERROR:  cannot set UNEXPANDED attribute on a column of a typed table
+DROP TYPE htest_type CASCADE;
+NOTICE:  drop cascades to table htest28
+-- Prepared statements
+PREPARE q1 AS SELECT * FROM htest1 WHERE a > $1;
+EXECUTE q1(0);
+     b      
+------------
+ htest1 one
+ htest1 two
+(2 rows)
+
+ALTER TABLE htest1 ALTER COLUMN a DROP UNEXPANDED;
+EXECUTE q1(0); -- error: cached plan change result type
+ERROR:  cached plan must not change result type
+ALTER TABLE htest1 ALTER COLUMN a SET UNEXPANDED;
+EXECUTE q1(0);
+     b      
+------------
+ htest1 one
+ htest1 two
+(2 rows)
+
+DEALLOCATE q1;
+-- SELECT * INTO and RETURNING * INTO has the same
+-- behavior, the unexpanded column is not returned.
+CREATE OR REPLACE PROCEDURE test_plpgsq_returning (p_a integer)
+AS $$
+DECLARE
+    v_lbl text;
+BEGIN
+    SELECT * INTO v_lbl FROM htest1 WHERE a = p_a;
+    RAISE NOTICE 'SELECT INTO Col b : %', v_lbl;
+
+    DELETE FROM htest1 WHERE a = p_a
+        RETURNING * INTO v_lbl; 
+    IF FOUND THEN
+	RAISE NOTICE 'RETURNING INTO Col b : %', v_lbl;
+    ELSE
+        RAISE NOTICE 'Noting found';
+    END IF;
+END
+$$
+LANGUAGE plpgsql;
+CALL test_plpgsq_returning(1);
+NOTICE:  SELECT INTO Col b : htest1 one
+NOTICE:  RETURNING INTO Col b : htest1 one
+-- Cleanup
+DROP TABLE htest0, htest1 CASCADE;
+NOTICE:  drop cascades to 2 other objects
+DETAIL:  drop cascades to view viewt1
+drop cascades to materialized view mviewt1
diff --git a/src/test/regress/expected/update.out b/src/test/regress/expected/update.out
index c809f88f54..48c0c3fcb3 100644
--- a/src/test/regress/expected/update.out
+++ b/src/test/regress/expected/update.out
@@ -743,14 +743,14 @@ DROP TRIGGER d15_insert_trig ON part_d_15_20;
 :init_range_parted;
 create table part_def partition of range_parted default;
 \d+ part_def
-                                       Table "public.part_def"
- Column |       Type        | Collation | Nullable | Default | Storage  | Stats target | Description 
---------+-------------------+-----------+----------+---------+----------+--------------+-------------
- a      | text              |           |          |         | extended |              | 
- b      | bigint            |           |          |         | plain    |              | 
- c      | numeric           |           |          |         | main     |              | 
- d      | integer           |           |          |         | plain    |              | 
- e      | character varying |           |          |         | extended |              | 
+                                            Table "public.part_def"
+ Column |       Type        | Collation | Nullable | Default | Expanded | Storage  | Stats target | Description 
+--------+-------------------+-----------+----------+---------+----------+----------+--------------+-------------
+ a      | text              |           |          |         |          | extended |              | 
+ b      | bigint            |           |          |         |          | plain    |              | 
+ c      | numeric           |           |          |         |          | main     |              | 
+ d      | integer           |           |          |         |          | plain    |              | 
+ e      | character varying |           |          |         |          | extended |              | 
 Partition of: range_parted DEFAULT
 Partition constraint: (NOT ((a IS NOT NULL) AND (b IS NOT NULL) AND (((a = 'a'::text) AND (b >= '1'::bigint) AND (b < '10'::bigint)) OR ((a = 'a'::text) AND (b >= '10'::bigint) AND (b < '20'::bigint)) OR ((a = 'b'::text) AND (b >= '1'::bigint) AND (b < '10'::bigint)) OR ((a = 'b'::text) AND (b >= '10'::bigint) AND (b < '20'::bigint)) OR ((a = 'b'::text) AND (b >= '20'::bigint) AND (b < '30'::bigint)))))
 
diff --git a/src/test/regress/expected/varchar.out b/src/test/regress/expected/varchar.out
index da23ae810b..958f9c07e0 100644
--- a/src/test/regress/expected/varchar.out
+++ b/src/test/regress/expected/varchar.out
@@ -52,12 +52,11 @@ SELECT c.*
    WHERE c.f1 < 'a';
  f1 
 ----
- A
  1
  2
  3
  
-(5 rows)
+(4 rows)
 
 SELECT c.*
    FROM VARCHAR_TBL c
@@ -65,20 +64,20 @@ SELECT c.*
  f1 
 ----
  a
- A
  1
  2
  3
  
-(6 rows)
+(5 rows)
 
 SELECT c.*
    FROM VARCHAR_TBL c
    WHERE c.f1 > 'a';
  f1 
 ----
+ A
  c
-(1 row)
+(2 rows)
 
 SELECT c.*
    FROM VARCHAR_TBL c
@@ -86,8 +85,9 @@ SELECT c.*
  f1 
 ----
  a
+ A
  c
-(2 rows)
+(3 rows)
 
 DROP TABLE VARCHAR_TBL;
 --
diff --git a/src/test/regress/expected/xml.out b/src/test/regress/expected/xml.out
index 55b65ef324..ec6457875f 100644
--- a/src/test/regress/expected/xml.out
+++ b/src/test/regress/expected/xml.out
@@ -3,80 +3,82 @@ CREATE TABLE xmltest (
     data xml
 );
 INSERT INTO xmltest VALUES (1, '<value>one</value>');
+ERROR:  unsupported XML feature
+LINE 1: INSERT INTO xmltest VALUES (1, '<value>one</value>');
+                                       ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 INSERT INTO xmltest VALUES (2, '<value>two</value>');
+ERROR:  unsupported XML feature
+LINE 1: INSERT INTO xmltest VALUES (2, '<value>two</value>');
+                                       ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 INSERT INTO xmltest VALUES (3, '<wrong');
-ERROR:  invalid XML content
+ERROR:  unsupported XML feature
 LINE 1: INSERT INTO xmltest VALUES (3, '<wrong');
                                        ^
-DETAIL:  line 1: Couldn't find end of Start Tag wrong line 1
-<wrong
-      ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT * FROM xmltest;
- id |        data        
-----+--------------------
-  1 | <value>one</value>
-  2 | <value>two</value>
-(2 rows)
+ id | data 
+----+------
+(0 rows)
 
 SELECT xmlcomment('test');
- xmlcomment  
--------------
- <!--test-->
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlcomment('-test');
-  xmlcomment  
---------------
- <!---test-->
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlcomment('test-');
-ERROR:  invalid XML comment
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlcomment('--test');
-ERROR:  invalid XML comment
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlcomment('te st');
-  xmlcomment  
---------------
- <!--te st-->
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlconcat(xmlcomment('hello'),
                  xmlelement(NAME qux, 'foo'),
                  xmlcomment('world'));
-               xmlconcat                
-----------------------------------------
- <!--hello--><qux>foo</qux><!--world-->
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlconcat('hello', 'you');
- xmlconcat 
------------
- helloyou
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xmlconcat('hello', 'you');
+                         ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlconcat(1, 2);
 ERROR:  argument of XMLCONCAT must be type xml, not type integer
 LINE 1: SELECT xmlconcat(1, 2);
                          ^
 SELECT xmlconcat('bad', '<syntax');
-ERROR:  invalid XML content
+ERROR:  unsupported XML feature
 LINE 1: SELECT xmlconcat('bad', '<syntax');
-                                ^
-DETAIL:  line 1: Couldn't find end of Start Tag syntax line 1
-<syntax
-       ^
+                         ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlconcat('<foo/>', NULL, '<?xml version="1.1" standalone="no"?><bar/>');
-  xmlconcat   
---------------
- <foo/><bar/>
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xmlconcat('<foo/>', NULL, '<?xml version="1.1" standa...
+                         ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlconcat('<?xml version="1.1"?><foo/>', NULL, '<?xml version="1.1" standalone="no"?><bar/>');
-             xmlconcat             
------------------------------------
- <?xml version="1.1"?><foo/><bar/>
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xmlconcat('<?xml version="1.1"?><foo/>', NULL, '<?xml...
+                         ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlconcat(NULL);
  xmlconcat 
 -----------
@@ -92,334 +94,240 @@ SELECT xmlconcat(NULL, NULL);
 SELECT xmlelement(name element,
                   xmlattributes (1 as one, 'deuce' as two),
                   'content');
-                   xmlelement                   
-------------------------------------------------
- <element one="1" two="deuce">content</element>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name element,
                   xmlattributes ('unnamed and wrong'));
-ERROR:  unnamed XML attribute value must be a column reference
-LINE 2:                   xmlattributes ('unnamed and wrong'));
-                                         ^
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name element, xmlelement(name nested, 'stuff'));
-                xmlelement                 
--------------------------------------------
- <element><nested>stuff</nested></element>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name employee, xmlforest(name, age, salary as pay)) FROM emp;
-                              xmlelement                              
-----------------------------------------------------------------------
- <employee><name>sharon</name><age>25</age><pay>1000</pay></employee>
- <employee><name>sam</name><age>30</age><pay>2000</pay></employee>
- <employee><name>bill</name><age>20</age><pay>1000</pay></employee>
- <employee><name>jeff</name><age>23</age><pay>600</pay></employee>
- <employee><name>cim</name><age>30</age><pay>400</pay></employee>
- <employee><name>linda</name><age>19</age><pay>100</pay></employee>
-(6 rows)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name duplicate, xmlattributes(1 as a, 2 as b, 3 as a));
-ERROR:  XML attribute name "a" appears more than once
-LINE 1: ...ment(name duplicate, xmlattributes(1 as a, 2 as b, 3 as a));
-                                                              ^
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name num, 37);
-  xmlelement   
----------------
- <num>37</num>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name foo, text 'bar');
-   xmlelement   
-----------------
- <foo>bar</foo>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name foo, xml 'bar');
-   xmlelement   
-----------------
- <foo>bar</foo>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name foo, text 'b<a/>r');
-       xmlelement        
--------------------------
- <foo>b&lt;a/&gt;r</foo>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name foo, xml 'b<a/>r');
-    xmlelement     
--------------------
- <foo>b<a/>r</foo>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name foo, array[1, 2, 3]);
-                               xmlelement                                
--------------------------------------------------------------------------
- <foo><element>1</element><element>2</element><element>3</element></foo>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SET xmlbinary TO base64;
 SELECT xmlelement(name foo, bytea 'bar');
-   xmlelement    
------------------
- <foo>YmFy</foo>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SET xmlbinary TO hex;
 SELECT xmlelement(name foo, bytea 'bar');
-    xmlelement     
--------------------
- <foo>626172</foo>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name foo, xmlattributes(true as bar));
-    xmlelement     
--------------------
- <foo bar="true"/>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name foo, xmlattributes('2009-04-09 00:24:37'::timestamp as bar));
-            xmlelement            
-----------------------------------
- <foo bar="2009-04-09T00:24:37"/>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name foo, xmlattributes('infinity'::timestamp as bar));
-ERROR:  timestamp out of range
-DETAIL:  XML does not support infinite timestamp values.
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlelement(name foo, xmlattributes('<>&"''' as funny, xml 'b<a/>r' as funnier));
-                         xmlelement                         
-------------------------------------------------------------
- <foo funny="&lt;&gt;&amp;&quot;'" funnier="b&lt;a/&gt;r"/>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(content '');
- xmlparse 
-----------
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(content '  ');
- xmlparse 
-----------
-   
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(content 'abc');
- xmlparse 
-----------
- abc
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(content '<abc>x</abc>');
-   xmlparse   
---------------
- <abc>x</abc>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(content '<invalidentity>&</invalidentity>');
-ERROR:  invalid XML content
-DETAIL:  line 1: xmlParseEntityRef: no name
-<invalidentity>&</invalidentity>
-                ^
-line 1: chunk is not well balanced
-<invalidentity>&</invalidentity>
-                                ^
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(content '<undefinedentity>&idontexist;</undefinedentity>');
-ERROR:  invalid XML content
-DETAIL:  line 1: Entity 'idontexist' not defined
-<undefinedentity>&idontexist;</undefinedentity>
-                             ^
-line 1: chunk is not well balanced
-<undefinedentity>&idontexist;</undefinedentity>
-                                               ^
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(content '<invalidns xmlns=''&lt;''/>');
-         xmlparse          
----------------------------
- <invalidns xmlns='&lt;'/>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(content '<relativens xmlns=''relative''/>');
-            xmlparse            
---------------------------------
- <relativens xmlns='relative'/>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(content '<twoerrors>&idontexist;</unbalanced>');
-ERROR:  invalid XML content
-DETAIL:  line 1: Entity 'idontexist' not defined
-<twoerrors>&idontexist;</unbalanced>
-                       ^
-line 1: Opening and ending tag mismatch: twoerrors line 1 and unbalanced
-<twoerrors>&idontexist;</unbalanced>
-                                    ^
-line 1: chunk is not well balanced
-<twoerrors>&idontexist;</unbalanced>
-                                    ^
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(content '<nosuchprefix:tag/>');
-      xmlparse       
----------------------
- <nosuchprefix:tag/>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(document '   ');
-ERROR:  invalid XML document
-DETAIL:  line 1: Start tag expected, '<' not found
-   
-   ^
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(document 'abc');
-ERROR:  invalid XML document
-DETAIL:  line 1: Start tag expected, '<' not found
-abc
-^
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(document '<abc>x</abc>');
-   xmlparse   
---------------
- <abc>x</abc>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(document '<invalidentity>&</abc>');
-ERROR:  invalid XML document
-DETAIL:  line 1: xmlParseEntityRef: no name
-<invalidentity>&</abc>
-                ^
-line 1: Opening and ending tag mismatch: invalidentity line 1 and abc
-<invalidentity>&</abc>
-                      ^
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(document '<undefinedentity>&idontexist;</abc>');
-ERROR:  invalid XML document
-DETAIL:  line 1: Entity 'idontexist' not defined
-<undefinedentity>&idontexist;</abc>
-                             ^
-line 1: Opening and ending tag mismatch: undefinedentity line 1 and abc
-<undefinedentity>&idontexist;</abc>
-                                   ^
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(document '<invalidns xmlns=''&lt;''/>');
-         xmlparse          
----------------------------
- <invalidns xmlns='&lt;'/>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(document '<relativens xmlns=''relative''/>');
-            xmlparse            
---------------------------------
- <relativens xmlns='relative'/>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(document '<twoerrors>&idontexist;</unbalanced>');
-ERROR:  invalid XML document
-DETAIL:  line 1: Entity 'idontexist' not defined
-<twoerrors>&idontexist;</unbalanced>
-                       ^
-line 1: Opening and ending tag mismatch: twoerrors line 1 and unbalanced
-<twoerrors>&idontexist;</unbalanced>
-                                    ^
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlparse(document '<nosuchprefix:tag/>');
-      xmlparse       
----------------------
- <nosuchprefix:tag/>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlpi(name foo);
-  xmlpi  
----------
- <?foo?>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlpi(name xml);
-ERROR:  invalid XML processing instruction
-DETAIL:  XML processing instruction target name cannot be "xml".
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlpi(name xmlstuff);
-    xmlpi     
---------------
- <?xmlstuff?>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlpi(name foo, 'bar');
-    xmlpi    
--------------
- <?foo bar?>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlpi(name foo, 'in?>valid');
-ERROR:  invalid XML processing instruction
-DETAIL:  XML processing instruction cannot contain "?>".
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlpi(name foo, null);
- xmlpi 
--------
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlpi(name xml, null);
-ERROR:  invalid XML processing instruction
-DETAIL:  XML processing instruction target name cannot be "xml".
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlpi(name xmlstuff, null);
- xmlpi 
--------
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlpi(name "xml-stylesheet", 'href="mystyle.css" type="text/css"');
-                         xmlpi                         
--------------------------------------------------------
- <?xml-stylesheet href="mystyle.css" type="text/css"?>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlpi(name foo, '   bar');
-    xmlpi    
--------------
- <?foo bar?>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlroot(xml '<foo/>', version no value, standalone no value);
- xmlroot 
----------
- <foo/>
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xmlroot(xml '<foo/>', version no value, standalone no...
+                           ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlroot(xml '<foo/>', version '2.0');
-           xmlroot           
------------------------------
- <?xml version="2.0"?><foo/>
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xmlroot(xml '<foo/>', version '2.0');
+                           ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlroot(xml '<foo/>', version no value, standalone yes);
-                   xmlroot                    
-----------------------------------------------
- <?xml version="1.0" standalone="yes"?><foo/>
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xmlroot(xml '<foo/>', version no value, standalone ye...
+                           ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlroot(xml '<?xml version="1.1"?><foo/>', version no value, standalone yes);
-                   xmlroot                    
-----------------------------------------------
- <?xml version="1.0" standalone="yes"?><foo/>
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xmlroot(xml '<?xml version="1.1"?><foo/>', version no...
+                           ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlroot(xmlroot(xml '<foo/>', version '1.0'), version '1.1', standalone no);
-                   xmlroot                   
----------------------------------------------
- <?xml version="1.1" standalone="no"?><foo/>
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xmlroot(xmlroot(xml '<foo/>', version '1.0'), version...
+                                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlroot('<?xml version="1.1" standalone="yes"?><foo/>', version no value, standalone no);
-                   xmlroot                   
----------------------------------------------
- <?xml version="1.0" standalone="no"?><foo/>
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xmlroot('<?xml version="1.1" standalone="yes"?><foo/>...
+                       ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlroot('<?xml version="1.1" standalone="yes"?><foo/>', version no value, standalone no value);
- xmlroot 
----------
- <foo/>
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xmlroot('<?xml version="1.1" standalone="yes"?><foo/>...
+                       ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlroot('<?xml version="1.1" standalone="yes"?><foo/>', version no value);
-                   xmlroot                    
-----------------------------------------------
- <?xml version="1.0" standalone="yes"?><foo/>
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xmlroot('<?xml version="1.1" standalone="yes"?><foo/>...
+                       ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlroot (
   xmlelement (
     name gazonk,
@@ -435,61 +343,60 @@ SELECT xmlroot (
   version '1.0',
   standalone yes
 );
-                                         xmlroot                                          
-------------------------------------------------------------------------------------------
- <?xml version="1.0" standalone="yes"?><gazonk name="val" num="2"><qux>foo</qux></gazonk>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlserialize(content data as character varying(20)) FROM xmltest;
-    xmlserialize    
---------------------
- <value>one</value>
- <value>two</value>
-(2 rows)
-
-SELECT xmlserialize(content 'good' as char(10));
  xmlserialize 
 --------------
- good      
-(1 row)
+(0 rows)
 
+SELECT xmlserialize(content 'good' as char(10));
+ERROR:  unsupported XML feature
+LINE 1: SELECT xmlserialize(content 'good' as char(10));
+                                    ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlserialize(document 'bad' as text);
-ERROR:  not an XML document
+ERROR:  unsupported XML feature
+LINE 1: SELECT xmlserialize(document 'bad' as text);
+                                     ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml '<foo>bar</foo>' IS DOCUMENT;
- ?column? 
-----------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xml '<foo>bar</foo>' IS DOCUMENT;
+                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml '<foo>bar</foo><bar>foo</bar>' IS DOCUMENT;
- ?column? 
-----------
- f
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xml '<foo>bar</foo><bar>foo</bar>' IS DOCUMENT;
+                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml '<abc/>' IS NOT DOCUMENT;
- ?column? 
-----------
- f
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xml '<abc/>' IS NOT DOCUMENT;
+                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml 'abc' IS NOT DOCUMENT;
- ?column? 
-----------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xml 'abc' IS NOT DOCUMENT;
+                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT '<>' IS NOT DOCUMENT;
-ERROR:  invalid XML content
+ERROR:  unsupported XML feature
 LINE 1: SELECT '<>' IS NOT DOCUMENT;
                ^
-DETAIL:  line 1: StartTag: invalid element name
-<>
- ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlagg(data) FROM xmltest;
-                xmlagg                
---------------------------------------
- <value>one</value><value>two</value>
+ xmlagg 
+--------
+ 
 (1 row)
 
 SELECT xmlagg(data) FROM xmltest WHERE id > 10;
@@ -499,226 +406,224 @@ SELECT xmlagg(data) FROM xmltest WHERE id > 10;
 (1 row)
 
 SELECT xmlelement(name employees, xmlagg(xmlelement(name name, name))) FROM emp;
-                                                           xmlelement                                                           
---------------------------------------------------------------------------------------------------------------------------------
- <employees><name>sharon</name><name>sam</name><name>bill</name><name>jeff</name><name>cim</name><name>linda</name></employees>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- Check mapping SQL identifier to XML name
 SELECT xmlpi(name ":::_xml_abc135.%-&_");
-                      xmlpi                      
--------------------------------------------------
- <?_x003A_::_x005F_xml_abc135._x0025_-_x0026__?>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlpi(name "123");
-     xmlpi     
----------------
- <?_x0031_23?>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 PREPARE foo (xml) AS SELECT xmlconcat('<foo/>', $1);
+ERROR:  unsupported XML feature
+LINE 1: PREPARE foo (xml) AS SELECT xmlconcat('<foo/>', $1);
+                                              ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SET XML OPTION DOCUMENT;
 EXECUTE foo ('<bar/>');
-  xmlconcat   
---------------
- <foo/><bar/>
-(1 row)
-
+ERROR:  prepared statement "foo" does not exist
 EXECUTE foo ('bad');
-ERROR:  invalid XML document
-LINE 1: EXECUTE foo ('bad');
-                     ^
-DETAIL:  line 1: Start tag expected, '<' not found
-bad
-^
+ERROR:  prepared statement "foo" does not exist
 SELECT xml '<!DOCTYPE a><a/><b/>';
-ERROR:  invalid XML document
+ERROR:  unsupported XML feature
 LINE 1: SELECT xml '<!DOCTYPE a><a/><b/>';
                    ^
-DETAIL:  line 1: Extra content at the end of the document
-<!DOCTYPE a><a/><b/>
-                ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SET XML OPTION CONTENT;
 EXECUTE foo ('<bar/>');
-  xmlconcat   
---------------
- <foo/><bar/>
-(1 row)
-
+ERROR:  prepared statement "foo" does not exist
 EXECUTE foo ('good');
- xmlconcat  
-------------
- <foo/>good
-(1 row)
-
+ERROR:  prepared statement "foo" does not exist
 SELECT xml '<!-- in SQL:2006+ a doc is content too--> <?y z?> <!DOCTYPE a><a/>';
-                                xml                                 
---------------------------------------------------------------------
- <!-- in SQL:2006+ a doc is content too--> <?y z?> <!DOCTYPE a><a/>
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xml '<!-- in SQL:2006+ a doc is content too--> <?y z?...
+                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml '<?xml version="1.0"?> <!-- hi--> <!DOCTYPE a><a/>';
-             xml              
-------------------------------
-  <!-- hi--> <!DOCTYPE a><a/>
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xml '<?xml version="1.0"?> <!-- hi--> <!DOCTYPE a><a/...
+                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml '<!DOCTYPE a><a/>';
-       xml        
-------------------
- <!DOCTYPE a><a/>
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xml '<!DOCTYPE a><a/>';
+                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml '<!-- hi--> oops <!DOCTYPE a><a/>';
-ERROR:  invalid XML content
+ERROR:  unsupported XML feature
 LINE 1: SELECT xml '<!-- hi--> oops <!DOCTYPE a><a/>';
                    ^
-DETAIL:  line 1: StartTag: invalid element name
-<!-- hi--> oops <!DOCTYPE a><a/>
-                 ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml '<!-- hi--> <oops/> <!DOCTYPE a><a/>';
-ERROR:  invalid XML content
+ERROR:  unsupported XML feature
 LINE 1: SELECT xml '<!-- hi--> <oops/> <!DOCTYPE a><a/>';
                    ^
-DETAIL:  line 1: StartTag: invalid element name
-<!-- hi--> <oops/> <!DOCTYPE a><a/>
-                    ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml '<!DOCTYPE a><a/><b/>';
-ERROR:  invalid XML content
+ERROR:  unsupported XML feature
 LINE 1: SELECT xml '<!DOCTYPE a><a/><b/>';
                    ^
-DETAIL:  line 1: Extra content at the end of the document
-<!DOCTYPE a><a/><b/>
-                ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- Test backwards parsing
 CREATE VIEW xmlview1 AS SELECT xmlcomment('test');
 CREATE VIEW xmlview2 AS SELECT xmlconcat('hello', 'you');
+ERROR:  unsupported XML feature
+LINE 1: CREATE VIEW xmlview2 AS SELECT xmlconcat('hello', 'you');
+                                                 ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 CREATE VIEW xmlview3 AS SELECT xmlelement(name element, xmlattributes (1 as ":one:", 'deuce' as two), 'content&');
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 CREATE VIEW xmlview4 AS SELECT xmlelement(name employee, xmlforest(name, age, salary as pay)) FROM emp;
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 CREATE VIEW xmlview5 AS SELECT xmlparse(content '<abc>x</abc>');
 CREATE VIEW xmlview6 AS SELECT xmlpi(name foo, 'bar');
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 CREATE VIEW xmlview7 AS SELECT xmlroot(xml '<foo/>', version no value, standalone yes);
+ERROR:  unsupported XML feature
+LINE 1: CREATE VIEW xmlview7 AS SELECT xmlroot(xml '<foo/>', version...
+                                                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
+ERROR:  unsupported XML feature
+LINE 1: ...EATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as ...
+                                                             ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
+ERROR:  unsupported XML feature
+LINE 1: ...EATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as ...
+                                                             ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_name, view_definition FROM information_schema.views
   WHERE table_name LIKE 'xmlview%' ORDER BY 1;
- table_name |                                                  view_definition                                                  
-------------+-------------------------------------------------------------------------------------------------------------------
+ table_name |                                view_definition                                 
+------------+--------------------------------------------------------------------------------
  xmlview1   |  SELECT xmlcomment('test'::text) AS xmlcomment;
- xmlview2   |  SELECT XMLCONCAT('hello'::xml, 'you'::xml) AS "xmlconcat";
- xmlview3   |  SELECT XMLELEMENT(NAME element, XMLATTRIBUTES(1 AS ":one:", 'deuce' AS two), 'content&') AS "xmlelement";
- xmlview4   |  SELECT XMLELEMENT(NAME employee, XMLFOREST(emp.name AS name, emp.age AS age, emp.salary AS pay)) AS "xmlelement"+
-            |    FROM emp;
  xmlview5   |  SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse";
- xmlview6   |  SELECT XMLPI(NAME foo, 'bar'::text) AS "xmlpi";
- xmlview7   |  SELECT XMLROOT('<foo/>'::xml, VERSION NO VALUE, STANDALONE YES) AS "xmlroot";
- xmlview8   |  SELECT (XMLSERIALIZE(CONTENT 'good'::xml AS character(10)))::character(10) AS "xmlserialize";
- xmlview9   |  SELECT XMLSERIALIZE(CONTENT 'good'::xml AS text) AS "xmlserialize";
-(9 rows)
+(2 rows)
 
 -- Text XPath expressions evaluation
 SELECT xpath('/value', data) FROM xmltest;
-        xpath         
-----------------------
- {<value>one</value>}
- {<value>two</value>}
-(2 rows)
+ xpath 
+-------
+(0 rows)
 
 SELECT xpath(NULL, NULL) IS NULL FROM xmltest;
  ?column? 
 ----------
- t
- t
-(2 rows)
+(0 rows)
 
 SELECT xpath('', '<!-- error -->');
-ERROR:  empty XPath expression
-CONTEXT:  SQL function "xpath" statement 1
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('', '<!-- error -->');
+                         ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('//text()', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>');
-     xpath      
-----------------
- {"number one"}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('//text()', '<local:data xmlns:local="http://12...
+                                 ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('//loc:piece/@id', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>', ARRAY[ARRAY['loc', 'http://127.0.0.1']]);
- xpath 
--------
- {1,2}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('//loc:piece/@id', '<local:data xmlns:local="ht...
+                                        ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('//loc:piece', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>', ARRAY[ARRAY['loc', 'http://127.0.0.1']]);
-                                                                     xpath                                                                      
-------------------------------------------------------------------------------------------------------------------------------------------------
- {"<local:piece xmlns:local=\"http://127.0.0.1\" id=\"1\">number one</local:piece>","<local:piece xmlns:local=\"http://127.0.0.1\" id=\"2\"/>"}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('//loc:piece', '<local:data xmlns:local="http:/...
+                                    ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('//loc:piece', '<local:data xmlns:local="http://127.0.0.1" xmlns="http://127.0.0.2"><local:piece id="1"><internal>number one</internal><internal2/></local:piece><local:piece id="2" /></local:data>', ARRAY[ARRAY['loc', 'http://127.0.0.1']]);
-                                                                                                   xpath                                                                                                    
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- {"<local:piece xmlns:local=\"http://127.0.0.1\" xmlns=\"http://127.0.0.2\" id=\"1\"><internal>number one</internal><internal2/></local:piece>","<local:piece xmlns:local=\"http://127.0.0.1\" id=\"2\"/>"}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('//loc:piece', '<local:data xmlns:local="http:/...
+                                    ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('//b', '<a>one <b>two</b> three <b>etc</b></a>');
-          xpath          
--------------------------
- {<b>two</b>,<b>etc</b>}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('//b', '<a>one <b>two</b> three <b>etc</b></a>'...
+                            ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('//text()', '<root>&lt;</root>');
- xpath  
---------
- {&lt;}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('//text()', '<root>&lt;</root>');
+                                 ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('//@value', '<root value="&lt;"/>');
- xpath  
---------
- {&lt;}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('//@value', '<root value="&lt;"/>');
+                                 ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('''<<invalid>>''', '<root/>');
-           xpath           
----------------------------
- {&lt;&lt;invalid&gt;&gt;}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('''<<invalid>>''', '<root/>');
+                                        ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('count(//*)', '<root><sub/><sub/></root>');
- xpath 
--------
- {3}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('count(//*)', '<root><sub/><sub/></root>');
+                                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('count(//*)=0', '<root><sub/><sub/></root>');
-  xpath  
----------
- {false}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('count(//*)=0', '<root><sub/><sub/></root>');
+                                     ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('count(//*)=3', '<root><sub/><sub/></root>');
- xpath  
---------
- {true}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('count(//*)=3', '<root><sub/><sub/></root>');
+                                     ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('name(/*)', '<root><sub/><sub/></root>');
- xpath  
---------
- {root}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('name(/*)', '<root><sub/><sub/></root>');
+                                 ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('/nosuchtag', '<root/>');
- xpath 
--------
- {}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('/nosuchtag', '<root/>');
+                                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath('root', '<root/>');
-   xpath   
------------
- {<root/>}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('root', '<root/>');
+                             ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- Round-trip non-ASCII data through xpath().
 DO $$
 DECLARE
@@ -756,45 +661,65 @@ END
 $$;
 -- Test xmlexists and xpath_exists
 SELECT xmlexists('//town[text() = ''Toronto'']' PASSING BY REF '<towns><town>Bidford-on-Avon</town><town>Cwmbran</town><town>Bristol</town></towns>');
- xmlexists 
------------
- f
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: ...sts('//town[text() = ''Toronto'']' PASSING BY REF '<towns><t...
+                                                             ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlexists('//town[text() = ''Cwmbran'']' PASSING BY REF '<towns><town>Bidford-on-Avon</town><town>Cwmbran</town><town>Bristol</town></towns>');
- xmlexists 
------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: ...sts('//town[text() = ''Cwmbran'']' PASSING BY REF '<towns><t...
+                                                             ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmlexists('count(/nosuchtag)' PASSING BY REF '<root/>');
- xmlexists 
------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: ...LECT xmlexists('count(/nosuchtag)' PASSING BY REF '<root/>')...
+                                                             ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath_exists('//town[text() = ''Toronto'']','<towns><town>Bidford-on-Avon</town><town>Cwmbran</town><town>Bristol</town></towns>'::xml);
- xpath_exists 
---------------
- f
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: ...ELECT xpath_exists('//town[text() = ''Toronto'']','<towns><t...
+                                                             ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath_exists('//town[text() = ''Cwmbran'']','<towns><town>Bidford-on-Avon</town><town>Cwmbran</town><town>Bristol</town></towns>'::xml);
- xpath_exists 
---------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: ...ELECT xpath_exists('//town[text() = ''Cwmbran'']','<towns><t...
+                                                             ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xpath_exists('count(/nosuchtag)', '<root/>'::xml);
- xpath_exists 
---------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath_exists('count(/nosuchtag)', '<root/>'::xml);
+                                                 ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 INSERT INTO xmltest VALUES (4, '<menu><beers><name>Budvar</name><cost>free</cost><name>Carling</name><cost>lots</cost></beers></menu>'::xml);
+ERROR:  unsupported XML feature
+LINE 1: INSERT INTO xmltest VALUES (4, '<menu><beers><name>Budvar</n...
+                                       ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 INSERT INTO xmltest VALUES (5, '<menu><beers><name>Molson</name><cost>free</cost><name>Carling</name><cost>lots</cost></beers></menu>'::xml);
+ERROR:  unsupported XML feature
+LINE 1: INSERT INTO xmltest VALUES (5, '<menu><beers><name>Molson</n...
+                                       ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 INSERT INTO xmltest VALUES (6, '<myns:menu xmlns:myns="http://myns.com"><myns:beers><myns:name>Budvar</myns:name><myns:cost>free</myns:cost><myns:name>Carling</myns:name><myns:cost>lots</myns:cost></myns:beers></myns:menu>'::xml);
+ERROR:  unsupported XML feature
+LINE 1: INSERT INTO xmltest VALUES (6, '<myns:menu xmlns:myns="http:...
+                                       ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 INSERT INTO xmltest VALUES (7, '<myns:menu xmlns:myns="http://myns.com"><myns:beers><myns:name>Molson</myns:name><myns:cost>free</myns:cost><myns:name>Carling</myns:name><myns:cost>lots</myns:cost></myns:beers></myns:menu>'::xml);
+ERROR:  unsupported XML feature
+LINE 1: INSERT INTO xmltest VALUES (7, '<myns:menu xmlns:myns="http:...
+                                       ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beer' PASSING data);
  count 
 -------
@@ -810,13 +735,13 @@ SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beer' PASSING BY REF data B
 SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beers' PASSING BY REF data);
  count 
 -------
-     2
+     0
 (1 row)
 
 SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beers/name[text() = ''Molson'']' PASSING BY REF data);
  count 
 -------
-     1
+     0
 (1 row)
 
 SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/menu/beer',data);
@@ -828,13 +753,13 @@ SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/menu/beer',data);
 SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/menu/beers',data);
  count 
 -------
-     2
+     0
 (1 row)
 
 SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/menu/beers/name[text() = ''Molson'']',data);
  count 
 -------
-     1
+     0
 (1 row)
 
 SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/myns:menu/myns:beer',data,ARRAY[ARRAY['myns','http://myns.com']]);
@@ -846,13 +771,13 @@ SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/myns:menu/myns:beer',data,ARR
 SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/myns:menu/myns:beers',data,ARRAY[ARRAY['myns','http://myns.com']]);
  count 
 -------
-     2
+     0
 (1 row)
 
 SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/myns:menu/myns:beers/myns:name[text() = ''Molson'']',data,ARRAY[ARRAY['myns','http://myns.com']]);
  count 
 -------
-     1
+     0
 (1 row)
 
 CREATE TABLE query ( expr TEXT );
@@ -860,126 +785,88 @@ INSERT INTO query VALUES ('/menu/beers/cost[text() = ''lots'']');
 SELECT COUNT(id) FROM xmltest, query WHERE xmlexists(expr PASSING BY REF data);
  count 
 -------
-     2
+     0
 (1 row)
 
 -- Test xml_is_well_formed and variants
 SELECT xml_is_well_formed_document('<foo>bar</foo>');
- xml_is_well_formed_document 
------------------------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed_document('abc');
- xml_is_well_formed_document 
------------------------------
- f
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed_content('<foo>bar</foo>');
- xml_is_well_formed_content 
-----------------------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed_content('abc');
- xml_is_well_formed_content 
-----------------------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SET xmloption TO DOCUMENT;
 SELECT xml_is_well_formed('abc');
- xml_is_well_formed 
---------------------
- f
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed('<>');
- xml_is_well_formed 
---------------------
- f
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed('<abc/>');
- xml_is_well_formed 
---------------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed('<foo>bar</foo>');
- xml_is_well_formed 
---------------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed('<foo>bar</foo');
- xml_is_well_formed 
---------------------
- f
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed('<foo><bar>baz</foo>');
- xml_is_well_formed 
---------------------
- f
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed('<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>');
- xml_is_well_formed 
---------------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed('<pg:foo xmlns:pg="http://postgresql.org/stuff">bar</my:foo>');
- xml_is_well_formed 
---------------------
- f
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed('<pg:foo xmlns:pg="http://postgresql.org/stuff">bar</pg:foo>');
- xml_is_well_formed 
---------------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed('<invalidentity>&</abc>');
- xml_is_well_formed 
---------------------
- f
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed('<undefinedentity>&idontexist;</abc>');
- xml_is_well_formed 
---------------------
- f
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed('<invalidns xmlns=''&lt;''/>');
- xml_is_well_formed 
---------------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed('<relativens xmlns=''relative''/>');
- xml_is_well_formed 
---------------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xml_is_well_formed('<twoerrors>&idontexist;</unbalanced>');
- xml_is_well_formed 
---------------------
- f
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SET xmloption TO CONTENT;
 SELECT xml_is_well_formed('abc');
- xml_is_well_formed 
---------------------
- t
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- Since xpath() deals with namespaces, it's a bit stricter about
 -- what's well-formed and what's not. If we don't obey these rules
 -- (i.e. ignore namespace-related errors from libxml), xpath()
@@ -992,46 +879,37 @@ SELECT xml_is_well_formed('abc');
 -- error messages, we suppress the DETAIL in this test.
 \set VERBOSITY terse
 SELECT xpath('/*', '<invalidns xmlns=''&lt;''/>');
-ERROR:  could not parse XML document
+ERROR:  unsupported XML feature at character 20
 \set VERBOSITY default
 -- Again, the XML isn't well-formed for namespace purposes
 SELECT xpath('/*', '<nosuchprefix:tag/>');
-ERROR:  could not parse XML document
-DETAIL:  line 1: Namespace prefix nosuchprefix on tag is not defined
-<nosuchprefix:tag/>
-                 ^
-CONTEXT:  SQL function "xpath" statement 1
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('/*', '<nosuchprefix:tag/>');
+                           ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- XPath deprecates relative namespaces, but they're not supposed to
 -- throw an error, only a warning.
 SELECT xpath('/*', '<relativens xmlns=''relative''/>');
-WARNING:  line 1: xmlns: URI relative is not absolute
-<relativens xmlns='relative'/>
-                            ^
-                xpath                 
---------------------------------------
- {"<relativens xmlns=\"relative\"/>"}
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT xpath('/*', '<relativens xmlns=''relative''/>');
+                           ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- External entity references should not leak filesystem information.
 SELECT XMLPARSE(DOCUMENT '<!DOCTYPE foo [<!ENTITY c SYSTEM "/etc/passwd">]><foo>&c;</foo>');
-                            xmlparse                             
------------------------------------------------------------------
- <!DOCTYPE foo [<!ENTITY c SYSTEM "/etc/passwd">]><foo>&c;</foo>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT XMLPARSE(DOCUMENT '<!DOCTYPE foo [<!ENTITY c SYSTEM "/etc/no.such.file">]><foo>&c;</foo>');
-                               xmlparse                                
------------------------------------------------------------------------
- <!DOCTYPE foo [<!ENTITY c SYSTEM "/etc/no.such.file">]><foo>&c;</foo>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- This might or might not load the requested DTD, but it mustn't throw error.
 SELECT XMLPARSE(DOCUMENT '<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"><chapter>&nbsp;</chapter>');
-                                                                       xmlparse                                                                       
-------------------------------------------------------------------------------------------------------------------------------------------------------
- <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"><chapter>&nbsp;</chapter>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- XMLPATH tests
 CREATE TABLE xmldata(data xml);
 INSERT INTO xmldata VALUES('<ROWS>
@@ -1066,6 +944,11 @@ INSERT INTO xmldata VALUES('<ROWS>
   <REGION_ID>3</REGION_ID><SIZE unit="km">791</SIZE>
 </ROW>
 </ROWS>');
+ERROR:  unsupported XML feature
+LINE 1: INSERT INTO xmldata VALUES('<ROWS>
+                                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- XMLTABLE with columns
 SELECT  xmltable.*
    FROM (SELECT data FROM xmldata) x,
@@ -1079,15 +962,9 @@ SELECT  xmltable.*
                                   size float PATH 'SIZE',
                                   unit text PATH 'SIZE/@unit',
                                   premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified');
- id | _id | country_name | country_id | region_id | size | unit | premier_name  
-----+-----+--------------+------------+-----------+------+------+---------------
-  1 |   1 | Australia    | AU         |         3 |      |      | not specified
-  2 |   2 | China        | CN         |         3 |      |      | not specified
-  3 |   3 | HongKong     | HK         |         3 |      |      | not specified
-  4 |   4 | India        | IN         |         3 |      |      | not specified
-  5 |   5 | Japan        | JP         |         3 |      |      | Sinzo Abe
-  6 |   6 | Singapore    | SG         |         3 |  791 | km   | not specified
-(6 rows)
+ id | _id | country_name | country_id | region_id | size | unit | premier_name 
+----+-----+--------------+------------+-----------+------+------+--------------
+(0 rows)
 
 CREATE VIEW xmltableview1 AS SELECT  xmltable.*
    FROM (SELECT data FROM xmldata) x,
@@ -1102,15 +979,9 @@ CREATE VIEW xmltableview1 AS SELECT  xmltable.*
                                   unit text PATH 'SIZE/@unit',
                                   premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified');
 SELECT * FROM xmltableview1;
- id | _id | country_name | country_id | region_id | size | unit | premier_name  
-----+-----+--------------+------------+-----------+------+------+---------------
-  1 |   1 | Australia    | AU         |         3 |      |      | not specified
-  2 |   2 | China        | CN         |         3 |      |      | not specified
-  3 |   3 | HongKong     | HK         |         3 |      |      | not specified
-  4 |   4 | India        | IN         |         3 |      |      | not specified
-  5 |   5 | Japan        | JP         |         3 |      |      | Sinzo Abe
-  6 |   6 | Singapore    | SG         |         3 |  791 | km   | not specified
-(6 rows)
+ id | _id | country_name | country_id | region_id | size | unit | premier_name 
+----+-----+--------------+------------+-----------+------+------+--------------
+(0 rows)
 
 \sv xmltableview1
 CREATE OR REPLACE VIEW public.xmltableview1 AS
@@ -1150,34 +1021,41 @@ SELECT * FROM XMLTABLE(XMLNAMESPACES('http://x.y' AS zz),
                       '/zz:rows/zz:row'
                       PASSING '<rows xmlns="http://x.y"><row><a>10</a></row></rows>'
                       COLUMNS a int PATH 'zz:a');
- a  
-----
- 10
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 3:                       PASSING '<rows xmlns="http://x.y"><row...
+                                      ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 CREATE VIEW xmltableview2 AS SELECT * FROM XMLTABLE(XMLNAMESPACES('http://x.y' AS zz),
                       '/zz:rows/zz:row'
                       PASSING '<rows xmlns="http://x.y"><row><a>10</a></row></rows>'
                       COLUMNS a int PATH 'zz:a');
+ERROR:  unsupported XML feature
+LINE 3:                       PASSING '<rows xmlns="http://x.y"><row...
+                                      ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT * FROM xmltableview2;
- a  
-----
- 10
-(1 row)
-
+ERROR:  relation "xmltableview2" does not exist
+LINE 1: SELECT * FROM xmltableview2;
+                      ^
 SELECT * FROM XMLTABLE(XMLNAMESPACES(DEFAULT 'http://x.y'),
                       '/rows/row'
                       PASSING '<rows xmlns="http://x.y"><row><a>10</a></row></rows>'
                       COLUMNS a int PATH 'a');
-ERROR:  DEFAULT namespace is not supported
+ERROR:  unsupported XML feature
+LINE 3:                       PASSING '<rows xmlns="http://x.y"><row...
+                                      ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT * FROM XMLTABLE('.'
                        PASSING '<foo/>'
                        COLUMNS a text PATH 'foo/namespace::node()');
-                  a                   
---------------------------------------
- http://www.w3.org/XML/1998/namespace
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 2:                        PASSING '<foo/>'
+                                       ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- used in prepare statements
 PREPARE pp AS
 SELECT  xmltable.*
@@ -1193,110 +1071,77 @@ SELECT  xmltable.*
                                   unit text PATH 'SIZE/@unit',
                                   premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified');
 EXECUTE pp;
- id | _id | country_name | country_id | region_id | size | unit | premier_name  
-----+-----+--------------+------------+-----------+------+------+---------------
-  1 |   1 | Australia    | AU         |         3 |      |      | not specified
-  2 |   2 | China        | CN         |         3 |      |      | not specified
-  3 |   3 | HongKong     | HK         |         3 |      |      | not specified
-  4 |   4 | India        | IN         |         3 |      |      | not specified
-  5 |   5 | Japan        | JP         |         3 |      |      | Sinzo Abe
-  6 |   6 | Singapore    | SG         |         3 |  791 | km   | not specified
-(6 rows)
+ id | _id | country_name | country_id | region_id | size | unit | premier_name 
+----+-----+--------------+------------+-----------+------+------+--------------
+(0 rows)
 
 SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS "COUNTRY_NAME" text, "REGION_ID" int);
  COUNTRY_NAME | REGION_ID 
 --------------+-----------
- India        |         3
- Japan        |         3
-(2 rows)
+(0 rows)
 
 SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id FOR ORDINALITY, "COUNTRY_NAME" text, "REGION_ID" int);
  id | COUNTRY_NAME | REGION_ID 
 ----+--------------+-----------
-  1 | India        |         3
-  2 | Japan        |         3
-(2 rows)
+(0 rows)
 
 SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id', "COUNTRY_NAME" text, "REGION_ID" int);
  id | COUNTRY_NAME | REGION_ID 
 ----+--------------+-----------
-  4 | India        |         3
-  5 | Japan        |         3
-(2 rows)
+(0 rows)
 
 SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id');
  id 
 ----
-  4
-  5
-(2 rows)
+(0 rows)
 
 SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id FOR ORDINALITY);
  id 
 ----
-  1
-  2
-(2 rows)
+(0 rows)
 
 SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id', "COUNTRY_NAME" text, "REGION_ID" int, rawdata xml PATH '.');
- id | COUNTRY_NAME | REGION_ID |                             rawdata                              
-----+--------------+-----------+------------------------------------------------------------------
-  4 | India        |         3 | <ROW id="4">                                                    +
-    |              |           |   <COUNTRY_ID>IN</COUNTRY_ID>                                   +
-    |              |           |   <COUNTRY_NAME>India</COUNTRY_NAME>                            +
-    |              |           |   <REGION_ID>3</REGION_ID>                                      +
-    |              |           | </ROW>
-  5 | Japan        |         3 | <ROW id="5">                                                    +
-    |              |           |   <COUNTRY_ID>JP</COUNTRY_ID>                                   +
-    |              |           |   <COUNTRY_NAME>Japan</COUNTRY_NAME>                            +
-    |              |           |   <REGION_ID>3</REGION_ID><PREMIER_NAME>Sinzo Abe</PREMIER_NAME>+
-    |              |           | </ROW>
-(2 rows)
+ id | COUNTRY_NAME | REGION_ID | rawdata 
+----+--------------+-----------+---------
+(0 rows)
 
 SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id', "COUNTRY_NAME" text, "REGION_ID" int, rawdata xml PATH './*');
- id | COUNTRY_NAME | REGION_ID |                                                           rawdata                                                           
-----+--------------+-----------+-----------------------------------------------------------------------------------------------------------------------------
-  4 | India        |         3 | <COUNTRY_ID>IN</COUNTRY_ID><COUNTRY_NAME>India</COUNTRY_NAME><REGION_ID>3</REGION_ID>
-  5 | Japan        |         3 | <COUNTRY_ID>JP</COUNTRY_ID><COUNTRY_NAME>Japan</COUNTRY_NAME><REGION_ID>3</REGION_ID><PREMIER_NAME>Sinzo Abe</PREMIER_NAME>
-(2 rows)
+ id | COUNTRY_NAME | REGION_ID | rawdata 
+----+--------------+-----------+---------
+(0 rows)
 
 SELECT * FROM xmltable('/root' passing '<root><element>a1a<!-- aaaa -->a2a<?aaaaa?> <!--z-->  bbbb<x>xxx</x>cccc</element></root>' COLUMNS element text);
-       element        
-----------------------
- a1aa2a   bbbbxxxcccc
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT * FROM xmltable('/root' passing '<root><element>a1a<!...
+                                               ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT * FROM xmltable('/root' passing '<root><element>a1a<!-- aaaa -->a2a<?aaaaa?> <!--z-->  bbbb<x>xxx</x>cccc</element></root>' COLUMNS element text PATH 'element/text()'); -- should fail
-ERROR:  more than one value returned by column XPath expression
+ERROR:  unsupported XML feature
+LINE 1: SELECT * FROM xmltable('/root' passing '<root><element>a1a<!...
+                                               ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- CDATA test
 select * from xmltable('d/r' passing '<d><r><c><![CDATA[<hello> &"<>!<a>foo</a>]]></c></r><r><c>2</c></r></d>' columns c text);
-            c            
--------------------------
- <hello> &"<>!<a>foo</a>
- 2
-(2 rows)
-
+ERROR:  unsupported XML feature
+LINE 1: select * from xmltable('d/r' passing '<d><r><c><![CDATA[<hel...
+                                             ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- XML builtin entities
 SELECT * FROM xmltable('/x/a' PASSING '<x><a><ent>&apos;</ent></a><a><ent>&quot;</ent></a><a><ent>&amp;</ent></a><a><ent>&lt;</ent></a><a><ent>&gt;</ent></a></x>' COLUMNS ent text);
- ent 
------
- '
- "
- &
- <
- >
-(5 rows)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT * FROM xmltable('/x/a' PASSING '<x><a><ent>&apos;</en...
+                                              ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT * FROM xmltable('/x/a' PASSING '<x><a><ent>&apos;</ent></a><a><ent>&quot;</ent></a><a><ent>&amp;</ent></a><a><ent>&lt;</ent></a><a><ent>&gt;</ent></a></x>' COLUMNS ent xml);
-       ent        
-------------------
- <ent>'</ent>
- <ent>"</ent>
- <ent>&amp;</ent>
- <ent>&lt;</ent>
- <ent>&gt;</ent>
-(5 rows)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT * FROM xmltable('/x/a' PASSING '<x><a><ent>&apos;</en...
+                                              ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 EXPLAIN (VERBOSE, COSTS OFF)
 SELECT  xmltable.*
    FROM (SELECT data FROM xmldata) x,
@@ -1325,8 +1170,7 @@ SELECT  xmltable.*
 SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS "COUNTRY_NAME" text, "REGION_ID" int) WHERE "COUNTRY_NAME" = 'Japan';
  COUNTRY_NAME | REGION_ID 
 --------------+-----------
- Japan        |         3
-(1 row)
+(0 rows)
 
 EXPLAIN (VERBOSE, COSTS OFF)
 SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS "COUNTRY_NAME" text, "REGION_ID" int) WHERE "COUNTRY_NAME" = 'Japan';
@@ -1360,6 +1204,11 @@ INSERT INTO xmldata VALUES('<ROWS>
   <REGION_ID>2</REGION_ID>
 </ROW>
 </ROWS>');
+ERROR:  unsupported XML feature
+LINE 1: INSERT INTO xmldata VALUES('<ROWS>
+                                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 INSERT INTO xmldata VALUES('<ROWS>
 <ROW id="20">
   <COUNTRY_ID>EG</COUNTRY_ID>
@@ -1372,6 +1221,11 @@ INSERT INTO xmldata VALUES('<ROWS>
   <REGION_ID>1</REGION_ID>
 </ROW>
 </ROWS>');
+ERROR:  unsupported XML feature
+LINE 1: INSERT INTO xmldata VALUES('<ROWS>
+                                   ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT  xmltable.*
    FROM (SELECT data FROM xmldata) x,
         LATERAL XMLTABLE('/ROWS/ROW'
@@ -1384,20 +1238,9 @@ SELECT  xmltable.*
                                   size float PATH 'SIZE',
                                   unit text PATH 'SIZE/@unit',
                                   premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified');
- id | _id |  country_name  | country_id | region_id | size | unit | premier_name  
-----+-----+----------------+------------+-----------+------+------+---------------
-  1 |   1 | Australia      | AU         |         3 |      |      | not specified
-  2 |   2 | China          | CN         |         3 |      |      | not specified
-  3 |   3 | HongKong       | HK         |         3 |      |      | not specified
-  4 |   4 | India          | IN         |         3 |      |      | not specified
-  5 |   5 | Japan          | JP         |         3 |      |      | Sinzo Abe
-  6 |   6 | Singapore      | SG         |         3 |  791 | km   | not specified
- 10 |   1 | Czech Republic | CZ         |         2 |      |      | Milos Zeman
- 11 |   2 | Germany        | DE         |         2 |      |      | not specified
- 12 |   3 | France         | FR         |         2 |      |      | not specified
- 20 |   1 | Egypt          | EG         |         1 |      |      | not specified
- 21 |   2 | Sudan          | SD         |         1 |      |      | not specified
-(11 rows)
+ id | _id | country_name | country_id | region_id | size | unit | premier_name 
+----+-----+--------------+------------+-----------+------+------+--------------
+(0 rows)
 
 SELECT  xmltable.*
    FROM (SELECT data FROM xmldata) x,
@@ -1412,12 +1255,9 @@ SELECT  xmltable.*
                                   unit text PATH 'SIZE/@unit',
                                   premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified')
   WHERE region_id = 2;
- id | _id |  country_name  | country_id | region_id | size | unit | premier_name  
-----+-----+----------------+------------+-----------+------+------+---------------
- 10 |   1 | Czech Republic | CZ         |         2 |      |      | Milos Zeman
- 11 |   2 | Germany        | DE         |         2 |      |      | not specified
- 12 |   3 | France         | FR         |         2 |      |      | not specified
-(3 rows)
+ id | _id | country_name | country_id | region_id | size | unit | premier_name 
+----+-----+--------------+------------+-----------+------+------+--------------
+(0 rows)
 
 EXPLAIN (VERBOSE, COSTS OFF)
 SELECT  xmltable.*
@@ -1458,7 +1298,10 @@ SELECT  xmltable.*
                                   size float PATH 'SIZE' NOT NULL,
                                   unit text PATH 'SIZE/@unit',
                                   premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified');
-ERROR:  null is not allowed in column "size"
+ id | _id | country_name | country_id | region_id | size | unit | premier_name 
+----+-----+--------------+------------+-----------+------+------+--------------
+(0 rows)
+
 -- if all is ok, then result is empty
 -- one line xml test
 WITH
@@ -1482,10 +1325,9 @@ WITH
                                          proargtypes text))
    SELECT * FROM z
    EXCEPT SELECT * FROM x;
- proname | proowner | procost | pronargs | proargnames | proargtypes 
----------+----------+---------+----------+-------------+-------------
-(0 rows)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- multi line xml test, result should be empty too
 WITH
    x AS (SELECT proname, proowner, procost::numeric, pronargs,
@@ -1508,60 +1350,65 @@ WITH
                                          proargtypes text))
    SELECT * FROM z
    EXCEPT SELECT * FROM x;
- proname | proowner | procost | pronargs | proargnames | proargtypes 
----------+----------+---------+----------+-------------+-------------
-(0 rows)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 CREATE TABLE xmltest2(x xml, _path text);
 INSERT INTO xmltest2 VALUES('<d><r><ac>1</ac></r></d>', 'A');
+ERROR:  unsupported XML feature
+LINE 1: INSERT INTO xmltest2 VALUES('<d><r><ac>1</ac></r></d>', 'A')...
+                                    ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 INSERT INTO xmltest2 VALUES('<d><r><bc>2</bc></r></d>', 'B');
+ERROR:  unsupported XML feature
+LINE 1: INSERT INTO xmltest2 VALUES('<d><r><bc>2</bc></r></d>', 'B')...
+                                    ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 INSERT INTO xmltest2 VALUES('<d><r><cc>3</cc></r></d>', 'C');
+ERROR:  unsupported XML feature
+LINE 1: INSERT INTO xmltest2 VALUES('<d><r><cc>3</cc></r></d>', 'C')...
+                                    ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 INSERT INTO xmltest2 VALUES('<d><r><dc>2</dc></r></d>', 'D');
+ERROR:  unsupported XML feature
+LINE 1: INSERT INTO xmltest2 VALUES('<d><r><dc>2</dc></r></d>', 'D')...
+                                    ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT xmltable.* FROM xmltest2, LATERAL xmltable('/d/r' PASSING x COLUMNS a int PATH '' || lower(_path) || 'c');
  a 
 ---
- 1
- 2
- 3
- 2
-(4 rows)
+(0 rows)
 
 SELECT xmltable.* FROM xmltest2, LATERAL xmltable(('/d/r/' || lower(_path) || 'c') PASSING x COLUMNS a int PATH '.');
  a 
 ---
- 1
- 2
- 3
- 2
-(4 rows)
+(0 rows)
 
 SELECT xmltable.* FROM xmltest2, LATERAL xmltable(('/d/r/' || lower(_path) || 'c') PASSING x COLUMNS a int PATH 'x' DEFAULT ascii(_path) - 54);
- a  
-----
- 11
- 12
- 13
- 14
-(4 rows)
+ a 
+---
+(0 rows)
 
 -- XPath result can be boolean or number too
 SELECT * FROM XMLTABLE('*' PASSING '<a>a</a>' COLUMNS a xml PATH '.', b text PATH '.', c text PATH '"hi"', d boolean PATH '. = "a"', e integer PATH 'string-length(.)');
-    a     | b | c  | d | e 
-----------+---+----+---+---
- <a>a</a> | a | hi | t | 1
-(1 row)
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT * FROM XMLTABLE('*' PASSING '<a>a</a>' COLUMNS a xml ...
+                                           ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 \x
 SELECT * FROM XMLTABLE('*' PASSING '<e>pre<!--c1--><?pi arg?><![CDATA[&ent1]]><n2>&amp;deep</n2>post</e>' COLUMNS x xml PATH 'node()', y xml PATH '/');
--[ RECORD 1 ]-----------------------------------------------------------
-x | pre<!--c1--><?pi arg?><![CDATA[&ent1]]><n2>&amp;deep</n2>post
-y | <e>pre<!--c1--><?pi arg?><![CDATA[&ent1]]><n2>&amp;deep</n2>post</e>+
-  | 
-
+ERROR:  unsupported XML feature
+LINE 1: SELECT * FROM XMLTABLE('*' PASSING '<e>pre<!--c1--><?pi arg?...
+                                           ^
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 \x
 SELECT * FROM XMLTABLE('.' PASSING XMLELEMENT(NAME a) columns a varchar(20) PATH '"<foo/>"', b xml PATH '"<foo/>"');
-   a    |      b       
---------+--------------
- <foo/> | &lt;foo/&gt;
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
diff --git a/src/test/regress/expected/xmlmap.out b/src/test/regress/expected/xmlmap.out
index c08f8a0d9c..f6dbf81666 100644
--- a/src/test/regress/expected/xmlmap.out
+++ b/src/test/regress/expected/xmlmap.out
@@ -6,1212 +6,111 @@ CREATE TABLE testxmlschema.test2 (z int, y varchar(500), x char(6), w numeric(9,
 ALTER TABLE testxmlschema.test2 DROP COLUMN aaa;
 INSERT INTO testxmlschema.test2 VALUES (55, 'abc', 'def', 98.6, 2, 999, 0, '21:07', '2009-06-08 21:07:30', '2009-06-08', NULL, 'ABC', true, 'XYZ');
 SELECT table_to_xml('testxmlschema.test1', false, false, '');
-                         table_to_xml                          
----------------------------------------------------------------
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-                                                              +
- <row>                                                        +
-   <a>1</a>                                                   +
-   <b>one</b>                                                 +
- </row>                                                       +
-                                                              +
- <row>                                                        +
-   <a>2</a>                                                   +
-   <b>two</b>                                                 +
- </row>                                                       +
-                                                              +
- <row>                                                        +
-   <a>-1</a>                                                  +
- </row>                                                       +
-                                                              +
- </test1>                                                     +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xml('testxmlschema.test1', true, false, 'foo');
-                               table_to_xml                                
----------------------------------------------------------------------------
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo">+
-                                                                          +
- <row>                                                                    +
-   <a>1</a>                                                               +
-   <b>one</b>                                                             +
- </row>                                                                   +
-                                                                          +
- <row>                                                                    +
-   <a>2</a>                                                               +
-   <b>two</b>                                                             +
- </row>                                                                   +
-                                                                          +
- <row>                                                                    +
-   <a>-1</a>                                                              +
-   <b xsi:nil="true"/>                                                    +
- </row>                                                                   +
-                                                                          +
- </test1>                                                                 +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xml('testxmlschema.test1', false, true, '');
-                         table_to_xml                          
----------------------------------------------------------------
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-   <a>1</a>                                                   +
-   <b>one</b>                                                 +
- </test1>                                                     +
-                                                              +
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-   <a>2</a>                                                   +
-   <b>two</b>                                                 +
- </test1>                                                     +
-                                                              +
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-   <a>-1</a>                                                  +
- </test1>                                                     +
-                                                              +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xml('testxmlschema.test1', true, true, '');
-                         table_to_xml                          
----------------------------------------------------------------
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-   <a>1</a>                                                   +
-   <b>one</b>                                                 +
- </test1>                                                     +
-                                                              +
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-   <a>2</a>                                                   +
-   <b>two</b>                                                 +
- </test1>                                                     +
-                                                              +
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-   <a>-1</a>                                                  +
-   <b xsi:nil="true"/>                                        +
- </test1>                                                     +
-                                                              +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xml('testxmlschema.test2', false, false, '');
-                         table_to_xml                          
----------------------------------------------------------------
- <test2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-                                                              +
- <row>                                                        +
-   <z>55</z>                                                  +
-   <y>abc</y>                                                 +
-   <x>def   </x>                                              +
-   <w>98.60</w>                                               +
-   <v>2</v>                                                   +
-   <u>999</u>                                                 +
-   <t>0</t>                                                   +
-   <s>21:07:00</s>                                            +
-   <r>2009-06-08T21:07:30</r>                                 +
-   <q>2009-06-08</q>                                          +
-   <o>ABC</o>                                                 +
-   <n>true</n>                                                +
-   <m>WFla</m>                                                +
- </row>                                                       +
-                                                              +
- </test2>                                                     +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xmlschema('testxmlschema.test1', false, false, '');
-                                               table_to_xmlschema                                                
------------------------------------------------------------------------------------------------------------------
- <xsd:schema                                                                                                    +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                              +
-                                                                                                                +
- <xsd:simpleType name="INTEGER">                                                                                +
-   <xsd:restriction base="xsd:int">                                                                             +
-     <xsd:maxInclusive value="2147483647"/>                                                                     +
-     <xsd:minInclusive value="-2147483648"/>                                                                    +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                                         +
-   <xsd:restriction base="xsd:string">                                                                          +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:complexType name="RowType.regression.testxmlschema.test1">                                                +
-   <xsd:sequence>                                                                                               +
-     <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element>                                          +
-     <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>                   +
-   </xsd:sequence>                                                                                              +
- </xsd:complexType>                                                                                             +
-                                                                                                                +
- <xsd:complexType name="TableType.regression.testxmlschema.test1">                                              +
-   <xsd:sequence>                                                                                               +
-     <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
-   </xsd:sequence>                                                                                              +
- </xsd:complexType>                                                                                             +
-                                                                                                                +
- <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/>                                    +
-                                                                                                                +
- </xsd:schema>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xmlschema('testxmlschema.test1', true, false, '');
-                                               table_to_xmlschema                                                
------------------------------------------------------------------------------------------------------------------
- <xsd:schema                                                                                                    +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                              +
-                                                                                                                +
- <xsd:simpleType name="INTEGER">                                                                                +
-   <xsd:restriction base="xsd:int">                                                                             +
-     <xsd:maxInclusive value="2147483647"/>                                                                     +
-     <xsd:minInclusive value="-2147483648"/>                                                                    +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                                         +
-   <xsd:restriction base="xsd:string">                                                                          +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:complexType name="RowType.regression.testxmlschema.test1">                                                +
-   <xsd:sequence>                                                                                               +
-     <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element>                                        +
-     <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>                 +
-   </xsd:sequence>                                                                                              +
- </xsd:complexType>                                                                                             +
-                                                                                                                +
- <xsd:complexType name="TableType.regression.testxmlschema.test1">                                              +
-   <xsd:sequence>                                                                                               +
-     <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
-   </xsd:sequence>                                                                                              +
- </xsd:complexType>                                                                                             +
-                                                                                                                +
- <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/>                                    +
-                                                                                                                +
- </xsd:schema>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xmlschema('testxmlschema.test1', false, true, 'foo');
-                                      table_to_xmlschema                                      
-----------------------------------------------------------------------------------------------
- <xsd:schema                                                                                 +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema"                                            +
-     targetNamespace="foo"                                                                   +
-     elementFormDefault="qualified">                                                         +
-                                                                                             +
- <xsd:simpleType name="INTEGER">                                                             +
-   <xsd:restriction base="xsd:int">                                                          +
-     <xsd:maxInclusive value="2147483647"/>                                                  +
-     <xsd:minInclusive value="-2147483648"/>                                                 +
-   </xsd:restriction>                                                                        +
- </xsd:simpleType>                                                                           +
-                                                                                             +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                      +
-   <xsd:restriction base="xsd:string">                                                       +
-   </xsd:restriction>                                                                        +
- </xsd:simpleType>                                                                           +
-                                                                                             +
- <xsd:complexType name="RowType.regression.testxmlschema.test1">                             +
-   <xsd:sequence>                                                                            +
-     <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element>                       +
-     <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>+
-   </xsd:sequence>                                                                           +
- </xsd:complexType>                                                                          +
-                                                                                             +
- <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/>                   +
-                                                                                             +
- </xsd:schema>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xmlschema('testxmlschema.test1', true, true, '');
-                                       table_to_xmlschema                                       
-------------------------------------------------------------------------------------------------
- <xsd:schema                                                                                   +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                             +
-                                                                                               +
- <xsd:simpleType name="INTEGER">                                                               +
-   <xsd:restriction base="xsd:int">                                                            +
-     <xsd:maxInclusive value="2147483647"/>                                                    +
-     <xsd:minInclusive value="-2147483648"/>                                                   +
-   </xsd:restriction>                                                                          +
- </xsd:simpleType>                                                                             +
-                                                                                               +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                        +
-   <xsd:restriction base="xsd:string">                                                         +
-   </xsd:restriction>                                                                          +
- </xsd:simpleType>                                                                             +
-                                                                                               +
- <xsd:complexType name="RowType.regression.testxmlschema.test1">                               +
-   <xsd:sequence>                                                                              +
-     <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element>                       +
-     <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>+
-   </xsd:sequence>                                                                             +
- </xsd:complexType>                                                                            +
-                                                                                               +
- <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/>                     +
-                                                                                               +
- </xsd:schema>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xmlschema('testxmlschema.test2', false, false, '');
-                                               table_to_xmlschema                                                
------------------------------------------------------------------------------------------------------------------
- <xsd:schema                                                                                                    +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                              +
-                                                                                                                +
- <xsd:simpleType name="INTEGER">                                                                                +
-   <xsd:restriction base="xsd:int">                                                                             +
-     <xsd:maxInclusive value="2147483647"/>                                                                     +
-     <xsd:minInclusive value="-2147483648"/>                                                                    +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="VARCHAR">                                                                                +
-   <xsd:restriction base="xsd:string">                                                                          +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="CHAR">                                                                                   +
-   <xsd:restriction base="xsd:string">                                                                          +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="NUMERIC">                                                                                +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="SMALLINT">                                                                               +
-   <xsd:restriction base="xsd:short">                                                                           +
-     <xsd:maxInclusive value="32767"/>                                                                          +
-     <xsd:minInclusive value="-32768"/>                                                                         +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="BIGINT">                                                                                 +
-   <xsd:restriction base="xsd:long">                                                                            +
-     <xsd:maxInclusive value="9223372036854775807"/>                                                            +
-     <xsd:minInclusive value="-9223372036854775808"/>                                                           +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="REAL">                                                                                   +
-   <xsd:restriction base="xsd:float"></xsd:restriction>                                                         +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="TIME">                                                                                   +
-   <xsd:restriction base="xsd:time">                                                                            +
-     <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/>                                            +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="TIMESTAMP">                                                                              +
-   <xsd:restriction base="xsd:dateTime">                                                                        +
-     <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/>              +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="DATE">                                                                                   +
-   <xsd:restriction base="xsd:date">                                                                            +
-     <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/>                                                       +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:complexType mixed="true">                                                                                 +
-   <xsd:sequence>                                                                                               +
-     <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/>                       +
-   </xsd:sequence>                                                                                              +
- </xsd:complexType>                                                                                             +
-                                                                                                                +
- <xsd:simpleType name="Domain.regression.public.testxmldomain">                                                 +
-   <xsd:restriction base="VARCHAR"/>                                                                            +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="BOOLEAN">                                                                                +
-   <xsd:restriction base="xsd:boolean"></xsd:restriction>                                                       +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="UDT.regression.pg_catalog.bytea">                                                        +
-   <xsd:restriction base="xsd:base64Binary">                                                                    +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:complexType name="RowType.regression.testxmlschema.test2">                                                +
-   <xsd:sequence>                                                                                               +
-     <xsd:element name="z" type="INTEGER" minOccurs="0"></xsd:element>                                          +
-     <xsd:element name="y" type="VARCHAR" minOccurs="0"></xsd:element>                                          +
-     <xsd:element name="x" type="CHAR" minOccurs="0"></xsd:element>                                             +
-     <xsd:element name="w" type="NUMERIC" minOccurs="0"></xsd:element>                                          +
-     <xsd:element name="v" type="SMALLINT" minOccurs="0"></xsd:element>                                         +
-     <xsd:element name="u" type="BIGINT" minOccurs="0"></xsd:element>                                           +
-     <xsd:element name="t" type="REAL" minOccurs="0"></xsd:element>                                             +
-     <xsd:element name="s" type="TIME" minOccurs="0"></xsd:element>                                             +
-     <xsd:element name="r" type="TIMESTAMP" minOccurs="0"></xsd:element>                                        +
-     <xsd:element name="q" type="DATE" minOccurs="0"></xsd:element>                                             +
-     <xsd:element name="p" type="XML" minOccurs="0"></xsd:element>                                              +
-     <xsd:element name="o" type="Domain.regression.public.testxmldomain" minOccurs="0"></xsd:element>           +
-     <xsd:element name="n" type="BOOLEAN" minOccurs="0"></xsd:element>                                          +
-     <xsd:element name="m" type="UDT.regression.pg_catalog.bytea" minOccurs="0"></xsd:element>                  +
-   </xsd:sequence>                                                                                              +
- </xsd:complexType>                                                                                             +
-                                                                                                                +
- <xsd:complexType name="TableType.regression.testxmlschema.test2">                                              +
-   <xsd:sequence>                                                                                               +
-     <xsd:element name="row" type="RowType.regression.testxmlschema.test2" minOccurs="0" maxOccurs="unbounded"/>+
-   </xsd:sequence>                                                                                              +
- </xsd:complexType>                                                                                             +
-                                                                                                                +
- <xsd:element name="test2" type="TableType.regression.testxmlschema.test2"/>                                    +
-                                                                                                                +
- </xsd:schema>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, false, '');
-                                           table_to_xml_and_xmlschema                                            
------------------------------------------------------------------------------------------------------------------
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="#">                +
-                                                                                                                +
- <xsd:schema                                                                                                    +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                              +
-                                                                                                                +
- <xsd:simpleType name="INTEGER">                                                                                +
-   <xsd:restriction base="xsd:int">                                                                             +
-     <xsd:maxInclusive value="2147483647"/>                                                                     +
-     <xsd:minInclusive value="-2147483648"/>                                                                    +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                                         +
-   <xsd:restriction base="xsd:string">                                                                          +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:complexType name="RowType.regression.testxmlschema.test1">                                                +
-   <xsd:sequence>                                                                                               +
-     <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element>                                          +
-     <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>                   +
-   </xsd:sequence>                                                                                              +
- </xsd:complexType>                                                                                             +
-                                                                                                                +
- <xsd:complexType name="TableType.regression.testxmlschema.test1">                                              +
-   <xsd:sequence>                                                                                               +
-     <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
-   </xsd:sequence>                                                                                              +
- </xsd:complexType>                                                                                             +
-                                                                                                                +
- <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/>                                    +
-                                                                                                                +
- </xsd:schema>                                                                                                  +
-                                                                                                                +
- <row>                                                                                                          +
-   <a>1</a>                                                                                                     +
-   <b>one</b>                                                                                                   +
- </row>                                                                                                         +
-                                                                                                                +
- <row>                                                                                                          +
-   <a>2</a>                                                                                                     +
-   <b>two</b>                                                                                                   +
- </row>                                                                                                         +
-                                                                                                                +
- <row>                                                                                                          +
-   <a>-1</a>                                                                                                    +
- </row>                                                                                                         +
-                                                                                                                +
- </test1>                                                                                                       +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, false, '');
-                                           table_to_xml_and_xmlschema                                            
------------------------------------------------------------------------------------------------------------------
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="#">                +
-                                                                                                                +
- <xsd:schema                                                                                                    +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                              +
-                                                                                                                +
- <xsd:simpleType name="INTEGER">                                                                                +
-   <xsd:restriction base="xsd:int">                                                                             +
-     <xsd:maxInclusive value="2147483647"/>                                                                     +
-     <xsd:minInclusive value="-2147483648"/>                                                                    +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                                         +
-   <xsd:restriction base="xsd:string">                                                                          +
-   </xsd:restriction>                                                                                           +
- </xsd:simpleType>                                                                                              +
-                                                                                                                +
- <xsd:complexType name="RowType.regression.testxmlschema.test1">                                                +
-   <xsd:sequence>                                                                                               +
-     <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element>                                        +
-     <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>                 +
-   </xsd:sequence>                                                                                              +
- </xsd:complexType>                                                                                             +
-                                                                                                                +
- <xsd:complexType name="TableType.regression.testxmlschema.test1">                                              +
-   <xsd:sequence>                                                                                               +
-     <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
-   </xsd:sequence>                                                                                              +
- </xsd:complexType>                                                                                             +
-                                                                                                                +
- <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/>                                    +
-                                                                                                                +
- </xsd:schema>                                                                                                  +
-                                                                                                                +
- <row>                                                                                                          +
-   <a>1</a>                                                                                                     +
-   <b>one</b>                                                                                                   +
- </row>                                                                                                         +
-                                                                                                                +
- <row>                                                                                                          +
-   <a>2</a>                                                                                                     +
-   <b>two</b>                                                                                                   +
- </row>                                                                                                         +
-                                                                                                                +
- <row>                                                                                                          +
-   <a>-1</a>                                                                                                    +
-   <b xsi:nil="true"/>                                                                                          +
- </row>                                                                                                         +
-                                                                                                                +
- </test1>                                                                                                       +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, '');
-                                  table_to_xml_and_xmlschema                                  
-----------------------------------------------------------------------------------------------
- <xsd:schema                                                                                 +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                           +
-                                                                                             +
- <xsd:simpleType name="INTEGER">                                                             +
-   <xsd:restriction base="xsd:int">                                                          +
-     <xsd:maxInclusive value="2147483647"/>                                                  +
-     <xsd:minInclusive value="-2147483648"/>                                                 +
-   </xsd:restriction>                                                                        +
- </xsd:simpleType>                                                                           +
-                                                                                             +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                      +
-   <xsd:restriction base="xsd:string">                                                       +
-   </xsd:restriction>                                                                        +
- </xsd:simpleType>                                                                           +
-                                                                                             +
- <xsd:complexType name="RowType.regression.testxmlschema.test1">                             +
-   <xsd:sequence>                                                                            +
-     <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element>                       +
-     <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>+
-   </xsd:sequence>                                                                           +
- </xsd:complexType>                                                                          +
-                                                                                             +
- <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/>                   +
-                                                                                             +
- </xsd:schema>                                                                               +
-                                                                                             +
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                               +
-   <a>1</a>                                                                                  +
-   <b>one</b>                                                                                +
- </test1>                                                                                    +
-                                                                                             +
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                               +
-   <a>2</a>                                                                                  +
-   <b>two</b>                                                                                +
- </test1>                                                                                    +
-                                                                                             +
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                               +
-   <a>-1</a>                                                                                 +
- </test1>                                                                                    +
-                                                                                             +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo');
-                                   table_to_xml_and_xmlschema                                   
-------------------------------------------------------------------------------------------------
- <xsd:schema                                                                                   +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema"                                              +
-     targetNamespace="foo"                                                                     +
-     elementFormDefault="qualified">                                                           +
-                                                                                               +
- <xsd:simpleType name="INTEGER">                                                               +
-   <xsd:restriction base="xsd:int">                                                            +
-     <xsd:maxInclusive value="2147483647"/>                                                    +
-     <xsd:minInclusive value="-2147483648"/>                                                   +
-   </xsd:restriction>                                                                          +
- </xsd:simpleType>                                                                             +
-                                                                                               +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                        +
-   <xsd:restriction base="xsd:string">                                                         +
-   </xsd:restriction>                                                                          +
- </xsd:simpleType>                                                                             +
-                                                                                               +
- <xsd:complexType name="RowType.regression.testxmlschema.test1">                               +
-   <xsd:sequence>                                                                              +
-     <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element>                       +
-     <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>+
-   </xsd:sequence>                                                                             +
- </xsd:complexType>                                                                            +
-                                                                                               +
- <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/>                     +
-                                                                                               +
- </xsd:schema>                                                                                 +
-                                                                                               +
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo">                     +
-   <a>1</a>                                                                                    +
-   <b>one</b>                                                                                  +
- </test1>                                                                                      +
-                                                                                               +
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo">                     +
-   <a>2</a>                                                                                    +
-   <b>two</b>                                                                                  +
- </test1>                                                                                      +
-                                                                                               +
- <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo">                     +
-   <a>-1</a>                                                                                   +
-   <b xsi:nil="true"/>                                                                         +
- </test1>                                                                                      +
-                                                                                               +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT query_to_xml('SELECT * FROM testxmlschema.test1', false, false, '');
-                         query_to_xml                          
----------------------------------------------------------------
- <table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-                                                              +
- <row>                                                        +
-   <a>1</a>                                                   +
-   <b>one</b>                                                 +
- </row>                                                       +
-                                                              +
- <row>                                                        +
-   <a>2</a>                                                   +
-   <b>two</b>                                                 +
- </row>                                                       +
-                                                              +
- <row>                                                        +
-   <a>-1</a>                                                  +
- </row>                                                       +
-                                                              +
- </table>                                                     +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT query_to_xmlschema('SELECT * FROM testxmlschema.test1', false, false, '');
-                                      query_to_xmlschema                                      
-----------------------------------------------------------------------------------------------
- <xsd:schema                                                                                 +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                           +
-                                                                                             +
- <xsd:simpleType name="INTEGER">                                                             +
-   <xsd:restriction base="xsd:int">                                                          +
-     <xsd:maxInclusive value="2147483647"/>                                                  +
-     <xsd:minInclusive value="-2147483648"/>                                                 +
-   </xsd:restriction>                                                                        +
- </xsd:simpleType>                                                                           +
-                                                                                             +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                      +
-   <xsd:restriction base="xsd:string">                                                       +
-   </xsd:restriction>                                                                        +
- </xsd:simpleType>                                                                           +
-                                                                                             +
- <xsd:complexType name="RowType">                                                            +
-   <xsd:sequence>                                                                            +
-     <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element>                       +
-     <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>+
-   </xsd:sequence>                                                                           +
- </xsd:complexType>                                                                          +
-                                                                                             +
- <xsd:complexType name="TableType">                                                          +
-   <xsd:sequence>                                                                            +
-     <xsd:element name="row" type="RowType" minOccurs="0" maxOccurs="unbounded"/>            +
-   </xsd:sequence>                                                                           +
- </xsd:complexType>                                                                          +
-                                                                                             +
- <xsd:element name="table" type="TableType"/>                                                +
-                                                                                             +
- </xsd:schema>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, true, '');
-                                   query_to_xml_and_xmlschema                                   
-------------------------------------------------------------------------------------------------
- <xsd:schema                                                                                   +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                             +
-                                                                                               +
- <xsd:simpleType name="INTEGER">                                                               +
-   <xsd:restriction base="xsd:int">                                                            +
-     <xsd:maxInclusive value="2147483647"/>                                                    +
-     <xsd:minInclusive value="-2147483648"/>                                                   +
-   </xsd:restriction>                                                                          +
- </xsd:simpleType>                                                                             +
-                                                                                               +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                        +
-   <xsd:restriction base="xsd:string">                                                         +
-   </xsd:restriction>                                                                          +
- </xsd:simpleType>                                                                             +
-                                                                                               +
- <xsd:complexType name="RowType">                                                              +
-   <xsd:sequence>                                                                              +
-     <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element>                       +
-     <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>+
-   </xsd:sequence>                                                                             +
- </xsd:complexType>                                                                            +
-                                                                                               +
- <xsd:element name="row" type="RowType"/>                                                      +
-                                                                                               +
- </xsd:schema>                                                                                 +
-                                                                                               +
- <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                                   +
-   <a>1</a>                                                                                    +
-   <b>one</b>                                                                                  +
- </row>                                                                                        +
-                                                                                               +
- <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                                   +
-   <a>2</a>                                                                                    +
-   <b>two</b>                                                                                  +
- </row>                                                                                        +
-                                                                                               +
- <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                                   +
-   <a>-1</a>                                                                                   +
-   <b xsi:nil="true"/>                                                                         +
- </row>                                                                                        +
-                                                                                               +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 DECLARE xc CURSOR WITH HOLD FOR SELECT * FROM testxmlschema.test1 ORDER BY 1, 2;
 SELECT cursor_to_xml('xc'::refcursor, 5, false, true, '');
-                        cursor_to_xml                        
--------------------------------------------------------------
- <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-   <a>-1</a>                                                +
- </row>                                                     +
-                                                            +
- <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-   <a>1</a>                                                 +
-   <b>one</b>                                               +
- </row>                                                     +
-                                                            +
- <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-   <a>2</a>                                                 +
-   <b>two</b>                                               +
- </row>                                                     +
-                                                            +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT cursor_to_xmlschema('xc'::refcursor, false, true, '');
-                                     cursor_to_xmlschema                                      
-----------------------------------------------------------------------------------------------
- <xsd:schema                                                                                 +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                           +
-                                                                                             +
- <xsd:simpleType name="INTEGER">                                                             +
-   <xsd:restriction base="xsd:int">                                                          +
-     <xsd:maxInclusive value="2147483647"/>                                                  +
-     <xsd:minInclusive value="-2147483648"/>                                                 +
-   </xsd:restriction>                                                                        +
- </xsd:simpleType>                                                                           +
-                                                                                             +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                      +
-   <xsd:restriction base="xsd:string">                                                       +
-   </xsd:restriction>                                                                        +
- </xsd:simpleType>                                                                           +
-                                                                                             +
- <xsd:complexType name="RowType">                                                            +
-   <xsd:sequence>                                                                            +
-     <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element>                       +
-     <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>+
-   </xsd:sequence>                                                                           +
- </xsd:complexType>                                                                          +
-                                                                                             +
- <xsd:element name="row" type="RowType"/>                                                    +
-                                                                                             +
- </xsd:schema>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 MOVE BACKWARD ALL IN xc;
 SELECT cursor_to_xml('xc'::refcursor, 5, true, false, '');
-                         cursor_to_xml                         
----------------------------------------------------------------
- <table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-                                                              +
- <row>                                                        +
-   <a>-1</a>                                                  +
-   <b xsi:nil="true"/>                                        +
- </row>                                                       +
-                                                              +
- <row>                                                        +
-   <a>1</a>                                                   +
-   <b>one</b>                                                 +
- </row>                                                       +
-                                                              +
- <row>                                                        +
-   <a>2</a>                                                   +
-   <b>two</b>                                                 +
- </row>                                                       +
-                                                              +
- </table>                                                     +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT cursor_to_xmlschema('xc'::refcursor, true, false, '');
-                                      cursor_to_xmlschema                                       
-------------------------------------------------------------------------------------------------
- <xsd:schema                                                                                   +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                             +
-                                                                                               +
- <xsd:simpleType name="INTEGER">                                                               +
-   <xsd:restriction base="xsd:int">                                                            +
-     <xsd:maxInclusive value="2147483647"/>                                                    +
-     <xsd:minInclusive value="-2147483648"/>                                                   +
-   </xsd:restriction>                                                                          +
- </xsd:simpleType>                                                                             +
-                                                                                               +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                        +
-   <xsd:restriction base="xsd:string">                                                         +
-   </xsd:restriction>                                                                          +
- </xsd:simpleType>                                                                             +
-                                                                                               +
- <xsd:complexType name="RowType">                                                              +
-   <xsd:sequence>                                                                              +
-     <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element>                       +
-     <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>+
-   </xsd:sequence>                                                                             +
- </xsd:complexType>                                                                            +
-                                                                                               +
- <xsd:complexType name="TableType">                                                            +
-   <xsd:sequence>                                                                              +
-     <xsd:element name="row" type="RowType" minOccurs="0" maxOccurs="unbounded"/>              +
-   </xsd:sequence>                                                                             +
- </xsd:complexType>                                                                            +
-                                                                                               +
- <xsd:element name="table" type="TableType"/>                                                  +
-                                                                                               +
- </xsd:schema>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT schema_to_xml('testxmlschema', false, true, '');
-                             schema_to_xml                             
------------------------------------------------------------------------
- <testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-                                                                      +
- <test1>                                                              +
-   <a>1</a>                                                           +
-   <b>one</b>                                                         +
- </test1>                                                             +
-                                                                      +
- <test1>                                                              +
-   <a>2</a>                                                           +
-   <b>two</b>                                                         +
- </test1>                                                             +
-                                                                      +
- <test1>                                                              +
-   <a>-1</a>                                                          +
- </test1>                                                             +
-                                                                      +
-                                                                      +
- <test2>                                                              +
-   <z>55</z>                                                          +
-   <y>abc</y>                                                         +
-   <x>def   </x>                                                      +
-   <w>98.60</w>                                                       +
-   <v>2</v>                                                           +
-   <u>999</u>                                                         +
-   <t>0</t>                                                           +
-   <s>21:07:00</s>                                                    +
-   <r>2009-06-08T21:07:30</r>                                         +
-   <q>2009-06-08</q>                                                  +
-   <o>ABC</o>                                                         +
-   <n>true</n>                                                        +
-   <m>WFla</m>                                                        +
- </test2>                                                             +
-                                                                      +
-                                                                      +
- </testxmlschema>                                                     +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT schema_to_xml('testxmlschema', true, false, '');
-                             schema_to_xml                             
------------------------------------------------------------------------
- <testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-                                                                      +
- <test1>                                                              +
-                                                                      +
- <row>                                                                +
-   <a>1</a>                                                           +
-   <b>one</b>                                                         +
- </row>                                                               +
-                                                                      +
- <row>                                                                +
-   <a>2</a>                                                           +
-   <b>two</b>                                                         +
- </row>                                                               +
-                                                                      +
- <row>                                                                +
-   <a>-1</a>                                                          +
-   <b xsi:nil="true"/>                                                +
- </row>                                                               +
-                                                                      +
- </test1>                                                             +
-                                                                      +
- <test2>                                                              +
-                                                                      +
- <row>                                                                +
-   <z>55</z>                                                          +
-   <y>abc</y>                                                         +
-   <x>def   </x>                                                      +
-   <w>98.60</w>                                                       +
-   <v>2</v>                                                           +
-   <u>999</u>                                                         +
-   <t>0</t>                                                           +
-   <s>21:07:00</s>                                                    +
-   <r>2009-06-08T21:07:30</r>                                         +
-   <q>2009-06-08</q>                                                  +
-   <p xsi:nil="true"/>                                                +
-   <o>ABC</o>                                                         +
-   <n>true</n>                                                        +
-   <m>WFla</m>                                                        +
- </row>                                                               +
-                                                                      +
- </test2>                                                             +
-                                                                      +
- </testxmlschema>                                                     +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT schema_to_xmlschema('testxmlschema', false, true, '');
-                                                schema_to_xmlschema                                                
--------------------------------------------------------------------------------------------------------------------
- <xsd:schema                                                                                                      +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                                +
-                                                                                                                  +
- <xsd:simpleType name="INTEGER">                                                                                  +
-   <xsd:restriction base="xsd:int">                                                                               +
-     <xsd:maxInclusive value="2147483647"/>                                                                       +
-     <xsd:minInclusive value="-2147483648"/>                                                                      +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                                           +
-   <xsd:restriction base="xsd:string">                                                                            +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="VARCHAR">                                                                                  +
-   <xsd:restriction base="xsd:string">                                                                            +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="CHAR">                                                                                     +
-   <xsd:restriction base="xsd:string">                                                                            +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="NUMERIC">                                                                                  +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="SMALLINT">                                                                                 +
-   <xsd:restriction base="xsd:short">                                                                             +
-     <xsd:maxInclusive value="32767"/>                                                                            +
-     <xsd:minInclusive value="-32768"/>                                                                           +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="BIGINT">                                                                                   +
-   <xsd:restriction base="xsd:long">                                                                              +
-     <xsd:maxInclusive value="9223372036854775807"/>                                                              +
-     <xsd:minInclusive value="-9223372036854775808"/>                                                             +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="REAL">                                                                                     +
-   <xsd:restriction base="xsd:float"></xsd:restriction>                                                           +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="TIME">                                                                                     +
-   <xsd:restriction base="xsd:time">                                                                              +
-     <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/>                                              +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="TIMESTAMP">                                                                                +
-   <xsd:restriction base="xsd:dateTime">                                                                          +
-     <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/>                +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="DATE">                                                                                     +
-   <xsd:restriction base="xsd:date">                                                                              +
-     <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/>                                                         +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:complexType mixed="true">                                                                                   +
-   <xsd:sequence>                                                                                                 +
-     <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/>                         +
-   </xsd:sequence>                                                                                                +
- </xsd:complexType>                                                                                               +
-                                                                                                                  +
- <xsd:simpleType name="Domain.regression.public.testxmldomain">                                                   +
-   <xsd:restriction base="VARCHAR"/>                                                                              +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="BOOLEAN">                                                                                  +
-   <xsd:restriction base="xsd:boolean"></xsd:restriction>                                                         +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="UDT.regression.pg_catalog.bytea">                                                          +
-   <xsd:restriction base="xsd:base64Binary">                                                                      +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:complexType name="SchemaType.regression.testxmlschema">                                                     +
-   <xsd:sequence>                                                                                                 +
-     <xsd:element name="test1" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
-     <xsd:element name="test2" type="RowType.regression.testxmlschema.test2" minOccurs="0" maxOccurs="unbounded"/>+
-   </xsd:sequence>                                                                                                +
- </xsd:complexType>                                                                                               +
-                                                                                                                  +
- <xsd:element name="testxmlschema" type="SchemaType.regression.testxmlschema"/>                                   +
-                                                                                                                  +
- </xsd:schema>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT schema_to_xmlschema('testxmlschema', true, false, '');
-                                        schema_to_xmlschema                                        
----------------------------------------------------------------------------------------------------
- <xsd:schema                                                                                      +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                +
-                                                                                                  +
- <xsd:simpleType name="INTEGER">                                                                  +
-   <xsd:restriction base="xsd:int">                                                               +
-     <xsd:maxInclusive value="2147483647"/>                                                       +
-     <xsd:minInclusive value="-2147483648"/>                                                      +
-   </xsd:restriction>                                                                             +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                           +
-   <xsd:restriction base="xsd:string">                                                            +
-   </xsd:restriction>                                                                             +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:simpleType name="VARCHAR">                                                                  +
-   <xsd:restriction base="xsd:string">                                                            +
-   </xsd:restriction>                                                                             +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:simpleType name="CHAR">                                                                     +
-   <xsd:restriction base="xsd:string">                                                            +
-   </xsd:restriction>                                                                             +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:simpleType name="NUMERIC">                                                                  +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:simpleType name="SMALLINT">                                                                 +
-   <xsd:restriction base="xsd:short">                                                             +
-     <xsd:maxInclusive value="32767"/>                                                            +
-     <xsd:minInclusive value="-32768"/>                                                           +
-   </xsd:restriction>                                                                             +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:simpleType name="BIGINT">                                                                   +
-   <xsd:restriction base="xsd:long">                                                              +
-     <xsd:maxInclusive value="9223372036854775807"/>                                              +
-     <xsd:minInclusive value="-9223372036854775808"/>                                             +
-   </xsd:restriction>                                                                             +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:simpleType name="REAL">                                                                     +
-   <xsd:restriction base="xsd:float"></xsd:restriction>                                           +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:simpleType name="TIME">                                                                     +
-   <xsd:restriction base="xsd:time">                                                              +
-     <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/>                              +
-   </xsd:restriction>                                                                             +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:simpleType name="TIMESTAMP">                                                                +
-   <xsd:restriction base="xsd:dateTime">                                                          +
-     <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/>+
-   </xsd:restriction>                                                                             +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:simpleType name="DATE">                                                                     +
-   <xsd:restriction base="xsd:date">                                                              +
-     <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/>                                         +
-   </xsd:restriction>                                                                             +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:complexType mixed="true">                                                                   +
-   <xsd:sequence>                                                                                 +
-     <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/>         +
-   </xsd:sequence>                                                                                +
- </xsd:complexType>                                                                               +
-                                                                                                  +
- <xsd:simpleType name="Domain.regression.public.testxmldomain">                                   +
-   <xsd:restriction base="VARCHAR"/>                                                              +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:simpleType name="BOOLEAN">                                                                  +
-   <xsd:restriction base="xsd:boolean"></xsd:restriction>                                         +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:simpleType name="UDT.regression.pg_catalog.bytea">                                          +
-   <xsd:restriction base="xsd:base64Binary">                                                      +
-   </xsd:restriction>                                                                             +
- </xsd:simpleType>                                                                                +
-                                                                                                  +
- <xsd:complexType name="SchemaType.regression.testxmlschema">                                     +
-   <xsd:all>                                                                                      +
-     <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/>                  +
-     <xsd:element name="test2" type="TableType.regression.testxmlschema.test2"/>                  +
-   </xsd:all>                                                                                     +
- </xsd:complexType>                                                                               +
-                                                                                                  +
- <xsd:element name="testxmlschema" type="SchemaType.regression.testxmlschema"/>                   +
-                                                                                                  +
- </xsd:schema>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo');
-                                            schema_to_xml_and_xmlschema                                            
--------------------------------------------------------------------------------------------------------------------
- <testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo" xsi:schemaLocation="foo #">     +
-                                                                                                                  +
- <xsd:schema                                                                                                      +
-     xmlns:xsd="http://www.w3.org/2001/XMLSchema"                                                                 +
-     targetNamespace="foo"                                                                                        +
-     elementFormDefault="qualified">                                                                              +
-                                                                                                                  +
- <xsd:simpleType name="INTEGER">                                                                                  +
-   <xsd:restriction base="xsd:int">                                                                               +
-     <xsd:maxInclusive value="2147483647"/>                                                                       +
-     <xsd:minInclusive value="-2147483648"/>                                                                      +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="UDT.regression.pg_catalog.text">                                                           +
-   <xsd:restriction base="xsd:string">                                                                            +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="VARCHAR">                                                                                  +
-   <xsd:restriction base="xsd:string">                                                                            +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="CHAR">                                                                                     +
-   <xsd:restriction base="xsd:string">                                                                            +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="NUMERIC">                                                                                  +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="SMALLINT">                                                                                 +
-   <xsd:restriction base="xsd:short">                                                                             +
-     <xsd:maxInclusive value="32767"/>                                                                            +
-     <xsd:minInclusive value="-32768"/>                                                                           +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="BIGINT">                                                                                   +
-   <xsd:restriction base="xsd:long">                                                                              +
-     <xsd:maxInclusive value="9223372036854775807"/>                                                              +
-     <xsd:minInclusive value="-9223372036854775808"/>                                                             +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="REAL">                                                                                     +
-   <xsd:restriction base="xsd:float"></xsd:restriction>                                                           +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="TIME">                                                                                     +
-   <xsd:restriction base="xsd:time">                                                                              +
-     <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/>                                              +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="TIMESTAMP">                                                                                +
-   <xsd:restriction base="xsd:dateTime">                                                                          +
-     <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/>                +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="DATE">                                                                                     +
-   <xsd:restriction base="xsd:date">                                                                              +
-     <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/>                                                         +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:complexType mixed="true">                                                                                   +
-   <xsd:sequence>                                                                                                 +
-     <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/>                         +
-   </xsd:sequence>                                                                                                +
- </xsd:complexType>                                                                                               +
-                                                                                                                  +
- <xsd:simpleType name="Domain.regression.public.testxmldomain">                                                   +
-   <xsd:restriction base="VARCHAR"/>                                                                              +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="BOOLEAN">                                                                                  +
-   <xsd:restriction base="xsd:boolean"></xsd:restriction>                                                         +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:simpleType name="UDT.regression.pg_catalog.bytea">                                                          +
-   <xsd:restriction base="xsd:base64Binary">                                                                      +
-   </xsd:restriction>                                                                                             +
- </xsd:simpleType>                                                                                                +
-                                                                                                                  +
- <xsd:complexType name="SchemaType.regression.testxmlschema">                                                     +
-   <xsd:sequence>                                                                                                 +
-     <xsd:element name="test1" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
-     <xsd:element name="test2" type="RowType.regression.testxmlschema.test2" minOccurs="0" maxOccurs="unbounded"/>+
-   </xsd:sequence>                                                                                                +
- </xsd:complexType>                                                                                               +
-                                                                                                                  +
- <xsd:element name="testxmlschema" type="SchemaType.regression.testxmlschema"/>                                   +
-                                                                                                                  +
- </xsd:schema>                                                                                                    +
-                                                                                                                  +
- <test1>                                                                                                          +
-   <a>1</a>                                                                                                       +
-   <b>one</b>                                                                                                     +
- </test1>                                                                                                         +
-                                                                                                                  +
- <test1>                                                                                                          +
-   <a>2</a>                                                                                                       +
-   <b>two</b>                                                                                                     +
- </test1>                                                                                                         +
-                                                                                                                  +
- <test1>                                                                                                          +
-   <a>-1</a>                                                                                                      +
-   <b xsi:nil="true"/>                                                                                            +
- </test1>                                                                                                         +
-                                                                                                                  +
-                                                                                                                  +
- <test2>                                                                                                          +
-   <z>55</z>                                                                                                      +
-   <y>abc</y>                                                                                                     +
-   <x>def   </x>                                                                                                  +
-   <w>98.60</w>                                                                                                   +
-   <v>2</v>                                                                                                       +
-   <u>999</u>                                                                                                     +
-   <t>0</t>                                                                                                       +
-   <s>21:07:00</s>                                                                                                +
-   <r>2009-06-08T21:07:30</r>                                                                                     +
-   <q>2009-06-08</q>                                                                                              +
-   <p xsi:nil="true"/>                                                                                            +
-   <o>ABC</o>                                                                                                     +
-   <n>true</n>                                                                                                    +
-   <m>WFla</m>                                                                                                    +
- </test2>                                                                                                         +
-                                                                                                                  +
-                                                                                                                  +
- </testxmlschema>                                                                                                 +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 -- test that domains are transformed like their base types
 CREATE DOMAIN testboolxmldomain AS bool;
 CREATE DOMAIN testdatexmldomain AS date;
@@ -1221,21 +120,10 @@ CREATE TABLE testxmlschema.test3
               '2013-02-21'::date c3,
               '2013-02-21'::testdatexmldomain c4;
 SELECT xmlforest(c1, c2, c3, c4) FROM testxmlschema.test3;
-                            xmlforest                             
-------------------------------------------------------------------
- <c1>true</c1><c2>true</c2><c3>2013-02-21</c3><c4>2013-02-21</c4>
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
 SELECT table_to_xml('testxmlschema.test3', true, true, '');
-                         table_to_xml                          
----------------------------------------------------------------
- <test3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
-   <c1>true</c1>                                              +
-   <c2>true</c2>                                              +
-   <c3>2013-02-21</c3>                                        +
-   <c4>2013-02-21</c4>                                        +
- </test3>                                                     +
-                                                              +
- 
-(1 row)
-
+ERROR:  unsupported XML feature
+DETAIL:  This functionality requires the server to be built with libxml support.
+HINT:  You need to rebuild PostgreSQL using --with-libxml.
diff --git a/src/test/regress/output/tablespace.source b/src/test/regress/output/tablespace.source
index e7629d470e..42a38762ad 100644
--- a/src/test/regress/output/tablespace.source
+++ b/src/test/regress/output/tablespace.source
@@ -330,10 +330,10 @@ Indexes:
 Number of partitions: 2 (Use \d+ to list them.)
 
 \d+ testschema.part
-                           Partitioned table "testschema.part"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- a      | integer |           |          |         | plain   |              | 
+                                 Partitioned table "testschema.part"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ a      | integer |           |          |         |          | plain   |              | 
 Partition key: LIST (a)
 Indexes:
     "part_a_idx" btree (a), tablespace "regress_tblspace"
@@ -350,10 +350,10 @@ Indexes:
     "part1_a_idx" btree (a), tablespace "regress_tblspace"
 
 \d+ testschema.part1
-                                 Table "testschema.part1"
- Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
---------+---------+-----------+----------+---------+---------+--------------+-------------
- a      | integer |           |          |         | plain   |              | 
+                                      Table "testschema.part1"
+ Column |  Type   | Collation | Nullable | Default | Expanded | Storage | Stats target | Description 
+--------+---------+-----------+----------+---------+----------+---------+--------------+-------------
+ a      | integer |           |          |         |          | plain   |              | 
 Partition of: testschema.part FOR VALUES IN (1)
 Partition constraint: ((a IS NOT NULL) AND (a = 1))
 Indexes:
diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule
index 7be89178f0..e1ef99df15 100644
--- a/src/test/regress/parallel_schedule
+++ b/src/test/regress/parallel_schedule
@@ -58,7 +58,7 @@ test: create_index create_index_spgist create_view index_including index_includi
 # ----------
 # Another group of parallel tests
 # ----------
-test: create_aggregate create_function_3 create_cast constraints triggers select inherit typed_table vacuum drop_if_exists updatable_views roleattributes create_am hash_func errors infinite_recurse
+test: create_aggregate create_function_3 create_cast constraints triggers select inherit typed_table vacuum drop_if_exists updatable_views roleattributes create_am hash_func errors infinite_recurse unexpanded
 
 # ----------
 # sanity_check does a vacuum, affecting the sort order of SELECT *
diff --git a/src/test/regress/sql/unexpanded.sql b/src/test/regress/sql/unexpanded.sql
new file mode 100644
index 0000000000..5c83fab3e6
--- /dev/null
+++ b/src/test/regress/sql/unexpanded.sql
@@ -0,0 +1,275 @@
+-- sanity check of system catalog
+SELECT attrelid, attname, attisunexpanded FROM pg_attribute WHERE attisunexpanded;
+
+
+CREATE TABLE htest0 (a int PRIMARY KEY, b text NOT NULL);
+ALTER TABLE htest0 ALTER COLUMN b SET UNEXPANDED;
+INSERT INTO htest0 (a, b) VALUES (1, 'htest0 one');
+INSERT INTO htest0 (a, b) VALUES (2, 'htest0 two');
+-- we do not allow that all columns of a relation be unexpanded
+ALTER TABLE htest0 ALTER COLUMN a SET UNEXPANDED; -- error
+CREATE TABLE htest1 (a bigserial PRIMARY KEY, b text);
+ALTER TABLE htest1 ALTER COLUMN a SET UNEXPANDED;
+-- Insert without named column must not include the unexpanded column
+INSERT INTO htest1 VALUES ('htest1 one');
+INSERT INTO htest1 VALUES ('htest1 two');
+-- INSERT + SELECT * should handle the unexpanded column
+CREATE TABLE htest1_1 (a bigserial PRIMARY KEY, b text);
+ALTER TABLE htest1_1 ALTER COLUMN a SET UNEXPANDED;
+INSERT INTO htest1_1 VALUES ('htest1 one');
+WITH cte AS (
+	DELETE FROM htest1_1 RETURNING *
+) SELECT * FROM cte;
+INSERT INTO htest1_1 SELECT * FROM htest0;
+SELECT a, b FROM htest1_1;
+DROP TABLE htest1_1;
+
+SELECT attrelid::regclass, attname, attisunexpanded FROM pg_attribute WHERE attisunexpanded;
+
+\d+ htest1
+
+-- DROP/SET unexpanded attribute
+ALTER TABLE htest0 ALTER COLUMN b DROP UNEXPANDED;
+
+\d+ htest0
+
+ALTER TABLE htest0 ALTER COLUMN b SET UNEXPANDED;
+
+-- Hidden column are not expandable and must not be returned
+SELECT * FROM htest0; -- return only column a
+SELECT t.* FROM htest1 t; -- return only column b
+-- the whole-row syntax do not take care of the unexpanded attribute
+SELECT t FROM htest1 t; -- return column a and b
+
+-- CTEs based on SELECT * only have visible column returned
+WITH foo AS (SELECT * FROM htest1) SELECT * FROM foo; -- Only column b is returned here
+
+-- Use of wildcard or whole-row in a function do not apply the unexpanded attribute
+SELECT row_to_json(t.*) FROM htest0 t;
+SELECT row_to_json(t) FROM htest0 t;
+
+-- inheritance, the unexpanded attribute is inherited
+CREATE TABLE htest1_1 () INHERITS (htest1);
+SELECT * FROM htest1_1;
+\d htest1_1
+INSERT INTO htest1_1 VALUES ('htest1 three');
+SELECT * FROM htest1_1;
+SELECT * FROM htest1;
+
+-- unexpanded column must be explicitely named to be returned
+SELECT a,b FROM htest1_1;
+SELECT a,b FROM htest1;
+DROP TABLE htest1_1;
+
+-- Default CREATE TABLE ... LIKE includes unexpanded columns, and they are not uinexpanded in the new table.
+CREATE TABLE htest_like1 (LIKE htest1);
+\d+ htest_like1
+-- CREATE TABLE ... LIKE includes unexpanded columns, and they are unexpanded if requested
+CREATE TABLE htest_like2 (LIKE htest1 INCLUDING UNEXPANDED);
+\d+ htest_like2
+CREATE TABLE htest_like3 (LIKE htest1 INCLUDING ALL);
+\d+ htest_like3
+DROP TABLE htest_like1, htest_like2, htest_like3;
+
+-- Insert without named column with and a not null unexpanded column must have a default value
+INSERT INTO htest0 VALUES (3); -- error
+ALTER TABLE htest0 ALTER COLUMN b SET DEFAULT 'unknown';
+INSERT INTO htest0 VALUES (3);
+-- Same with COPY
+COPY htest0 TO stdout;
+COPY htest0 (a, b) TO stdout;
+COPY htest0 FROM stdin;
+4
+5
+\.
+SELECT a,b FROM htest0;
+
+-- same but with drop/add the column between unexpanded columns (virtual columns can be made unexpanded)
+CREATE TABLE htest2 (a serial, b int, c int GENERATED ALWAYS AS (a * 2) STORED);
+ALTER TABLE htest2 ALTER COLUMN a SET UNEXPANDED;
+ALTER TABLE htest2 ALTER COLUMN c SET UNEXPANDED;
+SELECT * FROM htest2;
+INSERT INTO htest2 VALUES (2);
+SELECT a,b,c FROM htest2;
+ALTER TABLE htest2 DROP COLUMN b;
+ALTER TABLE htest2 ADD COLUMN b int;
+INSERT INTO htest2 VALUES (4);
+SELECT a,b,c FROM htest2;
+DROP TABLE htest2 CASCADE;
+
+-- a table can NOT have all columns unexpanded
+CREATE TABLE htest3 (a serial, b int);
+ALTER TABLE htest3
+    ALTER COLUMN a SET UNEXPANDED,
+    ALTER COLUMN b SET UNEXPANDED; -- error
+DROP TABLE htest3;
+
+-- inheritance with an additional single unexpanded column is possible
+CREATE TABLE htest3 (a serial, b int);
+ALTER TABLE htest3 ALTER COLUMN a SET UNEXPANDED;
+SELECT * FROM htest3;
+CREATE TABLE htest3_1 (c int) INHERITS (htest3);
+ALTER TABLE htest3_1 ALTER COLUMN c SET UNEXPANDED;
+SELECT * FROM htest3_1;
+\d+ htest3_1
+DROP TABLE htest3_1, htest3;
+
+-- Ordering do not include the unexpanded column
+CREATE TABLE t1 (col1 integer NOT NULL, col2 integer);
+ALTER TABLE t1 ALTER COLUMN col1 SET UNEXPANDED;
+INSERT INTO t1 (col1, col2) VALUES (1, 6), (3, 4);
+SELECT * FROM t1 ORDER BY 1 DESC;
+SELECT col1,col2 FROM t1 ORDER BY 2 DESC;
+-- unless it is called explicitly
+SELECT * FROM t1 ORDER BY col1 DESC;
+DROP TABLE t1;
+
+-- A table can be partitioned by an unexpanded column
+CREATE TABLE measurement (
+	city_id         int not null,
+	logdate         date not null,
+	peaktemp        int,
+	unitsales       int
+) PARTITION BY RANGE (logdate);
+ALTER TABLE measurement ALTER COLUMN logdate SET UNEXPANDED;
+CREATE TABLE measurement_y2006m02 PARTITION OF measurement
+    FOR VALUES FROM ('2021-01-01') TO ('2021-03-01');
+CREATE TABLE measurement_y2006m03 PARTITION OF measurement
+    FOR VALUES FROM ('2021-03-01') TO ('2021-05-01');
+INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-02-28', 34, 4);
+INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-04-12', 42, 6);
+EXPLAIN VERBOSE SELECT * FROM measurement;
+SELECT * FROM measurement;
+SELECT city_id, logdate, peaktemp, unitsales FROM measurement;
+DROP TABLE measurement CASCADE;
+-- Same but unitsales is unexpanded instead of the partition key
+CREATE TABLE measurement (
+	city_id         int not null,
+	logdate         date not null,
+	peaktemp        int,
+	unitsales       int
+) PARTITION BY RANGE (logdate);
+ALTER TABLE measurement ALTER COLUMN unitsales SET UNEXPANDED;
+CREATE TABLE measurement_y2006m02 PARTITION OF measurement
+    FOR VALUES FROM ('2021-01-01') TO ('2021-03-01');
+CREATE TABLE measurement_y2006m03 PARTITION OF measurement
+    FOR VALUES FROM ('2021-03-01') TO ('2021-05-01');
+INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-02-28', 34, 4);
+INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-04-12', 42, 6);
+EXPLAIN VERBOSE SELECT * FROM measurement;
+SELECT * FROM measurement;
+SELECT city_id, logdate, peaktemp, unitsales FROM measurement;
+SELECT * FROM measurement_y2006m03;
+DROP TABLE measurement CASCADE;
+
+-- Temporary tables can have invisible columns too.
+CREATE TEMPORARY TABLE htest_tmp (col1 integer NOT NULL, col2 integer);
+ALTER TABLE htest_tmp ALTER COLUMN col1 SET UNEXPANDED;
+INSERT INTO htest_tmp (col1, col2) VALUES (1, 6), (3, 4);
+SELECT * FROM htest_tmp ORDER BY 1 DESC;
+DROP TABLE htest_tmp;
+
+-- A table can use a composite type as an unexpanded column
+CREATE TYPE compfoo AS (f1 int, f2 text);
+CREATE TABLE htest4 (
+    a int,
+    b compfoo
+);
+ALTER TABLE htest4 ALTER COLUMN b SET UNEXPANDED;
+SELECT * FROM htest4;
+DROP TABLE htest4;
+DROP TYPE compfoo;
+
+-- Foreign key constraints can be defined on unexpanded columns, or unexpanded columns can be referenced.
+CREATE TABLE t1 (col1 integer UNIQUE, col2 integer);
+ALTER TABLE t1 ALTER COLUMN col1 SET UNEXPANDED;
+CREATE TABLE t2 (col1 integer PRIMARY KEY, col2 integer);
+ALTER TABLE t2 ALTER COLUMN col1 SET UNEXPANDED;
+ALTER TABLE t1 ADD CONSTRAINT fk_t1_col1 FOREIGN KEY (col1) REFERENCES t2(col1);
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_col1 FOREIGN KEY (col1) REFERENCES t1(col1);
+DROP TABLE t1, t2 CASCADE;
+
+-- CHECK constraints can be defined on invisible columns.
+CREATE TABLE t1 (col1 integer CHECK (col1 > 2), col2 integer NOT NULL);
+ALTER TABLE t1 ALTER COLUMN col1 SET UNEXPANDED;
+INSERT INTO t1 (col1, col2) VALUES (1, 6); -- error
+INSERT INTO t1 (col1, col2) VALUES (3, 6);
+-- An index can reference a unexpanded column
+CREATE INDEX ON t1 (col1);
+ALTER TABLE t1
+  ALTER COLUMN col1 TYPE bigint,
+  ALTER COLUMN col1 DROP UNEXPANDED,
+  ALTER COLUMN col2 SET UNEXPANDED;
+\d+ t1
+DROP TABLE t1;
+
+-- View must not include the unexpanded column when not explicitly listed
+CREATE VIEW viewt1 AS SELECT * FROM htest1;
+\d viewt1
+SELECT * FROM viewt1;
+-- If the unexpanded attribute on the column is removed the view result must not change
+ALTER TABLE htest1 ALTER COLUMN a DROP UNEXPANDED;
+SELECT * FROM viewt1;
+ALTER TABLE htest1 ALTER COLUMN a SET UNEXPANDED;
+DROP VIEW viewt1;
+-- Materialized view must include the unexpanded column when explicitly listed
+-- but the column is not unexpanded in the materialized view.
+CREATE VIEW viewt1 AS SELECT a, b FROM htest1;
+\d viewt1
+SELECT * FROM viewt1;
+
+-- Materialized view must not include the unexpanded column when not explicitly listed
+CREATE MATERIALIZED VIEW mviewt1 AS SELECT * FROM htest1;
+\d mviewt1
+REFRESH MATERIALIZED VIEW mviewt1;
+SELECT * FROM mviewt1;
+DROP MATERIALIZED VIEW mviewt1;
+-- Materialized view must include the unexpanded column when explicitly listed
+-- but the column is not unexpanded in the materialized view.
+CREATE MATERIALIZED VIEW mviewt1 AS SELECT a, b FROM htest1;
+\d mviewt1
+REFRESH MATERIALIZED VIEW mviewt1;
+SELECT * FROM mviewt1;
+
+-- typed tables with unexpanded column is not supported
+CREATE TYPE htest_type AS (f1 integer, f2 text, f3 bigint);
+CREATE TABLE htest28 OF htest_type (f1 WITH OPTIONS DEFAULT 3);
+ALTER TABLE htest28 ALTER COLUMN f1 SET UNEXPANDED; -- error
+DROP TYPE htest_type CASCADE;
+
+-- Prepared statements
+PREPARE q1 AS SELECT * FROM htest1 WHERE a > $1;
+EXECUTE q1(0);
+ALTER TABLE htest1 ALTER COLUMN a DROP UNEXPANDED;
+EXECUTE q1(0); -- error: cached plan change result type
+ALTER TABLE htest1 ALTER COLUMN a SET UNEXPANDED;
+EXECUTE q1(0);
+DEALLOCATE q1;
+
+
+-- SELECT * INTO and RETURNING * INTO has the same
+-- behavior, the unexpanded column is not returned.
+CREATE OR REPLACE PROCEDURE test_plpgsq_returning (p_a integer)
+AS $$
+DECLARE
+    v_lbl text;
+BEGIN
+    SELECT * INTO v_lbl FROM htest1 WHERE a = p_a;
+    RAISE NOTICE 'SELECT INTO Col b : %', v_lbl;
+
+    DELETE FROM htest1 WHERE a = p_a
+        RETURNING * INTO v_lbl; 
+    IF FOUND THEN
+	RAISE NOTICE 'RETURNING INTO Col b : %', v_lbl;
+    ELSE
+        RAISE NOTICE 'Noting found';
+    END IF;
+END
+$$
+LANGUAGE plpgsql;
+
+CALL test_plpgsq_returning(1);
+
+-- Cleanup
+DROP TABLE htest0, htest1 CASCADE;
+
