Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is not possible to create a ddl-trigger with "any DDL statement" clause [CORE3964] #4297

Closed
firebird-automations opened this issue Oct 29, 2012 · 4 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Frank Schlottmann-Goedde (fsg)

Using the following script in isql against the employee database demonstrates the error

/*
It is not possible to create a ddl-trigger with "any DDL statement" clause

fails with:

Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-CREATE TRIGGER TAA_SQL1 failed
-Invalid command
-Database trigger type can't be changed
probably due to the following code in DdlNodes.epp:
2967:// ASF: Unregistered bug (2.0, 2.1, 2.5, 3.0): CREATE OR ALTER TRIGGER accepts different table
// than one used in already created trigger.

AutoCacheRequest requestHandle\(tdbb, drq\_m\_trigger2, DYN\_REQUESTS\);

FOR \(REQUEST\_HANDLE requestHandle TRANSACTION\_HANDLE transaction\)
	TRG IN RDB$TRIGGERS
	WITH TRG\.RDB$TRIGGER\_NAME EQ name\.c\_str\(\)
\{
	if \(type\.specified && type\.value \!= \(FB\_UINT64\) TRG\.RDB$TRIGGER\_TYPE &&
		TRG\.RDB$RELATION\_NAME\.NULL\)
	\{
		status\_exception::raise\(
			Arg::Gds\(isc\_dsql\_command\_err\) <<
			Arg::Gds\(isc\_dsql\_db\_trigger\_type\_cant\_change\)\);
	\}

*/

CREATE TABLE MP$MODIFIED_TABLES (
RELATION_NAME CHAR(31)
);

CREATE INDEX MP$MODIFIED_TABLES_IDX ON MP$MODIFIED_TABLES (RELATION_NAME);

set term ^;
create trigger TAA_SQL1
active after any DDL statement position 0
as
begin
if ((RDB$GET_CONTEXT('DDL_TRIGGER', 'OBJECT_TYPE') = 'TABLE') and
(RDB$GET_CONTEXT('DDL_TRIGGER', 'EVENT_TYPE') in ('CREATE', 'DROP') or
(RDB$GET_CONTEXT('DDL_TRIGGER', 'SQL_SOURCE') containing 'FIELD'))) then
insert into MP$MODIFIED_TABLES (RELATION_NAME)
values (RDB$GET_CONTEXT('DDL_TRIGGER', 'OBJECT_NAME'));
end^
set term ;^

Commits: c0b11f5

====== Test Details ======

Perhaps, code in this test needs to be re-implemented: it looks like trivial and doesn't cover all cases.

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 3.0 Alpha 1 [ 10331 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Closed [ 6 ] => Closed [ 6 ]

QA Status: Done with caveats

Test Details: Perhaps, code in this test needs to be re-implemented: it looks like trivial and doesn't cover all cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants