Skip to content

64-bit integer columns are truncated to 32 bits when fetched #15

Description

@jkalias

Problem

Integer columns are read with the 32-bit sqlite3_column_int instead of the 64-bit sqlite3_column_int64:

  • FetchRecordsQuery::GetColumnValue (src/queries.cc): case SQLITE_INTEGER: return std::to_wstring(sqlite3_column_int(stmt_, col));
  • FetchMaxIdQuery::GetMaxId (src/queries.cc): reads sqlite3_column_int(stmt_, 0) and returns it as int64_t.

Impact

Any stored int64_t value above INT32_MAX (2,147,483,647) is silently truncated/wrapped on read. This is not a corner case: id is int64_t and with INTEGER PRIMARY KEY AUTOINCREMENT ids can legitimately exceed the 32-bit range, after which fetched ids become wrong — breaking subsequent Fetch(id) / Update / Delete.

Suggested direction

Use sqlite3_column_int64 for integer columns (in both GetColumnValue and GetMaxId). Add a regression test that stores and fetches a value greater than INT32_MAX.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions