mirror of
https://github.com/postgres/postgres.git
synced 2025-12-12 02:37:31 +03:00
Includes:
- LIKE <subtable> [ INCLUDING DEFAULTS | EXCLUDING DEFAULTS ] - Quick cleanup of analyze.c function prototypes. - New non-reserved keywords (INCLUDING, EXCLUDING, DEFAULTS), SQL 200X Opted not to extend for check constraints at this time. As per the definition that it's user defined columns, OIDs are NOT inherited. Doc and Source patches attached. -- Rod Taylor <rbt@rbt.ca>
This commit is contained in:
@@ -570,3 +570,46 @@ SELECT relname, bar.* FROM bar, pg_class where bar.tableoid = pg_class.oid;
|
||||
bar2 | 3 | 103
|
||||
(8 rows)
|
||||
|
||||
/* Test inheritance of structure (LIKE) */
|
||||
CREATE TABLE inhx (xx text DEFAULT 'text');
|
||||
/*
|
||||
* Test double inheritance
|
||||
*
|
||||
* Ensure that defaults are NOT included unless
|
||||
* INCLUDING DEFAULTS is specified
|
||||
*/
|
||||
CREATE TABLE inhe (ee text, LIKE inhx) inherits (b);
|
||||
INSERT INTO inhe VALUES ('ee-col1', 'ee-col2', DEFAULT, 'ee-col4');
|
||||
SELECT * FROM inhe; /* Columns aa, bb, xx value NULL, ee */
|
||||
aa | bb | ee | xx
|
||||
---------+---------+----+---------
|
||||
ee-col1 | ee-col2 | | ee-col4
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM inhx; /* Empty set since LIKE inherits structure only */
|
||||
xx
|
||||
----
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM b; /* Has ee entry */
|
||||
aa | bb
|
||||
---------+---------
|
||||
ee-col1 | ee-col2
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM a; /* Has ee entry */
|
||||
aa
|
||||
---------
|
||||
ee-col1
|
||||
(1 row)
|
||||
|
||||
CREATE TABLE inhf (LIKE inhx, LIKE inhx); /* Throw error */
|
||||
ERROR: CREATE TABLE: attribute "xx" duplicated
|
||||
CREATE TABLE inhf (LIKE inhx INCLUDING DEFAULTS);
|
||||
INSERT INTO inhf DEFAULT VALUES;
|
||||
SELECT * FROM inhf; /* Single entry with value 'text' */
|
||||
xx
|
||||
------
|
||||
text
|
||||
(1 row)
|
||||
|
||||
|
||||
@@ -609,6 +609,9 @@ SELECT user_relns() AS user_relns
|
||||
iexit
|
||||
ihighway
|
||||
inet_tbl
|
||||
inhe
|
||||
inhf
|
||||
inhx
|
||||
insert_seq
|
||||
insert_tbl
|
||||
int2_tbl
|
||||
@@ -657,7 +660,7 @@ SELECT user_relns() AS user_relns
|
||||
toyemp
|
||||
varchar_tbl
|
||||
xacttest
|
||||
(93 rows)
|
||||
(96 rows)
|
||||
|
||||
--SELECT name(equipment(hobby_construct(text 'skywalking', text 'mer'))) AS equip_name;
|
||||
SELECT hobbies_by_name('basketball');
|
||||
|
||||
@@ -119,3 +119,26 @@ insert into bar2 values(4,4,4);
|
||||
update bar set f2 = f2 + 100 where f1 in (select f1 from foo);
|
||||
|
||||
SELECT relname, bar.* FROM bar, pg_class where bar.tableoid = pg_class.oid;
|
||||
|
||||
|
||||
/* Test inheritance of structure (LIKE) */
|
||||
CREATE TABLE inhx (xx text DEFAULT 'text');
|
||||
|
||||
/*
|
||||
* Test double inheritance
|
||||
*
|
||||
* Ensure that defaults are NOT included unless
|
||||
* INCLUDING DEFAULTS is specified
|
||||
*/
|
||||
CREATE TABLE inhe (ee text, LIKE inhx) inherits (b);
|
||||
INSERT INTO inhe VALUES ('ee-col1', 'ee-col2', DEFAULT, 'ee-col4');
|
||||
SELECT * FROM inhe; /* Columns aa, bb, xx value NULL, ee */
|
||||
SELECT * FROM inhx; /* Empty set since LIKE inherits structure only */
|
||||
SELECT * FROM b; /* Has ee entry */
|
||||
SELECT * FROM a; /* Has ee entry */
|
||||
|
||||
CREATE TABLE inhf (LIKE inhx, LIKE inhx); /* Throw error */
|
||||
|
||||
CREATE TABLE inhf (LIKE inhx INCLUDING DEFAULTS);
|
||||
INSERT INTO inhf DEFAULT VALUES;
|
||||
SELECT * FROM inhf; /* Single entry with value 'text' */
|
||||
|
||||
Reference in New Issue
Block a user