diff options
Diffstat (limited to 'ext/pdo_sqlite/sqlite/src/main.c')
-rw-r--r-- | ext/pdo_sqlite/sqlite/src/main.c | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/ext/pdo_sqlite/sqlite/src/main.c b/ext/pdo_sqlite/sqlite/src/main.c index eccf83be69..c1f8f9ed6f 100644 --- a/ext/pdo_sqlite/sqlite/src/main.c +++ b/ext/pdo_sqlite/sqlite/src/main.c @@ -223,7 +223,7 @@ void sqlite3RollbackAll(sqlite3 *db){ */ const char *sqlite3ErrStr(int rc){ const char *z; - switch( rc ){ + switch( rc & 0xff ){ case SQLITE_ROW: case SQLITE_DONE: case SQLITE_OK: z = "not an error"; break; @@ -541,6 +541,32 @@ int sqlite3_create_function16( } #endif + +/* +** Declare that a function has been overloaded by a virtual table. +** +** If the function already exists as a regular global function, then +** this routine is a no-op. If the function does not exist, then create +** a new one that always throws a run-time error. +** +** When virtual tables intend to provide an overloaded function, they +** should call this routine to make sure the global function exists. +** A global function must exist in order for name resolution to work +** properly. +*/ +int sqlite3_overload_function( + sqlite3 *db, + const char *zName, + int nArg +){ + int nName = strlen(zName); + if( sqlite3FindFunction(db, zName, nName, nArg, SQLITE_UTF8, 0)==0 ){ + sqlite3CreateFunc(db, zName, nArg, SQLITE_UTF8, + 0, sqlite3InvalidFunction, 0, 0); + } + return sqlite3ApiExit(db, SQLITE_OK); +} + #ifndef SQLITE_OMIT_TRACE /* ** Register a trace function. The pArg from the previously registered trace @@ -763,7 +789,7 @@ int sqlite3_errcode(sqlite3 *db){ if( sqlite3SafetyCheck(db) ){ return SQLITE_MISUSE; } - return db->errCode; + return db->errCode & db->errMask; } /* @@ -841,6 +867,7 @@ static int openDatabase( /* Allocate the sqlite data structure */ db = sqliteMalloc( sizeof(sqlite3) ); if( db==0 ) goto opendb_out; + db->errMask = 0xff; db->priorNewRowid = 0; db->magic = SQLITE_MAGIC_BUSY; db->nDb = 2; @@ -907,11 +934,30 @@ static int openDatabase( ** is accessed. */ if( !sqlite3MallocFailed() ){ - sqlite3RegisterBuiltinFunctions(db); sqlite3Error(db, SQLITE_OK, 0); + sqlite3RegisterBuiltinFunctions(db); } db->magic = SQLITE_MAGIC_OPEN; + /* Load automatic extensions - extensions that have been registered + ** using the sqlite3_automatic_extension() API. + */ + (void)sqlite3AutoLoadExtensions(db); + +#ifdef SQLITE_ENABLE_FTS1 + { + extern int sqlite3Fts1Init(sqlite3*); + sqlite3Fts1Init(db); + } +#endif + +#ifdef SQLITE_ENABLE_FTS2 + { + extern int sqlite3Fts2Init(sqlite3*); + sqlite3Fts2Init(db); + } +#endif + opendb_out: if( SQLITE_NOMEM==(rc = sqlite3_errcode(db)) ){ sqlite3_close(db); @@ -999,6 +1045,7 @@ int sqlite3_reset(sqlite3_stmt *pStmt){ }else{ rc = sqlite3VdbeReset((Vdbe*)pStmt); sqlite3VdbeMakeReady((Vdbe*)pStmt, -1, 0, 0, 0); + assert( (rc & (sqlite3_db_handle(pStmt)->errMask))==rc ); } return rc; } @@ -1285,3 +1332,11 @@ int sqlite3_clear_bindings(sqlite3_stmt *pStmt){ int sqlite3_sleep(int ms){ return sqlite3OsSleep(ms); } + +/* +** Enable or disable the extended result codes. +*/ +int sqlite3_extended_result_codes(sqlite3 *db, int onoff){ + db->errMask = onoff ? 0xffffffff : 0xff; + return SQLITE_OK; +} |