#1 2021-02-26 10:53:34

L_VV
Member
Registered: 2020-10-29
Posts: 38

mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

Good afternoon,

I started learning mORMot2, and I adapted the example from the article
https://tamingthemormot.wordpress.com/2 … databases/

Almost everything worked, but at the last stage, after connecting to the database, when receiving the current time from the server, an exception in ZDbcResultSetMetadata.pas occurs (called from mormot.db.sql --> mormot.db.sql.zeos).
This is not my select, but the select from the mORMot code (select current_timestamp from rdb$database).
I can't figure out what I'm doing wrong, or may be this is a bug in mORMot / Zeos...

Below is a link to an archive with a script for creating a Firebird database with one table (create_db.sh) and a console application project on fpc / Lazarus:
https://drive.google.com/file/d/1WV1DQn … sp=sharing

You can run it and make a request from the console (test_curl_post.sh):
curl --header "Content-Type: application / json" --request POST --data '{"ID": "\ {A37E3E34-48AE-40B3-87A8-BBC3F97BEAD4 \}"}' http: // localhost: 8080 / root / UsrService / GetUsr

In response to it, the following json is returned:
{
"errorCode": 500,
"error":
{"EZSQLException":
{
        "ClassName": "EZSQLException",
        "Address": "7ffff5f2b300",
        "Message": "Bound variable index out of range: 1"
}}
}

as a result of the exception:
Project Test Application Server raised exception class 'EStringListError' with message:
List index (1) out of bounds
In file '../../src/dbc/ZDbcResultSetMetadata.pas' at line 694:
Result: = ColumnsLabels [ColumnIndex {$ IFNDEF GENERIC_INDEX} - 1 {$ ENDIF}];

and then

Project Test Application Server raised exception class 'EZSQLException' with message:
Bound variable index out of range: 1
In file '../../src/dbc/ZDbcFirebirdInterbase.pas' at line 3738:
raise EZSQLException.Create {$ IFDEF UNICODE} FUniTemp {$ ELSE} FRawTemp {$ ENDIF});


In a comment in the TUsrService.GetUsr method in the rest_Usr.pas file, I wrote the function calls that throw the exception.

Environment:
OS: 5.10.0-3-amd64 # 1 SMP Debian 5.10.12-1 (2021-01-30) x86_64 GNU / Linux
FPC / Lazarus: trunk / trunk (same on stable)
DB: Firebird 4 amd64 trunk

Please help me to solve this problem, because of this error I can not go further.

Last edited by L_VV (2021-02-26 11:21:41)

Offline

#2 2021-02-26 16:38:05

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

What is the SELECT statement executed?
Is it "select current_timestamp from rdb$database" ?
Then I guess this may be a Zeos issue.

Offline

#3 2021-02-27 15:58:48

L_VV
Member
Registered: 2020-10-29
Posts: 38

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

It is difficult to tell right away which of the two libraries the issue is in.

On the one hand, an exception occurs in ZeosLib, but on the other hand, an invalid column index = 1 is passed to the TZAbstractResultSetMetadata.GetColumnLabel () function from the TSqlDBZEOSStatement.ExecutePrepared() function of the mormot.db.sql.zeos unit.

The query 'select current_timestamp from rdb$database' returns one column whose index in the TStringList must be 0.
This query initiated by mORMot, not Zeos:

mormot.db.sql:  line 6562 - TSqlDBConnection.Connect()
                line 6572 - fServerTimestampAtConnection := ServerDateTime;

                line 6658 - TSqlDBConnection.GetServerDateTime: TDateTime;
                line 6667 - with Execute(fSqlGetServerTimestamp, []) do

                line 3098 - fSqlGetServerTimestamp := DB_SERVERTIME[db];
                line  400 - DB_SERVERTIME: array[TSqlDBDefinition] of RawUtf8 = (
                            ..., 'select current_timestamp from rdb$database', ...);


As we can see, TSqlDBZEOSStatement.ExecutePrepared() calls fResultInfo.GetColumnLabel() with parameter = 1:
                                   ...
mormot.db.sql.zeos:    line 1144 - fResultInfo := fResultSet.GetMetadata;
                                   n := fResultInfo.GetColumnCount;
                                   fColumn.Capacity := n;
                                   for i := 0 to n - 1 do
                                     begin
                       line 1149 -     name := fResultInfo.GetColumnLabel(i + FirstDbcIndex);
                                                                          ^^^^^^^^^^^^^^^^^
                                       HERE i = 0, FirstDbcIndex = 1,
                                       THEREAFTER IN TZAbstractResultSetMetadata.GetColumnLabel()
                                       PASSED VALUE = 1
                                       ...
                                     end;


ZDbcResultSetMetadata: line  641 - TZAbstractResultSetMetadata.GetColumnLabel(ColumnIndex: Integer): string;
                       line  692 -   if FColumnsLabelsCS = nil then
                                       FillListAndMakeUnique;
         EXCEPTION ==> line  694 -   Result := ColumnsLabels[ColumnIndex{$IFNDEF GENERIC_INDEX} - 1{$ENDIF}];
                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                       $GENERIC_INDEX IS DEFINED,
                                       THEREFORE IN FACT WE ARE TRYING TO GET A TStringList ITEM WITH INDEX = 1,
                                       THEREFORE THERE IS AN EXCEPTION List index (1) out of bounds
                                                                                     
Project Test Application Server raised exception class 'EStringListError' with message:
List index (1) out of bounds
In file '../../src/dbc/ZDbcResultSetMetadata.pas' at line 694:
Result := ColumnsLabels[ColumnIndex{$IFNDEF GENERIC_INDEX} - 1{$ENDIF}];


I made another, a very simple fpc example (console app) to reproduce this error.
The database can either be created with my script, or simply you can specify the path to another Firebird 4 database and correct the query in the project.

After starting the application from the IDE, the 'List index (1) out of bounds' exception will occur and you can see everything in the debugger.

Below is a link to the test example:
https://drive.google.com/file/d/1myazV8 … sp=sharing

Last edited by L_VV (2021-02-27 16:08:39)

Offline

#4 2021-02-27 17:38:48

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

So in mORMot there is FirstDbcIndex = 1 but in Zeos, GENERIC_INDEX expects 0-based indexes...

Why is GENERIC_INDEX defined?
AFAICT in Zeos.inc this GENERIC_INDEX is NOT defined by default.

Did you change something?
Our code expects the default undefined GENERIC_INDEX.
I just committed something which "may" fix your problem.

Offline

#5 2021-02-27 18:01:35

EgonHugeist
Member
From: Germany
Registered: 2013-02-15
Posts: 190

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

@ab,
propably all is correct except SynDBZeos/mormot.db.sql.zeos

there is a missing define:

{$IFNDEF ZEOS72UP} //<------ that's missing
const
  FirstDbcIndex = 1;
  TableNameIndex = 3;
  ColumnNameIndex = 4;
  TableColColumnTypeIndex = 5;
  TableColColumnTypeNameIndex = 6;
  TableColColumnSizeIndex = 7;
  TableColColumnDecimalDigitsIndex = 9;
  IndexInfoColColumnNameIndex = 9;
{$ELSE}
uses ZDbcMetadata;
{$ENDIF}

the constants are required for earlier versions than 7.2. propose to omit them, 7.1 is a dinosour, and 7.2 is old inbetween.

Last edited by EgonHugeist (2021-02-28 05:55:33)

Offline

#6 2021-02-27 22:37:48

L_VV
Member
Registered: 2020-10-29
Posts: 38

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

ab wrote:

So in mORMot there is FirstDbcIndex = 1 but in Zeos, GENERIC_INDEX expects 0-based indexes...

Why is GENERIC_INDEX defined?
AFAICT in Zeos.inc this GENERIC_INDEX is NOT defined by default.

Did you change something?
Our code expects the default undefined GENERIC_INDEX.


No, I did not changed anything.
Just cloned a fresh Zeos copy from git, and Zeos.inc contains:

