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
Persistent queries can be returned to two callers #73
Comments
andrew-d
added a commit
that referenced
this issue
Jun 7, 2023
This test case used to fail with: === RUN TestPrepareReuse sqlite_test.go:1129: rows2: num=2, want 1 --- FAIL: TestPrepareReuse (0.00s) This indicates that we were erroneously returning the same "persisted" query twice, which resulted in the two sets of Rows returned affecting each other. Instead, only persist queries in c.stmts on Close, after they've been reset and are ready for re-use. Updates #73 Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
andrew-d
added a commit
that referenced
this issue
Jun 7, 2023
This test case used to fail with: === RUN TestPrepareReuse sqlite_test.go:1129: rows2: num=2, want 1 --- FAIL: TestPrepareReuse (0.00s) This indicates that we were erroneously returning the same "persisted" query twice, which resulted in the two sets of Rows returned affecting each other. Instead, only persist queries in c.stmts on Close, after they've been reset and are ready for re-use. Updates #73 Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
andrew-d
added a commit
that referenced
this issue
Jun 7, 2023
This test case used to fail with: === RUN TestPrepareReuse sqlite_test.go:1129: rows2: num=2, want 1 --- FAIL: TestPrepareReuse (0.00s) This indicates that we were erroneously returning the same "persisted" query twice, which resulted in the two sets of Rows returned affecting each other. Instead, only persist queries in c.stmts on Close, after they've been reset and are ready for re-use. Updates #73 Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
andrew-d
added a commit
that referenced
this issue
Jun 8, 2023
This test case used to fail with: === RUN TestPrepareReuse sqlite_test.go:1129: rows2: num=2, want 1 --- FAIL: TestPrepareReuse (0.00s) This indicates that we were erroneously returning the same "persisted" query twice, which resulted in the two sets of Rows returned affecting each other. Instead, only persist queries in c.stmts on Close, after they've been reset and are ready for re-use. Updates #73 Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
andrew-d
added a commit
that referenced
this issue
Jun 8, 2023
This test case used to fail with: === RUN TestPrepareReuse sqlite_test.go:1129: rows2: num=2, want 1 --- FAIL: TestPrepareReuse (0.00s) This indicates that we were erroneously returning the same "persisted" query twice, which resulted in the two sets of Rows returned affecting each other. Instead, only persist queries in c.stmts on Close, after they've been reset and are ready for re-use. Updates #73 Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code doesn't check whether we've already returned the
*stmt
to a caller, so it's possible that callingconn.PrepareContext
twice in a row can return the same*stmt
to two different callers:https://github.com/tailscale/sqlite/blob/main/sqlite.go#L193-L196
This means that e.g. running a query from each of the two not-actually-different stmts, getting
rows1
androws2
, and then callingrows1.Next
will also steprows2
.The text was updated successfully, but these errors were encountered: