2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-26 21:10:46 +01:00
|
|
|
"""
|
|
|
|
ID: issue-6017
|
|
|
|
ISSUE: 6017
|
|
|
|
TITLE: ALTER TRIGGER check privilege for alter database instead of table
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-5754
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_5754
|
2023-11-25 17:28:25 +01:00
|
|
|
NOTES:
|
|
|
|
[25.11.2023] pzotov
|
|
|
|
Writing code requires more care since 6.0.0.150: ISQL does not allow specifying duplicate delimiters without any statements between them (two semicolon, two carets etc).
|
2022-01-26 21:10:46 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-26 21:10:46 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-26 21:10:46 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-26 21:10:46 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
set bail on;
|
|
|
|
|
|
|
|
create or alter user tmp$c5754 password '123';
|
|
|
|
commit;
|
|
|
|
|
|
|
|
recreate table test(id int);
|
|
|
|
recreate sequence g;
|
|
|
|
commit;
|
|
|
|
|
|
|
|
-- GRANT ALTER ANY <OBJECT> TO [USER | ROLE] <user/role name> [WITH GRANT OPTION];
|
|
|
|
-- DDL operations for managing triggers and indices re-use table privileges.
|
|
|
|
grant alter any table to tmp$c5754;
|
|
|
|
commit;
|
|
|
|
|
|
|
|
set term ^;
|
|
|
|
create or alter trigger test_bi for test active before insert position 0 as
|
|
|
|
begin
|
|
|
|
new.id = coalesce(new.id, gen_id(g, 1) );
|
|
|
|
end
|
|
|
|
^
|
|
|
|
set term ;^
|
|
|
|
commit;
|
|
|
|
|
|
|
|
connect '$(DSN)' user tmp$c5754 password '123';
|
|
|
|
|
|
|
|
set term ^;
|
|
|
|
|
|
|
|
-- Following attempt to alter trigger will fail on 4.0.0.890 with message:
|
|
|
|
-- Statement failed, SQLSTATE = 28000
|
|
|
|
-- unsuccessful metadata update
|
|
|
|
-- -ALTER TRIGGER TEST_BI failed
|
|
|
|
-- -no permission for ALTER access to DATABASE
|
|
|
|
alter trigger test_bi as
|
|
|
|
begin
|
|
|
|
-- this trigger was updated by tmp$c5754
|
|
|
|
if ( new.id is null ) then
|
|
|
|
new.id = gen_id(g, 1);
|
|
|
|
end
|
|
|
|
^
|
2023-11-25 17:28:25 +01:00
|
|
|
set term ;^
|
2021-04-26 20:07:00 +02:00
|
|
|
commit;
|
|
|
|
|
|
|
|
commit;
|
|
|
|
connect '$(DSN)' user sysdba password 'masterkey';
|
|
|
|
drop user tmp$c5754;
|
|
|
|
commit;
|
|
|
|
|
|
|
|
set list on;
|
|
|
|
|
|
|
|
select 1 as result
|
|
|
|
from rdb$triggers
|
|
|
|
where rdb$trigger_name = upper('test_bi')
|
|
|
|
and rdb$trigger_source containing 'tmp$c5754'
|
|
|
|
;
|
|
|
|
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-26 21:10:46 +01:00
|
|
|
act = isql_act('db', test_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-26 21:10:46 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
RESULT 1
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
@pytest.mark.version('>=3.0.4')
|
2022-01-26 21:10:46 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.execute()
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|