{.$DEFINE ZEOS_TEST_ONLY}
{$DEFINE GENERIC_INDEX}       <== defined
{.$DEFINE DISABLE_ZPARAM}
//common compilation directives
{$DEFINE ZEOS72UP}
{$DEFINE ZEOS73UP}
{$DEFINE ZEOS80UP}
...
{.$DEFINE USE_SYNCOMMONS} //enable JSON content support by using SynCommons.pas from Synopse project v1.18
{.$DEFINE MORMOT2} //enable JSON content support by using mormot.db.core.pas from Synopse project v2+
...
ab wrote:

I just committed something which "may" fix your problem.

Thank you, Arnaud, this fix worked smile
Stuff with ZeoIndex = {$ ifdef GENERIC_INDEX} 0 {$ else} 1 {$ endif}; will always allow such code to work correctly.
I tried run my test app with last trunk of mORMot2, no exceptions anymore smile


============
Also I tried to enable define MORMOT2 in Zeos.
But if I not enable define USE_SYNCOMMONS togeher with MORMOT2, then the unit ZDbcResultSet is not compiled because of that condition:

{$IFDEF USE_SYNCOMMONS}
const
  JSONBool: array[Boolean] of ShortString = ('false', 'true');
{$ENDIF USE_SYNCOMMONS}

Maybe both of these definitions should be used in the condition at once?
{$IFDEF MORMOT2} or {$IFDEF USE_SYNCOMMONS}

============
After that the compiler found a few incompatible types in ZDbcODBCResultSet.pas (and may be in other files), e.g.

JSONWriter.AddCurr64(ODBCNumeric2Curr(fColDataPtr)); -- Error: Incompatible type for arg no. 1: Got "Currency", expected "PInt64"
JSONWriter.Add(PGUID(fColDataPtr)^); -- Error: Incompatible type for arg no. 1: Got "TGuid", expected "PGuid"

and some identifiers not found, e.g.:

JSONWriter.AddNoJSONEscape(@JSON_SQLDATE_MAGIC_QUOTE_VAR,4) -- Error: Identifier not found "JSON_SQLDATE_MAGIC_QUOTE_VAR"

JSON_SQLDATE_MAGIC_QUOTE_VAR is declared in SynCommon from mORMot version 1, but in mORMot2 it's not defined.
And if I have only mORMot2 installed, than the app is not compiled.

And even I have mORMot v1 installed and added to search path in Zeos package,
but at the same time USE_SYNCOMMONS is not defined, than corresponding units are not available for Zeos:

  {$IFDEF MORMOT2}
  mormot.db.core, mormot.core.datetime,
  {$ELSE MORMOT2} {$IFDEF USE_SYNCOMMONS}
  SynCommons, SynTable,
  {$ENDIF USE_SYNCOMMONS} {$ENDIF MORMOT2}

============

So I had to turn off both of these defines for now...

Offline

#7 2021-02-28 06:08:15

EgonHugeist
Member
From: Germany
Registered: 2013-02-15
Posts: 190

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

@L_VV

interesting. On my side the code dit compile because the units

ZDbcFireBird, ZDbcODBCCon, ZDbcSQLAnywhere

are not part of SynDBZeos/mormot.db.sql.zeos.
Should be fixed by https://sourceforge.net/p/zeoslib/code-0/7348/

According the GENERIC_INDEX case: See my update last post. I dd change that some months ago. If Zeos8, which is stable, is released (just the releaes notes are not complete) i'll remove the define. Means all versions >V8.0 have the zero based index then.
According the defines:
You can NOT mix the USE_SYNCOMMONS and the MORMOT2 define. Just an approach to handle such ideas: https://sourceforge.net/p/zeoslib/code-0/7349/
USE_SYNCOMMONS uses the 1.18 filenames and MORMOT2 .. self explainatory, i guess, am i wrong?.

@AB
please consider my last post and:

  {$if defined(ENABLE_ADO) and not defined(ZEOS_DISABLE_ADO)}
  ZDbcAdo,
  {$ifend}
  {$if defined(ENABLE_DBLIB) and not defined(ZEOS_DISABLE_DBLIB)}
  ZDbcDbLib,
  {$ifend}
  {$if defined(ENABLE_MYSQL) and not defined(ZEOS_DISABLE_MYSQL)}
  ZDbcMySql,
  {$ifend}
  {$if defined(ENABLE_POSTGRESQL) and not defined(ZEOS_DISABLE_POSTGRESQL)}
  ZDbcPostgreSql,
  {$ifend}
  {$if defined(ENABLE_INTERBASE) and not defined(ZEOS_DISABLE_INTERBASE)}
  ZDbcInterbase6,
  {$ifend}
  {$if defined(ENABLE_FIREBIRD) and not defined(ZEOS_DISABLE_FIREBIRD)}
  ZDbcFirebird,
  {$ifend}
  {$if defined(ENABLE_SQLITE) and not defined(ZEOS_DISABLE_SQLITE)}
  ZDbcSqLite,
  {$ifend}
  {$if defined(ENABLE_ORACLE) and not defined(ZEOS_DISABLE_ORACLE)}
  ZDbcOracle,
  {$ifend}
  {$if defined(ENABLE_ASA) and not defined(ZEOS_DISABLE_ASA)}
  ZDbcASA,
  ZDbcSQLAnywhere,
  {$ifend}
  {$if defined(ENABLE_POOLED) and not defined(ZEOS_DISABLE_POOLED)}
  ZDbcPooled,
  {$ifend}
  {$if defined(ENABLE_OLEDB) and not defined(ZEOS_DISABLE_OLEDB)}
  ZDbcOleDB,
  {$ifend}
  {$if defined(ENABLE_ODBC) and not defined(ZEOS_DISABLE_ODBC)}
  ZDbcODBCCon,
  {$ifend}

or should i make a pullrequest?

BTW: What is ZDbcZeosCon? This unit is not known to me.

Last edited by EgonHugeist (2021-02-28 06:43:37)

Offline

#8 2021-02-28 10:27:57

L_VV
Member
Registered: 2020-10-29
Posts: 38

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

EgonHugeist wrote:

According the defines:
You can NOT mix the USE_SYNCOMMONS and the MORMOT2 define.

This is clear. But as I wrote, I tried to enable only the MORMOT2 define, and Zeos couldn't compile.
Therefore, just to test compilation, I have included USE_SYNCOMMONS as well.
The errors still remained, I showed them in the previous message.


Now, after updating the Zeos to the current trunk, if I enable the MORMOT2 define, other compilation errors occur, e.g.:

unit ZDbcPostgreSqlResultSet:

then JSONWriter.AddJSONEscape(P, ZDbcUtils.GetAbsorbedTrailingSpacesLen(P, {$IFDEF MORMOT2}mormot.core.base{$ELSE}SynCommons{$ENDIF}.StrLen(P)))
ZDbcPostgreSqlResultSet.pas(798,134) Error: Identifier not found "base"
ZDbcPostgreSqlResultSet.pas(909,134) Error: Identifier not found "base"

then {$IFDEF WITH_COLUMNS_TO_JSON}{$IFDEF MORMOT2}mormot.core.text{$ELSE}SynCommons{$ENDIF}.{$ENDIF}HexToBin(Buffer+2, @Result.D1, SizeOf(TGUID))
ZDbcPostgreSqlResultSet.pas(1949,71) Error: Identifier not found "text"


const PGOidLopOpenMode: Array[TZLobStreamMode] of Integer = (INV_READ or INV_WRITE, INV_WRITE, INV_READ or INV_WRITE);
ZDbcPostgreSqlResultSet.pas(2870,83) Error: Illegal expression
ZDbcPostgreSqlResultSet.pas(2870,117) Error: Illegal expression

Maybe this is due to the units names with dots in functions calls under fpc?
Although on an fpc trunk this should work...

then JSONWriter.AddJSONEscape(P, ZDbcUtils.GetAbsorbedTrailingSpacesLen(P, SynCommons.StrLen(P))) ==> was changed to:
then JSONWriter.AddJSONEscape(P, ZDbcUtils.GetAbsorbedTrailingSpacesLen(P, {$IFDEF MORMOT2}mormot.core.base{$ELSE}SynCommons{$ENDIF}.StrLen(P)))

