Skip to content

[backport 3.5] box: fix _func id overflow#12108

Merged
sergepetrenko merged 2 commits intorelease/3.5from
backport/release/3.5/12004
Dec 8, 2025
Merged

[backport 3.5] box: fix _func id overflow#12108
sergepetrenko merged 2 commits intorelease/3.5from
backport/release/3.5/12004

Conversation

@TarantoolBot
Copy link
Collaborator

@TarantoolBot TarantoolBot commented Dec 5, 2025

(This PR is a backport of #12004 to release/3.5 to a future 3.5.2 release.)


Each time one used the box.schema.func.create, the primary key of
the resulted function increased because of the
_func:auto_increment. Now the new key is chosen by the
generate_func_id in Lua and OP_GenFuncid SQL opcode, both implemented
using the new box_generate_func_id function that shares logic with
box_generate_space_id. Hence we are scanning the entire range of
possible ids [0, BOX_FUNCTION_MAX) before we are returning an
error.

Fixes #11849
Fixes #11851
NO_DOC=bugfix

Introduce the `box_generate_unique_id` function, which is useful for spaces
with limited primary key range such as `_func`.

Part of #11849
Part of #11851

NO_DOC=refactoring
NO_TEST=refactoring
NO_CHANGELOG=refactoring

(cherry picked from commit 80e580e)
Each time one used the `box.schema.func.create`, the primary key of
the resulted function increased because of the
`_func:auto_increment`. Now the new key is chosen by the
`generate_func_id` in Lua and `OP_GenFuncid` SQL opcode, both implemented
using the new `box_generate_func_id` function that shares logic with
`box_generate_space_id`. Hence we are scanning the entire range of
possible ids `[0, BOX_FUNCTION_MAX)` before we are returning an
error.

Fixes #11849
Fixes #11851
NO_DOC=bugfix

(cherry picked from commit 95d3550)
@TarantoolBot TarantoolBot added the full-ci Enables all tests for a pull request label Dec 5, 2025
@TarantoolBot TarantoolBot requested a review from a team as a code owner December 5, 2025 11:07
@TarantoolBot TarantoolBot added the full-ci Enables all tests for a pull request label Dec 5, 2025
@TarantoolBot TarantoolBot changed the title [Backport release/3.5] box: fix _func id overflow [backport 3.5] box: fix _func id overflow Dec 5, 2025
@coveralls
Copy link

Coverage Status

coverage: 87.614% (-0.006%) from 87.62%
when pulling 66d0a54 on backport/release/3.5/12004
into d3024aa
on release/3.5
.

@sergepetrenko sergepetrenko merged commit c2c91fc into release/3.5 Dec 8, 2025
45 of 64 checks passed
@sergepetrenko sergepetrenko deleted the backport/release/3.5/12004 branch December 8, 2025 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Enables all tests for a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants