Skip to content

box.space[YOUR_SPACE]:pairs:drop_while() does not work properly #6403

@maxim-komar

Description

@maxim-komar

Bug description

A clear and concise description of what the bug is.

  • OS: centos7
  • OS Version: CentOS Linux release 7.9.2009 (Core)
  • Architecture: amd64
$ tarantool -v
Tarantool 2.7.2-0-g4d8c068
Target: Linux-x86_64-RelWithDebInfo
Build options: cmake . -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_BACKTRACE=ON
Compiler: /opt/rh/devtoolset-8/root/usr/bin/cc /opt/rh/devtoolset-8/root/usr/bin/c++
C_FLAGS:-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -fopenmp -msse2 -std=c11 -Wall -Wextra -Wno-strict-aliasing -Wno-char-subscripts -Wno-format-truncation -Wno-gnu-alignof-expression -fno-gnu89-inline -Wno-cast-function-type -Werror
CXX_FLAGS:-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -fopenmp -msse2 -std=c++11 -Wall -Wextra -Wno-strict-aliasing -Wno-char-subscripts -Wno-format-truncation -Wno-invalid-offsetof -Wno-gnu-alignof-expression -Wno-cast-function-type -Werror

Steps to reproduce

require('strict').on()

box.cfg{}

local log = require('log')
local json = require('json')

local SPACE_NAME = 'test_space'

local function drop_space()
    if box.space[SPACE_NAME] then
        box.space[SPACE_NAME]:drop()
    end
end

local function create_space()
    local ID = 'id'

    local space = box.schema.space.create(SPACE_NAME, {
        engine = 'memtx',
        format = {
            {ID, 'number'}
        }
    })

    space:create_index('primary', { type = 'TREE', unique = true, parts = {ID}})
end

local function test_drop_while()
    local space = box.space[SPACE_NAME]

    space:insert({1})
    space:insert({2})
    space:insert({3})

    local select_result = space:select()
    -- > select result = [[1],[2],[3]]
    log.info('select result = %s', json.encode(select_result))

    local drop_while_with_bug = space:pairs():drop_while(function(t) return false end):totable()
    -- > drop_while with bug = [[2],[3]]
    log.info('drop_while with bug = %s', json.encode(drop_while_with_bug))

    local drop_while_fun = require('fun').iter(select_result):drop_while(function(t) return false end):totable()
    -- > drop_while from fun module = [[1],[2],[3]]
    log.info('drop_while from fun module = %s', json.encode(drop_while_fun))
end

drop_space()
create_space()
test_drop_while()

os.exit()
-- pcall(function() require'console'.start() os.exit() end)

How to run:

Just type tarantool reproducer.lua.

Actual behavior

space:pairs():drop_while(function(t) return false end):totable()

returns all the tuples except the first one

Expected behavior

space:pairs():drop_while(function(t) return false end):totable()

must return all the tuples from the space (compare with the luafun drop_while behaviour)

Metadata

Metadata

Assignees

Labels

2.11Target is 2.11 and all newer release/master branchesbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions