Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: RANDOM ROWID should be respected in VACUUM and bulk insert ops #1048

Merged
merged 2 commits into from
Feb 19, 2024

Conversation

avinassh
Copy link
Member

@avinassh avinassh commented Feb 19, 2024

bugfix: pass regNextRowid to OP_NewRowid call in xferOptimization

The register regNextRowid contains the LIBSQL_RANDOM_ROWID_MARKER value
which tells the VDBE to use a random value for row ids. The method xferOptimization
is used in VACUUM and bulk insert routines where data from one table is
inserted in another. Since the data is inserted in a loop, it checks for
max rowid once and then keeps inserting it serially. Hence we pass the marker
in each call, so that random id is generated.

Tests added for:

  1. VACUUM does not respect RANDOM ROWID - VACUUM should respect RANDOM ROWID table option #929
  2. Bulk insert into a fresh table does not respect RANDOM ROWID - Bulk insert into a fresh table from another table does not honor RANDOM ROWID #1046

In both cases, the table should end up random rowids, but they seem to have sequential ones.

Tests added for:

1. VACUUM does not respect RANDOM ROWID - #929
2. Bulk insert into a fresh table does not respect RANDOM ROWID - #1046

In both cases, the table should end up random rowids, but they seem to have sequential ones.
The register `regNextRowid` contains the `LIBSQL_RANDOM_ROWID_MARKER` value
which tells the VDBE to use a random value for row ids. The method `xferOptimization`
is used in `VACUUM` and bulk insert routines where data from one table is
inserted in another. Since the data is inserted in a loop, it checks for
max rowid once and then keeps inserting it serially. Hence we pass the marker
in each call, so that random id is generated.
@avinassh avinassh marked this pull request as ready for review February 19, 2024 12:42
@avinassh avinassh requested a review from penberg February 19, 2024 12:49
@MarinPostma MarinPostma added this pull request to the merge queue Feb 19, 2024
Merged via the queue into main with commit 112c72b Feb 19, 2024
16 checks passed
@MarinPostma MarinPostma deleted the 929-vacuum-rowid branch February 19, 2024 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants