From 937f856f376d7da20fdb6ee1b04f268a1228bc34 Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Thu, 20 May 2010 03:04:03 +0000 Subject: [PATCH] compile options --- Changes | 1 + SQLite.xs | 6 ++++++ dbdimp.c | 22 ++++++++++++++++++++++ lib/DBD/SQLite.pm | 8 +++++++- t/01_compile.t | 5 +++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 77554fa..e6e3b42 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,7 @@ Changes for Perl extension DBD-SQLite - Updated to SQLite 3.6.23.1 (ISHIGAKI) - Resolved #56693: [PATCH] Fix spelling errors (patch by Ansgar Burchardt) (ISHIGAKI) + - Added compile_options() to get compile options (ISHIGAKI) 1.30_02 Tue 30 Mar 2010 - Implemented sqlite_use_immediate_transaction database handle diff --git a/SQLite.xs b/SQLite.xs index 7e5c49c..5ed928e 100644 --- a/SQLite.xs +++ b/SQLite.xs @@ -205,6 +205,12 @@ MODULE = DBD::SQLite PACKAGE = DBD::SQLite PROTOTYPES: ENABLE +SV * +compile_options() + CODE: + ST(0) = (SV*)sqlite_compile_options(); + XSRETURN(1); + static int OK() CODE: diff --git a/dbdimp.c b/dbdimp.c index c887aff..6d8b4f4 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -990,6 +990,28 @@ sqlite_bind_col(SV *sth, imp_sth_t *imp_sth, SV *col, SV *ref, IV sql_type, SV * * Driver Private Methods *-----------------------------------------------------*/ +SV * +sqlite_compile_options() +{ + dTHX; + int i = 0; + const char *option; + +#if SQLITE_VERSION_NUMBER < 3006023 + return &PL_sv_undef; +#endif +#ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS + return &PL_sv_undef; +#endif + + AV *av = newAV(); + while(option = sqlite3_compileoption_get(i++)) { + av_push(av, newSVpv(option, 0)); + } + + return sv_2mortal(newRV_noinc((SV*)av)); +} + int sqlite_db_busy_timeout(pTHX_ SV *dbh, int timeout ) { diff --git a/lib/DBD/SQLite.pm b/lib/DBD/SQLite.pm index e66f104..279afae 100644 --- a/lib/DBD/SQLite.pm +++ b/lib/DBD/SQLite.pm @@ -781,7 +781,7 @@ named) placeholders to avoid confusion. B SQLite has started supporting foreign key constraints since 3.6.19 -(released on Oct 14, 2009; bundled with DBD::SQLite 1.26_05). +(released on Oct 14, 2009; bundled in DBD::SQLite 1.26_05). To be exact, SQLite has long been able to parse a schema with foreign keys, but the constraints has not been enforced. Now you can issue a pragma actually to enable this feature and enforce the constraints. @@ -1440,6 +1440,12 @@ sqlite3 extensions. After the call, you can load extensions like this: $sth = $dbh->prepare("select load_extension('libsqlitefunctions.so')") or die "Cannot prepare: " . $dbh->errstr(); +=head2 DBD::SQLite::compile_options() + +Returns an array reference of compile options (available since sqlite 3.6.23, +bundled in DBD::SQLite 1.30_01), or undef if the bundled library is old or +compiled with SQLITE_OMIT_COMPILEOPTION_DIAGS. + =head1 DRIVER CONSTANTS A subset of SQLite C constants are made available to Perl, diff --git a/t/01_compile.t b/t/01_compile.t index 739a46d..7c6e35d 100644 --- a/t/01_compile.t +++ b/t/01_compile.t @@ -16,3 +16,8 @@ use_ok('DBD::SQLite'); use_ok('t::lib::Test'); diag("\$DBI::VERSION=$DBI::VERSION"); + +if (my $compile_options = DBD::SQLite::compile_options()) { + diag("Compile Options:"); + diag(join "", map { " $_\n" } @$compile_options); +}