mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Test coverage for CREATE/ALTER FOREIGN DATA WRAPPER .. HANDLER.
Amit Langote, per a suggestion from Mark Dilger. Reviewed by Marc Dilger and Ashutosh Bapat. Discussion: http://postgr.es/m/CAFjFpReL0oeN7SCpnsEPbqJhB2Bp1wnH1uvbOF_w6KEuv6ZXvg@mail.gmail.com
This commit is contained in:
@ -89,6 +89,14 @@ CREATE FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator;
|
|||||||
postgresql | regress_foreign_data_user | - | postgresql_fdw_validator | | |
|
postgresql | regress_foreign_data_user | - | postgresql_fdw_validator | | |
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
|
-- HANDLER related checks
|
||||||
|
CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQL AS 'SELECT 1;';
|
||||||
|
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER invalid_fdw_handler; -- ERROR
|
||||||
|
ERROR: function invalid_fdw_handler must return type fdw_handler
|
||||||
|
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER invalid_fdw_handler; -- ERROR
|
||||||
|
ERROR: conflicting or redundant options
|
||||||
|
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler;
|
||||||
|
DROP FOREIGN DATA WRAPPER test_fdw;
|
||||||
-- ALTER FOREIGN DATA WRAPPER
|
-- ALTER FOREIGN DATA WRAPPER
|
||||||
ALTER FOREIGN DATA WRAPPER foo; -- ERROR
|
ALTER FOREIGN DATA WRAPPER foo; -- ERROR
|
||||||
ERROR: syntax error at or near ";"
|
ERROR: syntax error at or near ";"
|
||||||
@ -188,18 +196,26 @@ ALTER FOREIGN DATA WRAPPER foo RENAME TO foo1;
|
|||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
ALTER FOREIGN DATA WRAPPER foo1 RENAME TO foo;
|
ALTER FOREIGN DATA WRAPPER foo1 RENAME TO foo;
|
||||||
|
-- HANDLER related checks
|
||||||
|
ALTER FOREIGN DATA WRAPPER foo HANDLER invalid_fdw_handler; -- ERROR
|
||||||
|
ERROR: function invalid_fdw_handler must return type fdw_handler
|
||||||
|
ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler HANDLER anything; -- ERROR
|
||||||
|
ERROR: conflicting or redundant options
|
||||||
|
ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler;
|
||||||
|
WARNING: changing the foreign-data wrapper handler can change behavior of existing foreign tables
|
||||||
|
DROP FUNCTION invalid_fdw_handler();
|
||||||
-- DROP FOREIGN DATA WRAPPER
|
-- DROP FOREIGN DATA WRAPPER
|
||||||
DROP FOREIGN DATA WRAPPER nonexistent; -- ERROR
|
DROP FOREIGN DATA WRAPPER nonexistent; -- ERROR
|
||||||
ERROR: foreign-data wrapper "nonexistent" does not exist
|
ERROR: foreign-data wrapper "nonexistent" does not exist
|
||||||
DROP FOREIGN DATA WRAPPER IF EXISTS nonexistent;
|
DROP FOREIGN DATA WRAPPER IF EXISTS nonexistent;
|
||||||
NOTICE: foreign-data wrapper "nonexistent" does not exist, skipping
|
NOTICE: foreign-data wrapper "nonexistent" does not exist, skipping
|
||||||
\dew+
|
\dew+
|
||||||
List of foreign-data wrappers
|
List of foreign-data wrappers
|
||||||
Name | Owner | Handler | Validator | Access privileges | FDW options | Description
|
Name | Owner | Handler | Validator | Access privileges | FDW options | Description
|
||||||
------------+---------------------------+---------+--------------------------+-------------------+------------------------------+-------------
|
------------+---------------------------+------------------+--------------------------+-------------------+------------------------------+-------------
|
||||||
dummy | regress_foreign_data_user | - | - | | | useless
|
dummy | regress_foreign_data_user | - | - | | | useless
|
||||||
foo | regress_test_role_super | - | - | | (b '3', c '4', a '2', d '5') |
|
foo | regress_test_role_super | test_fdw_handler | - | | (b '3', c '4', a '2', d '5') |
|
||||||
postgresql | regress_foreign_data_user | - | postgresql_fdw_validator | | |
|
postgresql | regress_foreign_data_user | - | postgresql_fdw_validator | | |
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
DROP ROLE regress_test_role_super; -- ERROR
|
DROP ROLE regress_test_role_super; -- ERROR
|
||||||
|
@ -62,6 +62,12 @@ CREATE FUNCTION test_atomic_ops()
|
|||||||
AS '@libdir@/regress@DLSUFFIX@'
|
AS '@libdir@/regress@DLSUFFIX@'
|
||||||
LANGUAGE C;
|
LANGUAGE C;
|
||||||
|
|
||||||
|
-- Tests creating a FDW handler
|
||||||
|
CREATE FUNCTION test_fdw_handler()
|
||||||
|
RETURNS fdw_handler
|
||||||
|
AS '@libdir@/regress@DLSUFFIX@', 'test_fdw_handler'
|
||||||
|
LANGUAGE C;
|
||||||
|
|
||||||
-- Things that shouldn't work:
|
-- Things that shouldn't work:
|
||||||
|
|
||||||
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
|
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
|
||||||
|
@ -55,6 +55,11 @@ CREATE FUNCTION test_atomic_ops()
|
|||||||
RETURNS bool
|
RETURNS bool
|
||||||
AS '@libdir@/regress@DLSUFFIX@'
|
AS '@libdir@/regress@DLSUFFIX@'
|
||||||
LANGUAGE C;
|
LANGUAGE C;
|
||||||
|
-- Tests creating a FDW handler
|
||||||
|
CREATE FUNCTION test_fdw_handler()
|
||||||
|
RETURNS fdw_handler
|
||||||
|
AS '@libdir@/regress@DLSUFFIX@', 'test_fdw_handler'
|
||||||
|
LANGUAGE C;
|
||||||
-- Things that shouldn't work:
|
-- Things that shouldn't work:
|
||||||
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
|
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
|
||||||
AS 'SELECT ''not an integer'';';
|
AS 'SELECT ''not an integer'';';
|
||||||
|
@ -1096,3 +1096,10 @@ test_atomic_ops(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
PG_RETURN_BOOL(true);
|
PG_RETURN_BOOL(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PG_FUNCTION_INFO_V1(test_fdw_handler);
|
||||||
|
Datum
|
||||||
|
test_fdw_handler(PG_FUNCTION_ARGS)
|
||||||
|
{
|
||||||
|
PG_RETURN_NULL();
|
||||||
|
}
|
||||||
|
@ -51,6 +51,13 @@ RESET ROLE;
|
|||||||
CREATE FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator;
|
CREATE FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator;
|
||||||
\dew+
|
\dew+
|
||||||
|
|
||||||
|
-- HANDLER related checks
|
||||||
|
CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQL AS 'SELECT 1;';
|
||||||
|
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER invalid_fdw_handler; -- ERROR
|
||||||
|
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER invalid_fdw_handler; -- ERROR
|
||||||
|
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler;
|
||||||
|
DROP FOREIGN DATA WRAPPER test_fdw;
|
||||||
|
|
||||||
-- ALTER FOREIGN DATA WRAPPER
|
-- ALTER FOREIGN DATA WRAPPER
|
||||||
ALTER FOREIGN DATA WRAPPER foo; -- ERROR
|
ALTER FOREIGN DATA WRAPPER foo; -- ERROR
|
||||||
ALTER FOREIGN DATA WRAPPER foo VALIDATOR bar; -- ERROR
|
ALTER FOREIGN DATA WRAPPER foo VALIDATOR bar; -- ERROR
|
||||||
@ -88,6 +95,12 @@ ALTER FOREIGN DATA WRAPPER foo RENAME TO foo1;
|
|||||||
\dew+
|
\dew+
|
||||||
ALTER FOREIGN DATA WRAPPER foo1 RENAME TO foo;
|
ALTER FOREIGN DATA WRAPPER foo1 RENAME TO foo;
|
||||||
|
|
||||||
|
-- HANDLER related checks
|
||||||
|
ALTER FOREIGN DATA WRAPPER foo HANDLER invalid_fdw_handler; -- ERROR
|
||||||
|
ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler HANDLER anything; -- ERROR
|
||||||
|
ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler;
|
||||||
|
DROP FUNCTION invalid_fdw_handler();
|
||||||
|
|
||||||
-- DROP FOREIGN DATA WRAPPER
|
-- DROP FOREIGN DATA WRAPPER
|
||||||
DROP FOREIGN DATA WRAPPER nonexistent; -- ERROR
|
DROP FOREIGN DATA WRAPPER nonexistent; -- ERROR
|
||||||
DROP FOREIGN DATA WRAPPER IF EXISTS nonexistent;
|
DROP FOREIGN DATA WRAPPER IF EXISTS nonexistent;
|
||||||
|
Reference in New Issue
Block a user