Feature request: Statement context
(1) By anonymous on 2021-05-25 06:35:19
It would be convenient if it was possible to assign a context pointer to a sqlite3_stmt. Example usage (pseudo C code): ``` sqlite3_stmt *new_stmt(struct meta_data *ctx) { sqlite3_stmt stmt; int rc = sqlite3_prepare_v2(...); if (rc != SQLITE_OK) { /* error handling */ } rc = sqlite3_stmt_set_context(stmt, ctx); if (rc != SQLITE_OK) { /* error handling */ } return stmt; } /* later, iterate over all statements: */ void iterate() { sqlite3_stmt *stmt = NULL; while ((stmt = sqlite3_stmt_next(stmt))) { struct meta_data *ctx = sqlite3_stmt_get_context(stmt); /* do stuff with meta data */ } } ```
(2) By Larry Brasfield (larrybr) on 2021-05-25 11:24:33 in reply to 1 [link]
I can see that this might be convenient. But I do not see any advantage to it that cannot be achieved, with better type safety, by aggregating the sqlite3_stmt pointer with whatever associated information an application needs. Hence, I wonder: Can you make an argument for this feature that goes beyond coding convenience?
(3) By anonymous on 2021-05-26 18:22:02 in reply to 2 [link]
> Can you make an argument for this feature that goes beyond coding convenience? No; it's (just) coding convenience. I simply want to avoid having to maintain my own list of statements in use.