Why are some SQLite functions based on zero and some

The index parameter for sqlite3_column_* is zero based, and sqlite3_bind_* is one based.

Is there a reason for this?

+6
source share
1 answer

I have.

Charge sqlite3_bind_parameter_index :

Return the index of the SQL parameter with its name. The return value of the index is suitable for use as the second parameter for sqlite3_bind (). If there is no corresponding parameter, zero is returned.

So you go. An odd choice, given that they seem to use a signed int for the index, i.e. they could use -1 to indicate no match. Perhaps the reason is that it is more historical, SQLite has been around for a while ...

+2
source

Source: https://habr.com/ru/post/898818/


All Articles