mattn / mattn/go-sqlite3

SQLiteStmt.execSync should reset the statement on the normal path

Open
#912 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
9.2k
Forks
1.2k
Avg merge
19m
Merged PRs (30d)
4

Description

https://github.com/mattn/go-sqlite3/blob/3cbdae750e52afa881060732446298f98131e834/sqlite3.go#L1991-L2008

Should call C.sqlite3_reset(s.s) on the normal return path as well as abnormal. This is because implicit transactions are committed when the statement is reset: https://sqlite.org/lang_transaction.html#implicit_versus_explicit_transactions. If we don't reset the statement, then if the user executes the code like the following:

stmt, _ := conn.PrepareContext(ctx, "INSERT ...")

for ... {
  stmt.Exec()
  time.Sleep(time.Hour)
}

the INSERT statement may remain uncommitted for one hour, which violates the principle of least astonishment.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sqlite3.go around lines 1991-2008 and inspect SQLiteStmt.execSync, including its existing abnormal return handling. Confirm the normal path calls C.sqlite3_reset(s.s), then verify the driver tests cover repeated Exec calls on a prepared INSERT and that the transaction is committed before the next iteration.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sqlite
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.