mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 22:28:47 -04:00
fixes for VC6
This commit is contained in:
parent
ab008be4e3
commit
c1ddd22120
1 changed files with 75 additions and 51 deletions
126
dbdimp.c
126
dbdimp.c
|
@ -153,6 +153,7 @@ stacked_sv_from_sqlite3_value(pTHX_ sqlite3_value *value, int is_unicode)
|
||||||
STRLEN len;
|
STRLEN len;
|
||||||
sqlite_int64 iv;
|
sqlite_int64 iv;
|
||||||
int type = sqlite3_value_type(value);
|
int type = sqlite3_value_type(value);
|
||||||
|
SV *sv;
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SQLITE_INTEGER:
|
case SQLITE_INTEGER:
|
||||||
|
@ -174,7 +175,7 @@ stacked_sv_from_sqlite3_value(pTHX_ sqlite3_value *value, int is_unicode)
|
||||||
break;
|
break;
|
||||||
case SQLITE_TEXT:
|
case SQLITE_TEXT:
|
||||||
len = sqlite3_value_bytes(value);
|
len = sqlite3_value_bytes(value);
|
||||||
SV *sv = newSVpvn((const char *)sqlite3_value_text(value), len);
|
sv = newSVpvn((const char *)sqlite3_value_text(value), len);
|
||||||
if (is_unicode) {
|
if (is_unicode) {
|
||||||
SvUTF8_on(sv);
|
SvUTF8_on(sv);
|
||||||
}
|
}
|
||||||
|
@ -1703,7 +1704,7 @@ sqlite_db_aggr_step_dispatcher(sqlite3_context *context,
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
int i;
|
int i, is_unicode = 0; /* TODO : find out from db handle */
|
||||||
aggrInfo *aggr;
|
aggrInfo *aggr;
|
||||||
|
|
||||||
aggr = sqlite3_aggregate_context(context, sizeof (aggrInfo));
|
aggr = sqlite3_aggregate_context(context, sizeof (aggrInfo));
|
||||||
|
@ -1721,8 +1722,6 @@ sqlite_db_aggr_step_dispatcher(sqlite3_context *context,
|
||||||
if ( aggr->err || !aggr->aggr_inst )
|
if ( aggr->err || !aggr->aggr_inst )
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
int is_unicode = 0; /* TODO : find out from db handle */
|
|
||||||
|
|
||||||
|
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
XPUSHs( sv_2mortal( newSVsv( aggr->aggr_inst ) ));
|
XPUSHs( sv_2mortal( newSVsv( aggr->aggr_inst ) ));
|
||||||
|
@ -2798,9 +2797,10 @@ static int _call_perl_vtab_method(sqlite3_vtab *pVTab,
|
||||||
const char *method, int i) {
|
const char *method, int i) {
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
|
int count;
|
||||||
|
|
||||||
ENTER;
|
ENTER;
|
||||||
SAVETMPS;
|
SAVETMPS;
|
||||||
int count;
|
|
||||||
|
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
XPUSHs(((perl_vtab *) pVTab)->perl_vtab_obj);
|
XPUSHs(((perl_vtab *) pVTab)->perl_vtab_obj);
|
||||||
|
@ -2829,6 +2829,8 @@ static int perl_vt_New(const char *method,
|
||||||
perl_vtab_init *init_data = (perl_vtab_init *)pAux;
|
perl_vtab_init *init_data = (perl_vtab_init *)pAux;
|
||||||
int count, i;
|
int count, i;
|
||||||
int rc = SQLITE_ERROR;
|
int rc = SQLITE_ERROR;
|
||||||
|
SV *perl_vtab_obj;
|
||||||
|
SV *sql;
|
||||||
|
|
||||||
/* allocate a perl_vtab structure */
|
/* allocate a perl_vtab structure */
|
||||||
vt = (perl_vtab *) sqlite3_malloc(sizeof(*vt));
|
vt = (perl_vtab *) sqlite3_malloc(sizeof(*vt));
|
||||||
|
@ -2859,7 +2861,7 @@ static int perl_vt_New(const char *method,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the VirtualTable instance */
|
/* get the VirtualTable instance */
|
||||||
SV *perl_vtab_obj = POPs;
|
perl_vtab_obj = POPs;
|
||||||
if ( !sv_isobject(perl_vtab_obj) ) {
|
if ( !sv_isobject(perl_vtab_obj) ) {
|
||||||
*pzErr = sqlite3_mprintf("vtab->%s() should return a blessed reference",
|
*pzErr = sqlite3_mprintf("vtab->%s() should return a blessed reference",
|
||||||
method);
|
method);
|
||||||
|
@ -2884,7 +2886,7 @@ static int perl_vt_New(const char *method,
|
||||||
|
|
||||||
/* call sqlite3_declare_vtab with the sql returned from
|
/* call sqlite3_declare_vtab with the sql returned from
|
||||||
method VTAB_TO_DECLARE(), converted to utf8 */
|
method VTAB_TO_DECLARE(), converted to utf8 */
|
||||||
SV *sql = POPs;
|
sql = POPs;
|
||||||
rc = sqlite3_declare_vtab(db, SvPVutf8_nolen(sql));
|
rc = sqlite3_declare_vtab(db, SvPVutf8_nolen(sql));
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -2966,13 +2968,20 @@ _constraint_op_to_string(unsigned char op) {
|
||||||
static int perl_vt_BestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pIdxInfo){
|
static int perl_vt_BestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pIdxInfo){
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
|
int i, count;
|
||||||
|
int argvIndex;
|
||||||
|
AV *constraints;
|
||||||
|
AV *order_by;
|
||||||
|
SV *hashref;
|
||||||
|
SV **val;
|
||||||
|
HV *hv;
|
||||||
|
struct sqlite3_index_constraint_usage *pConsUsage;
|
||||||
|
|
||||||
ENTER;
|
ENTER;
|
||||||
SAVETMPS;
|
SAVETMPS;
|
||||||
|
|
||||||
int i, count;
|
|
||||||
|
|
||||||
/* build the "where_constraints" datastructure */
|
/* build the "where_constraints" datastructure */
|
||||||
AV *constraints = newAV();
|
constraints = newAV();
|
||||||
for (i=0; i<pIdxInfo->nConstraint; i++){
|
for (i=0; i<pIdxInfo->nConstraint; i++){
|
||||||
struct sqlite3_index_constraint const *pCons = &pIdxInfo->aConstraint[i];
|
struct sqlite3_index_constraint const *pCons = &pIdxInfo->aConstraint[i];
|
||||||
HV *constraint = newHV();
|
HV *constraint = newHV();
|
||||||
|
@ -2984,7 +2993,7 @@ static int perl_vt_BestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pIdxInfo){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* build the "order_by" datastructure */
|
/* build the "order_by" datastructure */
|
||||||
AV *order_by = newAV();
|
order_by = newAV();
|
||||||
for (i=0; i<pIdxInfo->nOrderBy; i++){
|
for (i=0; i<pIdxInfo->nOrderBy; i++){
|
||||||
struct sqlite3_index_orderby const *pOrder = &pIdxInfo->aOrderBy[i];
|
struct sqlite3_index_orderby const *pOrder = &pIdxInfo->aOrderBy[i];
|
||||||
HV *order = newHV();
|
HV *order = newHV();
|
||||||
|
@ -3005,11 +3014,10 @@ static int perl_vt_BestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pIdxInfo){
|
||||||
/* get values back from the returned hashref */
|
/* get values back from the returned hashref */
|
||||||
if (count != 1)
|
if (count != 1)
|
||||||
croak("BEST_INDEX() method returned %d vals instead of 1", count);
|
croak("BEST_INDEX() method returned %d vals instead of 1", count);
|
||||||
SV *hashref = POPs;
|
hashref = POPs;
|
||||||
if (!(hashref && SvROK(hashref) && SvTYPE(SvRV(hashref)) == SVt_PVHV))
|
if (!(hashref && SvROK(hashref) && SvTYPE(SvRV(hashref)) == SVt_PVHV))
|
||||||
croak("BEST_INDEX() method did not return a hashref");
|
croak("BEST_INDEX() method did not return a hashref");
|
||||||
HV *hv = (HV*)SvRV(hashref);
|
hv = (HV*)SvRV(hashref);
|
||||||
SV **val;
|
|
||||||
val = hv_fetch(hv, "idxNum", 6, FALSE);
|
val = hv_fetch(hv, "idxNum", 6, FALSE);
|
||||||
pIdxInfo->idxNum = (val && SvOK(*val)) ? SvIV(*val) : 0;
|
pIdxInfo->idxNum = (val && SvOK(*val)) ? SvIV(*val) : 0;
|
||||||
val = hv_fetch(hv, "idxStr", 6, FALSE);
|
val = hv_fetch(hv, "idxStr", 6, FALSE);
|
||||||
|
@ -3034,12 +3042,11 @@ static int perl_vt_BestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pIdxInfo){
|
||||||
SV **rv = av_fetch(constraints, i, FALSE);
|
SV **rv = av_fetch(constraints, i, FALSE);
|
||||||
if (!(rv && SvROK(*rv) && SvTYPE(SvRV(*rv)) == SVt_PVHV))
|
if (!(rv && SvROK(*rv) && SvTYPE(SvRV(*rv)) == SVt_PVHV))
|
||||||
croak("the call to BEST_INDEX() has corrupted constraint data");
|
croak("the call to BEST_INDEX() has corrupted constraint data");
|
||||||
HV *hv = (HV*)SvRV(*rv);
|
hv = (HV*)SvRV(*rv);
|
||||||
SV **val = hv_fetch(hv, "argvIndex", 9, FALSE);
|
val = hv_fetch(hv, "argvIndex", 9, FALSE);
|
||||||
int argvIndex = (val && SvOK(*val)) ? SvIV(*val) + 1: 0;
|
argvIndex = (val && SvOK(*val)) ? SvIV(*val) + 1: 0;
|
||||||
|
|
||||||
struct sqlite3_index_constraint_usage *pConsUsage
|
pConsUsage = &pIdxInfo->aConstraintUsage[i];
|
||||||
= &pIdxInfo->aConstraintUsage[i];
|
|
||||||
pConsUsage->argvIndex = argvIndex;
|
pConsUsage->argvIndex = argvIndex;
|
||||||
val = hv_fetch(hv, "omit", 4, FALSE);
|
val = hv_fetch(hv, "omit", 4, FALSE);
|
||||||
pConsUsage->omit = (val && SvTRUE(*val)) ? 1 : 0;
|
pConsUsage->omit = (val && SvTRUE(*val)) ? 1 : 0;
|
||||||
|
@ -3057,15 +3064,15 @@ static int perl_vt_BestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pIdxInfo){
|
||||||
static int perl_vt_Open(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
|
static int perl_vt_Open(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
ENTER;
|
|
||||||
SAVETMPS;
|
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
int rc = SQLITE_ERROR;
|
int rc = SQLITE_ERROR;
|
||||||
SV *perl_cursor;
|
SV *perl_cursor;
|
||||||
|
perl_vtab_cursor *cursor;
|
||||||
|
|
||||||
|
ENTER;
|
||||||
|
SAVETMPS;
|
||||||
|
|
||||||
/* allocate a perl_vtab_cursor structure */
|
/* allocate a perl_vtab_cursor structure */
|
||||||
perl_vtab_cursor *cursor;
|
|
||||||
cursor = (perl_vtab_cursor *) sqlite3_malloc(sizeof(*cursor));
|
cursor = (perl_vtab_cursor *) sqlite3_malloc(sizeof(*cursor));
|
||||||
if( cursor==NULL ) return SQLITE_NOMEM;
|
if( cursor==NULL ) return SQLITE_NOMEM;
|
||||||
memset(cursor, 0, sizeof(*cursor));
|
memset(cursor, 0, sizeof(*cursor));
|
||||||
|
@ -3111,14 +3118,16 @@ static int perl_vt_Open(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
|
||||||
static int perl_vt_Close(sqlite3_vtab_cursor *pVtabCursor){
|
static int perl_vt_Close(sqlite3_vtab_cursor *pVtabCursor){
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
|
int count;
|
||||||
|
perl_vtab_cursor *perl_pVTabCursor;
|
||||||
|
|
||||||
ENTER;
|
ENTER;
|
||||||
SAVETMPS;
|
SAVETMPS;
|
||||||
int count;
|
|
||||||
|
|
||||||
/* Note : there is no explicit call to a CLOSE() method; if
|
/* Note : there is no explicit call to a CLOSE() method; if
|
||||||
needed, the Perl class can implement a DESTROY() method */
|
needed, the Perl class can implement a DESTROY() method */
|
||||||
|
|
||||||
perl_vtab_cursor *perl_pVTabCursor = (perl_vtab_cursor *) pVtabCursor;
|
perl_pVTabCursor = (perl_vtab_cursor *) pVtabCursor;
|
||||||
SvREFCNT_dec(perl_pVTabCursor->perl_cursor_obj);
|
SvREFCNT_dec(perl_pVTabCursor->perl_cursor_obj);
|
||||||
sqlite3_free(perl_pVTabCursor);
|
sqlite3_free(perl_pVTabCursor);
|
||||||
|
|
||||||
|
@ -3134,11 +3143,12 @@ static int perl_vt_Filter( sqlite3_vtab_cursor *pVtabCursor,
|
||||||
int argc, sqlite3_value **argv ){
|
int argc, sqlite3_value **argv ){
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
ENTER;
|
|
||||||
SAVETMPS;
|
|
||||||
int i, count;
|
int i, count;
|
||||||
int is_unicode = _last_dbh_is_unicode();
|
int is_unicode = _last_dbh_is_unicode();
|
||||||
|
|
||||||
|
ENTER;
|
||||||
|
SAVETMPS;
|
||||||
|
|
||||||
/* call the FILTER() method with ($idxNum, $idxStr, @args) */
|
/* call the FILTER() method with ($idxNum, $idxStr, @args) */
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj);
|
XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj);
|
||||||
|
@ -3163,9 +3173,10 @@ static int perl_vt_Filter( sqlite3_vtab_cursor *pVtabCursor,
|
||||||
static int perl_vt_Next(sqlite3_vtab_cursor *pVtabCursor){
|
static int perl_vt_Next(sqlite3_vtab_cursor *pVtabCursor){
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
|
int i, count;
|
||||||
|
|
||||||
ENTER;
|
ENTER;
|
||||||
SAVETMPS;
|
SAVETMPS;
|
||||||
int i, count;
|
|
||||||
|
|
||||||
/* call the next() method */
|
/* call the next() method */
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
|
@ -3185,9 +3196,10 @@ static int perl_vt_Next(sqlite3_vtab_cursor *pVtabCursor){
|
||||||
static int perl_vt_Eof(sqlite3_vtab_cursor *pVtabCursor){
|
static int perl_vt_Eof(sqlite3_vtab_cursor *pVtabCursor){
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
|
int count, eof;
|
||||||
|
|
||||||
ENTER;
|
ENTER;
|
||||||
SAVETMPS;
|
SAVETMPS;
|
||||||
int count, eof;
|
|
||||||
|
|
||||||
/* call the eof() method */
|
/* call the eof() method */
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
|
@ -3217,11 +3229,12 @@ static int perl_vt_Column(sqlite3_vtab_cursor *pVtabCursor,
|
||||||
int col){
|
int col){
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
ENTER;
|
|
||||||
SAVETMPS;
|
|
||||||
int count;
|
int count;
|
||||||
int rc = SQLITE_ERROR;
|
int rc = SQLITE_ERROR;
|
||||||
|
|
||||||
|
ENTER;
|
||||||
|
SAVETMPS;
|
||||||
|
|
||||||
/* call the column() method */
|
/* call the column() method */
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj);
|
XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj);
|
||||||
|
@ -3251,11 +3264,12 @@ static int perl_vt_Rowid( sqlite3_vtab_cursor *pVtabCursor,
|
||||||
sqlite3_int64 *pRowid ){
|
sqlite3_int64 *pRowid ){
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
ENTER;
|
|
||||||
SAVETMPS;
|
|
||||||
int count;
|
int count;
|
||||||
int rc = SQLITE_ERROR;
|
int rc = SQLITE_ERROR;
|
||||||
|
|
||||||
|
ENTER;
|
||||||
|
SAVETMPS;
|
||||||
|
|
||||||
/* call the rowid() method */
|
/* call the rowid() method */
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj);
|
XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj);
|
||||||
|
@ -3283,11 +3297,13 @@ static int perl_vt_Update( sqlite3_vtab *pVTab,
|
||||||
sqlite3_int64 *pRowid ){
|
sqlite3_int64 *pRowid ){
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
ENTER;
|
|
||||||
SAVETMPS;
|
|
||||||
int count, i;
|
int count, i;
|
||||||
int is_unicode = _last_dbh_is_unicode();
|
int is_unicode = _last_dbh_is_unicode();
|
||||||
int rc = SQLITE_ERROR;
|
int rc = SQLITE_ERROR;
|
||||||
|
SV *rowidsv;
|
||||||
|
|
||||||
|
ENTER;
|
||||||
|
SAVETMPS;
|
||||||
|
|
||||||
/* call the _SQLITE_UPDATE() method */
|
/* call the _SQLITE_UPDATE() method */
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
|
@ -3307,7 +3323,7 @@ static int perl_vt_Update( sqlite3_vtab *pVTab,
|
||||||
&& sqlite3_value_type(argv[1]) == SQLITE_NULL) {
|
&& sqlite3_value_type(argv[1]) == SQLITE_NULL) {
|
||||||
/* this was an insert without any given rowid, so the result of
|
/* this was an insert without any given rowid, so the result of
|
||||||
the method call must be passed in *pRowid*/
|
the method call must be passed in *pRowid*/
|
||||||
SV *rowidsv = POPs;
|
rowidsv = POPs;
|
||||||
if (!SvOK(rowidsv))
|
if (!SvOK(rowidsv))
|
||||||
*pRowid = 0;
|
*pRowid = 0;
|
||||||
else if (SvUOK(rowidsv))
|
else if (SvUOK(rowidsv))
|
||||||
|
@ -3350,18 +3366,21 @@ static int perl_vt_FindFunction(sqlite3_vtab *pVTab,
|
||||||
void **ppArg){
|
void **ppArg){
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
ENTER;
|
|
||||||
SAVETMPS;
|
|
||||||
int count;
|
int count;
|
||||||
int is_overloaded = 0;
|
int is_overloaded = 0;
|
||||||
char *func_name = sqlite3_mprintf("%s\t%d", zName, nArg);
|
char *func_name = sqlite3_mprintf("%s\t%d", zName, nArg);
|
||||||
STRLEN len = strlen(func_name);
|
STRLEN len = strlen(func_name);
|
||||||
HV *functions = ((perl_vtab *) pVTab)->functions;
|
HV *functions = ((perl_vtab *) pVTab)->functions;
|
||||||
SV* coderef = NULL;
|
SV* coderef = NULL;
|
||||||
|
SV** val;
|
||||||
|
SV *result;
|
||||||
|
|
||||||
|
ENTER;
|
||||||
|
SAVETMPS;
|
||||||
|
|
||||||
/* check if that function was already in cache */
|
/* check if that function was already in cache */
|
||||||
if (hv_exists(functions, func_name, len)) {
|
if (hv_exists(functions, func_name, len)) {
|
||||||
SV** val = hv_fetch(functions, func_name, len, FALSE);
|
val = hv_fetch(functions, func_name, len, FALSE);
|
||||||
if (val && SvOK(*val)) {
|
if (val && SvOK(*val)) {
|
||||||
coderef = *val;
|
coderef = *val;
|
||||||
}
|
}
|
||||||
|
@ -3380,7 +3399,7 @@ static int perl_vt_FindFunction(sqlite3_vtab *pVTab,
|
||||||
SP -= count;
|
SP -= count;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
SV *result = POPs;
|
result = POPs;
|
||||||
if (SvTRUE(result)) {
|
if (SvTRUE(result)) {
|
||||||
/* the coderef must be valid for the lifetime of pVTab, so
|
/* the coderef must be valid for the lifetime of pVTab, so
|
||||||
make a copy */
|
make a copy */
|
||||||
|
@ -3411,11 +3430,12 @@ static int perl_vt_FindFunction(sqlite3_vtab *pVTab,
|
||||||
static int perl_vt_Rename(sqlite3_vtab *pVTab, const char *zNew){
|
static int perl_vt_Rename(sqlite3_vtab *pVTab, const char *zNew){
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
ENTER;
|
|
||||||
SAVETMPS;
|
|
||||||
int count;
|
int count;
|
||||||
int rc = SQLITE_ERROR;
|
int rc = SQLITE_ERROR;
|
||||||
|
|
||||||
|
ENTER;
|
||||||
|
SAVETMPS;
|
||||||
|
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
XPUSHs(((perl_vtab *) pVTab)->perl_vtab_obj);
|
XPUSHs(((perl_vtab *) pVTab)->perl_vtab_obj);
|
||||||
XPUSHs(sv_2mortal(newSVpv(zNew, 0)));
|
XPUSHs(sv_2mortal(newSVpv(zNew, 0)));
|
||||||
|
@ -3481,12 +3501,14 @@ sqlite_db_destroy_module_data(void *pAux)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
ENTER;
|
|
||||||
SAVETMPS;
|
|
||||||
int count;
|
int count;
|
||||||
int rc = SQLITE_ERROR;
|
int rc = SQLITE_ERROR;
|
||||||
|
perl_vtab_init *init_data;
|
||||||
|
|
||||||
perl_vtab_init *init_data = (perl_vtab_init *)pAux;
|
ENTER;
|
||||||
|
SAVETMPS;
|
||||||
|
|
||||||
|
init_data = (perl_vtab_init *)pAux;
|
||||||
|
|
||||||
/* call the DESTROY_MODULE() method */
|
/* call the DESTROY_MODULE() method */
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
|
@ -3511,11 +3533,14 @@ int
|
||||||
sqlite_db_create_module(pTHX_ SV *dbh, const char *name, const char *perl_class)
|
sqlite_db_create_module(pTHX_ SV *dbh, const char *name, const char *perl_class)
|
||||||
{
|
{
|
||||||
dSP;
|
dSP;
|
||||||
ENTER;
|
|
||||||
SAVETMPS;
|
|
||||||
|
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
int count, rc, retval = TRUE;
|
int count, rc, retval = TRUE;
|
||||||
|
char *module_ISA;
|
||||||
|
char *loading_code;
|
||||||
|
perl_vtab_init *init_data;
|
||||||
|
|
||||||
|
ENTER;
|
||||||
|
SAVETMPS;
|
||||||
|
|
||||||
if (!DBIc_ACTIVE(imp_dbh)) {
|
if (!DBIc_ACTIVE(imp_dbh)) {
|
||||||
sqlite_error(dbh, -2, "attempt to create module on inactive database handle");
|
sqlite_error(dbh, -2, "attempt to create module on inactive database handle");
|
||||||
|
@ -3523,16 +3548,15 @@ sqlite_db_create_module(pTHX_ SV *dbh, const char *name, const char *perl_class)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load the module if needed */
|
/* load the module if needed */
|
||||||
char *module_ISA = sqlite3_mprintf("%s::ISA", perl_class);
|
module_ISA = sqlite3_mprintf("%s::ISA", perl_class);
|
||||||
if (!get_av(module_ISA, 0)) {
|
if (!get_av(module_ISA, 0)) {
|
||||||
char *loading_code = sqlite3_mprintf("use %s", perl_class);
|
loading_code = sqlite3_mprintf("use %s", perl_class);
|
||||||
eval_pv(loading_code, TRUE);
|
eval_pv(loading_code, TRUE);
|
||||||
sqlite3_free(loading_code);
|
sqlite3_free(loading_code);
|
||||||
}
|
}
|
||||||
sqlite3_free(module_ISA);
|
sqlite3_free(module_ISA);
|
||||||
|
|
||||||
/* build the init datastructure that will be passed to perl_vt_New() */
|
/* build the init datastructure that will be passed to perl_vt_New() */
|
||||||
perl_vtab_init *init_data;
|
|
||||||
init_data = sqlite3_malloc(sizeof(*init_data));
|
init_data = sqlite3_malloc(sizeof(*init_data));
|
||||||
init_data->dbh = newRV(dbh);
|
init_data->dbh = newRV(dbh);
|
||||||
sv_rvweaken(init_data->dbh);
|
sv_rvweaken(init_data->dbh);
|
||||||
|
|
Loading…
Add table
Reference in a new issue