That code is very legacy and dates from a time when Update..Returning did not exist.

Actually, it works the same as the modern version. My point was about what the user expects. If you execute an Update...Returning with the code you pasted in below, with Firebird 4.0.0 it drops through the SQLExecProcedure and the user can access the returned values immediately afterwards.

In Firebird 5, the code executes the SQLSelect case. Note that only if FGoToFirstRecordOnExecute is true will the returned values be available immediately. Otherwise, the user has to call "Next" explicitly. That is why the change to Update...Returning can break user code.

In order to try and maintain the TIBSQL semantics for Firebird 5, I need to be able to distinguish between a true select query, an Update...Returning that returns a singleton row and one that returns a cursor. I may be able to find an answer by experimenting with the new behaviour, but that will not stop me moaning that the extension of Update..Returning has been implemented without keeping faith with existing code.

On 26/11/2021 16:47, Dimitry Sibiryakov wrote:
Tony Whyman wrote 26.11.2021 17:13:
Legacy code can often appear "insane" with the benefit of hindsight. The problem is that it exists and it is your starting point. You don't break it without good reason.

  Ok, here is legacy code from TIBSQL.ExecQuery:

  case FSQLType of
    SQLSelect:
    begin
      Call(FGDSLibrary.isc_dsql_execute2(StatusVector,
                            TRHandle,
                            @FHandle,
                            Database.SQLDialect,
                            FSQLParams.AsXSQLDA,
                            nil), True);
      Call(
        FGDSLibrary.isc_dsql_set_cursor_name(StatusVector, @FHandle, PChar(FCursor), 0),
        True);
      FOpen := True;
      FBOF := True;
      FEOF := False;
      FRecordCount := 0;
      if FGoToFirstRecordOnExecute then
        Next;
    end;
    SQLExecProcedure:
    begin
      fetch_res := Call(FGDSLibrary.isc_dsql_execute2(StatusVector,
                            TRHandle,
                            @FHandle,
                            Database.SQLDialect,
                            FSQLParams.AsXSQLDA,
                            FSQLRecord.AsXSQLDA), False);
..... and so on.......

  As you can see it IS sane and won't be broken so if _current_ IBX code differs from it - the one who "improved" it must be blamed. Firebird team cannot help in this case.



Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to