parameters wrongly in the sql's beginning

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
dcoun
Fresh Boarder
Fresh Boarder
Posts: 10
Joined: 16.09.2022, 08:44

parameters wrongly in the sql's beginning

Post by dcoun »

After an exception in a previous query I am getting the following error using Zeos8.0-fixes last trunk and mormot2 with Delphi 11.2 win32:

Code: Select all

Exception: 20221023 07461843  * EXC   EZSQLException {Message:"SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '100804359select pid as ID from table where iid=? limit 1' at line 1
Code: 1064 SQL: select pid as ID from table where iid=? limit 1"} 
[Pool9-TEslave] at 01f194c0 ZDbcMySql.pas TZMySQLConnection.HandleErrorOrWarning (1271)  
ZDbcMySql.pas TZMySQLConnection.HandleErrorOrWarning (1271) 
ZDbcMySqlStatement.pas ExecuteEmulated (1040) 
ZDbcMySqlStatement.pas TZAbstractMySQLPreparedStatement.ExecuteQueryPrepared (1052) 
mormot.db.sql.zeos.pas TSqlDBZeosStatement.ExecutePrepared (1180) 
mormot.db.sql.pas TSqlDBStatement.ExecutePreparedAndFetchAllAsJson (6664) 
mormot.orm.sql.pas TRestStorageExternal.EngineList (1380) 
mormot.orm.server.pas TRestOrmServer.EngineList (1073) 
mormot.orm.rest.pas TRestOrm.ExecuteList (1676) 
mormot.orm.rest.pas TRestOrm.MultiFieldValue (977) ...... 
It seems that the parameter of the query exists in the beginning of the SQL query.
I have put a log point to see where the sql is created like than and the sql squery return from ComposeRawSQLQuery in TZAbstractMySQLPreparedStatement.ExecuteQueryPrepared is returned as

Code: Select all

100804359select pid as ID from table where iid=? limit 1


Before that in TSqlDBZeosStatement.ExecutePrepared from mormot.db.sql.zeos the fStatement.GetSQL returns the correct query:

Code: Select all

select pid as ID from patient where amka=? limit 1
What do you propose to log in order to debug it more?
I can reproduce that in an example and for the moment I just log such a problem when it happens.
Thank you in advance
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: parameters wrongly in the sql's beginning

Post by marsupilami »

Hello,

that sounds strange to me because on MariaDB Zeos has no reason to chenge the SQL statements and try to insert parameters there. Did you already check if this also happens without mormot? For example something like this:

Code: Select all

  ZQuery.Close;
  ZQuery.SQL.Text := 'select pid as ID from table where iid=:iid limit 1';
  ZQuery.ParamByName('iid').AsInteger := 100804359;
  ZQuery.Open;
Just to see if this isn't introduced by mORMot in any way?

Best regards,

Jan
dcoun
Fresh Boarder
Fresh Boarder
Posts: 10
Joined: 16.09.2022, 08:44

Re: parameters wrongly in the sql's beginning

Post by dcoun »

The problem is that this seldom happens and usually after an other exception (like a duplicate primary index or a field insert with out of range value).
Do you propose to add somewhere in the source a log point to find more info?
Post Reply