FirebirdSQL / firebird

Firebird server, client and tools
https://firebirdsql.org
1.26k stars 217 forks source link

Client could crash if DDL and DML are executed in the same transaction [CORE2130] #2561

Open firebird-automations opened 16 years ago

firebird-automations commented 16 years ago

Submitted by: Kuznetsov Eugene (eugene)

Testing for 2.5, but other versions are also undergone.

isql failed (AV in fbclient.dll) when trying executing select statement, as no fields exist at that moment. Server should return an error, but doesn't do it.

SET AUTODDL OFF; SET SQL DIALECT 3; SET NAMES WIN1251;

CONNECT test25 USER 'SYSDBA' PASSWORD 'masterkey';

CREATE TABLE NEW_TABLE7 (ID SMALLINT NOT NULL); COMMIT;

insert into NEW_TABLE7(ID) VALUES (0); COMMIT;

ALTER TABLE NEW_TABLE7 ADD FIELD1 CHAR(1) NOT NULL;

ALTER TABLE NEW_TABLE7 DROP ID;

select * from New_table7;

COMMIT;

-- Best regards, Eugene

firebird-automations commented 16 years ago
Modified by: @dyemanov summary: Client could failed if DDL and DML are produced in the same transaction =\> Client could crash if DDL and DML are executed in the same transaction
firebird-automations commented 16 years ago
Modified by: @dyemanov priority: Minor \[ 4 \] =\> Major \[ 3 \]
firebird-automations commented 16 years ago
Modified by: @dyemanov assignee: Dmitry Yemanov \[ dimitr \]
firebird-automations commented 16 years ago

Commented by: @dyemanov

Actually, this ticket is not about metadata handling but about API usage. This test case forces the prepare/describe call to clear the sqld value of XSQLDA and pass it to the fetch call. It works okay for the embedded engine but fails for other connection types in the remote protocol code. This situation could be easily reproduced at the API level with any valid select statement.

So, this issue leaves us with a question: should we allow to fetch records with empty output XSQLDA (sqld == 0) or not? The engine itself is ready for that. Also, some clever person could use this trick to check for EOF (or count rows) without retrieving the values of the select list. Therefore, I tend to fix the code to allow such queries. From another side, this "feature" doesn't make any sense for 99% of the users...

Opinions?

firebird-automations commented 16 years ago

Commented by: Kuznetsov Eugene (eugene)

To Dmitry Yemanov

> Opinions? Though dataset without columns sounds strange for me, it can make sense for optimization goals. Maybe, we should hear developers dealing with API - Dmitry Kovalenko or Dimitry Sibiryakov, for example. -- Best regards, Eugene

firebird-automations commented 16 years ago

Commented by: @AlexPeshkoff

As a minimum requirement AV should be fixed. But IMHO it's better to let remote select 0 columns in SQLDA - if it does not require rewriting half of remote's code.

firebird-automations commented 9 years ago
Modified by: @dyemanov assignee: Dmitry Yemanov \[ dimitr \] =\>