fix file_fdw testcase

This commit is contained in:
xiong_xjun 2021-05-27 18:58:03 +08:00
parent 03c646cfda
commit 985a292971
3 changed files with 122 additions and 128 deletions

View File

@ -1,4 +1,4 @@
56 7.8
100 99.097
0 0.09561
42 324.78
56 7.8
100 99.097
0 0.09561
42 324.78

View File

@ -7,65 +7,62 @@ SET client_min_messages TO 'error';
DROP ROLE IF EXISTS file_fdw_superuser, file_fdw_user, no_priv_user;
RESET client_min_messages;
CREATE ROLE file_fdw_superuser LOGIN SUPERUSER; -- is a superuser
CREATE ROLE file_fdw_user LOGIN; -- has priv and user mapping
CREATE ROLE no_priv_user LOGIN; -- has priv but no user mapping
-- Install file_fdw
CREATE EXTENSION file_fdw;
CREATE ROLE file_fdw_superuser LOGIN sysadmin PASSWORD 'Gauss_123'; -- is a superuser
CREATE ROLE file_fdw_user LOGIN pguser PASSWORD 'Gauss_123'; -- has priv and user mapping
CREATE ROLE no_priv_user LOGIN PASSWORD 'Gauss_123'; -- has priv but no user mapping
-- file_fdw_superuser owns fdw-related objects
SET ROLE file_fdw_superuser;
SET ROLE file_fdw_superuser PASSWORD 'Gauss_123';
CREATE SERVER file_server FOREIGN DATA WRAPPER file_fdw;
-- privilege tests
SET ROLE file_fdw_user;
CREATE FOREIGN DATA WRAPPER file_fdw2 HANDLER file_fdw_handler VALIDATOR file_fdw_validator; -- ERROR
CREATE SERVER file_server2 FOREIGN DATA WRAPPER file_fdw; -- ERROR
SET ROLE file_fdw_user PASSWORD 'Gauss_123';
CREATE FOREIGN DATA WRAPPER file_fdw HANDLER file_fdw_handler VALIDATOR file_fdw_validator; -- ERROR
CREATE SERVER file_server FOREIGN DATA WRAPPER file_fdw; -- ERROR
CREATE USER MAPPING FOR file_fdw_user SERVER file_server; -- ERROR
SET ROLE file_fdw_superuser;
SET ROLE file_fdw_superuser PASSWORD 'Gauss_123';
GRANT USAGE ON FOREIGN SERVER file_server TO file_fdw_user;
SET ROLE file_fdw_user;
SET ROLE file_fdw_user PASSWORD 'Gauss_123';
CREATE USER MAPPING FOR file_fdw_user SERVER file_server;
-- create user mappings and grant privilege to test users
SET ROLE file_fdw_superuser;
SET ROLE file_fdw_superuser PASSWORD 'Gauss_123';
CREATE USER MAPPING FOR file_fdw_superuser SERVER file_server;
CREATE USER MAPPING FOR no_priv_user SERVER file_server;
-- validator tests
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'xml'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', header 'true'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', quote ':'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', escape ':'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'binary', header 'true'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'binary', quote ':'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'binary', escape ':'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', delimiter 'a'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', escape '-'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', quote '-', null '=-='); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', delimiter '-', null '=-='); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', delimiter '-', quote '-'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', delimiter '---'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', quote '---'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', escape '---'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', delimiter '\'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', delimiter '.'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', delimiter '1'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', delimiter 'a'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', delimiter '
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'xml'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', header 'true'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', quote ':'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', escape ':'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'binary', header 'true'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'binary', quote ':'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'binary', escape ':'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', delimiter 'a'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', escape '-'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', quote '-', null '=-='); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', delimiter '-', null '=-='); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', delimiter '-', quote '-'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', delimiter '---'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', quote '---'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', escape '---'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', delimiter '\'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', delimiter '.'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', delimiter '1'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', delimiter 'a'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', delimiter '
'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', null '
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', null '
'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server; -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server; -- ERROR
CREATE FOREIGN TABLE agg_text (
a int2,
b float4
) SERVER file_server
OPTIONS (format 'text', filename '@abs_srcdir@/data/agg.data', delimiter ' ', null '\N');
OPTIONS (format 'text', filename '@abs_srcdir@/data/agg.data', delimiter ' ', null '\N');
GRANT SELECT ON agg_text TO file_fdw_user;
CREATE FOREIGN TABLE agg_csv (
a int2,
@ -92,7 +89,7 @@ SELECT * FROM text_csv;
ALTER FOREIGN DATA WRAPPER file_fdw OPTIONS (ADD force_not_null '*'); -- ERROR
ALTER SERVER file_server OPTIONS (ADD force_not_null '*'); -- ERROR
CREATE USER MAPPING FOR public SERVER file_server OPTIONS (force_not_null '*'); -- ERROR
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (force_not_null '*'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (force_not_null '*'); -- ERROR
-- basic query tests
SELECT * FROM agg_text WHERE b > 10.0 ORDER BY a;
@ -111,8 +108,7 @@ EXECUTE st(100);
EXECUTE st(100);
DEALLOCATE st;
-- tableoid
SELECT tableoid::regclass, b FROM agg_csv;
SELECT b FROM agg_csv;
-- updates aren't supported
INSERT INTO agg_csv VALUES(1,2.0);
@ -122,26 +118,28 @@ DELETE FROM agg_csv WHERE a = 100;
SELECT * FROM agg_csv FOR UPDATE;
-- privilege tests
SET ROLE file_fdw_superuser;
SET ROLE file_fdw_superuser PASSWORD 'Gauss_123';
SELECT * FROM agg_text ORDER BY a;
SET ROLE file_fdw_user;
SET ROLE file_fdw_user PASSWORD 'Gauss_123';
SELECT * FROM agg_text ORDER BY a;
SET ROLE no_priv_user;
SET ROLE no_priv_user PASSWORD 'Gauss_123';
SELECT * FROM agg_text ORDER BY a; -- ERROR
SET ROLE file_fdw_user;
SET ROLE file_fdw_user PASSWORD 'Gauss_123';
\t on
EXPLAIN (VERBOSE, COSTS FALSE) SELECT * FROM agg_text WHERE a > 0;
\t off
-- privilege tests for object
SET ROLE file_fdw_superuser;
SET ROLE file_fdw_superuser PASSWORD 'Gauss_123';
ALTER FOREIGN TABLE agg_text OWNER TO file_fdw_user;
ALTER FOREIGN TABLE agg_text OPTIONS (SET format 'text');
SET ROLE file_fdw_user;
SET ROLE file_fdw_user PASSWORD 'Gauss_123';
ALTER FOREIGN TABLE agg_text OPTIONS (SET format 'text');
SET ROLE file_fdw_superuser;
SET ROLE file_fdw_superuser PASSWORD 'Gauss_123';
-- cleanup
RESET ROLE;
DROP EXTENSION file_fdw CASCADE;
DROP FOREIGN TABLE agg_bad, agg_csv, text_csv;
DROP USER MAPPING FOR file_fdw_superuser SERVER file_server;
DROP SERVER file_server CASCADE;;
DROP ROLE file_fdw_superuser, file_fdw_user, no_priv_user;

View File

@ -1,87 +1,85 @@
--
-- Test foreign-data wrapper file_fdw.
--
-- Clean up in case a prior regression run failed
---
--- Test foreign-data wrapper file_fdw.
---
--- Clean up in case a prior regression run failed
SET client_min_messages TO 'error';
DROP ROLE IF EXISTS file_fdw_superuser, file_fdw_user, no_priv_user;
RESET client_min_messages;
CREATE ROLE file_fdw_superuser LOGIN SUPERUSER; -- is a superuser
CREATE ROLE file_fdw_user LOGIN; -- has priv and user mapping
CREATE ROLE no_priv_user LOGIN; -- has priv but no user mapping
-- Install file_fdw
CREATE EXTENSION file_fdw;
CREATE ROLE file_fdw_superuser LOGIN SYSADMIN PASSWORD 'Gauss_123'; -- is a sysadmin
CREATE ROLE file_fdw_user LOGIN PGUSER PASSWORD 'Gauss_123'; -- has priv and user mapping
CREATE ROLE no_priv_user LOGIN PASSWORD 'Gauss_123'; -- has priv but no user mapping
-- file_fdw_superuser owns fdw-related objects
SET ROLE file_fdw_superuser;
SET ROLE file_fdw_superuser PASSWORD 'Gauss_123';
CREATE SERVER file_server FOREIGN DATA WRAPPER file_fdw;
-- privilege tests
SET ROLE file_fdw_user;
SET ROLE file_fdw_user PASSWORD 'Gauss_123';
CREATE FOREIGN DATA WRAPPER file_fdw2 HANDLER file_fdw_handler VALIDATOR file_fdw_validator; -- ERROR
ERROR: permission denied to create foreign-data wrapper "file_fdw2"
HINT: Must be superuser to create a foreign-data wrapper.
HINT: Must be system admin to create a foreign-data wrapper.
CREATE SERVER file_server2 FOREIGN DATA WRAPPER file_fdw; -- ERROR
ERROR: permission denied for foreign-data wrapper file_fdw
CREATE USER MAPPING FOR file_fdw_user SERVER file_server; -- ERROR
ERROR: permission denied for foreign server file_server
SET ROLE file_fdw_superuser;
SET ROLE file_fdw_superuser PASSWORD 'Gauss_123';
GRANT USAGE ON FOREIGN SERVER file_server TO file_fdw_user;
SET ROLE file_fdw_user;
SET ROLE file_fdw_user PASSWORD 'Gauss_123';
CREATE USER MAPPING FOR file_fdw_user SERVER file_server;
-- create user mappings and grant privilege to test users
SET ROLE file_fdw_superuser;
SET ROLE file_fdw_superuser PASSWORD 'Gauss_123';
CREATE USER MAPPING FOR file_fdw_superuser SERVER file_server;
CREATE USER MAPPING FOR no_priv_user SERVER file_server;
-- validator tests
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'xml'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'xml'); -- ERROR
ERROR: COPY format "xml" not recognized
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', header 'true'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', header 'true'); -- ERROR
ERROR: COPY HEADER available only in CSV mode
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', quote ':'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', quote ':'); -- ERROR
ERROR: COPY quote available only in CSV mode
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', escape ':'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', escape ':'); -- ERROR
ERROR: COPY escape available only in CSV mode
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'binary', header 'true'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'binary', header 'true'); -- ERROR
ERROR: COPY HEADER available only in CSV mode
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'binary', quote ':'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'binary', quote ':'); -- ERROR
ERROR: COPY quote available only in CSV mode
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'binary', escape ':'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'binary', escape ':'); -- ERROR
ERROR: COPY escape available only in CSV mode
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', delimiter 'a'); -- ERROR
ERROR: COPY delimiter cannot be "a"
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', escape '-'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', delimiter 'a'); -- ERROR
ERROR: delimiter "a" cannot contain any characters in"\.abcdefghijklmnopqrstuvwxyz0123456789"
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', escape '-'); -- ERROR
ERROR: COPY escape available only in CSV mode
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', quote '-', null '=-='); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', quote '-', null '=-='); -- ERROR
ERROR: CSV quote character must not appear in the NULL specification
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', delimiter '-', null '=-='); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', delimiter '-', null '=-='); -- ERROR
ERROR: COPY delimiter must not appear in the NULL specification
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', delimiter '-', quote '-'); -- ERROR
ERROR: COPY delimiter and quote must be different
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', delimiter '---'); -- ERROR
ERROR: COPY delimiter must be a single one-byte character
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', quote '---'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', delimiter '-', quote '-'); -- ERROR
ERROR: delimiter cannot contain quote character
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', delimiter '---'); -- ERROR
ERROR: filename is required for file_fdw foreign tables
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', quote '---'); -- ERROR
ERROR: COPY quote must be a single one-byte character
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', escape '---'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', escape '---'); -- ERROR
ERROR: COPY escape must be a single one-byte character
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', delimiter '\'); -- ERROR
ERROR: COPY delimiter cannot be "\"
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', delimiter '.'); -- ERROR
ERROR: COPY delimiter cannot be "."
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', delimiter '1'); -- ERROR
ERROR: COPY delimiter cannot be "1"
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'text', delimiter 'a'); -- ERROR
ERROR: COPY delimiter cannot be "a"
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', delimiter '
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', delimiter '\'); -- ERROR
ERROR: delimiter "\" cannot contain any characters in"\.abcdefghijklmnopqrstuvwxyz0123456789"
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', delimiter '.'); -- ERROR
ERROR: delimiter "." cannot contain any characters in"\.abcdefghijklmnopqrstuvwxyz0123456789"
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', delimiter '1'); -- ERROR
ERROR: delimiter "1" cannot contain any characters in"\.abcdefghijklmnopqrstuvwxyz0123456789"
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'text', delimiter 'a'); -- ERROR
ERROR: delimiter "a" cannot contain any characters in"\.abcdefghijklmnopqrstuvwxyz0123456789"
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', delimiter '
'); -- ERROR
ERROR: COPY delimiter cannot be newline or carriage return
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (format 'csv', null '
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (format 'csv', null '
'); -- ERROR
ERROR: COPY null representation cannot use newline or carriage return
CREATE FOREIGN TABLE tbl () SERVER file_server; -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server; -- ERROR
ERROR: filename is required for file_fdw foreign tables
CREATE FOREIGN TABLE agg_text (
a int2,
b float4
) SERVER file_server
OPTIONS (format 'text', filename '@abs_srcdir@/data/agg.data', delimiter ' ', null '\N');
OPTIONS (format 'text', filename '@abs_srcdir@/data/agg.data', delimiter ' ', null '\N');
GRANT SELECT ON agg_text TO file_fdw_user;
CREATE FOREIGN TABLE agg_csv (
a int2,
@ -121,7 +119,7 @@ HINT: There are no valid options in this context.
CREATE USER MAPPING FOR public SERVER file_server OPTIONS (force_not_null '*'); -- ERROR
ERROR: invalid option "force_not_null"
HINT: There are no valid options in this context.
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (force_not_null '*'); -- ERROR
CREATE FOREIGN TABLE tbl (a int) SERVER file_server OPTIONS (force_not_null '*'); -- ERROR
ERROR: invalid option "force_not_null"
HINT: Valid options in this context are: filename, format, header, delimiter, quote, escape, null, encoding
-- basic query tests
@ -135,7 +133,7 @@ SELECT * FROM agg_text WHERE b > 10.0 ORDER BY a;
SELECT * FROM agg_csv ORDER BY a;
a | b
-----+---------
0 | 0.09561
0 | .09561
42 | 324.78
100 | 99.097
(3 rows)
@ -143,7 +141,7 @@ SELECT * FROM agg_csv ORDER BY a;
SELECT * FROM agg_csv c JOIN agg_text t ON (t.a = c.a) ORDER BY c.a;
a | b | a | b
-----+---------+-----+---------
0 | 0.09561 | 0 | 0.09561
0 | .09561 | 0 | .09561
42 | 324.78 | 42 | 324.78
100 | 99.097 | 100 | 99.097
(3 rows)
@ -174,56 +172,58 @@ EXECUTE st(100);
(1 row)
DEALLOCATE st;
-- tableoid
SELECT tableoid::regclass, b FROM agg_csv;
tableoid | b
----------+---------
agg_csv | 99.097
agg_csv | 0.09561
agg_csv | 324.78
SELECT b FROM agg_csv;
b
--------
99.097
.09561
324.78
(3 rows)
-- updates aren't supported
INSERT INTO agg_csv VALUES(1,2.0);
ERROR: cannot insert into foreign table "agg_csv"
ERROR: Un-support feature
DETAIL: insert statement is an INSERT INTO VALUES(...)
UPDATE agg_csv SET a = 1;
ERROR: cannot update foreign table "agg_csv"
ERROR: Un-support feature
DETAIL: statements contains unsupport feature to foreign table
DELETE FROM agg_csv WHERE a = 100;
ERROR: cannot delete from foreign table "agg_csv"
ERROR: Un-support feature
DETAIL: statements contains unsupport feature to foreign table
-- but this should be ignored
SELECT * FROM agg_csv FOR UPDATE;
a | b
-----+---------
100 | 99.097
0 | 0.09561
0 | .09561
42 | 324.78
(3 rows)
-- privilege tests
SET ROLE file_fdw_superuser;
SET ROLE file_fdw_superuser PASSWORD 'Gauss_123';
SELECT * FROM agg_text ORDER BY a;
a | b
-----+---------
0 | 0.09561
0 | .09561
42 | 324.78
56 | 7.8
100 | 99.097
(4 rows)
SET ROLE file_fdw_user;
SET ROLE file_fdw_user PASSWORD 'Gauss_123';
SELECT * FROM agg_text ORDER BY a;
a | b
-----+---------
0 | 0.09561
0 | .09561
42 | 324.78
56 | 7.8
100 | 99.097
(4 rows)
SET ROLE no_priv_user;
SET ROLE no_priv_user PASSWORD 'Gauss_123';
SELECT * FROM agg_text ORDER BY a; -- ERROR
ERROR: permission denied for relation agg_text
SET ROLE file_fdw_user;
SET ROLE file_fdw_user PASSWORD 'Gauss_123';
\t on
EXPLAIN (VERBOSE, COSTS FALSE) SELECT * FROM agg_text WHERE a > 0;
Foreign Scan on public.agg_text
@ -233,23 +233,19 @@ EXPLAIN (VERBOSE, COSTS FALSE) SELECT * FROM agg_text WHERE a > 0;
\t off
-- privilege tests for object
SET ROLE file_fdw_superuser;
SET ROLE file_fdw_superuser PASSWORD 'Gauss_123';
ALTER FOREIGN TABLE agg_text OWNER TO file_fdw_user;
ALTER FOREIGN TABLE agg_text OPTIONS (SET format 'text');
SET ROLE file_fdw_user;
SET ROLE file_fdw_user PASSWORD 'Gauss_123';
ALTER FOREIGN TABLE agg_text OPTIONS (SET format 'text');
ERROR: only superuser can change options of a file_fdw foreign table
SET ROLE file_fdw_superuser;
SET ROLE file_fdw_superuser PASSWORD 'Gauss_123';
-- cleanup
RESET ROLE;
DROP EXTENSION file_fdw CASCADE;
NOTICE: drop cascades to 8 other objects
DETAIL: drop cascades to server file_server
drop cascades to user mapping for file_fdw_user
drop cascades to user mapping for file_fdw_superuser
DROP FOREIGN TABLE agg_bad, agg_csv, text_csv;
DROP USER MAPPING FOR file_fdw_user SERVER file_server;
DROP SERVER file_server CASCADE;
NOTICE: drop cascades to 3 other objects
DETAIL: drop cascades to user mapping for file_fdw_user
drop cascades to user mapping for no_priv_user
drop cascades to foreign table agg_text
drop cascades to foreign table agg_csv
drop cascades to foreign table agg_bad
drop cascades to foreign table text_csv
DROP ROLE file_fdw_superuser, file_fdw_user, no_priv_user;