Skip to content

Commit

Permalink
feat: fix lookup vindex schema and add consistent lookup vindex
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <manan@planetscale.com>
  • Loading branch information
GuptaManan100 committed Dec 9, 2024
1 parent ab7b516 commit dd6ef5b
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 17 deletions.
3 changes: 3 additions & 0 deletions go/test/endtoend/transaction/twopc/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ func cleanup(t *testing.T) {
twopcutil.ClearOutTable(t, vtParams, "twopc_lookup")
twopcutil.ClearOutTable(t, vtParams, "lookup_unique")
twopcutil.ClearOutTable(t, vtParams, "lookup")
twopcutil.ClearOutTable(t, vtParams, "twopc_consistent_lookup")
twopcutil.ClearOutTable(t, vtParams, "consistent_lookup_unique")
twopcutil.ClearOutTable(t, vtParams, "consistent_lookup")
sm.reset()
}

Expand Down
29 changes: 26 additions & 3 deletions go/test/endtoend/transaction/twopc/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,38 @@ create table twopc_lookup

create table lookup
(
col varchar(128),
col bigint,
id bigint,
keyspace_id varbinary(100),
primary key (id)
primary key (col, id)
) Engine = InnoDB;

create table lookup_unique
(
col_unique varchar(128),
col_unique bigint,
keyspace_id varbinary(100),
primary key (col_unique)
) Engine = InnoDB;

create table twopc_consistent_lookup
(
id bigint,
col bigint,
col_unique bigint,
primary key (id)
) Engine=InnoDB;

create table consistent_lookup
(
col bigint,
id bigint,
keyspace_id varbinary(100),
primary key (col, id)
) Engine = InnoDB;

create table consistent_lookup_unique
(
col_unique bigint,
keyspace_id varbinary(100),
primary key (col_unique)
) Engine = InnoDB;
28 changes: 14 additions & 14 deletions go/test/endtoend/transaction/twopc/twopc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1480,8 +1480,8 @@ func TestVindexes(t *testing.T) {
"update:[INT64(6) INT64(9) INT64(9)]",
},
"ks.lookup:80-": {
"delete:[VARCHAR(\"4\") INT64(6) VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"insert:[VARCHAR(\"9\") INT64(6) VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"delete:[INT64(4) INT64(6) VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"insert:[INT64(9) INT64(6) VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
},
},
},
Expand All @@ -1508,8 +1508,8 @@ func TestVindexes(t *testing.T) {
"update:[INT64(6) INT64(4) INT64(20)]",
},
"ks.lookup_unique:80-": {
"delete:[VARCHAR(\"9\") VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"insert:[VARCHAR(\"20\") VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"delete:[INT64(9) VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"insert:[INT64(20) VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
},
},
},
Expand All @@ -1536,10 +1536,10 @@ func TestVindexes(t *testing.T) {
"delete:[INT64(6) INT64(4) INT64(9)]",
},
"ks.lookup_unique:80-": {
"delete:[VARCHAR(\"9\") VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"delete:[INT64(9) VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
},
"ks.lookup:80-": {
"delete:[VARCHAR(\"4\") INT64(6) VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"delete:[INT64(4) INT64(6) VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
},
},
},
Expand All @@ -1561,10 +1561,10 @@ func TestVindexes(t *testing.T) {
"delete:[VARCHAR(\"dtid-3\") INT64(1) BLOB(\"insert into lookup(col, id, keyspace_id) values (4, 20, _binary'(\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0')\")]",
},
"ks.lookup:80-": {
"insert:[VARCHAR(\"4\") INT64(20) VARBINARY(\"(\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"insert:[INT64(4) INT64(20) VARBINARY(\"(\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
},
"ks.lookup_unique:-40": {
"insert:[VARCHAR(\"22\") VARBINARY(\"(\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"insert:[INT64(22) VARBINARY(\"(\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
},
"ks.twopc_lookup:-40": {
"insert:[INT64(20) INT64(4) INT64(22)]",
Expand Down Expand Up @@ -1614,16 +1614,16 @@ func TestVindexes(t *testing.T) {
"delete:[INT64(9) INT64(4) INT64(4)]",
},
"ks.lookup_unique:-40": {
"insert:[VARCHAR(\"22\") VARBINARY(\"(\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"insert:[INT64(22) VARBINARY(\"(\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
},
"ks.lookup_unique:80-": {
"delete:[VARCHAR(\"4\") VARBINARY(\"\\x90\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"delete:[INT64(4) VARBINARY(\"\\x90\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
},
"ks.lookup:80-": {
"insert:[VARCHAR(\"4\") INT64(20) VARBINARY(\"(\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"delete:[VARCHAR(\"4\") INT64(6) VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"insert:[VARCHAR(\"9\") INT64(6) VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"delete:[VARCHAR(\"4\") INT64(9) VARBINARY(\"\\x90\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"insert:[INT64(4) INT64(20) VARBINARY(\"(\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"delete:[INT64(4) INT64(6) VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"insert:[INT64(9) INT64(6) VARBINARY(\"`\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
"delete:[INT64(4) INT64(9) VARBINARY(\"\\x90\\x00\\x00\\x00\\x00\\x00\\x00\\x00\")]",
},
},
},
Expand Down
53 changes: 53 additions & 0 deletions go/test/endtoend/transaction/twopc/vschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@
"to": "keyspace_id"
},
"owner": "twopc_lookup"
},
"consistent_lookup_vdx": {
"type": "consistent_lookup",
"params": {
"table": "consistent_lookup",
"from": "col,id",
"to": "keyspace_id"
},
"owner": "twopc_consistent_lookup"
},
"consistent_lookup_unique_vdx": {
"type": "consistent_lookup_unique",
"params": {
"table": "consistent_lookup_unique",
"from": "col_unique",
"to": "keyspace_id"
},
"owner": "twopc_consistent_lookup"
}
},
"tables": {
Expand Down Expand Up @@ -85,6 +103,41 @@
"name": "xxhash"
}
]
},
"twopc_consistent_lookup": {
"column_vindexes": [
{
"column": "id",
"name": "reverse_bits"
},
{
"columns": [
"col",
"id"
],
"name": "consistent_lookup_vdx"
},
{
"column": "col_unique",
"name": "consistent_lookup_unique_vdx"
}
]
},
"consistent_lookup": {
"column_vindexes": [
{
"column": "col",
"name": "xxhash"
}
]
},
"consistent_lookup_unique": {
"column_vindexes": [
{
"column": "col_unique",
"name": "xxhash"
}
]
}
}
}

0 comments on commit dd6ef5b

Please sign in to comment.