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

Delete from view only deletes a single record, not all matching records #6993

Closed
PaVeloR opened this issue Oct 6, 2021 · 6 comments
Closed

Comments

@PaVeloR
Copy link

PaVeloR commented Oct 6, 2021

    set names win1251;
    
    set sql dialect 3;
    
    create database 'X:\BG.fdb'
    user "usr" password 'pwd'
    page_size 4096
    default character set win1251;

create domain id integer not null;
create domain name varchar(40) not null;
create table R(id id, name name, constraint R_PK primary key(id));
create table D(id id, rid id, DT timestamp not null, constraint D_pk primary key(id), constraint D_R_FK foreign key(rid) references R(id));
create table DD(DID id, DIDX id, fld0 integer, fld1 integer, fld2 integer, fld3 integer, constraint DD_PK primary key(DID, DIDX), constraint DD_D_FK foreign key(DID) references D(id));

create view VDD as
select DD.*, D.DT ddt, R.id rid from dd
inner join D on D.id=dd.did
inner join r on d.rid=r.id;

set term ^ ;

CREATE OR ALTER trigger VDD_BD for VDD
active before delete position 0
as begin
delete from DD where DD.did=old.did and dd.didx=old.didx;
end^

insert into R values (1, '1')^
insert into D values (1, 1, current_timestamp)^
insert into dd values (1, 1, 1, 1, 1, 1)^
insert into dd values (1, 2, 1, 1, 1, 1)^
insert into dd values (1, 3, 1, 1, 1, 1)^
insert into dd values (1, 4, 1, 1, 1, 0)^
insert into dd values (1, 5, 1, 1, 1, 1)^
insert into dd values (1, 6, 1, 1, 1, 1)^
insert into dd values (1, 7, 1, 1, 1, 1)^
insert into dd values (1, 8, 1, 1, 1, 0)^
insert into dd values (1, 9, 1, 1, 1, 1)^
insert into dd values (1, 10, 1, 1, 1, 1)^
insert into dd values (1, 11, 1, 1, 1, 1)^
insert into dd values (1, 12, 1, 1, 1, 0)^
commit^
delete from vdd where did=1 and fld3=0^-- The query only deletes one line!!!!!!!!!!!!
--delete from vdd; The query only deletes one line
commit^
/*CREATE VIEW sVDD(
DID,
DIDX,
FLD0,
FLD1,
FLD2,
FLD3)
AS
select * from dd^
--delete fro svdd-- is work;
*/

@PaVeloR PaVeloR changed the title delete from view FB4 delete from view. Oct 6, 2021
@dyemanov
Copy link
Member

dyemanov commented Oct 6, 2021

Duplicate for #6838?

@dyemanov
Copy link
Member

dyemanov commented Oct 6, 2021

It should be already fixed in snapshot builds.

@PaVeloR
Copy link
Author

PaVeloR commented Oct 6, 2021

Server Version Info

Server Version: WI-V4.0.0.2496 Firebird 4.0
Server Implementation: Firebird/Windows/AMD/Intel/x64
Service Version: 2

full reproduce!

@PaVeloR
Copy link
Author

PaVeloR commented Oct 6, 2021

Firebird-4.0.1.2623 full reproduce

@dyemanov
Copy link
Member

dyemanov commented Oct 6, 2021

Just tested with LI-V4.0.1.2622, three rows are deleted.

@PaVeloR
Copy link
Author

PaVeloR commented Oct 6, 2021

Yes !!! Server Version Info

Server Version: WI-V4.0.1.2623 Firebird 4.0
Server Implementation: Firebird/Windows/AMD/Intel/x64
Service Version: 2
OK

@mrotteveel mrotteveel changed the title FB4 delete from view. Delete from view only deletes a single record, not all matching records Oct 6, 2021
@PaVeloR PaVeloR closed this as completed Oct 7, 2021
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

3 participants