#1 Yesterday 18:23:01

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 510

mormot or zeos?

I am having a strange error when using TrestBatch. I am getting an exception error when batch is send that happens the same way in the same part of the code and I can not find a solution:

Bind^.indicators is null and gives exception in line 3201 in ZDBcMysqlStatement:

procedure TZMariaDBBatchDMLPreparedStatement.SetNullArray(
  ParameterIndex: Integer; const SQLType: TZSQLType; const Value;
  const VariantType: TZVariantType);
var
  Bind: PMYSQL_aligned_BIND;
  aArray: PZArray;
  I: Integer;
begin
  inherited SetNullArray(ParameterIndex, SQLType, Value, VariantType);
  {$IFNDEF GENERIC_INDEX}
  ParameterIndex := ParameterIndex - 1;
  {$ENDIF}
  {$R-}
  Bind := @FMYSQL_aligned_BINDs[ParameterIndex];
  {$IFDEF RangeCheckEnabled}{$R+}{$ENDIF}
  if (FMYSQL_STMT = nil) then
    InternalRealPrepare;
  if (FMYSQL_STMT = nil) then
    raise EZSQLException.Create(SFailedtoPrepareStmt);
  aArray := BindList[ParameterIndex].Value;
  if Pointer(Value) = nil
  then FillChar(Bind^.indicators^, BatchDMLArrayCount, Char(MySQLNullIndicatorMatrix[False, FUseDefaults]))
  else for i := 0 to BatchDMLArrayCount -1 do
    {$R-}
{3201 line}    Bind^.indicators[I] :=  MySQLNullIndicatorMatrix[(Bind^.indicators[i] = Ord(STMT_INDICATOR_NULL)) or IsNullFromArray(aArray, I), FUseDefaults];
    {$IFDEF RangeCheckEnabled}{$R+}{$ENDIF}
end;

ParameterIndex is 0 as it is called from TZeosArrayBinding.Create line 1091 of mormot.db.sql.zeos where fStatement does not seem to have something unsual.

I am using Delphi 12.3 64bit, with mariadb 10.6.7 and 10.6.24 dll
This problem does not happen in 32bit with mariadb 3.1.24 dll but it gives an error in function TZAbstractMySQLPreparedStatement.GetUpdateCount in line 1314 (LastUpdateCount := FPlainDriver.mysql_stmt_affected_rows(FMYSQL_STMT);)
Also this happens with only 3 Torms that they do not have something special. And all this happens exactly the same in any case for these torms
One of the them is:

  TormEhfymdIcd=class(Torm)
    private
      Fdescr, Fcod: rawutf8; Fsdat, Fedat: tdatetime;
    public
      class procedure InitializeTable(const Server: IRestOrmServer; const FieldName: RawUtf8; Options: TOrmInitializeTableOptions); override;
    published
      property cod: rawutf8 index 25 read Fcod write Fcod;
      property descr: rawutf8 index 1500 read Fdescr write Fdescr;
      property sdat: tdatetime read Fsdat write Fsdat;
      property edat: tdatetime read Fedat write Fedat;
  end;

Any help? I really can not understand what happens. Thank you in advance

Last edited by dcoun (Yesterday 18:24:38)

Offline

#2 Yesterday 23:49:17

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 510

Re: mormot or zeos?

Looking the logs probably I have find the problem:
Mormot creates a query to update a Torm where the datetime field "approved" is 0 and in the query is shown as '', producing the error:
update pinakas set vid=295,abnorm=0,monas=0,timi='6 , 13:45',sim='',parentbcode=74272047418,approved='' where ID=959894
The above query does not run in mariadb

Last edited by dcoun (Yesterday 23:49:29)

Offline

#3 Today 07:49:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,385
Website

Re: mormot or zeos?

What is the exception message?

You want to insert null into a non nullable field I guess.

Offline

#4 Today 08:49:45

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 510

Re: mormot or zeos?

ThreadId=3080
ProcessId=9
ThreadName="pool10-TepresSlave"
ExceptionMessage="Access violation at address 0000000000BC119E. Read of address 0000000000000000"
ExceptionName="EAccessViolation"
ExceptionDisplayName="$C0000005"
ExceptionAddress=00BC119E
FileName="C:\DG\zeoslib\src\dbc\ZDbcMySqlStatement.pas"
LineNumber=3201

I delete the table and left mormot to recreate it, but the same exception happened again
Entering 0 in a Tdatetime field in a Torm is allowed?

How can I debug it more?

Last edited by dcoun (Today 08:50:41)

Offline

#5 Today 08:54:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,385
Website

Re: mormot or zeos?

An access violation here seems more like a problem in ZDBC (e.g. buffer overflow).

Especially if it works on some targets, but not on others.

Offline

#6 Today 09:50:42

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 510

Re: mormot or zeos?

I removed the updates from trestbatch and now it seems that everything works with updates
Now I have again a problem with Trestbatch in the same zeos file in TZAbstractMySQLPreparedStatement.GetUpdateCount: Integer; line 1314
        LastUpdateCount := FPlainDriver.mysql_stmt_affected_rows(FMYSQL_STMT);
That gives Range Check Error when called from TSqlDBZeosStatement.UpdateCount

What do you recommend to use as alternative to zeos for mariab and mormot2?
For windows and linux

Offline

#7 Today 10:42:18

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 510

Re: mormot or zeos?

I also found in the logs the following error that it is not connected with zeos:
20260123 10355947  5 EXC   ESqlite3Exception {Message:"Error SQLITE_ERROR (1) [Step] using 3.51.2 - SQL logic error",ErrorCode:1,SQLite3ErrorCode:"secERROR"} [pool15-TepresSlave] at 01232ca2  {6 2.57 65532.92 8 5GB/7.7GB 66581b01}
20260123 10355947  5 ERROR mormot.rest.sqlite3.TRestServerDB(02187594f480) {"ESqlite3Exception(02182f9aab20)":{Message:"Error SQLITE_ERROR (1) [Step] using 3.51.2 - SQL logic error",ErrorCode:1,SQLite3ErrorCode:"secERROR"}} for update EhfyResult set exid=:(4674): where RowID in (:(112150186198810):,:(112150186198811):) // update EhfyResult set exid=? where RowID in (?,?)
20260123 10355947  5 EXC   EZUnsupportedException {Message:"Unsupported operation"} [pool15-TepresSlave] at e58408  {6 2.57 65532.92 8 5GB/7.7GB 66581b01}

Offline

Board footer

Powered by FluxBB