Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
db19532f
Commit
db19532f
authored
10 years ago
by
Alexandr
Browse files
Options
Downloads
Patches
Plain Diff
fix gh-464 lua iterators fix
parent
d8f92d85
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/box/index.h
+1
-0
1 addition, 0 deletions
src/box/index.h
src/box/lua/index.cc
+3
-0
3 additions, 0 deletions
src/box/lua/index.cc
test/big/iterator.result
+49
-0
49 additions, 0 deletions
test/big/iterator.result
test/big/iterator.test.lua
+25
-0
25 additions, 0 deletions
test/big/iterator.test.lua
with
78 additions
and
0 deletions
src/box/index.h
+
1
−
0
View file @
db19532f
...
@@ -88,6 +88,7 @@ struct iterator {
...
@@ -88,6 +88,7 @@ struct iterator {
int
sc_version
;
int
sc_version
;
uint32_t
space_id
;
uint32_t
space_id
;
uint32_t
index_id
;
uint32_t
index_id
;
class
Index
*
index
;
};
};
static
inline
void
static
inline
void
...
...
This diff is collapsed.
Click to expand it.
src/box/lua/index.cc
+
3
−
0
View file @
db19532f
...
@@ -98,6 +98,7 @@ boxffi_index_iterator(uint32_t space_id, uint32_t index_id, int type,
...
@@ -98,6 +98,7 @@ boxffi_index_iterator(uint32_t space_id, uint32_t index_id, int type,
it
->
sc_version
=
sc_version
;
it
->
sc_version
=
sc_version
;
it
->
space_id
=
space_id
;
it
->
space_id
=
space_id
;
it
->
index_id
=
index_id
;
it
->
index_id
=
index_id
;
it
->
index
=
index
;
return
it
;
return
it
;
}
catch
(
Exception
*
)
{
}
catch
(
Exception
*
)
{
if
(
it
)
if
(
it
)
...
@@ -113,6 +114,8 @@ boxffi_iterator_next(struct iterator *itr)
...
@@ -113,6 +114,8 @@ boxffi_iterator_next(struct iterator *itr)
if
(
itr
->
sc_version
!=
sc_version
)
{
if
(
itr
->
sc_version
!=
sc_version
)
{
try
{
try
{
Index
*
index
=
check_index
(
itr
->
space_id
,
itr
->
index_id
);
Index
*
index
=
check_index
(
itr
->
space_id
,
itr
->
index_id
);
if
(
index
!=
itr
->
index
)
return
NULL
;
if
(
index
->
sc_version
>
itr
->
sc_version
)
if
(
index
->
sc_version
>
itr
->
sc_version
)
return
NULL
;
return
NULL
;
itr
->
sc_version
=
sc_version
;
itr
->
sc_version
=
sc_version
;
...
...
This diff is collapsed.
Click to expand it.
test/big/iterator.result
+
49
−
0
View file @
db19532f
...
@@ -911,3 +911,52 @@ gen(param, state)
...
@@ -911,3 +911,52 @@ gen(param, state)
space:drop()
space:drop()
---
---
...
...
-------------------------------------------------------------------------------
-- Iterator: https://github.com/tarantool/tarantool/issues/464
-- Iterator safety after changing schema
-------------------------------------------------------------------------------
space = box.schema.create_space('test', {temporary=true})
---
...
space:create_index('primary', {type='HASH',unique=true})
---
...
space:create_index('t1', {type='TREE',unique=true})
---
...
space:create_index('t2', {type='TREE',unique=true})
---
...
box.space.test:insert{0}
---
- [0]
...
box.space.test:insert{1}
---
- [1]
...
gen, param, state = space.index.t1:pairs({}, {iterator = box.index.ALL})
---
...
print(gen(param, state))
---
...
id = s.index.t1.id
---
- error: '[string "id = s.index.t1.id "]:1: attempt to index field ''t1'' (a nil value)'
...
box.schema.index.drop(s.id, id)
---
- error: Illegal parameters, index_id should be a number
...
box.schema.index.alter(s.id, s.index.t2.id, {id = id})
---
- error: '[string "return box.schema.index.alter(s.id, s.index.t..."]:1: attempt to
index field ''t2'' (a nil value)'
...
print(gen(param, state))
---
...
space:drop()
---
...
This diff is collapsed.
Click to expand it.
test/big/iterator.test.lua
+
25
−
0
View file @
db19532f
...
@@ -169,3 +169,28 @@ index_space:delete{space.id, space.index['i1'].id}
...
@@ -169,3 +169,28 @@ index_space:delete{space.id, space.index['i1'].id}
gen
(
param
,
state
)
gen
(
param
,
state
)
space
:
drop
()
space
:
drop
()
-------------------------------------------------------------------------------
-- Iterator: https://github.com/tarantool/tarantool/issues/464
-- Iterator safety after changing schema
-------------------------------------------------------------------------------
space
=
box
.
schema
.
create_space
(
'test'
,
{
temporary
=
true
})
space
:
create_index
(
'primary'
,
{
type
=
'HASH'
,
unique
=
true
})
space
:
create_index
(
't1'
,
{
type
=
'TREE'
,
unique
=
true
})
space
:
create_index
(
't2'
,
{
type
=
'TREE'
,
unique
=
true
})
box
.
space
.
test
:
insert
{
0
}
box
.
space
.
test
:
insert
{
1
}
gen
,
param
,
state
=
space
.
index
.
t1
:
pairs
({},
{
iterator
=
box
.
index
.
ALL
})
print
(
gen
(
param
,
state
))
id
=
s
.
index
.
t1
.
id
box
.
schema
.
index
.
drop
(
s
.
id
,
id
)
box
.
schema
.
index
.
alter
(
s
.
id
,
s
.
index
.
t2
.
id
,
{
id
=
id
})
print
(
gen
(
param
,
state
))
space
:
drop
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment