Skip to content

database/sql: Multiple statements in Exec/Query #96

Answered by ncruces
ncruces asked this question in Q&A
Discussion options

You must be logged in to vote

I wouldn't consider this a bug. I actually believe it's a misfeature of other drivers.

I don't see how this can be correctly implemented in the face of numbered (?NNN) parameters, and especially numbered (?NNN) and positional (?) parameters mixed together.

The problem is that SQLite doesn't allow to bind parameters to sqlite3_exec, and sqlite3_prepare_v3 does not accept multiple statements. So, suddenly, which parameters go to which statement is up to interpretation, and IMO there is no correct answer.

To see what I mean, consider this example:

_, err = db.Exec(`
	insert into t1(name1) values(?, ?3);
	insert into t2(name2) values(?, ?1);
`, 1, 2, 3, 4)

SQLite would see insert into t1(name…

Replies: 1 comment

Comment options

ncruces
Jun 11, 2024
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by ncruces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
1 participant