Use CSV foreign data wrapper for tests of CREATE FOREIGN TABLE.
authorShigeru Hanada <[email protected]>
Thu, 14 Oct 2010 08:09:16 +0000 (17:09 +0900)
committerShigeru Hanada <[email protected]>
Thu, 14 Oct 2010 08:09:16 +0000 (17:09 +0900)
It makes all regression tests pass.

src/test/regress/expected/foreign_data.out
src/test/regress/sql/foreign_data.sql

index b1c0c91104e66b5e1380ddf5a01ce194e4569e8f..af2cb7923a6c7358580f258eba1498fc5c7c44e4 100644 (file)
@@ -367,6 +367,7 @@ CREATE SERVER t2 FOREIGN DATA WRAPPER foo;
 
 RESET ROLE;
 REVOKE regress_test_indirect FROM regress_test_role;
+CREATE SERVER sc FOREIGN DATA WRAPPER csv;
 -- ALTER SERVER
 ALTER SERVER s0;                                            -- ERROR
 ERROR:  syntax error at or near ";"
@@ -393,9 +394,10 @@ GRANT USAGE ON FOREIGN SERVER s6 TO regress_test_role2 WITH GRANT OPTION;
       |                   |                      | regress_test_role2=U*/foreign_data_user |        |         | 
  s7   | foreign_data_user | foo                  |                                         | oracle | 17.0    | {host=a,dbname=b}
  s8   | foreign_data_user | postgresql           |                                         |        |         | {host=localhost,dbname=s8db}
+ sc   | foreign_data_user | csv                  |                                         |        |         | 
  t1   | regress_test_role | foo                  |                                         |        |         | 
  t2   | regress_test_role | foo                  |                                         |        |         | 
-(10 rows)
+(11 rows)
 
 SET ROLE regress_test_role;
 ALTER SERVER s1 VERSION '1.1';                              -- ERROR
@@ -444,9 +446,10 @@ privileges for foreign-data wrapper foo
       |                       |                      | regress_test_role2=U*/foreign_data_user |        |         | 
  s7   | foreign_data_user     | foo                  |                                         | oracle | 17.0    | {host=a,dbname=b}
  s8   | foreign_data_user     | postgresql           |                                         |        |         | {dbname=db1,connect_timeout=30}
+ sc   | foreign_data_user     | csv                  |                                         |        |         | 
  t1   | regress_test_role     | foo                  |                                         |        |         | 
  t2   | regress_test_role     | foo                  |                                         |        |         | 
-(10 rows)
+(11 rows)
 
 -- DROP SERVER
 DROP SERVER nonexistent;                                    -- ERROR
@@ -465,9 +468,10 @@ NOTICE:  server "nonexistent" does not exist, skipping
  s6   | foreign_data_user     | foo
  s7   | foreign_data_user     | foo
  s8   | foreign_data_user     | postgresql
+ sc   | foreign_data_user     | csv
  t1   | regress_test_role     | foo
  t2   | regress_test_role     | foo
-(10 rows)
+(11 rows)
 
 SET ROLE regress_test_role;
 DROP SERVER s2;                                             -- ERROR
@@ -485,9 +489,10 @@ RESET ROLE;
  s6   | foreign_data_user | foo
  s7   | foreign_data_user | foo
  s8   | foreign_data_user | postgresql
+ sc   | foreign_data_user | csv
  t1   | regress_test_role | foo
  t2   | regress_test_role | foo
-(9 rows)
+(10 rows)
 
 ALTER SERVER s2 OWNER TO regress_test_role;
 SET ROLE regress_test_role;
@@ -503,9 +508,10 @@ RESET ROLE;
  s6   | foreign_data_user | foo
  s7   | foreign_data_user | foo
  s8   | foreign_data_user | postgresql
+ sc   | foreign_data_user | csv
  t1   | regress_test_role | foo
  t2   | regress_test_role | foo
-(8 rows)
+(9 rows)
 
 CREATE USER MAPPING FOR current_user SERVER s3;
 \deu
@@ -530,9 +536,10 @@ NOTICE:  drop cascades to user mapping for foreign_data_user
  s6   | foreign_data_user | foo
  s7   | foreign_data_user | foo
  s8   | foreign_data_user | postgresql
+ sc   | foreign_data_user | csv
  t1   | regress_test_role | foo
  t2   | regress_test_role | foo
-(7 rows)
+(8 rows)
 
 \deu
 List of user mappings
@@ -563,6 +570,7 @@ ERROR:  permission denied for foreign server s7
 CREATE USER MAPPING FOR public SERVER s8;                   -- ERROR
 ERROR:  must be owner of foreign server s8
 RESET ROLE;
+CREATE USER MAPPING FOR public SERVER sc;
 ALTER SERVER t1 OWNER TO regress_test_indirect;
 SET ROLE regress_test_role;
 CREATE USER MAPPING FOR current_user SERVER t1 OPTIONS (username 'bob', password 'boo');
@@ -577,9 +585,10 @@ RESET ROLE;
  s5     | regress_test_role
  s6     | regress_test_role
  s8     | foreign_data_user
+ sc     | public
  t1     | public
  t1     | regress_test_role
-(7 rows)
+(8 rows)
 
 -- ALTER USER MAPPING
 ALTER USER MAPPING FOR regress_test_missing_role SERVER s4 OPTIONS (gotcha 'true'); -- ERROR
@@ -607,9 +616,10 @@ RESET ROLE;
  s5     | regress_test_role | {modified=1}
  s6     | regress_test_role | {username=test}
  s8     | foreign_data_user | {password=public}
+ sc     | public            | 
  t1     | public            | {modified=1}
  t1     | regress_test_role | {username=bob,password=boo}
-(7 rows)
+(8 rows)
 
 -- DROP USER MAPPING
 DROP USER MAPPING FOR regress_test_missing_role SERVER s4;  -- ERROR
@@ -640,9 +650,10 @@ DROP SERVER s7;
  s6     | regress_test_role
  s8     | foreign_data_user
  s8     | public
+ sc     | public
  t1     | public
  t1     | regress_test_role
-(8 rows)
+(9 rows)
 
 -- CREATE FOREIGN TABLE
 CREATE TABLE t1 (
@@ -659,13 +670,13 @@ LINE 2: CREATE FOREIGN TABLE ft1 ();
         ^
 CREATE FOREIGN TABLE ft1 () SERVER no_server;                   -- ERROR
 ERROR:  server "no_server" does not exist
-CREATE FOREIGN TABLE ft1 () INHERITS () SERVER s4;              -- ERROR
+CREATE FOREIGN TABLE ft1 () INHERITS () SERVER sc;              -- ERROR
 ERROR:  syntax error at or near ")"
-LINE 1: CREATE FOREIGN TABLE ft1 () INHERITS () SERVER s4;
+LINE 1: CREATE FOREIGN TABLE ft1 () INHERITS () SERVER sc;
                                               ^
-CREATE FOREIGN TABLE ft1 () INHERITS (no_table) SERVER s4;      -- ERROR
+CREATE FOREIGN TABLE ft1 () INHERITS (no_table) SERVER sc;      -- ERROR
 ERROR:  relation "no_table" does not exist
-CREATE FOREIGN TABLE ft1 (c1 serial) SERVER s4;                 -- ERROR
+CREATE FOREIGN TABLE ft1 (c1 serial) SERVER sc;                 -- ERROR
 NOTICE:  CREATE TABLE will create implicit sequence "ft1_c1_seq" for serial column "ft1.c1"
 ERROR:  referenced relation "ft1" is not a table
 CREATE FOREIGN TABLE ft1 (
@@ -673,7 +684,7 @@ CREATE FOREIGN TABLE ft1 (
    c2 text DEFAULT 'foo',
    c3 date CHECK (c3 > '2000-01-01'::date),
    CONSTRAINT ft1_c1_check CHECK (c1 > 0)
-) SERVER s4 OPTIONS (opt1 'val1', opt2 'val2');
+) SERVER sc OPTIONS (delimiter ',', quote '"');
 CREATE RULE ft1_insert_rule AS ON INSERT TO ft1 DO INSTEAD
    INSERT INTO t1 VALUES (new.c1, new.c2, new.c3);
 \d+ ft1
@@ -690,10 +701,10 @@ Rules:
     ft1_insert_rule AS
     ON INSERT TO ft1 DO INSTEAD  INSERT INTO t1 (c1, c2, c3) 
   VALUES (new.c1, new.c2, new.c3)
-Server: s4
+Server: sc
 Has OIDs: no
 
-CREATE FOREIGN TABLE ft2 () INHERITS (t1) SERVER s4 WITH OIDS OPTIONS (opt1 'val1', opt2 'val2');
+CREATE FOREIGN TABLE ft2 () INHERITS (t1) SERVER sc WITH OIDS OPTIONS (delimiter ' ', quote '`');
 \d+ ft2
                    Foreign table "public.ft2"
  Column |  Type   |      Modifiers      | Storage  | Description 
@@ -704,16 +715,16 @@ CREATE FOREIGN TABLE ft2 () INHERITS (t1) SERVER s4 WITH OIDS OPTIONS (opt1 'val
 Check constraints:
     "t1_c1_check" CHECK (c1 > 0)
     "t1_c3_check" CHECK (c3 > '01-01-2000'::date)
-Server: s4
+Server: sc
 Inherits: t1
 Has OIDs: yes
 
 \det+
-         List of foreign tables
- Table | Server |        Options        
--------+--------+-----------------------
- ft1   | s4     | {opt1=val1,opt2=val2}
- ft2   | s4     | {opt1=val1,opt2=val2}
+           List of foreign tables
+ Table | Server |          Options           
+-------+--------+----------------------------
+ ft1   | sc     | {"delimiter=,","quote=\""}
+ ft2   | sc     | {"delimiter= ",quote=`}
 (2 rows)
 
 CREATE INDEX id_ft1_c2 ON ft1 (c2);                             -- ERROR
@@ -755,7 +766,7 @@ ALTER FOREIGN TABLE ft1 DISABLE RULE ft1_insert_rule;
 ALTER FOREIGN TABLE ft1 INHERIT t2;
 ALTER FOREIGN TABLE ft1 NO INHERIT t2;
 ALTER FOREIGN TABLE ft1 OWNER TO regress_test_role;
-ALTER FOREIGN TABLE ft1 OPTIONS (DROP opt1, SET opt2 'VAL2', ADD opt3 'val3');
+ALTER FOREIGN TABLE ft1 OPTIONS (DROP delimiter, SET quote '~', ADD escape '@');
 ALTER FOREIGN TABLE ft1 DROP COLUMN no_column;                  -- ERROR
 ERROR:  column "no_column" of relation "ft1" does not exist
 ALTER FOREIGN TABLE ft1 DROP COLUMN IF EXISTS no_column;
@@ -787,7 +798,7 @@ Disabled rules:
     ft1_insert_rule AS
     ON INSERT TO foreign_schema.foreign_table_1 DO INSTEAD  INSERT INTO t1 (c1, c2, c3) 
   VALUES (new.foreign_column_1, new.c2, new.c3)
-Server: s4
+Server: sc
 
 -- DROP FOREIGN TABLE
 DROP FOREIGN TABLE no_table;                                    -- ERROR
@@ -818,9 +829,10 @@ SELECT * FROM information_schema.foreign_servers ORDER BY 1, 2;
  regression             | s5                  | regression                   | foo                       |                     | 15.0                   | regress_test_role
  regression             | s6                  | regression                   | foo                       |                     | 16.0                   | regress_test_indirect
  regression             | s8                  | regression                   | postgresql                |                     |                        | foreign_data_user
+ regression             | sc                  | regression                   | csv                       |                     |                        | foreign_data_user
  regression             | t1                  | regression                   | foo                       |                     |                        | regress_test_indirect
  regression             | t2                  | regression                   | foo                       |                     |                        | regress_test_role
-(6 rows)
+(7 rows)
 
 SELECT * FROM information_schema.foreign_server_options ORDER BY 1, 2, 3;
  foreign_server_catalog | foreign_server_name |   option_name   | option_value 
@@ -840,11 +852,12 @@ SELECT * FROM information_schema.user_mappings ORDER BY lower(authorization_iden
  foreign_data_user        | regression             | s8
  PUBLIC                   | regression             | s4
  PUBLIC                   | regression             | s8
+ PUBLIC                   | regression             | sc
  PUBLIC                   | regression             | t1
  regress_test_role        | regression             | s5
  regress_test_role        | regression             | s6
  regress_test_role        | regression             | t1
-(8 rows)
+(9 rows)
 
 SELECT * FROM information_schema.user_mapping_options ORDER BY lower(authorization_identifier), 2, 3, 4;
  authorization_identifier | foreign_server_catalog | foreign_server_name | option_name | option_value 
@@ -879,14 +892,14 @@ SELECT * FROM information_schema.role_usage_grants WHERE object_type LIKE 'FOREI
 SELECT * FROM information_schema.foreign_tables ORDER BY 1, 2, 3;
  foreign_table_catalog | foreign_table_schema | foreign_table_name | foreign_server_catalog | foreign_server_name 
 -----------------------+----------------------+--------------------+------------------------+---------------------
- regression            | public               | ft2                | regression             | s4
+ regression            | public               | ft2                | regression             | sc
 (1 row)
 
 SELECT * FROM information_schema.foreign_table_options ORDER BY 1, 2, 3, 4;
  foreign_table_catalog | foreign_table_schema | foreign_table_name | option_name | option_value 
 -----------------------+----------------------+--------------------+-------------+--------------
- regression            | public               | ft2                | opt1        | val1
- regression            | public               | ft2                | opt2        | val2
+ regression            | public               | ft2                | delimiter   |  
+ regression            | public               | ft2                | quote       | `
 (2 rows)
 
 SET ROLE regress_test_role;
@@ -1159,6 +1172,9 @@ REVOKE ALL ON FOREIGN DATA WRAPPER postgresql FROM unprivileged_role;
 DROP ROLE unprivileged_role;
 DROP ROLE regress_test_role2;
 DROP FOREIGN DATA WRAPPER csv CASCADE;
+NOTICE:  drop cascades to 2 other objects
+DETAIL:  drop cascades to server sc
+drop cascades to user mapping for public
 DROP FOREIGN DATA WRAPPER postgresql CASCADE;
 DROP FOREIGN DATA WRAPPER dummy CASCADE;
 \c
index 3120e53800ac77427df57fef83385c552389d772..f691ed793e8bab9391029e1794bb73d4ce61cc1f 100644 (file)
@@ -150,6 +150,8 @@ CREATE SERVER t2 FOREIGN DATA WRAPPER foo;
 RESET ROLE;
 REVOKE regress_test_indirect FROM regress_test_role;
 
+CREATE SERVER sc FOREIGN DATA WRAPPER csv;
+
 -- ALTER SERVER
 ALTER SERVER s0;                                            -- ERROR
 ALTER SERVER s0 OPTIONS (a '1');                            -- ERROR
@@ -222,6 +224,7 @@ CREATE USER MAPPING FOR current_user SERVER s6 OPTIONS (username 'test');
 CREATE USER MAPPING FOR current_user SERVER s7;             -- ERROR
 CREATE USER MAPPING FOR public SERVER s8;                   -- ERROR
 RESET ROLE;
+CREATE USER MAPPING FOR public SERVER sc;
 
 ALTER SERVER t1 OWNER TO regress_test_indirect;
 SET ROLE regress_test_role;
@@ -268,19 +271,19 @@ CREATE TABLE t2 ();
 CREATE TABLE f1
 CREATE FOREIGN TABLE ft1 ();                                    -- ERROR
 CREATE FOREIGN TABLE ft1 () SERVER no_server;                   -- ERROR
-CREATE FOREIGN TABLE ft1 () INHERITS () SERVER s4;              -- ERROR
-CREATE FOREIGN TABLE ft1 () INHERITS (no_table) SERVER s4;      -- ERROR
-CREATE FOREIGN TABLE ft1 (c1 serial) SERVER s4;                 -- ERROR
+CREATE FOREIGN TABLE ft1 () INHERITS () SERVER sc;              -- ERROR
+CREATE FOREIGN TABLE ft1 () INHERITS (no_table) SERVER sc;      -- ERROR
+CREATE FOREIGN TABLE ft1 (c1 serial) SERVER sc;                 -- ERROR
 CREATE FOREIGN TABLE ft1 (
    c1 integer NOT NULL,
    c2 text DEFAULT 'foo',
    c3 date CHECK (c3 > '2000-01-01'::date),
    CONSTRAINT ft1_c1_check CHECK (c1 > 0)
-) SERVER s4 OPTIONS (opt1 'val1', opt2 'val2');
+) SERVER sc OPTIONS (delimiter ',', quote '"');
 CREATE RULE ft1_insert_rule AS ON INSERT TO ft1 DO INSTEAD
    INSERT INTO t1 VALUES (new.c1, new.c2, new.c3);
 \d+ ft1
-CREATE FOREIGN TABLE ft2 () INHERITS (t1) SERVER s4 WITH OIDS OPTIONS (opt1 'val1', opt2 'val2');
+CREATE FOREIGN TABLE ft2 () INHERITS (t1) SERVER sc WITH OIDS OPTIONS (delimiter ' ', quote '`');
 \d+ ft2
 \det+
 CREATE INDEX id_ft1_c2 ON ft1 (c2);                             -- ERROR
@@ -319,7 +322,7 @@ ALTER FOREIGN TABLE ft1 DISABLE RULE ft1_insert_rule;
 ALTER FOREIGN TABLE ft1 INHERIT t2;
 ALTER FOREIGN TABLE ft1 NO INHERIT t2;
 ALTER FOREIGN TABLE ft1 OWNER TO regress_test_role;
-ALTER FOREIGN TABLE ft1 OPTIONS (DROP opt1, SET opt2 'VAL2', ADD opt3 'val3');
+ALTER FOREIGN TABLE ft1 OPTIONS (DROP delimiter, SET quote '~', ADD escape '@');
 ALTER FOREIGN TABLE ft1 DROP COLUMN no_column;                  -- ERROR
 ALTER FOREIGN TABLE ft1 DROP COLUMN IF EXISTS no_column;
 ALTER FOREIGN TABLE ft1 DROP COLUMN c9;