then {$IFDEF USE_SYNCOMMONS}SynCommons.{$ENDIF}HexToBin(Buffer+2, @Result.D1, SizeOf(TGUID)) ==> was changed to:
then {$IFDEF WITH_COLUMNS_TO_JSON}{$IFDEF MORMOT2}mormot.core.text{$ELSE}SynCommons{$ENDIF}.{$ENDIF}HexToBin(Buffer+2, @Result.D1, SizeOf(TGUID))

Perhaps the same could be in other units affected.


Also the unit mormot.db.sql.zeos uses unit ZURL, but it is missing in the package ZComponent, so I added it manually.

Last edited by L_VV (2021-02-28 10:40:45)

Offline

#9 2021-02-28 10:57:59

L_VV
Member
Registered: 2020-10-29
Posts: 38

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

Looked at the Zeos.inc file
It turns out that in order for Zeos to compile, you need to include the WITH_INLINE definition in addition to MORMOT2?

{$IFDEF MORMOT2}
mormot.db.core, mormot.core.datetime, {$IFDEF WITH_INLINE}mormot.core.text,
mormot.core.base,{$ENDIF}
{$ELSE MORMOT2} {$IFDEF USE_SYNCOMMONS}
SynCommons, SynTable,
{$ENDIF USE_SYNCOMMONS} {$ENDIF MORMOT2}

Then the following lines will compile normally:

then JSONWriter.AddJSONEscape(P, ZDbcUtils.GetAbsorbedTrailingSpacesLen(P, {$IFDEF MORMOT2}mormot.core.base{$ELSE}SynCommons{$ENDIF}.StrLen(P)))

then {$IFDEF WITH_COLUMNS_TO_JSON}{$IFDEF MORMOT2}mormot.core.text{$ELSE}SynCommons{$ENDIF}.{$ENDIF}HexToBin(Buffer+2, @Result.D1, SizeOf(TGUID))

Under fpc I see that define (WITH_INLINE) is not defined...

Last edited by L_VV (2021-02-28 11:00:14)

Offline

#10 2021-02-28 11:58:57

L_VV
Member
Registered: 2020-10-29
Posts: 38

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

Yes, after I forcibly enabled the WITH_INLINE define, Zeos compiled successfully,
only about 30 warnings were issued that the functions was not inline:

mormot.core.datetime.pas(1027,13) Note: Call to subroutine "function Iso8601ToDateTimePUtf8Char(P:PUtf8Char;L:LongInt=`0`):Double;" marked as inline is not inlined
mormot.core.datetime.pas(1294,9) Note: Call to subroutine "function VariantToUtf8(const V:Variant;var Text:UTF8String):Boolean;" marked as inline is not inlined
mormot.core.datetime.pas(1323,7) Note: Call to subroutine "procedure TSynSystemTime.Clear;" marked as inline is not inlined
mormot.core.datetime.pas(1693,5) Note: Call to subroutine "function UInt2DigitsToShortFast(Value:Byte):ShortString[4];" marked as inline is not inlined
mormot.core.datetime.pas(1694,5) Note: Call to subroutine "function UInt4DigitsToShort(Value:LongWord):ShortString[4];" marked as inline is not inlined
mormot.core.datetime.pas(1875,33) Note: Call to subroutine "function UInt3DigitsToShort(Value:LongWord):ShortString[4];" marked as inline is not inlined

Offline

#11 2021-02-28 16:33:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

I guess you could include mormot.core.base, mormot.core.text even if WITH_INLINE is not defined.
It won't hurt.

I tried to include all @Michael proposals in this new commit:
https://github.com/synopse/mORMot2/comm … 0af2cacc39

Offline

#12 2021-02-28 16:50:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

@Michael,

After my commit, I don't find ZDbcFirebird unit in 7.2.10-stable build at 2021-01-12 08:55:31.
What did I wrong?

Edit: it seems that ZDBC 7.2.10 expects ENABLE_INTERBASE and not ENABLE_FIREBIRD...
Sounds fine now:

 2.1. External database:
  ...
  - Firebird embedded via ZDBC over HTTP: 339 assertions passed  1.30s
  Total failed: 0 / 825,473  - External database PASSED  10.67s

