-
Notifications
You must be signed in to change notification settings - Fork 2.3k
v3: write_only support for unique lookup vindexes #3658
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,6 +141,17 @@ func TestUpdateEqual(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| func TestUpdateEqualKeyrange(t *testing.T) { | ||
| executor, _, _, _ := createExecutorEnv() | ||
|
|
||
| // If a unique vindex returns a keyrange, we fail the update | ||
| _, err := executorExec(executor, "update keyrange_table set a=2 where krcol_unique = 1", nil) | ||
| want := "execUpdateEqual: vindex could not map the value to a unique keyspace id" | ||
| if err == nil || err.Error() != want { | ||
| t.Errorf("executorExec error: %v, want %s", err, want) | ||
| } | ||
| } | ||
|
|
||
| func TestUpdateMultiOwned(t *testing.T) { | ||
| vschema := ` | ||
| { | ||
|
|
@@ -491,6 +502,17 @@ func TestDeleteEqual(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| func TestDeleteEqualKeyrange(t *testing.T) { | ||
| executor, _, _, _ := createExecutorEnv() | ||
|
|
||
| // If a unique vindex returns a keyrange, we fail the delete | ||
| _, err := executorExec(executor, "delete from keyrange_table where krcol_unique = 1", nil) | ||
| want := "execDeleteEqual: vindex could not map the value to a unique keyspace id" | ||
| if err == nil || err.Error() != want { | ||
| t.Errorf("executorExec error: %v, want %s", err, want) | ||
| } | ||
| } | ||
|
|
||
| func TestDeleteSharded(t *testing.T) { | ||
| executor, sbc1, sbc2, _ := createExecutorEnv() | ||
| _, err := executorExec(executor, "delete from user_extra", nil) | ||
|
|
@@ -667,6 +689,17 @@ func TestInsertSharded(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| func TestInsertShardedKeyrange(t *testing.T) { | ||
| executor, _, _, _ := createExecutorEnv() | ||
|
|
||
| // If a unique vindex returns a keyrange, we fail the insert | ||
| _, err := executorExec(executor, "insert into keyrange_table(krcol_unique, krcol) values(1, 1)", nil) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had a question around this that @sougou responded in Slack. For future reference, adding here. It was not clear to me what would happen if you have an unique LookupIndex that is in write mode and then it enters in this code path. In that case, it would mean that lookup was the primary vindex and it should fail. |
||
| want := "execInsertSharded: getInsertShardedRoute: vindex could not map the value to a unique keyspace id" | ||
| if err == nil || err.Error() != want { | ||
| t.Errorf("executorExec error: %v, want %s", err, want) | ||
| } | ||
| } | ||
|
|
||
| func TestInsertShardedAutocommitLookup(t *testing.T) { | ||
|
|
||
| vschema := ` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a comment here explaining in which cases it will be a range vs an ID (i.e when using this feature). Otherwise, in this context it's going to be hard to understand why it could be one way or the other.