From c06965544188244efa703f6a97f3088a291d57b5 Mon Sep 17 00:00:00 2001 From: Neil Conway Date: Mon, 14 Mar 2005 00:19:37 +0000 Subject: Allow ALTER FUNCTION to change a function's strictness, volatility, and whether or not it is a security definer. Changing a function's strictness is required by SQL2003, and the other capabilities make sense. Also, allow an optional RESTRICT noise word to be specified, for SQL conformance. Some trivial regression tests added and the documentation has been updated. --- src/test/regress/expected/alter_table.out | 35 +++++++++++++++++++++++++++++++ src/test/regress/sql/alter_table.sql | 17 +++++++++++++++ 2 files changed, 52 insertions(+) (limited to 'src/test') diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index fbb23a4b127..b9edbc649d4 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -1235,3 +1235,38 @@ select * from another; (3 rows) drop table another; +-- +-- alter function +-- +create function test_strict(text) returns text as + 'select coalesce($1, ''got passed a null'');' + language sql returns null on null input; +select test_strict(NULL); + test_strict +------------- + +(1 row) + +alter function test_strict(text) called on null input; +select test_strict(NULL); + test_strict +------------------- + got passed a null +(1 row) + +create function non_strict(text) returns text as + 'select coalesce($1, ''got passed a null'');' + language sql called on null input; +select non_strict(NULL); + non_strict +------------------- + got passed a null +(1 row) + +alter function non_strict(text) returns null on null input; +select non_strict(NULL); + non_strict +------------ + +(1 row) + diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index e6be119ff7d..445fabf7e09 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -975,3 +975,20 @@ alter table another select * from another; drop table another; + +-- +-- alter function +-- +create function test_strict(text) returns text as + 'select coalesce($1, ''got passed a null'');' + language sql returns null on null input; +select test_strict(NULL); +alter function test_strict(text) called on null input; +select test_strict(NULL); + +create function non_strict(text) returns text as + 'select coalesce($1, ''got passed a null'');' + language sql called on null input; +select non_strict(NULL); +alter function non_strict(text) returns null on null input; +select non_strict(NULL); \ No newline at end of file -- cgit v1.2.3