Offline

#13 2021-02-28 19:16:26

L_VV
Member
Registered: 2020-10-29
Posts: 38

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

ab wrote:

I tried to include all @Michael proposals in this new commit:
https://github.com/synopse/mORMot2/comm … 0af2cacc39

Arnaud, the current trunk version of mORMot2 returns error 400 - bad request.

If I go back to a previous version of mormot.rest.core, everything works fine.

Last edited by L_VV (2021-02-28 19:16:37)

Offline

#14 2021-03-01 05:48:42

EgonHugeist
Member
From: Germany
Registered: 2013-02-15
Posts: 190

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

@Arnaud
Nice! Well two small things should be worth it todo:

Index: mormot.db.sql.zeos.pas
===================================================================
--- mormot.db.sql.zeos.pas	(revision 1078)
+++ mormot.db.sql.zeos.pas	(working copy)
@@ -64,7 +64,8 @@
   ZDbcOracle,
   {$ifend}
   {$if defined(ENABLE_ASA) and not defined(ZEOS_DISABLE_ASA)}
-  ZDbcASA,
+  ZDbcASA, //protocol name = ASA
+  ZDbcSQLAnywhere, //protocol name = asa_capi
   {$ifend}
   {$if defined(ENABLE_POOLED) and not defined(ZEOS_DISABLE_POOLED)}
   ZDbcPooled,
@@ -79,7 +80,9 @@
   // main ZDBC units
   ZCompatibility,
   ZVariant,
+  {$ifndef ZEOS80UP}
   ZURL,
+  {$endfif}
   ZDbcIntfs,
   ZDbcResultSet,
   ZDbcMetadata,
@@ -681,7 +684,7 @@
     sSchema := Utf8ToString(Schema);
     { mormot does not create the Tables casesensitive but gives mixed cased strings as tablename
       so we normalize the identifiers to database defaults : }
-    sTableName := meta.GetIdentifierConvertor.ExtractQuote(Utf8ToString(TableName));
+    sTableName := meta.{$ifdef ZEOS80UP}GetIdentifierConverter{$else}GetIdentifierConvertor{$ifend}.ExtractQuote(Utf8ToString(TableName));
     sTableName := meta.AddEscapeCharToWildcards(sTableName);
     //do not use "like" search patterns ['_','%'] so they need to be escaped
     res := meta.GetColumns('', sSchema, sTableName, '');

Summary:
the ZURL unit is empty inbetween, the TZURL class is moved to global connectivity unit ZDbcIntfs. This also fixes a dreprecated hint for the "GetIdentifierConvertor" -> replaced by "GetIdentifierConverter".

Finally, please merge the changes to 1.18

@L_VV
thank you too. According the WITH_INLINE define: It's defined in ZeosLazarus.Inc for FPC see:

{$IFDEF SYSTEMINLINE} //global FPC define
  {$DEFINE WITH_INLINE}           // compiler supports inline methodes
{$ENDIF}

seems the global define proposed by FPC-core seems to be unavailable? Can you confirm it?
According the units: https://sourceforge.net/p/zeoslib/code-0/7351/

If there are still changes required, make a diff/patch. Thank your for your support.

Last edited by EgonHugeist (2021-03-01 05:49:59)

Offline

#15 2021-03-01 07:43:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

I can't find ZDbcSQLAnywhere in my fresh downloaded 7.2.10-stable build at 2021-01-12 08:55:31.
This is why I did not include it.

I have merged your other changes to mORMot 2.
Thanks!

Offline

#16 2021-03-01 08:19:50

L_VV
Member
Registered: 2020-10-29
Posts: 38

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

Arnaud, yesterday I wrote that after the last commit in git, my test rest service stopped working.
It started returning error 400 - bad request.
After replacing the mormot.rest.core.pas file with its previous version, the error gone.

As I can see, the sequence of calling destructors has changed:

old:

FreeAndNil(fRun);
FreeAndNil(fServices);
for cmd := Low(cmd) to high(cmd) do
  FreeAndNil(fAcquireExecution[cmd]); // calls fOrmInstance.OnEndThread

new:

for cmd := Low(cmd) to high(cmd) do
  FreeAndNil(fAcquireExecution[cmd]); // calls fOrmInstance.OnEndThread
FreeAndNil(fServices);
FreeAndNil(fRun); // after fAcquireExecution+fServices

With the new sequence of destructors, the method (GetUsr) declared in the interface is not called:

  IUsrService = interface(IInvokable)
    ['{64CDE670-5D34-4050-B0E6-36A21F0C21CE}']
    function GetUsr(const ID: RawUTF8; out Usr: TUsrDto): TCQRSResult;
  end;

Offline

#17 2021-03-01 08:25:25

L_VV
Member
Registered: 2020-10-29
Posts: 38

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

Oh, sorry, with last versions of mORMot2 and Zeos all works fine.

Thank you!

Offline

#18 2021-03-01 09:06:38

L_VV
Member
Registered: 2020-10-29
Posts: 38

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

EgonHugeist wrote:

According the WITH_INLINE define: It's defined in ZeosLazarus.Inc for FPC see:

{$IFDEF SYSTEMINLINE} //global FPC define
  {$DEFINE WITH_INLINE}           // compiler supports inline methodes
{$ENDIF}

seems the global define proposed by FPC-core seems to be unavailable? Can you confirm it?


It’s strange. In the file .../fpcsrc/rtl/inc/systemh.inc
there are lines:

{ Using inlining for small system functions/wrappers }
{$inline on}
{$define SYSTEMINLINE}

But at the same time, opening the file .../zeoslib/src/ZeosLazarus.inc

{$IFDEF SYSTEMINLINE} //global FPC define
  {$DEFINE WITH_INLINE}           // compiler supports inline methodes
{$ENDIF}

I see the line {$DEFINE WITH_INLINE} in a pale color, i.e. as if SYSTEMINLINE is not defined.

I'll see this in more details later.

Offline

#19 2021-03-01 12:06:06

L_VV
Member
Registered: 2020-10-29
Posts: 38

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

Can't figure out why SYSTEMINLINE, defined in .../fpcsrc.rtl/inc/systemh.inc:

{ Using inlining for small system functions/wrappers }
{$inline on}
{$define SYSTEMINLINE}

works in this file (for example, on this line the word 'inline' is in bold black, i.e. enabled),
and in other files it doesn't work?:

Function  Lo(B: Byte):Byte;{$ifdef SYSTEMINLINE}inline;{$endif}


For example, in a freshly created project I write:

  {$ifdef SYSTEMINLINE}
    writeln('SYSTEMINLINE defined');
  {$endif}

and here the line "writeln('SYSTEMINLINE defined');"
highlighted in pale color, i.e. SYSTEMINLINE is not defined, and this line is not executed.

Perhaps the environment somehow influences?
CPU: AMD Ryzen 7 2700X
OS: Debian 5.10.13-1 (2021-02-06) x86_64 GNU/Linux


Maybe someone else knows why the SYSTEMINLINE, defined in the .inc file, does not work?

Offline

#20 2021-03-02 06:29:13

EgonHugeist
Member
From: Germany
Registered: 2013-02-15
Posts: 190

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

@L_VV
I moved the define. I can't say why "SYSTEMINLINE" should be out of scope.

@Arnaud,

you are right! ENABLE_SQLANY/ZEOS_DISABLE_SQLANY added see: https://sourceforge.net/p/zeoslib/code-0/7357/
Btw. That's the reason for the ugly "duplicate Enable/Disable" check.

So plz add

  {$if defined(ENABLE_SQLANY) and not defined(ZEOS_DISABLE_SQLANY)}
  ZDbcSQLAnywhere,
  {$ifend}

To both units. Thank's for the 1.18 Merge.

Offline

#21 2021-03-02 18:39:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: mORMot2: List index out of bounds in ZDbcResultSetMetadata.pas

Done.

Thanks!

Offline

Board footer

Powered by FluxBB