Subject INSERT ... RETURNING vs AutoCommit
Author

Hello,


I have the following database structure:


CREATE GENERATOR S_FILES_ID;

CREATE TABLE FILES (
    ID BIGINT NOT NULL,
    CONTENT BLOB SUB_TYPE 0 NOT NULL
);

ALTER TABLE FILES ADD CONSTRAINT PK_FILES PRIMARY KEY (ID);

SET TERM ^ ;

CREATE OR ALTER TRIGGER BI_FILES FOR FILES
ACTIVE BEFORE INSERT POSITION 0
AS   
BEGIN
  NEW.ID = NEXT VALUE FOR S_FILES_ID;
END^

SET TERM ; ^


Now, when I insert into it with the following code:


function InsertFile: Int64;
var
  LQuery: TIBOQuery;
begin
  LQuery := TIBOQuery.Create(nil);
  try
    LQuery.SQL.Text := 'INSERT INTO FILES (CONTENT) VALUES (:CONTENT) RETURNING ID';
    LQuery.ParamByName('CONTENT').LoadFromFile('C:\...', ftBlob);
    LQuery.Open;
    Result := LQuery.FieldByName('ID').AsLargeInt;
    LQuery.Close;
  finally
    LQuery.Free;
  end;
end;


and a TIBODatabase elsewhere that has AutoCommit enabled, the insert does not seem to be automatically committed to the database. Only when I close the (demo) application, the inserted record shows up in another transaction with ReadCommitted isolation. When I remove the RETURNING clause, the commit is instant.


I've tested this with IBO 5.7.7 2340. I did not see any changes in the log that indicate anything related to this changed in the few versions since then. Am I doing something wrong, or is this a bug?


Thanks!