From b71da5e3b396231a15ca619fb8df98d0f29499ff Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Thu, 16 Nov 2023 15:48:31 +0530 Subject: [PATCH] added plan test Signed-off-by: Harshit Gangal --- .../planbuilder/testdata/lock_cases.json | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/go/vt/vtgate/planbuilder/testdata/lock_cases.json b/go/vt/vtgate/planbuilder/testdata/lock_cases.json index c14ba026869..568b066fa22 100644 --- a/go/vt/vtgate/planbuilder/testdata/lock_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/lock_cases.json @@ -124,5 +124,95 @@ "main.dual" ] } + }, + { + "comment": "select nowait", + "query": "select u.col, u.bar from user u join music m on u.foo = m.foo for update nowait", + "plan": { + "QueryType": "SELECT", + "Original": "select u.col, u.bar from user u join music m on u.foo = m.foo for update nowait", + "Instructions": { + "OperatorType": "Join", + "Variant": "Join", + "JoinColumnIndexes": "L:0,L:1", + "JoinVars": { + "u_foo": 2 + }, + "TableName": "`user`_music", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "Scatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "FieldQuery": "select u.col, u.bar, u.foo from `user` as u where 1 != 1", + "Query": "select u.col, u.bar, u.foo from `user` as u for update nowait", + "Table": "`user`" + }, + { + "OperatorType": "Route", + "Variant": "Scatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "FieldQuery": "select 1 from music as m where 1 != 1", + "Query": "select 1 from music as m where m.foo = :u_foo for update nowait", + "Table": "music" + } + ] + }, + "TablesUsed": [ + "user.music", + "user.user" + ] + } + }, + { + "comment": "select skip locked", + "query": "select u.col, u.bar from user u join music m on u.foo = m.foo for share skip locked", + "plan": { + "QueryType": "SELECT", + "Original": "select u.col, u.bar from user u join music m on u.foo = m.foo for share skip locked", + "Instructions": { + "OperatorType": "Join", + "Variant": "Join", + "JoinColumnIndexes": "L:0,L:1", + "JoinVars": { + "u_foo": 2 + }, + "TableName": "`user`_music", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "Scatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "FieldQuery": "select u.col, u.bar, u.foo from `user` as u where 1 != 1", + "Query": "select u.col, u.bar, u.foo from `user` as u for share skip locked", + "Table": "`user`" + }, + { + "OperatorType": "Route", + "Variant": "Scatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "FieldQuery": "select 1 from music as m where 1 != 1", + "Query": "select 1 from music as m where m.foo = :u_foo for share skip locked", + "Table": "music" + } + ] + }, + "TablesUsed": [ + "user.music", + "user.user" + ] + } } ]