Skip to content
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

sqlite.Session.Attach does not respect tableName argument #75

Closed
AdamSLevy opened this issue Oct 9, 2019 · 0 comments · Fixed by #76
Closed

sqlite.Session.Attach does not respect tableName argument #75

AdamSLevy opened this issue Oct 9, 2019 · 0 comments · Fixed by #76

Comments

@AdamSLevy
Copy link
Collaborator

When calling sqlite.Session.Attach, all tables are attached regardless of whether the argument tableName is empty or not.

The bug is cause by inadvertently shadowing the ctable variable:

sqlite/session.go

Lines 89 to 97 in 66f853b

func (s *Session) Attach(tableName string) error {
var ctable *C.char
if tableName != "" {
ctable := C.CString(tableName)
defer C.free(unsafe.Pointer(ctable))
}
res := C.sqlite3session_attach(s.ptr, ctable)
return reserr("Session.Attach", tableName, "", res)
}

Because the variable is used within the if branch, the compiler doesn't flag it as unused.

Line 92 should be changed to

ctable = C.CString(tableName)
AdamSLevy added a commit to AdamSLevy/sqlite that referenced this issue Oct 9, 2019
AdamSLevy added a commit to AdamSLevy/sqlite that referenced this issue Oct 9, 2019
AdamSLevy added a commit that referenced this issue Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant