\pset null _null_ SET ROLE postgres; SET client_min_messages = warning; CREATE EXTENSION file_fdw; CREATE EXTENSION adminpack; CREATE TEMPORARY TABLE t1 AS SELECT pg_file_unlink('pgddltest.tmp'); SELECT pg_file_write('pgddltest.tmp',E'Hello, World!\nThis is some text\n',false); pg_file_write --------------- 32 (1 row) CREATE SERVER serv FOREIGN DATA WRAPPER file_fdw; CREATE FOREIGN TABLE test_class_f ( line text options ( force_not_null 'true' ) ) SERVER serv OPTIONS ( filename 'pgddltest.tmp', format 'text' ); COMMENT ON FOREIGN TABLE test_class_f IS 'A Foreign table'; COMMENT ON COLUMN test_class_f.line IS 'A Line of text'; GRANT ALL ON test_class_f TO PUBLIC; -- SELECT * FROM test_class_f; SELECT ddlx_script('test_class_f'::regclass); ddlx_script -------------------------------------------------------------- BEGIN; + + /* + DROP FOREIGN TABLE test_class_f; + */ + + -- Type: FOREIGN TABLE ; Name: test_class_f; Owner: postgres+ + CREATE FOREIGN TABLE test_class_f ( + line text OPTIONS ( force_not_null 'true' ) + ) + SERVER serv + OPTIONS ( + filename 'pgddltest.tmp', + format 'text' + ); + + COMMENT ON FOREIGN TABLE test_class_f IS 'A Foreign table'; + COMMENT ON COLUMN test_class_f.line IS 'A Line of text'; + + ALTER FOREIGN TABLE test_class_f OWNER TO postgres; + GRANT INSERT ON test_class_f TO PUBLIC; + GRANT SELECT ON test_class_f TO PUBLIC; + GRANT UPDATE ON test_class_f TO PUBLIC; + GRANT DELETE ON test_class_f TO PUBLIC; + GRANT TRUNCATE ON test_class_f TO PUBLIC; + GRANT REFERENCES ON test_class_f TO PUBLIC; + GRANT TRIGGER ON test_class_f TO PUBLIC; + + END; + (1 row) SELECT ddlx_create((select oid from pg_foreign_data_wrapper where fdwname='file_fdw')); ddlx_create -------------------------------------------------------- CREATE FOREIGN DATA WRAPPER file_fdw + HANDLER file_fdw_handler + VALIDATOR file_fdw_validator; + COMMENT ON FOREIGN DATA WRAPPER file_fdw IS NULL; + ALTER FOREIGN DATA WRAPPER file_fdw OWNER TO postgres;+ (1 row) SELECT ddlx_drop((select oid from pg_foreign_data_wrapper where fdwname='file_fdw')); ddlx_drop ------------------------------------- DROP FOREIGN DATA WRAPPER file_fdw;+ (1 row) SELECT ddlx_create((select oid from pg_foreign_server where srvname='serv')); ddlx_create -------------------------------------- CREATE SERVER serv + FOREIGN DATA WRAPPER file_fdw; + COMMENT ON SERVER serv IS NULL; + ALTER SERVER serv OWNER TO postgres;+ (1 row) SELECT ddlx_drop((select oid from pg_foreign_server where srvname='serv')); ddlx_drop ------------------- DROP SERVER serv;+ (1 row)