Re: [sqlite] SQLITE_DBCONFIG_DEFENSIVE documentation looks confusing

2019-01-29 Thread Dan Kennedy


On 29/1/62 23:18, Chris Brody wrote:

I think my sample code should have read as follows:

To activate the "defensive" flag for a database connection:
sqlite3_db_config(db, SQLITE_DBCONFIG_DEFENSIVE, 1, NULL);

(I got the wrong prefix before, and I discovered that it crashes if I
do not add the NULL argument.)

I hope I got this right, really wish it were better documented.


Passing NULL is fine. It's the same interface as 
SQLITE_DBCONFIG_ENABLE_FKEY and most of the others. Unless it is NULL, 
the int indicated by the (int*) parameter is set to 0 or 1 to indicate 
whether the connection is in DEFENSIVE mode or not following the call.


  int bDefensive;
  sqlite3_db_config(db, SQLITE_DBCONFIG_DEFENSIVE, 1, );
  if( bDefensive ){
    printf("connection in defensive mode!\n");
  }else{
    printf("connection not in defensive mode :(\n");
  }

Dan.







On Tue, Jan 29, 2019 at 10:17 AM Chris Brody  wrote:

I am very sorry to say that I have found the usage of the
SQLITE_DBCONFIG_DEFENSIVE option to be somewhat confusing.

 From my first reading of https://www.sqlite.org/releaselog/3_26_0.html
I thought SQLITE_DBCONFIG_DEFENSIVE was a compile-time option. (I was
proven wrong pretty quickly.)

Then I found the following in
https://www.sqlite.org/c3ref/c_dbconfig_defensive.html to be
confusing:

Looking at this entry:

#define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */

seems to indicate to me that I should pass 2 integer values after
SQLITE_DBCONFIG_DEFENSIVE in the sqlite_db_config() call (which I
think is wrong). I found it especially confusing since the example
code for SQLITE_DBCONFIG_RESET_DATABASE shows 2 integers after
SQLITE_DBCONFIG_RESET_DATABASE.

I think there should be example code for SQLITE_DBCONFIG_DEFENSIVE
that reads something like this:

To activate the "defensive" flag for a database connection:
sqlite_db_config(db, SQLITE_DBCONFIG_DEFENSIVE, 1);

I think it would be ideal if there would be a compile-time flag that
would tell SQLite to enable the "defensive" flag by default whenever
the application opens a database.

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLITE_DBCONFIG_DEFENSIVE documentation looks confusing

2019-01-29 Thread Chris Brody
I think my sample code should have read as follows:

To activate the "defensive" flag for a database connection:
sqlite3_db_config(db, SQLITE_DBCONFIG_DEFENSIVE, 1, NULL);

(I got the wrong prefix before, and I discovered that it crashes if I
do not add the NULL argument.)

I hope I got this right, really wish it were better documented.


On Tue, Jan 29, 2019 at 10:17 AM Chris Brody  wrote:
>
> I am very sorry to say that I have found the usage of the
> SQLITE_DBCONFIG_DEFENSIVE option to be somewhat confusing.
>
> From my first reading of https://www.sqlite.org/releaselog/3_26_0.html
> I thought SQLITE_DBCONFIG_DEFENSIVE was a compile-time option. (I was
> proven wrong pretty quickly.)
>
> Then I found the following in
> https://www.sqlite.org/c3ref/c_dbconfig_defensive.html to be
> confusing:
>
> Looking at this entry:
>
> #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
>
> seems to indicate to me that I should pass 2 integer values after
> SQLITE_DBCONFIG_DEFENSIVE in the sqlite_db_config() call (which I
> think is wrong). I found it especially confusing since the example
> code for SQLITE_DBCONFIG_RESET_DATABASE shows 2 integers after
> SQLITE_DBCONFIG_RESET_DATABASE.
>
> I think there should be example code for SQLITE_DBCONFIG_DEFENSIVE
> that reads something like this:
>
> To activate the "defensive" flag for a database connection:
> sqlite_db_config(db, SQLITE_DBCONFIG_DEFENSIVE, 1);
>
> I think it would be ideal if there would be a compile-time flag that
> would tell SQLite to enable the "defensive" flag by default whenever
> the application opens a database.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] SQLITE_DBCONFIG_DEFENSIVE documentation looks confusing

2019-01-29 Thread Chris Brody
I am very sorry to say that I have found the usage of the
SQLITE_DBCONFIG_DEFENSIVE option to be somewhat confusing.

From my first reading of https://www.sqlite.org/releaselog/3_26_0.html
I thought SQLITE_DBCONFIG_DEFENSIVE was a compile-time option. (I was
proven wrong pretty quickly.)

Then I found the following in
https://www.sqlite.org/c3ref/c_dbconfig_defensive.html to be
confusing:

Looking at this entry:

#define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */

seems to indicate to me that I should pass 2 integer values after
SQLITE_DBCONFIG_DEFENSIVE in the sqlite_db_config() call (which I
think is wrong). I found it especially confusing since the example
code for SQLITE_DBCONFIG_RESET_DATABASE shows 2 integers after
SQLITE_DBCONFIG_RESET_DATABASE.

I think there should be example code for SQLITE_DBCONFIG_DEFENSIVE
that reads something like this:

To activate the "defensive" flag for a database connection:
sqlite_db_config(db, SQLITE_DBCONFIG_DEFENSIVE, 1);

I think it would be ideal if there would be a compile-time flag that
would tell SQLite to enable the "defensive" flag by default whenever
the application opens a database.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users