Skip to content

SQL queries decode msgpack's int64 incorrectly #10084

@oleg-jukovec

Description

@oleg-jukovec

Bug description

SQL queries return incorrect values for positive integers encoded as msgpack's int64. But it works fine with negative values.

  • OS: Linux
  • OS Version: Archlinux
  • Architecture: amd64
$ tarantool --version
Tarantool 3.1.0-0-g96f6d8859
Target: Linux-x86_64-Release
Build options: cmake . -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BACKTRACE=TRUE
Compiler: GNU-14.1.1
C_FLAGS: -fexceptions -funwind-tables -fasynchronous-unwind-tables -fno-common -msse2 -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong -fPIC -fmacro-prefix-map=/home/ozi/src/tarantool=. -std=c11 -Wall -Wextra -Wno-gnu-alignof-expression -fno-gnu89-inline -Wno-cast-function-type -O3 -DNDEBUG 
CXX_FLAGS: -fexceptions -funwind-tables -fasynchronous-unwind-tables -fno-common -msse2 -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong -fPIC -fmacro-prefix-map=/home/ozi/src/tarantool=. -std=c++11 -Wall -Wextra -Wno-invalid-offsetof -Wno-gnu-alignof-expression -Wno-cast-function-type -O3 -DNDEBUG

Steps to reproduce

The reproducer script (test.lua):

#!/usr/bin/env tarantool

box.cfg{}

local s = box.schema.space.create('q', {
    if_not_exists = true,
    format = {
        {name = "id", type = "integer"},
    },
})
s:create_index('primary', {
    type = 'tree',
    parts = {1, 'int'},
    if_not_exists = true
})

s:replace(require('msgpack').object_from_raw(string.fromhex("91d30000000000000001")))
s:replace(require('msgpack').object_from_raw(string.fromhex("91d300000000665c9ec4")))

print("space:select():")
print(require('json').encode(s:select({}, {limit = 10})))
print("\nSQL select:")
print(require('json').encode(box.execute("SELECT * FROM seqscan q;")))

os.exit()

How to run:

Just type tarantool test.lua.

Actual behavior

The output:

space:select():
[[1],[1717345988]]

SQL select:
{"metadata":[{"name":"id","type":"integer"}],"rows":[[-31],[-28]]}

Expected behavior

space:select():
[[1],[1717345988]]

SQL select:
{"metadata":[{"name":"id","type":"integer"}],"rows":[[1],[1717345988]]}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions