The question you are asking is properly adressed by the logic that creates the statements itself. The statement generator itself needs to keep track of the SQL parameters it has created and that something has been bound for each parameter before issuing a call to sqlite3_step. Note that as far as SQlite is concerned, binding NULL ist equivalent to unbinding a parameter, whereas you are looking for a distinction between "never bound anything" and "bound NULL on purpose", so even if SQLite could tell you if a bound parameter was NULL or not, that still would not answer your question.
SQLite itself is only concerned with the total number of parameters required to execute the statement and their names, if given, in case you want to bind by name. Or, in a nutshell, the data storage layer (SQLite) is neither designed for nor able to answer internals of the data processing layer (your query generator) -----Ursprüngliche Nachricht----- Von: sqlite-users [mailto:[email protected]] Im Auftrag von test user Gesendet: Montag, 22. Juli 2019 11:53 An: SQLite mailing list <[email protected]> Betreff: Re: [sqlite] [EXTERNAL] Determining valid statement placeholders. Simon Slavin: "Please don't use numbers as names." The manual states: - "?NNN": where N is an *integer*. - "?": Programmers are encouraged to use one of the symbolic formats below or the ?NNN format above instead." The use case: I am creating a library that takes SQL from the application and runs it via the SQLite FFI. I want to be able to write this function: if has_bound_all_placeholders_in_query_string() { // run query } else { throw Error("You must bind all query parameters.") // This branch cannot be created with the current SQLite FFI APIs. // It is useful because the SQLite default is to bind NULL to unbound placeholders, which may not be what the user wanted. If they wanted this they would of just used the constant NULL instead of a placeholder. // In dynamic languages where both the query string and the data could be dynamically generated, being able to enforce binding all placeholders is useful for correctness. } A new function could be added: For query string "SELECT ?, ?10" `sqlite3_bind_parameter_valid_indexes() -> [1, 10]` How can I propose adding this? On Mon, Jul 22, 2019 at 6:52 AM Hick Gunter <[email protected]> wrote: > No. As the creator of a statement, you are expected to know either the > position or the name of any SQL parameters contained therein. > Determining which indexes are legal does not help in determining what > has been bound, not even if anything has been bound. Please note that > sqlite3_reset() does not clear the bindings. > > What is the underlying use case? > > -----Ursprüngliche Nachricht----- > Von: sqlite-users > [mailto:[email protected]] > Im Auftrag von test user > Gesendet: Sonntag, 21. Juli 2019 21:04 > An: [email protected] > Betreff: [EXTERNAL] [sqlite] Determining valid statement placeholders. > > Is there a `sqlite3` C FFI API that allows me to determine which index > values are valid to bind to? > > The `sqlite3_bind_parameter_*` APIs (count, name, index) do not > actually provide the valid indexes. > > For example: "?, ?10" would have two valid indexes: (1, 10). > > But how can I know that indexes 2-9 are invalid from the API? > > I have tried binding null to 2-9, but get SQLITE_OK. > > I want to be able to check clients have provided all data needed for a > query instead having SQLite bind null by default for placeholders with > no data binding. > > Thanks. > _______________________________________________ > sqlite-users mailing list > [email protected] > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > > > ___________________________________________ > Gunter Hick | Software Engineer | Scientific Games International GmbH > | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 > | (O) > +43 1 80100 - 0 > > May be privileged. May be confidential. Please delete if not the addressee. > _______________________________________________ > sqlite-users mailing list > [email protected] > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___________________________________________ Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0 May be privileged. May be confidential. Please delete if not the addressee. _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

