Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
6510c832
Commit
6510c832
authored
Mar 06, 2015
by
Alvaro Herrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some more tests on event triggers
Fabien Coelho Reviewed by Robert Haas
parent
e3bfe6d8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
2 deletions
+109
-2
src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
+18
-0
src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
+23
-0
src/test/regress/expected/event_trigger.out
src/test/regress/expected/event_trigger.out
+37
-1
src/test/regress/sql/event_trigger.sql
src/test/regress/sql/event_trigger.sql
+31
-1
No files found.
src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
View file @
6510c832
...
...
@@ -85,3 +85,21 @@ SELECT objtype, objname, provider, label FROM pg_seclabels
view | dummy_seclabel_view1 | dummy | classified
(9 rows)
-- check for event trigger
CREATE FUNCTION event_trigger_test()
RETURNS event_trigger AS $$
BEGIN RAISE NOTICE 'event %: %', TG_EVENT, TG_TAG; END;
$$ LANGUAGE plpgsql;
CREATE EVENT TRIGGER always_start ON ddl_command_start
EXECUTE PROCEDURE event_trigger_test();
CREATE EVENT TRIGGER always_end ON ddl_command_end
EXECUTE PROCEDURE event_trigger_test();
CREATE EVENT TRIGGER always_drop ON sql_drop
EXECUTE PROCEDURE event_trigger_test();
CREATE EVENT TRIGGER always_rewrite ON table_rewrite
EXECUTE PROCEDURE event_trigger_test();
-- should trigger ddl_command_{start,end}
SECURITY LABEL ON TABLE dummy_seclabel_tbl1 IS 'classified';
NOTICE: event ddl_command_start: SECURITY LABEL
NOTICE: event ddl_command_end: SECURITY LABEL
DROP EVENT TRIGGER always_start, always_end, always_drop, always_rewrite;
src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
View file @
6510c832
...
...
@@ -77,3 +77,26 @@ SECURITY LABEL ON SCHEMA dummy_seclabel_test IS 'unclassified'; -- OK
SELECT
objtype
,
objname
,
provider
,
label
FROM
pg_seclabels
ORDER
BY
objtype
,
objname
;
-- check for event trigger
CREATE
FUNCTION
event_trigger_test
()
RETURNS
event_trigger
AS
$$
BEGIN
RAISE
NOTICE
'event %: %'
,
TG_EVENT
,
TG_TAG
;
END
;
$$
LANGUAGE
plpgsql
;
CREATE
EVENT
TRIGGER
always_start
ON
ddl_command_start
EXECUTE
PROCEDURE
event_trigger_test
();
CREATE
EVENT
TRIGGER
always_end
ON
ddl_command_end
EXECUTE
PROCEDURE
event_trigger_test
();
CREATE
EVENT
TRIGGER
always_drop
ON
sql_drop
EXECUTE
PROCEDURE
event_trigger_test
();
CREATE
EVENT
TRIGGER
always_rewrite
ON
table_rewrite
EXECUTE
PROCEDURE
event_trigger_test
();
-- should trigger ddl_command_{start,end}
SECURITY
LABEL
ON
TABLE
dummy_seclabel_tbl1
IS
'classified'
;
DROP
EVENT
TRIGGER
always_start
,
always_end
,
always_drop
,
always_rewrite
;
src/test/regress/expected/event_trigger.out
View file @
6510c832
...
...
@@ -9,6 +9,15 @@ BEGIN
RAISE NOTICE 'test_event_trigger: % %', tg_event, tg_tag;
END
$$ language plpgsql;
-- should fail, event triggers cannot have declared arguments
create function test_event_trigger_arg(name text)
returns event_trigger as $$ BEGIN RETURN 1; END $$ language plpgsql;
ERROR: event trigger functions cannot have declared arguments
CONTEXT: compilation of PL/pgSQL function "test_event_trigger_arg" near line 1
-- should fail, SQL functions cannot be event triggers
create function test_event_trigger_sql() returns event_trigger as $$
SELECT 1 $$ language sql;
ERROR: SQL functions cannot return type event_trigger
-- should fail, no elephant_bootstrap entry point
create event trigger regress_event_trigger on elephant_bootstrap
execute procedure test_event_trigger();
...
...
@@ -39,11 +48,32 @@ create event trigger regress_event_trigger2 on ddl_command_start
when tag in ('DROP EVENT TRIGGER')
execute procedure test_event_trigger();
ERROR: event triggers are not supported for DROP EVENT TRIGGER
-- should fail, can't have event triggers on global objects
create event trigger regress_event_trigger2 on ddl_command_start
when tag in ('CREATE ROLE')
execute procedure test_event_trigger();
ERROR: event triggers are not supported for CREATE ROLE
-- should fail, can't have event triggers on global objects
create event trigger regress_event_trigger2 on ddl_command_start
when tag in ('CREATE DATABASE')
execute procedure test_event_trigger();
ERROR: event triggers are not supported for CREATE DATABASE
-- should fail, can't have event triggers on global objects
create event trigger regress_event_trigger2 on ddl_command_start
when tag in ('CREATE TABLESPACE')
execute procedure test_event_trigger();
ERROR: event triggers are not supported for CREATE TABLESPACE
-- should fail, can't have same filter variable twice
create event trigger regress_event_trigger2 on ddl_command_start
when tag in ('create table') and tag in ('CREATE FUNCTION')
execute procedure test_event_trigger();
ERROR: filter variable "tag" specified more than once
-- should fail, can't have arguments
create event trigger regress_event_trigger2 on ddl_command_start
execute procedure test_event_trigger('argument not allowed');
ERROR: syntax error at or near "'argument not allowed'"
LINE 2: execute procedure test_event_trigger('argument not allowe...
^
-- OK
create event trigger regress_event_trigger2 on ddl_command_start
when tag in ('create table', 'CREATE FUNCTION')
...
...
@@ -71,7 +101,13 @@ alter event trigger regress_event_trigger disable;
create table event_trigger_fire1 (a int);
NOTICE: test_event_trigger: ddl_command_start CREATE TABLE
NOTICE: test_event_trigger: ddl_command_end CREATE TABLE
-- regress_event_trigger_end should fire here
-- regress_event_trigger_end should fire on these commands
grant all on table event_trigger_fire1 to public;
NOTICE: test_event_trigger: ddl_command_end GRANT
comment on table event_trigger_fire1 is 'here is a comment';
NOTICE: test_event_trigger: ddl_command_end COMMENT
revoke all on table event_trigger_fire1 from public;
NOTICE: test_event_trigger: ddl_command_end REVOKE
drop table event_trigger_fire1;
NOTICE: test_event_trigger: ddl_command_end DROP TABLE
-- alter owner to non-superuser should fail
...
...
src/test/regress/sql/event_trigger.sql
View file @
6510c832
...
...
@@ -10,6 +10,14 @@ BEGIN
END
$$
language
plpgsql
;
-- should fail, event triggers cannot have declared arguments
create
function
test_event_trigger_arg
(
name
text
)
returns
event_trigger
as
$$
BEGIN
RETURN
1
;
END
$$
language
plpgsql
;
-- should fail, SQL functions cannot be event triggers
create
function
test_event_trigger_sql
()
returns
event_trigger
as
$$
SELECT
1
$$
language
sql
;
-- should fail, no elephant_bootstrap entry point
create
event
trigger
regress_event_trigger
on
elephant_bootstrap
execute
procedure
test_event_trigger
();
...
...
@@ -42,11 +50,30 @@ create event trigger regress_event_trigger2 on ddl_command_start
when
tag
in
(
'DROP EVENT TRIGGER'
)
execute
procedure
test_event_trigger
();
-- should fail, can't have event triggers on global objects
create
event
trigger
regress_event_trigger2
on
ddl_command_start
when
tag
in
(
'CREATE ROLE'
)
execute
procedure
test_event_trigger
();
-- should fail, can't have event triggers on global objects
create
event
trigger
regress_event_trigger2
on
ddl_command_start
when
tag
in
(
'CREATE DATABASE'
)
execute
procedure
test_event_trigger
();
-- should fail, can't have event triggers on global objects
create
event
trigger
regress_event_trigger2
on
ddl_command_start
when
tag
in
(
'CREATE TABLESPACE'
)
execute
procedure
test_event_trigger
();
-- should fail, can't have same filter variable twice
create
event
trigger
regress_event_trigger2
on
ddl_command_start
when
tag
in
(
'create table'
)
and
tag
in
(
'CREATE FUNCTION'
)
execute
procedure
test_event_trigger
();
-- should fail, can't have arguments
create
event
trigger
regress_event_trigger2
on
ddl_command_start
execute
procedure
test_event_trigger
(
'argument not allowed'
);
-- OK
create
event
trigger
regress_event_trigger2
on
ddl_command_start
when
tag
in
(
'create table'
,
'CREATE FUNCTION'
)
...
...
@@ -75,7 +102,10 @@ alter event trigger regress_event_trigger disable;
-- regress_event_trigger
create
table
event_trigger_fire1
(
a
int
);
-- regress_event_trigger_end should fire here
-- regress_event_trigger_end should fire on these commands
grant
all
on
table
event_trigger_fire1
to
public
;
comment
on
table
event_trigger_fire1
is
'here is a comment'
;
revoke
all
on
table
event_trigger_fire1
from
public
;
drop
table
event_trigger_fire1
;
-- alter owner to non-superuser should fail
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment