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

Single attachment produces "SQLSTATE = 40001 / deadlock / read conflicts with concurrent update" when doing DDL which has block with SET AUTODDL OFF and attempting to compile SP which write into read-only view [CORE4961] #5252

Open
firebird-automations opened this issue Oct 12, 2015 · 0 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @pavel-zotov

Consider following script (WI-V3.0.0.32070):

show version;
create or alter procedure sp\_update as begin end;
create or alter view v\_test\(pid, f01\) as select 1 pid, 2 f01 from rdb$database;
commit;

recreate table test1\(id int primary key\);
recreate table test2\(id int primary key, pid int, f01 numeric\(12,2\)\);
commit;

create or alter view v\_test as
select <http://a.id> as pid, b\.f01
from test1 a left join test2 b on a\.id=b\.pid;

commit;

set autoddl off; \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \[ 1 \]

set term ^;
create or alter procedure sp\_dummy as 
    declare c int;
begin 
    select count\(\*\) from rdb$types into c;
end 
^ 

\-\- commit ^                                        \-\-\-\-\-\-\-\-\- \[ 2 \]

create or alter procedure sp\_update as 
begin
   update v\_test set f01 = 1 where pid = 0;
end 
^

set term ;^
commit;

set autoddl on;

set term ^;
create trigger test1\_bi for test1 active before insert position 0 as
begin
  if \(<http://new.id> is null\) then execute procedure sp\_dummy;
end 
^
set term ;^
commit;

set list on;
set blob all;
select rdb$procedure\_name, rdb$procedure\_source from rdb$procedures;

show procedure sp\_dummy;

quit;

===

When 'commit' that is marked as "[ 2 ]" is commented, this script produces:

Statement failed, SQLSTATE = 2F000
Error while parsing procedure SP_UPDATE's BLR
-cannot update read-only view V_TEST
After line 34 in file meta-deadlock.sql
Statement failed, SQLSTATE = 40001
unsuccessful metadata update
-CREATE TRIGGER TEST1_BI failed
-deadlock
-read conflicts with concurrent update ------------------------------------------------ [ A ]
-concurrent transaction number is 589
After line 39 in file meta-deadlock.sql
Statement failed, SQLSTATE = 2F000
Error while parsing procedure SP_UPDATE's BLR
-cannot update read-only view V_TEST
After line 45 in file meta-deadlock.sql

RDB$PROCEDURE_NAME SP_UPDATE
RDB$PROCEDURE_SOURCE 1a:3ee
begin
update v_test set f01 = 1 where pid = 0;
end

RDB$PROCEDURE_NAME SP_DUMMY
RDB$PROCEDURE_SOURCE 1a:3e5
declare c int;
begin
select count(*) from rdb$types into c;
end

Statement failed, SQLSTATE = 40001
deadlock
-read conflicts with concurrent update -------------------------------------------------- [ B ]
-concurrent transaction number is 589
After line 50 in file meta-deadlock.sql
Command error: show procedure sp_dummy

Line "[ A ]" relates to 'create trigger' statement and line '[ B ]' - to 'show procedure sp_dummy'.
Both these message looks very strange. Record in RDB$PROCEDURES for 'SP_DUMMY' entry is locked.

But "who" does this if there is COMMIT statement before "create trigger test1_bi" ?

PS. When 'commit' that is marked as "[ 2 ]" is UNcommented, I get only

Statement failed, SQLSTATE = 2F000
Error while parsing procedure SP_UPDATE's BLR
-cannot update read-only view V_TEST
After line 34 in file meta-deadlock.sql
Statement failed, SQLSTATE = 2F000
Error while parsing procedure SP_UPDATE's BLR
-cannot update read-only view V_TEST
After line 45 in file meta-deadlock.sql

PPS. When [1] is Commented, I get:

Statement failed, SQLSTATE = 2F000
Error while parsing procedure SP_UPDATE's BLR
-cannot update read-only view V_TEST
After line 24 in file meta-deadlock.sql

(i.e. only one message rather than two).

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

1 participant