Hi, Keith,

On Sat, Oct 20, 2012 at 11:10 PM, Keith Medcalf <kmedc...@dessus.com> wrote:
> On Saturday, 20 October, 2012 at 23:42, Igor Korot <ikoro...@gmail.com> wrote:
>
>> According to http://www.sqlite.org/foreignkeys.html the FOREIGN KEY
>> support is disabled by default.
>
> Yes, foreign key enforcement is disabled by default.

OK.

>
>> In order to enable it I need to compile SQLITE with 2 defines undefined.
>
> Not quite.  The default setting for the enforcement of foreign key 
> constraints is controlled by the define
>
> SQLITE_DEFAULT_FOREIGN_KEYS
>
> The default value is 0, which disables foreign key constraint enforcement by 
> default.
> Recompiling with a value of 1 enables foreign key constraint enforcement by 
> default.
>
> At runtime, you can use the SQL statements
> PRAGMA FOREIGN_KEYS=1;
> to enable foreign key constraint enforcement and
> PRAGMA FOREIGN_KEYS=0;
> to disable foreign key constraint enforcement.
> PRAGMA FOREIGN_KEYS;
> will return 0 or 1 indicating whether foreign key constraints are being 
> enforced or not.

All this contradicts the document I referenced above. See part 2 of it.

[quote]
In order to use foreign key constraints in SQLite, the library must be
compiled with neither SQLITE_OMIT_FOREIGN_KEY or SQLITE_OMIT_TRIGGER
defined.
[/quote]

The constant you mentioned is not present in this part of online documentation.

>
>> I downloaded the file sqlite-amalgamation-3071400.zip, unpacked it,
>> added .c and .h file to my project and inspected them.
>
>> SQLITE_OMIT_FOREIGN_KEY can not be found in both .h files and I don't
>> see the #define of this constant anywhere in the .c file.
>
> By default nothing is omitted.  However, if you *do* choose to omit parts of 
> the engine, the effect will be as described:
>
> If SQLITE_OMIT_TRIGGER is defined but SQLITE_OMIT_FOREIGN_KEY is not, then 
> SQLite behaves as it did prior to version 3.6.19 - foreign key definitions 
> are parsed and may be queried using PRAGMA foreign_key_list, but foreign key 
> constraints are not enforced. The PRAGMA foreign_keys command is a no-op in 
> this configuration. If OMIT_FOREIGN_KEY is defined, then foreign key 
> definitions cannot even be parsed (attempting to specify a foreign key 
> definition is a syntax error).

Well let me clarify a bit.
I am trying to develop a software which will communicate with SQLite
database. In order for that to happen properly I need the
foreing key constraint to be included.
And now I need to look for a third constant that was not in a picture. ;-)

>
>> Is foreign key documentation outdated?
>
> No, it is correct.  See http://www.sqlite.org/compile.html for the options 
> you can define at compile time, the defaults, and the effect.

Well it does not mention the constant you were talking about so at the
very least it's incorrect/incomplete.

>
>> Also one minor question: do I need both .h files or just one will suffice?
>
> sqlite3ext.h is used when compiling extensions to the sqlite3 engine that are 
> not part of the engine itself -- that is, loadable modules.  sqlite3.h is the 
> header file which must be included by c sources which are part of the engine, 
> such as the sqlite3.c amalgamation itself, or extension modules that will be 
> built-in.

OK, so sqlite3.h should be enough to work with basic query. That's
what I thought but needed confirmation for.

Thank you.

>
>> Thank you.
>
>
> ---
> ()  ascii ribbon campaign against html e-mail
> /\  www.asciiribbon.org
>
>
>
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to