diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-05-11 14:28:11 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-05-11 14:28:11 -0400 |
commit | 6303a5730914dfe6ef2709b28b225553315c573c (patch) | |
tree | 05c755b1dc4c42d9d0db201e0595e1c08608537b /src/test/regress/input/create_function_0.source | |
parent | 6d177e2813a2b4415539e2861b595583cc1a8f71 (diff) | |
download | postgresql-6303a5730914dfe6ef2709b28b225553315c573c.tar.gz postgresql-6303a5730914dfe6ef2709b28b225553315c573c.zip |
Replace opr_sanity test's binary_coercible() function with C code.
opr_sanity's binary_coercible() function has always been meant
to match the parser's notion of binary coercibility, but it also
has always been a rather poor approximation of the parser's
real rules (as embodied in IsBinaryCoercible()). That hasn't
bit us so far, but it's predictable that it will eventually.
It also now emerges that implementing this check in plpgsql
performs absolutely horribly in clobber-cache-always testing.
(Perhaps we could do something about that, but I suspect it just
means that plpgsql is exploiting catalog caching to the hilt.)
Hence, let's replace binary_coercible() with a C shim that directly
invokes IsBinaryCoercible(), eliminating both the semantic hazard
and the performance issue.
Most of regress.c's C functions are declared in create_function_1,
but we can't simply move that to before opr_sanity/type_sanity
since those tests would complain about the resulting shell types.
I chose to split it into create_function_0 and create_function_1.
Since create_function_0 now runs as part of a parallel group while
create_function_1 doesn't, reduce the latter to create just those
functions that opr_sanity and type_sanity would whine about.
To make room for create_function_0 in the second parallel group
of tests, move tstypes to the third parallel group.
In passing, clean up some ordering deviations between
parallel_schedule and serial_schedule.
Discussion: https://postgr.es/m/292305.1620503097@sss.pgh.pa.us
Diffstat (limited to 'src/test/regress/input/create_function_0.source')
-rw-r--r-- | src/test/regress/input/create_function_0.source | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/test/regress/input/create_function_0.source b/src/test/regress/input/create_function_0.source new file mode 100644 index 00000000000..f47f635789a --- /dev/null +++ b/src/test/regress/input/create_function_0.source @@ -0,0 +1,95 @@ +-- +-- CREATE_FUNCTION_0 +-- + +-- Create a bunch of C functions that will be used by later tests: + +CREATE FUNCTION check_primary_key () + RETURNS trigger + AS '@libdir@/refint@DLSUFFIX@' + LANGUAGE C; + +CREATE FUNCTION check_foreign_key () + RETURNS trigger + AS '@libdir@/refint@DLSUFFIX@' + LANGUAGE C; + +CREATE FUNCTION autoinc () + RETURNS trigger + AS '@libdir@/autoinc@DLSUFFIX@' + LANGUAGE C; + +CREATE FUNCTION trigger_return_old () + RETURNS trigger + AS '@libdir@/regress@DLSUFFIX@' + LANGUAGE C; + +CREATE FUNCTION ttdummy () + RETURNS trigger + AS '@libdir@/regress@DLSUFFIX@' + LANGUAGE C; + +CREATE FUNCTION set_ttdummy (int4) + RETURNS int4 + AS '@libdir@/regress@DLSUFFIX@' + LANGUAGE C STRICT; + +CREATE FUNCTION make_tuple_indirect (record) + RETURNS record + AS '@libdir@/regress@DLSUFFIX@' + LANGUAGE C STRICT; + +CREATE FUNCTION test_atomic_ops() + RETURNS bool + AS '@libdir@/regress@DLSUFFIX@' + LANGUAGE C; + +CREATE FUNCTION test_fdw_handler() + RETURNS fdw_handler + AS '@libdir@/regress@DLSUFFIX@', 'test_fdw_handler' + LANGUAGE C; + +CREATE FUNCTION test_support_func(internal) + RETURNS internal + AS '@libdir@/regress@DLSUFFIX@', 'test_support_func' + LANGUAGE C STRICT; + +CREATE FUNCTION test_opclass_options_func(internal) + RETURNS void + AS '@libdir@/regress@DLSUFFIX@', 'test_opclass_options_func' + LANGUAGE C; + +CREATE FUNCTION test_enc_conversion(bytea, name, name, bool, validlen OUT int, result OUT bytea) + AS '@libdir@/regress@DLSUFFIX@', 'test_enc_conversion' + LANGUAGE C STRICT; + +CREATE FUNCTION binary_coercible(oid, oid) + RETURNS bool + AS '@libdir@/regress@DLSUFFIX@', 'binary_coercible' + LANGUAGE C STRICT STABLE PARALLEL SAFE; + +-- Things that shouldn't work: + +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'SELECT ''not an integer'';'; + +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'not even SQL'; + +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'SELECT 1, 2, 3;'; + +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'SELECT $2;'; + +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'a', 'b'; + +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C + AS 'nosuchfile'; + +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C + AS '@libdir@/regress@DLSUFFIX@', 'nosuchsymbol'; + +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE internal + AS 'nosuch'; |