View Ticket
Not logged in
Ticket Hash: 7d4b236572e4302d8275920bbda5c2c4f811db69
Title: Sql formatting used int32 instead of int64
Status: Closed Type: Code_Defect
Severity: Critical Priority: Immediate
Subsystem: Resolution: Fixed
Last Modified: 2018-07-29 20:00:45
Version Found In:
User Comments:
anonymous added on 2018-03-21 03:37:22:

Based on reported issue:
https://groups.google.com/forum/#!topic/spatialite-users/mDWg_LYiOH8


Using VirtualPG such as

INSERT INTO pg_table(id) VALUES (110100014258002);

where pg_table is the virtual table, which connects to a pg table with a bigint field, actually inserts a value -1472374958.
(bigint = int8 = signed long = SQLITE_INTEGER)
This is possibly caused in 2 places in the 'virtualpg.c' code where:

    sql = sqlite3_mprintf ("%d", sqlite3_value_int (argv[c2]));

is being used.


Changing these 2 statements in

vpgInsertRow
    sql = sqlite3_mprintf ("%ld", sqlite3_value_int64 (argv[c]));

vpgUpdateRow
    sql = sqlite3_mprintf ("%ld", sqlite3_value_int64 (argv[c2]));

should resolve the problem.
Everything else seems to properly support int64

(vpgSetIntValue formats from string to sqlite3_int64 value).


The Postgres CTID seems to be 32 bit (OID is documented as such, but no meantion of the type for CTID)
    'OIDs are 32-bit quantities'
5.4. System Columns
    https://www.postgresql.org/docs/8.2/static/ddl-system-columns.html
and
8.12. Object Identifier Types
    https://www.postgresql.org/docs/8.2/static/datatype-oid.html

The only other use of sqlite3_value_int are for BOOLEAN values.

So everything else looks correct.
Mark


sandro added on 2018-07-29 20:00:45:
fixed by commit 184b370334