Wrong script executed without error.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Wrong script executed without error.

GattoDispettoso
Flamerobin: latest available - firebird WI-V2.1.3.18185

the following script is executed without errors:

alter table noteconsegna_tv drop constraint "NOTECONSEGNATV_PRIMARY";
commit
alter table noteconsegna_tv add CONSTRAINT "NOTECONSEGNATV_PRIMARY" PRIMARY KEY ("ANNO", "SERIE", "NUMERO", "AGGIUNTIVO", "RIGA");
commit;

NOTE the missing semicolon after the first commit statement.
Executing it all seems ok (no errors returned), the original primary key is dropped but the new primary key is not created. All subsequent statements are executed as expected. Fields are declared as: ANNO smallint ,SERIE smallint ,NUMERO integer, RIGA integer, AGGIUNTIVO varchar(4).

VERY DANGEROUS!
Reply | Threaded
Open this post in threaded view
|

Re: Wrong script executed without error.

Milan Babuskov-4
Here's a simple SQL script to reproduce, just copy/paste into SQL editor:

---------------------------------------------
RECREATE TABLE t1
(
    c1 integer not null,
    c2 integer not null,
    CONSTRAINT t1pk PRIMARY KEY (c1)
);
commit;

alter table t1 drop constraint t1pk;
commit
alter table t1 add constraint t1pk2 primary key (c1,c2);
commit;
---------------------------------------------

This works as-designed, if statement begins with COMMIT or ROLLBACK
everything that follows is ignored. I'm not sure whether this is a
real problem that needs fixing, it never happened to me or anyone I
know in 10 years of using Firebird. But then again, I rarely place
COMMIT in the scripts manually.

Doesn't seem to easy to fix either. The statement is never sent to
Firebird's parser, so we would need to be clever to filter what tokens
would be ok and which ones not. Also, a valid script might contain
COMMIT STATEMENT construct and maybe some other variant. It would need
testing.

Thoughts?

--
Milan Babuskov
http://www.guacosoft.com

------------------------------------------------------------------------------
Storage Efficiency Calculator
This modeling tool is based on patent-pending intellectual property that
has been used successfully in hundreds of IBM storage optimization engage-
ments, worldwide.  Store less, Store more with what you own, Move data to
the right place. Try It Now! http://www.accelacomm.com/jaw/sfnl/114/51427378/
_______________________________________________
Flamerobin-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/flamerobin-devel