Skip to content

Add eval-many and tests - #30

Open
veqqq wants to merge 5 commits into
janet-lang:masterfrom
veqqq:master
Open

Add eval-many and tests#30
veqqq wants to merge 5 commits into
janet-lang:masterfrom
veqqq:master

Conversation

@veqqq

@veqqq veqqq commented Jul 19, 2026

Copy link
Copy Markdown

I finally realized that assert errs driving jpm test!

@sogaiu

sogaiu commented Jul 22, 2026

Copy link
Copy Markdown

Worth checking the return values of the following?

Their signatures suggest return values of int, not void.

@veqqq

veqqq commented Jul 22, 2026

Copy link
Copy Markdown
Author

return values of int

I'm not sure what to return (such that it's meaningful). sqlite3_reset only pushes sqlite3_step's return through which in the success path is SQLITE_OK (nothing else gets to reset). Do you think it should just emit SQLITE_OK?

@veqqq

veqqq commented Jul 22, 2026

Copy link
Copy Markdown
Author

I added a benchmark and fixed doc string formating

@veqqq

veqqq commented Jul 23, 2026

Copy link
Copy Markdown
Author

I still feel pretty new to c and just broke some prior beliefs where I thought: 0 is success, -1 is err everywhere but that's apparently only POSIX. E.g. SQLITE_BUSY is e.g. 5 or SQLITE_ROW 100. So they're giving actual values here

My intuition suggests not returning anything on the base case, since this is just for the side effect of writing.

execute and bindmany and bind1 return null on success. But they're not userfacing exactly.

@sogaiu

sogaiu commented Jul 23, 2026

Copy link
Copy Markdown

I don't have a detailed understanding of sqlite3 C bits, but I noticed this document which has the prose:

Many of the routines in the SQLite C-language Interface return numeric result codes indicating either success or failure, and in the event of a failure, providing some idea of the cause of the failure. This document strives to explain what each of those numeric result codes means.

Very roughly speaking, it seems reasonable to try to detect if there is an error after each of the sqlite3_* functions that can indicate errors via their return values. The idea is that one would probably want to know if something did not go as planned.

@kamisori

Copy link
Copy Markdown

regarding reset:

The sqlite3_reset(S) interface might also return an error code if there were no prior errors but the process of resetting the prepared statement caused a new error. For example, if an INSERT statement with a RETURNING clause is only stepped one time, that one call to sqlite3_step(S) might return SQLITE_ROW but the overall statement might still fail and the sqlite3_reset(S) call might return SQLITE_BUSY if locking constraints prevent the database change from committing. Therefore, it is important that applications check the return code from sqlite3_reset(S) even if no prior call to sqlite3_step(S) indicated a problem.

finalize:

If the most recent evaluation of statement S failed, then sqlite3_finalize(S) returns the appropriate error code or extended error code.

clearbindings would need a look into its source code to determine whether its return value has informative value

it depends on the documentation and implementation and individual case but in cases like this, where the function call only creates a sideeffect, like pp or print do, i like to do what pp and print do: return nil

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 this pull request may close these issues.

3 participants