@@ -570,3 +570,46 @@ SELECT relname, bar.* FROM bar, pg_class where bar.tableoid = pg_class.oid;
570570 bar2 | 3 | 103
571571(8 rows)
572572
573+ /* Test inheritance of structure (LIKE) */
574+ CREATE TABLE inhx (xx text DEFAULT 'text');
575+ /*
576+ * Test double inheritance
577+ *
578+ * Ensure that defaults are NOT included unless
579+ * INCLUDING DEFAULTS is specified
580+ */
581+ CREATE TABLE inhe (ee text, LIKE inhx) inherits (b);
582+ INSERT INTO inhe VALUES ('ee-col1', 'ee-col2', DEFAULT, 'ee-col4');
583+ SELECT * FROM inhe; /* Columns aa, bb, xx value NULL, ee */
584+ aa | bb | ee | xx
585+ ---------+---------+----+---------
586+ ee-col1 | ee-col2 | | ee-col4
587+ (1 row)
588+
589+ SELECT * FROM inhx; /* Empty set since LIKE inherits structure only */
590+ xx
591+ ----
592+ (0 rows)
593+
594+ SELECT * FROM b; /* Has ee entry */
595+ aa | bb
596+ ---------+---------
597+ ee-col1 | ee-col2
598+ (1 row)
599+
600+ SELECT * FROM a; /* Has ee entry */
601+ aa
602+ ---------
603+ ee-col1
604+ (1 row)
605+
606+ CREATE TABLE inhf (LIKE inhx, LIKE inhx); /* Throw error */
607+ ERROR: CREATE TABLE: attribute "xx" duplicated
608+ CREATE TABLE inhf (LIKE inhx INCLUDING DEFAULTS);
609+ INSERT INTO inhf DEFAULT VALUES;
610+ SELECT * FROM inhf; /* Single entry with value 'text' */
611+ xx
612+ ------
613+ text
614+ (1 row)
615+