Skip to content

Commit aec977a

Browse files
committed
clean up impl
1 parent 0085a3c commit aec977a

File tree

3 files changed

+17
-62
lines changed

3 files changed

+17
-62
lines changed

enginetest/memory_engine_test.go

Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -200,68 +200,23 @@ func TestSingleQueryPrepared(t *testing.T) {
200200

201201
// Convenience test for debugging a single query. Unskip and set to the desired query.
202202
func TestSingleScript(t *testing.T) {
203-
// t.Skip()
203+
t.Skip()
204204
var scripts = []queries.ScriptTest{
205205
{
206-
// https://github.com/dolthub/dolt/issues/9873
207-
Name: "FOR UPDATE OF syntax support tests",
208-
SetUpScript: []string{
209-
"CREATE TABLE task_instance (id INT PRIMARY KEY, task_id VARCHAR(255), dag_id VARCHAR(255), run_id VARCHAR(255), state VARCHAR(50), queued_by_job_id INT)",
210-
"CREATE TABLE job (id INT PRIMARY KEY, state VARCHAR(50))",
211-
"CREATE TABLE dag_run (dag_id VARCHAR(255), run_id VARCHAR(255), state VARCHAR(50))",
212-
"CREATE TABLE t (id INT PRIMARY KEY, name VARCHAR(50))",
213-
"INSERT INTO task_instance VALUES (1, 'task1', 'dag1', 'run1', 'running', 1)",
214-
"INSERT INTO job VALUES (1, 'running')",
215-
"INSERT INTO dag_run VALUES ('dag1', 'run1', 'running')",
216-
"INSERT INTO t VALUES (1, 'test')",
217-
},
206+
Name: "AS OF propagates to nested CALLs",
207+
SetUpScript: []string{},
218208
Assertions: []queries.ScriptTestAssertion{
219209
{
220-
Query: `SELECT task_instance.id, task_instance.task_id, task_instance.dag_id, task_instance.run_id
221-
FROM task_instance INNER JOIN job ON job.id = task_instance.queued_by_job_id INNER JOIN dag_run ON dag_run.dag_id = task_instance.dag_id AND dag_run.run_id = task_instance.run_id
222-
WHERE task_instance.state IN ('running', 'queued', 'scheduled') AND NOT (job.state <=> 'running') AND dag_run.state = 'running' FOR UPDATE OF task_instance SKIP LOCKED`,
223-
Expected: []sql.Row{},
224-
},
225-
{
226-
Query: "SELECT * FROM t FOR UPDATE",
227-
Expected: []sql.Row{{1, "test"}},
228-
},
229-
{
230-
Query: "SELECT * FROM t FOR UPDATE OF t",
231-
Expected: []sql.Row{{1, "test"}},
232-
},
233-
{
234-
Query: "SELECT * FROM t FOR UPDATE OF t SKIP LOCKED",
235-
Expected: []sql.Row{{1, "test"}},
236-
},
237-
{
238-
Query: "SELECT * FROM t FOR UPDATE OF t NOWAIT",
239-
Expected: []sql.Row{{1, "test"}},
240-
},
241-
{
242-
Query: "SELECT * FROM task_instance t1, job t2 FOR UPDATE OF t1, t2",
243-
Expected: []sql.Row{{1, "task1", "dag1", "run1", "running", 1, 1, "running"}},
244-
},
245-
{
246-
Query: "SELECT * FROM t FOR UPDATE OF nonexistent_table",
247-
ExpectedErr: sql.ErrUnresolvedTableLock,
248-
},
249-
{
250-
Query: "SELECT * FROM t FOR UPDATE OF t, nonexistent_table",
251-
ExpectedErr: sql.ErrUnresolvedTableLock,
252-
ExpectedErrStr: fmt.Sprintf(sql.ErrUnresolvedTableLock.Message, "nonexistent_table"),
253-
},
254-
{
255-
Query: "SELECT * FROM t FOR UPDATE OF",
256-
ExpectedErr: sql.ErrSyntaxError,
257-
},
258-
{
259-
Query: "SELECT * FROM t FOR UPDATE test",
260-
ExpectedErr: sql.ErrSyntaxError,
210+
Query: "create procedure create_proc() create table t (i int primary key, j int);",
211+
Expected: []sql.Row{
212+
{types.NewOkResult(0)},
213+
},
261214
},
262215
{
263-
Query: "SELECT * FROM t FOR UPDATE",
264-
Expected: []sql.Row{{1, "test"}},
216+
Query: "call create_proc()",
217+
Expected: []sql.Row{
218+
{types.NewOkResult(0)},
219+
},
265220
},
266221
},
267222
},

enginetest/queries/script_queries.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ type ScriptTestAssertion struct {
124124
var ScriptTests = []ScriptTest{
125125
{
126126
// https://github.com/dolthub/dolt/issues/9873
127+
// TODO: `FOR UPDATE OF` (`FOR UPDATE` in general) is currently a no-op: https://www.dolthub.com/blog/2023-10-23-hold-my-beer/
127128
Name: "FOR UPDATE OF syntax support tests",
128129
SetUpScript: []string{
129130
"CREATE TABLE task_instance (id INT PRIMARY KEY, task_id VARCHAR(255), dag_id VARCHAR(255), run_id VARCHAR(255), state VARCHAR(50), queued_by_job_id INT)",

sql/planbuilder/select.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ func (b *Builder) buildSelect(inScope *scope, s *ast.Select) (outScope *scope) {
123123
outScope.node = l
124124
}
125125

126-
if s.Lock != nil {
127-
b.buildForUpdateOf(s.Lock, fromScope)
128-
}
126+
b.buildForUpdateOf(s.Lock, fromScope)
129127

130128
return
131129
}
@@ -243,7 +241,10 @@ func (b *Builder) renameSource(scope *scope, table string, cols []string) {
243241
}
244242
}
245243

246-
// buildForUpdateOf builds the FOR UPDATE OF clause. Currently a no-op that validates table names.
244+
// buildForUpdateOf builds the `FOR UPDATE OF` clause, ensuring that all tables listed are
245+
// present in the clause. `FOR UPDATE` in general is a no-op, so `FOR UPDATE OF` is
246+
// also a no-op: https://www.dolthub.com/blog/2023-10-23-hold-my-beer/
247+
// TODO: implement actual row-level locking for `FOR UPDATE` clauses in general.
247248
func (b *Builder) buildForUpdateOf(lock *ast.Lock, fromScope *scope) {
248249
if lock == nil {
249250
return
@@ -257,6 +258,4 @@ func (b *Builder) buildForUpdateOf(lock *ast.Lock, fromScope *scope) {
257258
return
258259
}
259260
}
260-
261-
// This is currently a no-op: https://www.dolthub.com/blog/2023-10-23-hold-my-beer/
262261
}

0 commit comments

Comments
 (0)