#1 2015-01-14 12:47:42

alpinistbg
Member
Registered: 2014-11-12
Posts: 124

JSONRetrieveIDField() overflow

JSONRetrieveIDField() calls function GetInteger(P: PUTF8Char): PtrInt which overflows badly on '{"RowID":10073450777,...}' at SynCommons.pas:19215.

Offline

#2 2015-01-14 14:38:13

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

Re: JSONRetrieveIDField() overflow

Fixed by http://synopse.info/fossil/info/95068648b4

Thanks for the feedback!

Offline

#3 2015-01-14 18:12:08

alpinistbg
Member
Registered: 2014-11-12
Posts: 124

Re: JSONRetrieveIDField() overflow

You're welcome! Ditto for:

Index: SQLite3/mORMotDB.pas
==================================================================
--- SQLite3/mORMotDB.pas
+++ SQLite3/mORMotDB.pas
@@ -175,1 +175,1 @@
-    fEngineLockedLastID: integer;
+    fEngineLockedLastID: TID;
@@ -190,1 +190,2 @@
-    fBatchCapacity, fBatchCount, fBatchFirstAddedID: integer;
+    fBatchCapacity, fBatchCount: integer;
+    fBatchFirstAddedID: TID;
@@ -220,1 +221,1 @@
-    function EngineLockedNextID: Integer; virtual;
+    function EngineLockedNextID: TID; virtual;
@@ -242,1 +243,1 @@
-    function InternalBatchAdd(const aValue: RawUTF8; aID: TID): integer;
+    function InternalBatchAdd(const aValue: RawUTF8; aID: TID): TID;
@@ -259,1 +260,1 @@
-      UpdatedID: TID): integer;
+      UpdatedID: TID): TID;
@@ -907,1 +908,1 @@
-function TSQLRestStorageExternal.EngineLockedNextID: Integer;
+function TSQLRestStorageExternal.EngineLockedNextID: TID;
@@ -1090,1 +1091,1 @@
-  const aValue: RawUTF8; aID: TID): integer;
+  const aValue: RawUTF8; aID: TID): TID;
@@ -1647,1 +1648,1 @@
-  const SentData: RawUTF8; Occasion: TSQLOccasion; UpdatedID: TID): integer;
+  const SentData: RawUTF8; Occasion: TSQLOccasion; UpdatedID: TID): TID;
@@ -1652,1 +1653,1 @@
-    InsertedID, F: integer;
+    InsertedID: TID; F: integer;
@@ -1956,1 +1957,1 @@
-end.
+end.

Offline

#4 2015-01-14 19:17:10

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

Re: JSONRetrieveIDField() overflow

This was on purpose that the EngineLockedNextID / BatchInsert methods do use integer and not TID.
A generated ID, with linear increase, won't overflow the 32 bit.

We would certainly change that when I will implement some new Feature Requests (like big data sharding).
But in the meanwhile, current code seems correct.

Offline

#5 2015-01-15 08:22:04

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

Re: JSONRetrieveIDField() overflow

Edit:

I've introduced several fixes and enhancements related to TID = Int64 process.
I made another code review, and found some problems - which are now fixed.
It would help preparing the upcoming features, by the way, to have TID everywhere - and it makes code more obvious.

See http://synopse.info/fossil/info/93e54b45a6

Thanks for your feedback!

Offline

#6 2015-01-15 14:09:04

alpinistbg
Member
Registered: 2014-11-12
Posts: 124

Re: JSONRetrieveIDField() overflow

Just see the type of the InsertedID local variable in the TSQLRestStorageExternal.ExecuteFromJSON() and how it gets assigned with the call of JSONRetrieveIDField() just a few lines after. Not much different, regardless the http://synopse.info/fossil/info/95068648b4.

Offline

#7 2015-01-15 17:59:10

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

Re: JSONRetrieveIDField() overflow

JSONRetrieveIDField() returned a Int64 = TID now, so I do not think there is a problem, right?

Offline

#8 2015-01-16 10:01:09

alpinistbg
Member
Registered: 2014-11-12
Posts: 124

Re: JSONRetrieveIDField() overflow

ab wrote:

JSONRetrieveIDField() returned a Int64 = TID now, so I do not think there is a problem, right?

Sorry, my fault! Playing with mORMotDB, SynDBODBC and I was stuck to the previous fossil revision.

Offline

Board footer

Powered by FluxBB