sqlite icon indicating copy to clipboard operation
sqlite copied to clipboard

Calling stmt.Step from a sqliteutil.Exec resultFn causes a infinite loop

Open FiloSottile opened this issue 7 years ago • 2 comments

I see the mistake I was making now, but it would have been nicer if it had panic'd.

I got tempted by sqliteutil.ResultText. Maybe some docs could have stopped me, but not sure where.

FiloSottile avatar Apr 18 '18 05:04 FiloSottile

Nasty. It used to be that sqlite3_reset was always necessary before step would re-execute a statement, but that appears to have changed. It looks like we could use SQLITE_OMIT_AUTORESET to work around that, but I'd rather not.

One possibility: what if the argument to resultFn wasn't a *Stmt, but an interface type that only exposed the methods from Stmt used to read values?

crawshaw avatar Apr 19 '18 14:04 crawshaw

I kind of like the type reuse there. How about just setting a private flag on Stmt that makes it panic on Step?

FiloSottile avatar May 10 '18 22:05 FiloSottile