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. > 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. > 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). > 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. > 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. > 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