mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 22:28:47 -04:00
Silence(!) Win64 build warnings
This commit is contained in:
parent
1087a50857
commit
14b507835b
6 changed files with 1273 additions and 1397 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,6 +1,10 @@
|
||||||
*.o
|
*.o
|
||||||
*.bs
|
*.bs
|
||||||
blib/
|
blib/
|
||||||
|
*.def
|
||||||
|
dll.base
|
||||||
|
dll.def
|
||||||
|
dll.exp
|
||||||
SQLite.c
|
SQLite.c
|
||||||
*.xsi
|
*.xsi
|
||||||
pm_to_blib
|
pm_to_blib
|
||||||
|
|
382
dbdimp.c
382
dbdimp.c
|
@ -1,4 +1,4 @@
|
||||||
#define PERL_NO_GET_CONTEXT
|
/* $Id: dbdimp.c,v 1.64 2006/09/18 18:54:05 matt Exp $ */
|
||||||
|
|
||||||
#include "SQLiteXS.h"
|
#include "SQLiteXS.h"
|
||||||
|
|
||||||
|
@ -18,11 +18,9 @@ DBISTATE_DECLARE;
|
||||||
#define call_sv(x,y) perl_call_sv(x,y)
|
#define call_sv(x,y) perl_call_sv(x,y)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define sqlite_error(h,xxh,rc,what) _sqlite_error(aTHX_ __FILE__, __LINE__, h, xxh, rc, what)
|
#define sqlite_error(h,xxh,rc,what) _sqlite_error(__FILE__, __LINE__, h, xxh, rc, what)
|
||||||
|
|
||||||
/* XXX: is there any good way to use pTHX_/aTHX_ here like above? */
|
|
||||||
#if defined(__GNUC__) && (__GNUC__ > 2)
|
#if defined(__GNUC__) && (__GNUC__ > 2)
|
||||||
# define sqlite_trace(h,xxh,level,fmt...) _sqlite_tracef(__FILE__, __LINE__, h, xxh, level, fmt)
|
# define sqlite_trace(level,fmt...) _sqlite_tracef(__FILE__, __LINE__, level, fmt)
|
||||||
#else
|
#else
|
||||||
# define sqlite_trace _sqlite_tracef_noline
|
# define sqlite_trace _sqlite_tracef_noline
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,52 +28,53 @@ DBISTATE_DECLARE;
|
||||||
void
|
void
|
||||||
sqlite_init(dbistate_t *dbistate)
|
sqlite_init(dbistate_t *dbistate)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHR;
|
||||||
DBISTATE_INIT; /* Initialize the DBI macros */
|
DBIS = dbistate;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_sqlite_error(pTHX_ char *file, int line, SV *h, imp_xxh_t *imp_xxh, int rc, char *what)
|
_sqlite_error(char *file, int line, SV *h, imp_xxh_t *imp_xxh, int rc, char *what)
|
||||||
{
|
{
|
||||||
DBIh_SET_ERR_CHAR(h, imp_xxh, Nullch, rc, what, Nullch, Nullch);
|
dTHR;
|
||||||
|
|
||||||
|
SV *errstr = DBIc_ERRSTR(imp_xxh);
|
||||||
|
sv_setiv(DBIc_ERR(imp_xxh), (IV)rc);
|
||||||
|
sv_setpv(errstr, what);
|
||||||
/* #7753: DBD::SQLite error shouldn't include extraneous info */
|
/* #7753: DBD::SQLite error shouldn't include extraneous info */
|
||||||
/* sv_catpvf(errstr, "(%d) at %s line %d", rc, file, line); */
|
/* sv_catpvf(errstr, "(%d) at %s line %d", rc, file, line); */
|
||||||
if ( DBIc_TRACE_LEVEL(imp_xxh) >= 3 ) {
|
|
||||||
PerlIO_printf(
|
if ( DBIS->debug >= 3 ) {
|
||||||
DBIc_LOGPIO(imp_xxh),
|
PerlIO_printf(DBILOGFP, "sqlite error %d recorded: %s at %s line %d\n",
|
||||||
"sqlite error %d recorded: %s at %s line %d\n",
|
rc, what, file, line);
|
||||||
rc, what, file, line
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_sqlite_tracef(char *file, int line, SV *h, imp_xxh_t *imp_xxh, int level, const char *fmt, ...)
|
_sqlite_tracef(char *file, int line, int level, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHR;
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
if ( DBIc_TRACE_LEVEL(imp_xxh) >= level ) {
|
if (DBIS->debug >= level) {
|
||||||
char format[8192];
|
char format[8192];
|
||||||
sqlite3_snprintf(8191, format, "sqlite trace: %s at %s line %d\n", fmt, file, line);
|
sqlite3_snprintf(8191, format, "sqlite trace: %s at %s line %d\n", fmt, file, line);
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
PerlIO_vprintf(DBIc_LOGPIO(imp_xxh), format, ap);
|
PerlIO_vprintf(DBILOGFP, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_sqlite_tracef_noline(SV *h, imp_xxh_t *imp_xxh, int level, const char *fmt, ...)
|
_sqlite_tracef_noline(int level, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHR;
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
if ( DBIc_TRACE_LEVEL(imp_xxh) >= level ) {
|
if (DBIS->debug >= level) {
|
||||||
char format[8192];
|
char format[8192];
|
||||||
sqlite3_snprintf(8191, format, "sqlite trace: %s\n", fmt);
|
sqlite3_snprintf(8191, format, "sqlite trace: %s\n", fmt);
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
PerlIO_vprintf(DBIc_LOGPIO(imp_xxh), format, ap);
|
PerlIO_vprintf(DBILOGFP, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,18 +82,18 @@ _sqlite_tracef_noline(SV *h, imp_xxh_t *imp_xxh, int level, const char *fmt, ...
|
||||||
int
|
int
|
||||||
sqlite_db_login(SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *user, char *pass)
|
sqlite_db_login(SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *user, char *pass)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHR;
|
||||||
int retval;
|
int retval;
|
||||||
char *errmsg = NULL;
|
char *errmsg = NULL;
|
||||||
|
|
||||||
if ( DBIc_TRACE_LEVEL(imp_dbh) >= 3 ) {
|
if (DBIS->debug >= 3) {
|
||||||
PerlIO_printf(DBILOGFP, " login '%s' (version %s)\n",
|
PerlIO_printf(DBILOGFP, " login '%s' (version %s)\n",
|
||||||
dbname, sqlite3_version);
|
dbname, sqlite3_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((retval = sqlite3_open(dbname, &(imp_dbh->db))) != SQLITE_OK ) {
|
if (sqlite3_open(dbname, &(imp_dbh->db)) != SQLITE_OK) {
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, (char*)sqlite3_errmsg(imp_dbh->db));
|
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, 1, (char*)sqlite3_errmsg(imp_dbh->db));
|
||||||
return FALSE; /* -> undef in lib/DBD/SQLite.pm */
|
return FALSE;
|
||||||
}
|
}
|
||||||
DBIc_IMPSET_on(imp_dbh);
|
DBIc_IMPSET_on(imp_dbh);
|
||||||
|
|
||||||
|
@ -103,6 +102,7 @@ sqlite_db_login(SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *user, char *pas
|
||||||
imp_dbh->functions = newAV();
|
imp_dbh->functions = newAV();
|
||||||
imp_dbh->aggregates = newAV();
|
imp_dbh->aggregates = newAV();
|
||||||
imp_dbh->timeout = SQL_TIMEOUT;
|
imp_dbh->timeout = SQL_TIMEOUT;
|
||||||
|
|
||||||
imp_dbh->handle_binary_nulls = FALSE;
|
imp_dbh->handle_binary_nulls = FALSE;
|
||||||
|
|
||||||
sqlite3_busy_timeout(imp_dbh->db, SQL_TIMEOUT);
|
sqlite3_busy_timeout(imp_dbh->db, SQL_TIMEOUT);
|
||||||
|
@ -113,7 +113,7 @@ sqlite_db_login(SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *user, char *pas
|
||||||
{
|
{
|
||||||
/* warn("failed to set pragma: %s\n", errmsg); */
|
/* warn("failed to set pragma: %s\n", errmsg); */
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
||||||
return FALSE; /* -> undef in lib/DBD/SQLite.pm */
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((retval = sqlite3_exec(imp_dbh->db, "PRAGMA show_datatypes = ON",
|
if ((retval = sqlite3_exec(imp_dbh->db, "PRAGMA show_datatypes = ON",
|
||||||
|
@ -122,28 +122,16 @@ sqlite_db_login(SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *user, char *pas
|
||||||
{
|
{
|
||||||
/* warn("failed to set pragma: %s\n", errmsg); */
|
/* warn("failed to set pragma: %s\n", errmsg); */
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
||||||
return FALSE; /* -> undef in lib/DBD/SQLite.pm */
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBIc_ACTIVE_on(imp_dbh);
|
DBIc_ACTIVE_on(imp_dbh);
|
||||||
|
|
||||||
/*
|
|
||||||
if ( DBIc_WARN(imp_dbh) ) {
|
|
||||||
warn("DBIc_WARN is on");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
warn("DBIc_WARN if off");
|
|
||||||
}
|
|
||||||
if ( DBIc_is(imp_dbh, DBIcf_PrintWarn) ) {
|
|
||||||
warn("DBIcf_PrintWarn is on");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dbd_set_sqlite3_busy_timeout (pTHX_ SV *dbh, int timeout )
|
dbd_set_sqlite3_busy_timeout ( SV *dbh, int timeout )
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
|
@ -156,7 +144,7 @@ dbd_set_sqlite3_busy_timeout (pTHX_ SV *dbh, int timeout )
|
||||||
int
|
int
|
||||||
sqlite_db_disconnect (SV *dbh, imp_dbh_t *imp_dbh)
|
sqlite_db_disconnect (SV *dbh, imp_dbh_t *imp_dbh)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHR;
|
||||||
sqlite3_stmt *pStmt;
|
sqlite3_stmt *pStmt;
|
||||||
DBIc_ACTIVE_off(imp_dbh);
|
DBIc_ACTIVE_off(imp_dbh);
|
||||||
|
|
||||||
|
@ -188,14 +176,9 @@ sqlite_db_disconnect (SV *dbh, imp_dbh_t *imp_dbh)
|
||||||
void
|
void
|
||||||
sqlite_db_destroy (SV *dbh, imp_dbh_t *imp_dbh)
|
sqlite_db_destroy (SV *dbh, imp_dbh_t *imp_dbh)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHR;
|
||||||
if (DBIc_ACTIVE(imp_dbh)) {
|
if (DBIc_ACTIVE(imp_dbh)) {
|
||||||
/* warn("DBIc_ACTIVE is on"); */
|
|
||||||
sqlite_db_disconnect(dbh, imp_dbh);
|
sqlite_db_disconnect(dbh, imp_dbh);
|
||||||
/*
|
|
||||||
} else {
|
|
||||||
warn("DBIc_ACTIVE is off");
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
DBIc_IMPSET_off(imp_dbh);
|
DBIc_IMPSET_off(imp_dbh);
|
||||||
}
|
}
|
||||||
|
@ -203,18 +186,18 @@ sqlite_db_destroy (SV *dbh, imp_dbh_t *imp_dbh)
|
||||||
int
|
int
|
||||||
sqlite_db_rollback(SV *dbh, imp_dbh_t *imp_dbh)
|
sqlite_db_rollback(SV *dbh, imp_dbh_t *imp_dbh)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHR;
|
||||||
int retval;
|
int retval;
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
|
|
||||||
if (imp_dbh->in_tran) {
|
if (imp_dbh->in_tran) {
|
||||||
sqlite_trace(dbh, (imp_xxh_t*)imp_dbh, 2, "ROLLBACK TRAN");
|
sqlite_trace(2, "ROLLBACK TRAN");
|
||||||
if ((retval = sqlite3_exec(imp_dbh->db, "ROLLBACK TRANSACTION",
|
if ((retval = sqlite3_exec(imp_dbh->db, "ROLLBACK TRANSACTION",
|
||||||
NULL, NULL, &errmsg))
|
NULL, NULL, &errmsg))
|
||||||
!= SQLITE_OK)
|
!= SQLITE_OK)
|
||||||
{
|
{
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
||||||
return FALSE; /* -> &sv_no in SQLite.xsi */
|
return FALSE;
|
||||||
}
|
}
|
||||||
imp_dbh->in_tran = FALSE;
|
imp_dbh->in_tran = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -225,23 +208,23 @@ sqlite_db_rollback(SV *dbh, imp_dbh_t *imp_dbh)
|
||||||
int
|
int
|
||||||
sqlite_db_commit(SV *dbh, imp_dbh_t *imp_dbh)
|
sqlite_db_commit(SV *dbh, imp_dbh_t *imp_dbh)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHR;
|
||||||
int retval;
|
int retval;
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
|
|
||||||
if (DBIc_is(imp_dbh, DBIcf_AutoCommit)) {
|
if (DBIc_is(imp_dbh, DBIcf_AutoCommit)) {
|
||||||
/* We don't need to warn, because the DBI layer will do it for us */
|
warn("commit ineffective with AutoCommit");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imp_dbh->in_tran) {
|
if (imp_dbh->in_tran) {
|
||||||
sqlite_trace(dbh, (imp_xxh_t*)imp_dbh, 2, "COMMIT TRAN");
|
sqlite_trace(2, "COMMIT TRAN");
|
||||||
if ((retval = sqlite3_exec(imp_dbh->db, "COMMIT TRANSACTION",
|
if ((retval = sqlite3_exec(imp_dbh->db, "COMMIT TRANSACTION",
|
||||||
NULL, NULL, &errmsg))
|
NULL, NULL, &errmsg))
|
||||||
!= SQLITE_OK)
|
!= SQLITE_OK)
|
||||||
{
|
{
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
||||||
return FALSE; /* -> &sv_no in SQLite.xsi */
|
return FALSE;
|
||||||
}
|
}
|
||||||
imp_dbh->in_tran = FALSE;
|
imp_dbh->in_tran = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -251,14 +234,13 @@ sqlite_db_commit(SV *dbh, imp_dbh_t *imp_dbh)
|
||||||
int
|
int
|
||||||
sqlite_discon_all(SV *drh, imp_drh_t *imp_drh)
|
sqlite_discon_all(SV *drh, imp_drh_t *imp_drh)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHR;
|
||||||
return FALSE; /* no way to do this */
|
return FALSE; /* no way to do this */
|
||||||
}
|
}
|
||||||
|
|
||||||
SV *
|
SV *
|
||||||
sqlite_db_last_insert_id(SV *dbh, imp_dbh_t *imp_dbh, SV *catalog, SV *schema, SV *table, SV *field, SV *attr)
|
sqlite_db_last_insert_id(SV *dbh, imp_dbh_t *imp_dbh, SV *catalog, SV *schema, SV *table, SV *field, SV *attr)
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
return newSViv(sqlite3_last_insert_rowid(imp_dbh->db));
|
return newSViv(sqlite3_last_insert_rowid(imp_dbh->db));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,22 +248,22 @@ int
|
||||||
sqlite_st_prepare (SV *sth, imp_sth_t *imp_sth,
|
sqlite_st_prepare (SV *sth, imp_sth_t *imp_sth,
|
||||||
char *statement, SV *attribs)
|
char *statement, SV *attribs)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHR;
|
||||||
D_imp_dbh_from_sth;
|
D_imp_dbh_from_sth;
|
||||||
const char *extra;
|
const char *extra;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
if (!DBIc_ACTIVE(imp_dbh)) {
|
if (!DBIc_ACTIVE(imp_dbh)) {
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, -2, "attempt to prepare on inactive database handle");
|
sqlite_error(sth, (imp_xxh_t*)imp_sth, retval, "attempt to prepare on inactive database handle");
|
||||||
return FALSE; /* -> undef in lib/DBD/SQLite.pm */
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(statement) < 1) {
|
if (strlen(statement) < 1) {
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, -2, "attempt to prepare empty statement");
|
sqlite_error(sth, (imp_xxh_t*)imp_sth, retval, "attempt to prepare empty statement");
|
||||||
return FALSE; /* -> undef in lib/DBD/SQLite.pm */
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite_trace(sth, (imp_xxh_t*)imp_sth, 2, "prepare statement: %s", statement);
|
sqlite_trace(2, "prepare statement: %s", statement);
|
||||||
imp_sth->nrow = -1;
|
imp_sth->nrow = -1;
|
||||||
imp_sth->retval = SQLITE_OK;
|
imp_sth->retval = SQLITE_OK;
|
||||||
imp_sth->params = newAV();
|
imp_sth->params = newAV();
|
||||||
|
@ -295,7 +277,7 @@ sqlite_st_prepare (SV *sth, imp_sth_t *imp_sth,
|
||||||
sqlite3_finalize(imp_sth->stmt);
|
sqlite3_finalize(imp_sth->stmt);
|
||||||
}
|
}
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, retval, (char*)sqlite3_errmsg(imp_dbh->db));
|
sqlite_error(sth, (imp_xxh_t*)imp_sth, retval, (char*)sqlite3_errmsg(imp_dbh->db));
|
||||||
return FALSE; /* -> undef in lib/DBD/SQLite.pm */
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store the query for later re-use if required */
|
/* store the query for later re-use if required */
|
||||||
|
@ -311,7 +293,6 @@ sqlite_st_prepare (SV *sth, imp_sth_t *imp_sth,
|
||||||
char *
|
char *
|
||||||
sqlite_quote(imp_dbh_t *imp_dbh, SV *val)
|
sqlite_quote(imp_dbh_t *imp_dbh, SV *val)
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
STRLEN len;
|
STRLEN len;
|
||||||
char *cval = SvPV(val, len);
|
char *cval = SvPV(val, len);
|
||||||
SV *ret = sv_2mortal(NEWSV(0, SvCUR(val) + 2));
|
SV *ret = sv_2mortal(NEWSV(0, SvCUR(val) + 2));
|
||||||
|
@ -331,7 +312,7 @@ sqlite_quote(imp_dbh_t *imp_dbh, SV *val)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sqlite_st_reset (pTHX_ SV *sth)
|
sqlite_st_reset (SV *sth)
|
||||||
{
|
{
|
||||||
D_imp_sth(sth);
|
D_imp_sth(sth);
|
||||||
if (DBIc_IMPSET(imp_sth))
|
if (DBIc_IMPSET(imp_sth))
|
||||||
|
@ -341,41 +322,41 @@ sqlite_st_reset (pTHX_ SV *sth)
|
||||||
int
|
int
|
||||||
sqlite_st_execute (SV *sth, imp_sth_t *imp_sth)
|
sqlite_st_execute (SV *sth, imp_sth_t *imp_sth)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHR;
|
||||||
D_imp_dbh_from_sth;
|
D_imp_dbh_from_sth;
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
int num_params = DBIc_NUM_PARAMS(imp_sth);
|
int num_params = DBIc_NUM_PARAMS(imp_sth);
|
||||||
int i;
|
int i;
|
||||||
int retval = 0;
|
int retval;
|
||||||
|
|
||||||
sqlite_trace(sth, (imp_xxh_t*)imp_sth, 3, "execute");
|
sqlite_trace(3, "execute");
|
||||||
|
|
||||||
/* warn("execute\n"); */
|
/* warn("execute\n"); */
|
||||||
|
|
||||||
if (!DBIc_ACTIVE(imp_dbh)) {
|
if (!DBIc_ACTIVE(imp_dbh)) {
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, -2, "attempt to execute on inactive database handle");
|
sqlite_error(sth, (imp_xxh_t*)imp_sth, retval, "attempt to execute on inactive database handle");
|
||||||
return -2; /* -> undef in SQLite.xsi */
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBIc_ACTIVE(imp_sth)) {
|
if (DBIc_ACTIVE(imp_sth)) {
|
||||||
sqlite_trace(sth, (imp_xxh_t*)imp_sth, 3, "execute still active, reset");
|
sqlite_trace(3, "execute still active, reset");
|
||||||
if ((imp_sth->retval = sqlite3_reset(imp_sth->stmt)) != SQLITE_OK) {
|
if ((imp_sth->retval = sqlite3_reset(imp_sth->stmt)) != SQLITE_OK) {
|
||||||
char *errmsg = (char*)sqlite3_errmsg(imp_dbh->db);
|
char *errmsg = (char*)sqlite3_errmsg(imp_dbh->db);
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, errmsg);
|
sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, errmsg);
|
||||||
return -2; /* -> undef in SQLite.xsi */
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < num_params; i++) {
|
for (i = 0; i < num_params; i++) {
|
||||||
SV *value = av_shift(imp_sth->params);
|
SV *value = av_shift(imp_sth->params);
|
||||||
SV *sql_type_sv = av_shift(imp_sth->params);
|
SV *sql_type_sv = av_shift(imp_sth->params);
|
||||||
int sql_type = SvIV(sql_type_sv);
|
int sql_type = (int)SvIV(sql_type_sv);
|
||||||
|
|
||||||
sqlite_trace(sth, (imp_xxh_t*)imp_sth, 4, "params left in 0x%p: %d", imp_sth->params, 1+av_len(imp_sth->params));
|
sqlite_trace(4, "params left in 0x%p: %d", imp_sth->params, 1+av_len(imp_sth->params));
|
||||||
sqlite_trace(sth, (imp_xxh_t*)imp_sth, 4, "bind %d type %d as %s", i, sql_type, SvPV_nolen_undef_ok(value));
|
sqlite_trace(4, "bind %d type %d as %s", i, sql_type, SvPV_nolen_undef_ok(value));
|
||||||
|
|
||||||
if (!SvOK(value)) {
|
if (!SvOK(value)) {
|
||||||
sqlite_trace(sth, (imp_xxh_t*)imp_sth, 5, "binding null");
|
sqlite_trace(5, "binding null");
|
||||||
retval = sqlite3_bind_null(imp_sth->stmt, i+1);
|
retval = sqlite3_bind_null(imp_sth->stmt, i+1);
|
||||||
}
|
}
|
||||||
else if (sql_type >= SQL_NUMERIC && sql_type <= SQL_SMALLINT) {
|
else if (sql_type >= SQL_NUMERIC && sql_type <= SQL_SMALLINT) {
|
||||||
|
@ -391,34 +372,12 @@ sqlite_st_execute (SV *sth, imp_sth_t *imp_sth)
|
||||||
else if (sql_type == SQL_BLOB) {
|
else if (sql_type == SQL_BLOB) {
|
||||||
STRLEN len;
|
STRLEN len;
|
||||||
char * data = SvPV(value, len);
|
char * data = SvPV(value, len);
|
||||||
retval = sqlite3_bind_blob(imp_sth->stmt, i+1, data, len, SQLITE_TRANSIENT);
|
retval = sqlite3_bind_blob(imp_sth->stmt, i+1, data, (int)len, SQLITE_TRANSIENT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if 0
|
|
||||||
/* stop guessing until we figure out better way to do this */
|
|
||||||
const int numtype = looks_like_number(value);
|
|
||||||
if ((numtype & (IS_NUMBER_IN_UV|IS_NUMBER_NOT_INT)) == IS_NUMBER_IN_UV) {
|
|
||||||
#if defined(USE_64_BIT_INT)
|
|
||||||
retval = sqlite3_bind_int64(imp_sth->stmt, i+1, SvIV(value));
|
|
||||||
#else
|
|
||||||
retval = sqlite3_bind_int(imp_sth->stmt, i+1, SvIV(value));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if ((numtype & (IS_NUMBER_NOT_INT|IS_NUMBER_INFINITY|IS_NUMBER_NAN)) == IS_NUMBER_NOT_INT) {
|
|
||||||
retval = sqlite3_bind_double(imp_sth->stmt, i+1, SvNV(value));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
#endif
|
|
||||||
STRLEN len;
|
STRLEN len;
|
||||||
char *data;
|
char * data = SvPV(value, len);
|
||||||
if (imp_dbh->unicode) {
|
retval = sqlite3_bind_text(imp_sth->stmt, i+1, data, (int)len, SQLITE_TRANSIENT);
|
||||||
sv_utf8_upgrade(value);
|
|
||||||
}
|
|
||||||
data = SvPV(value, len);
|
|
||||||
retval = sqlite3_bind_text(imp_sth->stmt, i+1, data, len, SQLITE_TRANSIENT);
|
|
||||||
#if 0
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
|
@ -427,25 +386,25 @@ sqlite_st_execute (SV *sth, imp_sth_t *imp_sth)
|
||||||
SvREFCNT_dec(sql_type_sv);
|
SvREFCNT_dec(sql_type_sv);
|
||||||
if (retval != SQLITE_OK) {
|
if (retval != SQLITE_OK) {
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, retval, (char*)sqlite3_errmsg(imp_dbh->db));
|
sqlite_error(sth, (imp_xxh_t*)imp_sth, retval, (char*)sqlite3_errmsg(imp_dbh->db));
|
||||||
return -4; /* -> undef in SQLite.xsi */
|
return -4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (!DBIc_is(imp_dbh, DBIcf_AutoCommit)) && (!imp_dbh->in_tran) ) {
|
if ( (!DBIc_is(imp_dbh, DBIcf_AutoCommit)) && (!imp_dbh->in_tran) ) {
|
||||||
sqlite_trace(sth, (imp_xxh_t*)imp_sth, 2, "BEGIN TRAN");
|
sqlite_trace(2, "BEGIN TRAN");
|
||||||
if ((retval = sqlite3_exec(imp_dbh->db, "BEGIN TRANSACTION",
|
if ((retval = sqlite3_exec(imp_dbh->db, "BEGIN TRANSACTION",
|
||||||
NULL, NULL, &errmsg))
|
NULL, NULL, &errmsg))
|
||||||
!= SQLITE_OK)
|
!= SQLITE_OK)
|
||||||
{
|
{
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, retval, errmsg);
|
sqlite_error(sth, (imp_xxh_t*)imp_sth, retval, errmsg);
|
||||||
return -2; /* -> undef in SQLite.xsi */
|
return -2;
|
||||||
}
|
}
|
||||||
imp_dbh->in_tran = TRUE;
|
imp_dbh->in_tran = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
imp_sth->nrow = 0;
|
imp_sth->nrow = 0;
|
||||||
|
|
||||||
sqlite_trace(sth, (imp_xxh_t*)imp_sth, 3, "Execute returned %d cols\n", DBIc_NUM_FIELDS(imp_sth));
|
sqlite_trace(3, "Execute returned %d cols\n", DBIc_NUM_FIELDS(imp_sth));
|
||||||
if (DBIc_NUM_FIELDS(imp_sth) == 0) {
|
if (DBIc_NUM_FIELDS(imp_sth) == 0) {
|
||||||
while ((imp_sth->retval = sqlite3_step(imp_sth->stmt)) != SQLITE_DONE) {
|
while ((imp_sth->retval = sqlite3_step(imp_sth->stmt)) != SQLITE_DONE) {
|
||||||
if (imp_sth->retval == SQLITE_ROW) {
|
if (imp_sth->retval == SQLITE_ROW) {
|
||||||
|
@ -453,7 +412,7 @@ sqlite_st_execute (SV *sth, imp_sth_t *imp_sth)
|
||||||
}
|
}
|
||||||
sqlite3_reset(imp_sth->stmt);
|
sqlite3_reset(imp_sth->stmt);
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, (char*)sqlite3_errmsg(imp_dbh->db));
|
sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, (char*)sqlite3_errmsg(imp_dbh->db));
|
||||||
return -5; /* -> undef in SQLite.xsi */
|
return -5;
|
||||||
}
|
}
|
||||||
/* warn("Finalize\n"); */
|
/* warn("Finalize\n"); */
|
||||||
sqlite3_reset(imp_sth->stmt);
|
sqlite3_reset(imp_sth->stmt);
|
||||||
|
@ -468,12 +427,12 @@ sqlite_st_execute (SV *sth, imp_sth_t *imp_sth)
|
||||||
switch (imp_sth->retval) {
|
switch (imp_sth->retval) {
|
||||||
case SQLITE_ROW:
|
case SQLITE_ROW:
|
||||||
case SQLITE_DONE: DBIc_ACTIVE_on(imp_sth);
|
case SQLITE_DONE: DBIc_ACTIVE_on(imp_sth);
|
||||||
sqlite_trace(sth, (imp_xxh_t*)imp_sth, 5, "exec ok - %d rows, %d cols\n", imp_sth->nrow, DBIc_NUM_FIELDS(imp_sth));
|
sqlite_trace(5, "exec ok - %d rows, %d cols\n", imp_sth->nrow, DBIc_NUM_FIELDS(imp_sth));
|
||||||
return 0; /* -> '0E0' in SQLite.xsi */
|
return 0;
|
||||||
default: sqlite3_reset(imp_sth->stmt);
|
default: sqlite3_reset(imp_sth->stmt);
|
||||||
imp_sth->stmt = NULL;
|
imp_sth->stmt = NULL;
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, (char*)sqlite3_errmsg(imp_dbh->db));
|
sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, (char*)sqlite3_errmsg(imp_dbh->db));
|
||||||
return -6; /* -> undef in SQLite.xsi */
|
return -6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +452,6 @@ sqlite_bind_ph (SV *sth, imp_sth_t *imp_sth,
|
||||||
SV *param, SV *value, IV sql_type, SV *attribs,
|
SV *param, SV *value, IV sql_type, SV *attribs,
|
||||||
int is_inout, IV maxlen)
|
int is_inout, IV maxlen)
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
int pos;
|
int pos;
|
||||||
if (!looks_like_number(param)) {
|
if (!looks_like_number(param)) {
|
||||||
STRLEN len;
|
STRLEN len;
|
||||||
|
@ -501,27 +459,21 @@ sqlite_bind_ph (SV *sth, imp_sth_t *imp_sth,
|
||||||
paramstring = SvPV(param, len);
|
paramstring = SvPV(param, len);
|
||||||
if(paramstring[len] == 0 && strlen(paramstring) == len) {
|
if(paramstring[len] == 0 && strlen(paramstring) == len) {
|
||||||
pos = sqlite3_bind_parameter_index(imp_sth->stmt, paramstring);
|
pos = sqlite3_bind_parameter_index(imp_sth->stmt, paramstring);
|
||||||
if (pos==0) {
|
if (pos==0)
|
||||||
char errmsg[8192];
|
croak("Unknown named parameter: %s", paramstring);
|
||||||
sqlite3_snprintf(8191, errmsg, "Unknown named parameter: %s", paramstring);
|
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, -2, errmsg);
|
|
||||||
return FALSE; /* -> &sv_no in SQLite.xsi */
|
|
||||||
}
|
|
||||||
pos = 2 * (pos - 1);
|
pos = 2 * (pos - 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, -2, "<param> could not be coerced to a C string");
|
croak("<param> could not be coerced to a C string");
|
||||||
return FALSE; /* -> &sv_no in SQLite.xsi */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (is_inout) {
|
if (is_inout) {
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, -2, "InOut bind params not implemented");
|
croak("InOut bind params not implemented");
|
||||||
return FALSE; /* -> &sv_no in SQLite.xsi */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pos = 2 * (SvIV(param) - 1);
|
pos = (int)( 2 * (SvIV(param) - 1) );
|
||||||
sqlite_trace(sth, (imp_xxh_t*)imp_sth, 3, "bind into 0x%p: %d => %s (%d) pos %d\n",
|
sqlite_trace(3, "bind into 0x%p: %d => %s (%d) pos %d\n",
|
||||||
imp_sth->params, SvIV(param), SvPV_nolen_undef_ok(value), sql_type, pos);
|
imp_sth->params, SvIV(param), SvPV_nolen_undef_ok(value), sql_type, pos);
|
||||||
av_store(imp_sth->params, pos, SvREFCNT_inc(value));
|
av_store(imp_sth->params, pos, SvREFCNT_inc(value));
|
||||||
av_store(imp_sth->params, pos+1, newSViv(sql_type));
|
av_store(imp_sth->params, pos+1, newSViv(sql_type));
|
||||||
|
@ -532,10 +484,8 @@ sqlite_bind_ph (SV *sth, imp_sth_t *imp_sth,
|
||||||
int
|
int
|
||||||
sqlite_bind_col(SV *sth, imp_sth_t *imp_sth, SV *col, SV *ref, IV sql_type, SV *attribs)
|
sqlite_bind_col(SV *sth, imp_sth_t *imp_sth, SV *col, SV *ref, IV sql_type, SV *attribs)
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
|
|
||||||
/* store the type */
|
/* store the type */
|
||||||
av_store(imp_sth->col_types, SvIV(col)-1, newSViv(sql_type));
|
av_store(imp_sth->col_types, (I32)SvIV(col)-1, newSViv(sql_type));
|
||||||
|
|
||||||
/* Allow default implementation to continue */
|
/* Allow default implementation to continue */
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -544,15 +494,13 @@ sqlite_bind_col(SV *sth, imp_sth_t *imp_sth, SV *col, SV *ref, IV sql_type, SV *
|
||||||
AV *
|
AV *
|
||||||
sqlite_st_fetch (SV *sth, imp_sth_t *imp_sth)
|
sqlite_st_fetch (SV *sth, imp_sth_t *imp_sth)
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
|
|
||||||
AV *av;
|
AV *av;
|
||||||
D_imp_dbh_from_sth;
|
D_imp_dbh_from_sth;
|
||||||
int numFields = DBIc_NUM_FIELDS(imp_sth);
|
int numFields = DBIc_NUM_FIELDS(imp_sth);
|
||||||
int chopBlanks = DBIc_is(imp_sth, DBIcf_ChopBlanks);
|
int chopBlanks = DBIc_is(imp_sth, DBIcf_ChopBlanks);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sqlite_trace(sth, (imp_xxh_t*)imp_sth, 6, "numFields == %d, nrow == %d\n", numFields, imp_sth->nrow);
|
sqlite_trace(6, "numFields == %d, nrow == %d\n", numFields, imp_sth->nrow);
|
||||||
|
|
||||||
if (!DBIc_ACTIVE(imp_sth)) {
|
if (!DBIc_ACTIVE(imp_sth)) {
|
||||||
return Nullav;
|
return Nullav;
|
||||||
|
@ -567,12 +515,12 @@ sqlite_st_fetch (SV *sth, imp_sth_t *imp_sth)
|
||||||
/* error */
|
/* error */
|
||||||
sqlite_st_finish(sth, imp_sth);
|
sqlite_st_finish(sth, imp_sth);
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, (char*)sqlite3_errmsg(imp_dbh->db));
|
sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, (char*)sqlite3_errmsg(imp_dbh->db));
|
||||||
return Nullav; /* -> undef in SQLite.xsi */
|
return Nullav;
|
||||||
}
|
}
|
||||||
|
|
||||||
imp_sth->nrow++;
|
imp_sth->nrow++;
|
||||||
|
|
||||||
av = DBIc_DBISTATE((imp_xxh_t *)imp_sth)->get_fbav(imp_sth);
|
av = DBIS->get_fbav(imp_sth);
|
||||||
for (i = 0; i < numFields; i++) {
|
for (i = 0; i < numFields; i++) {
|
||||||
int len;
|
int len;
|
||||||
char * val;
|
char * val;
|
||||||
|
@ -580,7 +528,7 @@ sqlite_st_fetch (SV *sth, imp_sth_t *imp_sth)
|
||||||
SV **sql_type = av_fetch(imp_sth->col_types, i, 0);
|
SV **sql_type = av_fetch(imp_sth->col_types, i, 0);
|
||||||
if (sql_type && SvOK(*sql_type)) {
|
if (sql_type && SvOK(*sql_type)) {
|
||||||
if (SvIV(*sql_type)) {
|
if (SvIV(*sql_type)) {
|
||||||
col_type = SvIV(*sql_type);
|
col_type = (int)SvIV(*sql_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch(col_type) {
|
switch(col_type) {
|
||||||
|
@ -639,8 +587,6 @@ sqlite_st_finish (SV *sth, imp_sth_t *imp_sth)
|
||||||
int
|
int
|
||||||
sqlite_st_finish3 (SV *sth, imp_sth_t *imp_sth, int is_destroy)
|
sqlite_st_finish3 (SV *sth, imp_sth_t *imp_sth, int is_destroy)
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
|
|
||||||
D_imp_dbh_from_sth;
|
D_imp_dbh_from_sth;
|
||||||
|
|
||||||
/* warn("finish statement\n"); */
|
/* warn("finish statement\n"); */
|
||||||
|
@ -662,7 +608,7 @@ sqlite_st_finish3 (SV *sth, imp_sth_t *imp_sth, int is_destroy)
|
||||||
char *errmsg = (char*)sqlite3_errmsg(imp_dbh->db);
|
char *errmsg = (char*)sqlite3_errmsg(imp_dbh->db);
|
||||||
/* warn("finalize failed! %s\n", errmsg); */
|
/* warn("finalize failed! %s\n", errmsg); */
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, errmsg);
|
sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, errmsg);
|
||||||
return FALSE; /* -> &sv_no (or void) in SQLite.xsi */
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -671,8 +617,6 @@ sqlite_st_finish3 (SV *sth, imp_sth_t *imp_sth, int is_destroy)
|
||||||
void
|
void
|
||||||
sqlite_st_destroy (SV *sth, imp_sth_t *imp_sth)
|
sqlite_st_destroy (SV *sth, imp_sth_t *imp_sth)
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
|
|
||||||
D_imp_dbh_from_sth;
|
D_imp_dbh_from_sth;
|
||||||
/* warn("destroy statement: %s\n", imp_sth->statement); */
|
/* warn("destroy statement: %s\n", imp_sth->statement); */
|
||||||
DBIc_ACTIVE_off(imp_sth);
|
DBIc_ACTIVE_off(imp_sth);
|
||||||
|
@ -696,7 +640,7 @@ sqlite_st_blob_read (SV *sth, imp_sth_t *imp_sth,
|
||||||
int
|
int
|
||||||
sqlite_db_STORE_attrib (SV *dbh, imp_dbh_t *imp_dbh, SV *keysv, SV *valuesv)
|
sqlite_db_STORE_attrib (SV *dbh, imp_dbh_t *imp_dbh, SV *keysv, SV *valuesv)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHR;
|
||||||
char *key = SvPV_nolen(keysv);
|
char *key = SvPV_nolen(keysv);
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
int retval;
|
int retval;
|
||||||
|
@ -705,13 +649,13 @@ sqlite_db_STORE_attrib (SV *dbh, imp_dbh_t *imp_dbh, SV *keysv, SV *valuesv)
|
||||||
if (SvTRUE(valuesv)) {
|
if (SvTRUE(valuesv)) {
|
||||||
/* commit tran? */
|
/* commit tran? */
|
||||||
if ( (!DBIc_is(imp_dbh, DBIcf_AutoCommit)) && (imp_dbh->in_tran) ) {
|
if ( (!DBIc_is(imp_dbh, DBIcf_AutoCommit)) && (imp_dbh->in_tran) ) {
|
||||||
sqlite_trace(dbh, (imp_xxh_t*)imp_dbh, 2, "COMMIT TRAN");
|
sqlite_trace(2, "COMMIT TRAN");
|
||||||
if ((retval = sqlite3_exec(imp_dbh->db, "COMMIT TRANSACTION",
|
if ((retval = sqlite3_exec(imp_dbh->db, "COMMIT TRANSACTION",
|
||||||
NULL, NULL, &errmsg))
|
NULL, NULL, &errmsg))
|
||||||
!= SQLITE_OK)
|
!= SQLITE_OK)
|
||||||
{
|
{
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
||||||
return TRUE; /* XXX: is this correct? */
|
return TRUE;
|
||||||
}
|
}
|
||||||
imp_dbh->in_tran = FALSE;
|
imp_dbh->in_tran = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -720,12 +664,7 @@ sqlite_db_STORE_attrib (SV *dbh, imp_dbh_t *imp_dbh, SV *keysv, SV *valuesv)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (strEQ(key, "unicode")) {
|
if (strEQ(key, "unicode")) {
|
||||||
#if (PERL_REVISION <= 5) && ((PERL_VERSION < 8) || (PERL_VERSION == 8 && PERL_SUBVERSION < 5))
|
|
||||||
sqlite_trace(dbh, (imp_xxh_t*)imp_dbh, 2, "Unicode support is disabled for this version of perl.");
|
|
||||||
imp_dbh->unicode = 0;
|
|
||||||
#else
|
|
||||||
imp_dbh->unicode = !(! SvTRUE(valuesv));
|
imp_dbh->unicode = !(! SvTRUE(valuesv));
|
||||||
#endif
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -734,19 +673,14 @@ sqlite_db_STORE_attrib (SV *dbh, imp_dbh_t *imp_dbh, SV *keysv, SV *valuesv)
|
||||||
SV *
|
SV *
|
||||||
sqlite_db_FETCH_attrib (SV *dbh, imp_dbh_t *imp_dbh, SV *keysv)
|
sqlite_db_FETCH_attrib (SV *dbh, imp_dbh_t *imp_dbh, SV *keysv)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHR;
|
||||||
char *key = SvPV_nolen(keysv);
|
char *key = SvPV_nolen(keysv);
|
||||||
|
|
||||||
if (strEQ(key, "sqlite_version")) {
|
if (strEQ(key, "sqlite_version")) {
|
||||||
return newSVpv(sqlite3_version,0);
|
return newSVpv(sqlite3_version,0);
|
||||||
}
|
}
|
||||||
if (strEQ(key, "unicode")) {
|
if (strEQ(key, "unicode")) {
|
||||||
#if (PERL_REVISION <= 5) && ((PERL_VERSION < 8) || (PERL_VERSION == 8 && PERL_SUBVERSION < 5))
|
|
||||||
sqlite_trace(dbh, (imp_xxh_t*)imp_dbh, 2, "Unicode support is disabled for this version of perl.");
|
|
||||||
return newSViv(0);
|
|
||||||
#else
|
|
||||||
return newSViv(imp_dbh->unicode ? 1 : 0);
|
return newSViv(imp_dbh->unicode ? 1 : 0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -755,7 +689,6 @@ sqlite_db_FETCH_attrib (SV *dbh, imp_dbh_t *imp_dbh, SV *keysv)
|
||||||
int
|
int
|
||||||
sqlite_st_STORE_attrib (SV *sth, imp_sth_t *imp_sth, SV *keysv, SV *valuesv)
|
sqlite_st_STORE_attrib (SV *sth, imp_sth_t *imp_sth, SV *keysv, SV *valuesv)
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
char *key = SvPV_nolen(keysv);
|
char *key = SvPV_nolen(keysv);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -776,8 +709,6 @@ type_to_odbc_type (int type)
|
||||||
SV *
|
SV *
|
||||||
sqlite_st_FETCH_attrib (SV *sth, imp_sth_t *imp_sth, SV *keysv)
|
sqlite_st_FETCH_attrib (SV *sth, imp_sth_t *imp_sth, SV *keysv)
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
D_imp_dbh_from_sth;
|
|
||||||
char *key = SvPV_nolen(keysv);
|
char *key = SvPV_nolen(keysv);
|
||||||
SV *retsv = NULL;
|
SV *retsv = NULL;
|
||||||
int i,n;
|
int i,n;
|
||||||
|
@ -829,26 +760,7 @@ sqlite_st_FETCH_attrib (SV *sth, imp_sth_t *imp_sth, SV *keysv)
|
||||||
}
|
}
|
||||||
else if (strEQ(key, "NULLABLE")) {
|
else if (strEQ(key, "NULLABLE")) {
|
||||||
AV *av = newAV();
|
AV *av = newAV();
|
||||||
av_extend(av, i);
|
|
||||||
retsv = sv_2mortal(newRV(sv_2mortal((SV*)av)));
|
retsv = sv_2mortal(newRV(sv_2mortal((SV*)av)));
|
||||||
#if defined(SQLITE_ENABLE_COLUMN_METADATA)
|
|
||||||
for (n = 0; n < i; n++) {
|
|
||||||
const char *database = sqlite3_column_database_name(imp_sth->stmt, n);
|
|
||||||
const char *tablename = sqlite3_column_table_name(imp_sth->stmt, n);
|
|
||||||
const char *fieldname = sqlite3_column_name(imp_sth->stmt, n);
|
|
||||||
const char *datatype, *collseq;
|
|
||||||
int notnull, primary, autoinc;
|
|
||||||
int retval = sqlite3_table_column_metadata(imp_dbh->db, database, tablename, fieldname, &datatype, &collseq, ¬null, &primary, &autoinc);
|
|
||||||
if (retval != SQLITE_OK) {
|
|
||||||
char *errmsg = (char*)sqlite3_errmsg(imp_dbh->db);
|
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, retval, errmsg);
|
|
||||||
av_store(av, n, newSViv(2)); /* SQL_NULLABLE_UNKNOWN */
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
av_store(av, n, newSViv(!notnull));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (strEQ(key, "SCALE")) {
|
else if (strEQ(key, "SCALE")) {
|
||||||
AV *av = newAV();
|
AV *av = newAV();
|
||||||
|
@ -862,14 +774,14 @@ sqlite_st_FETCH_attrib (SV *sth, imp_sth_t *imp_sth, SV *keysv)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sqlite_db_set_result(pTHX_ sqlite3_context *context, SV *result, int is_error )
|
sqlite_db_set_result(sqlite3_context *context, SV *result, int is_error )
|
||||||
{
|
{
|
||||||
STRLEN len;
|
STRLEN len;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
if ( is_error ) {
|
if ( is_error ) {
|
||||||
s = SvPV(result, len);
|
s = (char*)SvPV(result, len);
|
||||||
sqlite3_result_error( context, s, len );
|
sqlite3_result_error( context, s, (int)len );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -878,22 +790,21 @@ sqlite_db_set_result(pTHX_ sqlite3_context *context, SV *result, int is_error )
|
||||||
sqlite3_result_null( context );
|
sqlite3_result_null( context );
|
||||||
} else if( SvIOK_UV(result) ) {
|
} else if( SvIOK_UV(result) ) {
|
||||||
s = SvPV(result, len);
|
s = SvPV(result, len);
|
||||||
sqlite3_result_text( context, s, len, SQLITE_TRANSIENT );
|
sqlite3_result_text( context, s, (int)len, SQLITE_TRANSIENT );
|
||||||
}
|
}
|
||||||
else if ( SvIOK(result) ) {
|
else if ( SvIOK(result) ) {
|
||||||
sqlite3_result_int( context, SvIV(result));
|
sqlite3_result_int( context, (int)SvIV(result));
|
||||||
} else if ( !is_error && SvIOK(result) ) {
|
} else if ( !is_error && SvIOK(result) ) {
|
||||||
sqlite3_result_double( context, SvNV(result));
|
sqlite3_result_double( context, SvNV(result));
|
||||||
} else {
|
} else {
|
||||||
s = SvPV(result, len);
|
s = SvPV(result, len);
|
||||||
sqlite3_result_text( context, s, len, SQLITE_TRANSIENT );
|
sqlite3_result_text( context, s, (int)len, SQLITE_TRANSIENT );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sqlite_db_func_dispatcher(int is_unicode, sqlite3_context *context, int argc, sqlite3_value **value)
|
sqlite_db_func_dispatcher(sqlite3_context *context, int argc, sqlite3_value **value)
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
dSP;
|
dSP;
|
||||||
int count;
|
int count;
|
||||||
int i;
|
int i;
|
||||||
|
@ -919,11 +830,7 @@ sqlite_db_func_dispatcher(int is_unicode, sqlite3_context *context, int argc, sq
|
||||||
arg = sv_2mortal(newSVnv(sqlite3_value_double(value[i])));
|
arg = sv_2mortal(newSVnv(sqlite3_value_double(value[i])));
|
||||||
break;
|
break;
|
||||||
case SQLITE_TEXT:
|
case SQLITE_TEXT:
|
||||||
arg = newSVpvn((const char *)sqlite3_value_text(value[i]), len);
|
arg = sv_2mortal(newSVpvn((const char *)sqlite3_value_text(value[i]), len));
|
||||||
if (is_unicode) {
|
|
||||||
SvUTF8_on(arg);
|
|
||||||
}
|
|
||||||
arg = sv_2mortal(arg);
|
|
||||||
break;
|
break;
|
||||||
case SQLITE_BLOB:
|
case SQLITE_BLOB:
|
||||||
arg = sv_2mortal(newSVpvn(sqlite3_value_blob(value[i]), len));
|
arg = sv_2mortal(newSVpvn(sqlite3_value_blob(value[i]), len));
|
||||||
|
@ -942,19 +849,19 @@ sqlite_db_func_dispatcher(int is_unicode, sqlite3_context *context, int argc, sq
|
||||||
|
|
||||||
/* Check for an error */
|
/* Check for an error */
|
||||||
if (SvTRUE(ERRSV) ) {
|
if (SvTRUE(ERRSV) ) {
|
||||||
sqlite_db_set_result(aTHX_ context, ERRSV, 1);
|
sqlite_db_set_result( context, ERRSV, 1);
|
||||||
POPs;
|
POPs;
|
||||||
} else if ( count != 1 ) {
|
} else if ( count != 1 ) {
|
||||||
SV *err = sv_2mortal(newSVpvf( "function should return 1 argument, got %d",
|
SV *err = sv_2mortal(newSVpvf( "function should return 1 argument, got %d",
|
||||||
count ));
|
count ));
|
||||||
|
|
||||||
sqlite_db_set_result(aTHX_ context, err, 1);
|
sqlite_db_set_result( context, err, 1);
|
||||||
/* Clear the stack */
|
/* Clear the stack */
|
||||||
for ( i=0; i < count; i++ ) {
|
for ( i=0; i < count; i++ ) {
|
||||||
POPs;
|
POPs;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sqlite_db_set_result(aTHX_ context, POPs, 0 );
|
sqlite_db_set_result( context, POPs, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
PUTBACK;
|
PUTBACK;
|
||||||
|
@ -963,55 +870,24 @@ sqlite_db_func_dispatcher(int is_unicode, sqlite3_context *context, int argc, sq
|
||||||
LEAVE;
|
LEAVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
sqlite_db_func_dispatcher_unicode(sqlite3_context *context, int argc, sqlite3_value **value)
|
|
||||||
{
|
|
||||||
sqlite_db_func_dispatcher(1, context, argc, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
sqlite_db_func_dispatcher_no_unicode(sqlite3_context *context, int argc, sqlite3_value **value)
|
|
||||||
{
|
|
||||||
sqlite_db_func_dispatcher(0, context, argc, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sqlite3_db_create_function(pTHX_ SV *dbh, const char *name, int argc, SV *func )
|
sqlite3_db_create_function( SV *dbh, const char *name, int argc, SV *func )
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
int retval;
|
int rv;
|
||||||
|
|
||||||
/* Copy the function reference */
|
/* Copy the function reference */
|
||||||
SV *func_sv = newSVsv(func);
|
SV *func_sv = newSVsv(func);
|
||||||
av_push( imp_dbh->functions, func_sv );
|
av_push( imp_dbh->functions, func_sv );
|
||||||
|
|
||||||
/* warn("create_function %s with %d args\n", name, argc); */
|
/* warn("create_function %s with %d args\n", name, argc); */
|
||||||
retval = sqlite3_create_function( imp_dbh->db, name, argc, SQLITE_UTF8,
|
rv = sqlite3_create_function( imp_dbh->db, name, argc, SQLITE_UTF8,
|
||||||
func_sv,
|
func_sv,
|
||||||
imp_dbh->unicode ? sqlite_db_func_dispatcher_unicode
|
sqlite_db_func_dispatcher, NULL, NULL );
|
||||||
: sqlite_db_func_dispatcher_no_unicode,
|
if ( rv != SQLITE_OK )
|
||||||
NULL, NULL );
|
|
||||||
if ( retval != SQLITE_OK )
|
|
||||||
{
|
{
|
||||||
char errmsg[8192];
|
croak( "sqlite_create_function failed with error %s",
|
||||||
sqlite3_snprintf(8191, errmsg, "sqlite_create_function failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
sqlite3_errmsg(imp_dbh->db) );
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
sqlite3_db_enable_load_extension(pTHX_ SV *dbh, int onoff )
|
|
||||||
{
|
|
||||||
D_imp_dbh(dbh);
|
|
||||||
int retval;
|
|
||||||
|
|
||||||
retval = sqlite3_enable_load_extension( imp_dbh->db, onoff );
|
|
||||||
if ( retval != SQLITE_OK )
|
|
||||||
{
|
|
||||||
char errmsg[8192];
|
|
||||||
sqlite3_snprintf(8191, errmsg, "sqlite_enable_load_extension failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1023,7 +899,7 @@ struct aggrInfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sqlite_db_aggr_new_dispatcher(pTHX_ sqlite3_context *context, aggrInfo *aggr_info )
|
sqlite_db_aggr_new_dispatcher( sqlite3_context *context, aggrInfo *aggr_info )
|
||||||
{
|
{
|
||||||
dSP;
|
dSP;
|
||||||
SV *pkg = NULL;
|
SV *pkg = NULL;
|
||||||
|
@ -1082,7 +958,6 @@ static void
|
||||||
sqlite_db_aggr_step_dispatcher (sqlite3_context *context,
|
sqlite_db_aggr_step_dispatcher (sqlite3_context *context,
|
||||||
int argc, sqlite3_value **value)
|
int argc, sqlite3_value **value)
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
dSP;
|
dSP;
|
||||||
int i;
|
int i;
|
||||||
aggrInfo *aggr;
|
aggrInfo *aggr;
|
||||||
|
@ -1096,7 +971,7 @@ sqlite_db_aggr_step_dispatcher (sqlite3_context *context,
|
||||||
|
|
||||||
/* initialize on first step */
|
/* initialize on first step */
|
||||||
if ( !aggr->inited ) {
|
if ( !aggr->inited ) {
|
||||||
sqlite_db_aggr_new_dispatcher(aTHX_ context, aggr );
|
sqlite_db_aggr_new_dispatcher( context, aggr );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( aggr->err || !aggr->aggr_inst )
|
if ( aggr->err || !aggr->aggr_inst )
|
||||||
|
@ -1147,7 +1022,6 @@ sqlite_db_aggr_step_dispatcher (sqlite3_context *context,
|
||||||
static void
|
static void
|
||||||
sqlite_db_aggr_finalize_dispatcher( sqlite3_context *context )
|
sqlite_db_aggr_finalize_dispatcher( sqlite3_context *context )
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
dSP;
|
dSP;
|
||||||
aggrInfo *aggr, myAggr;
|
aggrInfo *aggr, myAggr;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -1163,7 +1037,7 @@ sqlite_db_aggr_finalize_dispatcher( sqlite3_context *context )
|
||||||
aggr = &myAggr;
|
aggr = &myAggr;
|
||||||
aggr->aggr_inst = NULL;
|
aggr->aggr_inst = NULL;
|
||||||
aggr->err = NULL;
|
aggr->err = NULL;
|
||||||
sqlite_db_aggr_new_dispatcher(aTHX_ context, aggr);
|
sqlite_db_aggr_new_dispatcher (context, aggr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! aggr->err && aggr->aggr_inst ) {
|
if ( ! aggr->err && aggr->aggr_inst ) {
|
||||||
|
@ -1187,16 +1061,15 @@ sqlite_db_aggr_finalize_dispatcher( sqlite3_context *context )
|
||||||
POPs;
|
POPs;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sqlite_db_set_result(aTHX_ context, POPs, 0 );
|
sqlite_db_set_result( context, POPs, 0 );
|
||||||
}
|
}
|
||||||
PUTBACK;
|
PUTBACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( aggr->err ) {
|
if ( aggr->err ) {
|
||||||
warn( "DBD::SQLite: error in aggregator cannot be reported to SQLite: %s",
|
warn( "DBD::SQLite: error in aggregator cannot be reported to SQLite: %s", SvPV_nolen( aggr->err ) );
|
||||||
SvPV_nolen( aggr->err ) );
|
|
||||||
|
|
||||||
/* sqlite_db_set_result(aTHX_ context, aggr->err, 1 ); */
|
/* sqlite_db_set_result( context, aggr->err, 1 ); */
|
||||||
SvREFCNT_dec( aggr->err );
|
SvREFCNT_dec( aggr->err );
|
||||||
aggr->err = NULL;
|
aggr->err = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1211,27 +1084,26 @@ sqlite_db_aggr_finalize_dispatcher( sqlite3_context *context )
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sqlite3_db_create_aggregate(pTHX_ SV *dbh, const char *name, int argc, SV *aggr_pkg )
|
sqlite3_db_create_aggregate( SV *dbh, const char *name, int argc, SV *aggr_pkg )
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
int retval;
|
int rv;
|
||||||
|
|
||||||
/* Copy the aggregate reference */
|
/* Copy the aggregate reference */
|
||||||
SV *aggr_pkg_copy = newSVsv(aggr_pkg);
|
SV *aggr_pkg_copy = newSVsv(aggr_pkg);
|
||||||
av_push( imp_dbh->aggregates, aggr_pkg_copy );
|
av_push( imp_dbh->aggregates, aggr_pkg_copy );
|
||||||
|
|
||||||
retval = sqlite3_create_function( imp_dbh->db, name, argc, SQLITE_UTF8,
|
rv = sqlite3_create_function( imp_dbh->db, name, argc, SQLITE_UTF8,
|
||||||
aggr_pkg_copy,
|
aggr_pkg_copy,
|
||||||
NULL,
|
NULL,
|
||||||
sqlite_db_aggr_step_dispatcher,
|
sqlite_db_aggr_step_dispatcher,
|
||||||
sqlite_db_aggr_finalize_dispatcher
|
sqlite_db_aggr_finalize_dispatcher
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( retval != SQLITE_OK )
|
if ( rv != SQLITE_OK )
|
||||||
{
|
{
|
||||||
char errmsg[8192];
|
croak( "sqlite_create_aggregate failed with error %s",
|
||||||
sqlite3_snprintf(8191, errmsg, "sqlite_create_aggregate failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
sqlite3_errmsg(imp_dbh->db) );
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1239,7 +1111,6 @@ sqlite3_db_create_aggregate(pTHX_ SV *dbh, const char *name, int argc, SV *aggr_
|
||||||
int sqlite_db_collation_dispatcher(void *func, int len1, const void *string1,
|
int sqlite_db_collation_dispatcher(void *func, int len1, const void *string1,
|
||||||
int len2, const void *string2)
|
int len2, const void *string2)
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
dSP;
|
dSP;
|
||||||
int cmp;
|
int cmp;
|
||||||
int n_retval;
|
int n_retval;
|
||||||
|
@ -1255,7 +1126,7 @@ int sqlite_db_collation_dispatcher(void *func, int len1, const void *string1,
|
||||||
croak("collation function returned %d arguments", n_retval);
|
croak("collation function returned %d arguments", n_retval);
|
||||||
}
|
}
|
||||||
SPAGAIN;
|
SPAGAIN;
|
||||||
cmp = POPi;
|
cmp = (int)POPi;
|
||||||
PUTBACK;
|
PUTBACK;
|
||||||
FREETMPS;
|
FREETMPS;
|
||||||
LEAVE;
|
LEAVE;
|
||||||
|
@ -1267,7 +1138,6 @@ int sqlite_db_collation_dispatcher_utf8(
|
||||||
void *func, int len1, const void *string1,
|
void *func, int len1, const void *string1,
|
||||||
int len2, const void *string2)
|
int len2, const void *string2)
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
dSP;
|
dSP;
|
||||||
int cmp;
|
int cmp;
|
||||||
int n_retval;
|
int n_retval;
|
||||||
|
@ -1288,7 +1158,7 @@ int sqlite_db_collation_dispatcher_utf8(
|
||||||
croak("collation function returned %d arguments", n_retval);
|
croak("collation function returned %d arguments", n_retval);
|
||||||
}
|
}
|
||||||
SPAGAIN;
|
SPAGAIN;
|
||||||
cmp = POPi;
|
cmp = (int)POPi;
|
||||||
PUTBACK;
|
PUTBACK;
|
||||||
FREETMPS;
|
FREETMPS;
|
||||||
LEAVE;
|
LEAVE;
|
||||||
|
@ -1298,7 +1168,7 @@ int sqlite_db_collation_dispatcher_utf8(
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sqlite3_db_create_collation(pTHX_ SV *dbh, const char *name, SV *func )
|
sqlite3_db_create_collation( SV *dbh, const char *name, SV *func )
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
int rv, rv2;
|
int rv, rv2;
|
||||||
|
@ -1331,15 +1201,14 @@ sqlite3_db_create_collation(pTHX_ SV *dbh, const char *name, SV *func )
|
||||||
|
|
||||||
if ( rv != SQLITE_OK )
|
if ( rv != SQLITE_OK )
|
||||||
{
|
{
|
||||||
char errmsg[8192];
|
croak( "sqlite_create_collation failed with error %s",
|
||||||
sqlite3_snprintf(8191, errmsg, "sqlite_create_collation failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
sqlite3_errmsg(imp_dbh->db) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int sqlite_db_progress_handler_dispatcher( void *handler )
|
int sqlite_db_progress_handler_dispatcher( void *handler )
|
||||||
{
|
{
|
||||||
dTHX;
|
|
||||||
dSP;
|
dSP;
|
||||||
int n_retval;
|
int n_retval;
|
||||||
int retval;
|
int retval;
|
||||||
|
@ -1350,7 +1219,7 @@ int sqlite_db_progress_handler_dispatcher( void *handler )
|
||||||
croak( "progress_handler returned %d arguments", n_retval );
|
croak( "progress_handler returned %d arguments", n_retval );
|
||||||
}
|
}
|
||||||
SPAGAIN;
|
SPAGAIN;
|
||||||
retval = POPi;
|
retval = (int)POPi;
|
||||||
PUTBACK;
|
PUTBACK;
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -1359,7 +1228,7 @@ int sqlite_db_progress_handler_dispatcher( void *handler )
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sqlite3_db_progress_handler(pTHX_ SV *dbh, int n_opcodes, SV *handler )
|
sqlite3_db_progress_handler( SV *dbh, int n_opcodes, SV *handler )
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
|
|
||||||
|
@ -1380,4 +1249,7 @@ sqlite3_db_progress_handler(pTHX_ SV *dbh, int n_opcodes, SV *handler )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* end */
|
/* end */
|
||||||
|
>>>>>>> 64bit-warnings:dbdimp.c
|
||||||
|
|
10
fts3.c
10
fts3.c
|
@ -1719,7 +1719,7 @@ static char *string_dup_n(const char *s, int n){
|
||||||
* (We don't use strdup() since it is not part of the standard C library and
|
* (We don't use strdup() since it is not part of the standard C library and
|
||||||
* may not be available everywhere.) */
|
* may not be available everywhere.) */
|
||||||
static char *string_dup(const char *s){
|
static char *string_dup(const char *s){
|
||||||
return string_dup_n(s, strlen(s));
|
return string_dup_n(s, (int)strlen(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Format a string, replacing each occurrence of the % character with
|
/* Format a string, replacing each occurrence of the % character with
|
||||||
|
@ -1742,7 +1742,7 @@ static char *string_format(const char *zFormat,
|
||||||
}
|
}
|
||||||
len += 1; /* for null terminator */
|
len += 1; /* for null terminator */
|
||||||
|
|
||||||
r = result = sqlite3_malloc(len);
|
r = result = sqlite3_malloc((int)len);
|
||||||
for(p = zFormat; *p; ++p){
|
for(p = zFormat; *p; ++p){
|
||||||
if( *p=='%' ){
|
if( *p=='%' ){
|
||||||
memcpy(r, zDb, nDb);
|
memcpy(r, zDb, nDb);
|
||||||
|
@ -2565,7 +2565,7 @@ typedef struct FtsToken {
|
||||||
*/
|
*/
|
||||||
static char **tokenizeString(const char *z, int *pnToken){
|
static char **tokenizeString(const char *z, int *pnToken){
|
||||||
int nToken = 0;
|
int nToken = 0;
|
||||||
FtsToken *aToken = sqlite3_malloc( strlen(z) * sizeof(aToken[0]) );
|
FtsToken *aToken = sqlite3_malloc( (int)( strlen(z) * sizeof(aToken[0]) ) );
|
||||||
int n = 1;
|
int n = 1;
|
||||||
int e, i;
|
int e, i;
|
||||||
int totalSize = 0;
|
int totalSize = 0;
|
||||||
|
@ -2765,7 +2765,7 @@ static int parseSpec(TableSpec *pSpec, int argc, const char *const*argv,
|
||||||
*/
|
*/
|
||||||
CLEAR(pSpec);
|
CLEAR(pSpec);
|
||||||
for(i=n=0; i<argc; i++){
|
for(i=n=0; i<argc; i++){
|
||||||
n += strlen(argv[i]) + 1;
|
n += (int)( strlen(argv[i]) + 1 );
|
||||||
}
|
}
|
||||||
azArg = sqlite3_malloc( sizeof(char*)*argc + n );
|
azArg = sqlite3_malloc( sizeof(char*)*argc + n );
|
||||||
if( azArg==0 ){
|
if( azArg==0 ){
|
||||||
|
@ -2905,7 +2905,7 @@ static int constructVtab(
|
||||||
if( !zTok ){
|
if( !zTok ){
|
||||||
zTok = "simple";
|
zTok = "simple";
|
||||||
}
|
}
|
||||||
nTok = strlen(zTok)+1;
|
nTok = (int)( strlen(zTok)+1 );
|
||||||
|
|
||||||
m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zTok, nTok);
|
m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zTok, nTok);
|
||||||
if( !m ){
|
if( !m ){
|
||||||
|
|
10
fts3_expr.c
10
fts3_expr.c
|
@ -358,7 +358,7 @@ static int getNextNode(
|
||||||
pRet->eType = pKey->eType;
|
pRet->eType = pKey->eType;
|
||||||
pRet->nNear = nNear;
|
pRet->nNear = nNear;
|
||||||
*ppExpr = pRet;
|
*ppExpr = pRet;
|
||||||
*pnConsumed = (zInput - z) + nKey;
|
*pnConsumed = (int)( (zInput - z) + nKey );
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,14 +378,14 @@ static int getNextNode(
|
||||||
if( rc==SQLITE_OK && !*ppExpr ){
|
if( rc==SQLITE_OK && !*ppExpr ){
|
||||||
rc = SQLITE_DONE;
|
rc = SQLITE_DONE;
|
||||||
}
|
}
|
||||||
*pnConsumed = (zInput - z) + 1 + nConsumed;
|
*pnConsumed = (int)( (zInput - z) + 1 + nConsumed );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for a close bracket. */
|
/* Check for a close bracket. */
|
||||||
if( *zInput==')' ){
|
if( *zInput==')' ){
|
||||||
pParse->nNest--;
|
pParse->nNest--;
|
||||||
*pnConsumed = (zInput - z) + 1;
|
*pnConsumed = (int)( (zInput - z) + 1 );
|
||||||
return SQLITE_DONE;
|
return SQLITE_DONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ static int getNextNode(
|
||||||
*/
|
*/
|
||||||
if( *zInput=='"' ){
|
if( *zInput=='"' ){
|
||||||
for(ii=1; ii<nInput && zInput[ii]!='"'; ii++);
|
for(ii=1; ii<nInput && zInput[ii]!='"'; ii++);
|
||||||
*pnConsumed = (zInput - z) + ii + 1;
|
*pnConsumed = (int)( (zInput - z) + ii + 1 );
|
||||||
if( ii==nInput ){
|
if( ii==nInput ){
|
||||||
return SQLITE_ERROR;
|
return SQLITE_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -685,7 +685,7 @@ int sqlite3Fts3ExprParse(
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
if( n<0 ){
|
if( n<0 ){
|
||||||
n = strlen(z);
|
n = (int)strlen(z);
|
||||||
}
|
}
|
||||||
rc = fts3ExprParse(&sParse, z, n, ppExpr, &nParsed);
|
rc = fts3ExprParse(&sParse, z, n, ppExpr, &nParsed);
|
||||||
|
|
||||||
|
|
|
@ -547,7 +547,7 @@ static void porter_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){
|
||||||
/* z[] is now the stemmed word in reverse order. Flip it back
|
/* z[] is now the stemmed word in reverse order. Flip it back
|
||||||
** around into forward order and return.
|
** around into forward order and return.
|
||||||
*/
|
*/
|
||||||
*pnOut = i = strlen(z);
|
*pnOut = i = (int)strlen(z);
|
||||||
zOut[i] = 0;
|
zOut[i] = 0;
|
||||||
while( *z ){
|
while( *z ){
|
||||||
zOut[--i] = *(z++);
|
zOut[--i] = *(z++);
|
||||||
|
|
|
@ -75,7 +75,7 @@ static int simpleCreate(
|
||||||
** information on the initial create.
|
** information on the initial create.
|
||||||
*/
|
*/
|
||||||
if( argc>1 ){
|
if( argc>1 ){
|
||||||
int i, n = strlen(argv[1]);
|
int i, n = (int)strlen(argv[1]);
|
||||||
for(i=0; i<n; i++){
|
for(i=0; i<n; i++){
|
||||||
unsigned char ch = argv[1][i];
|
unsigned char ch = argv[1][i];
|
||||||
/* We explicitly don't support UTF-8 delimiters for now. */
|
/* We explicitly don't support UTF-8 delimiters for now. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue