ext/pdo_sqlite/sqlite/src/prepare.c
/*
** Initialize all database files - the main database file, the file
** used to store temporary tables, and any additional database files
** created using ATTACH statements.  Return a success code.  If an
** error occurs, write an error message into *pzErrMsg.
**
** After a database is initialized, the DB_SchemaLoaded bit is set
** bit is set in the flags field of the Db structure. If the database
** file was of zero-length, then the DB_Empty flag is also set.
*/
Initialize all database files - the main database file, the file
used to store temporary tables, and any additional database files
created using ATTACH statements.  Return a success code.  If an
error occurs, write an error message into *pzErrMsg.

After a database is initialized, the DB_SchemaLoaded bit is set
bit is set in the flags field of the Db structure. If the database
file was of zero-length, then the DB_Empty flag is also set.
Initialize all database files - the main database file the file used to store temporary tables and any additional database files created using ATTACH statements . Return a success code . If an error occurs write an error message into * pzErrMsg . After a database is initialized the DB_SchemaLoaded bit is set bit is set in the flags field of the Db structure . If the database file was of zero - length then the DB_Empty flag is also set .
int sqlite3Init(sqlite3 *db, char **pzErrMsg){
  int i, rc;
  int called_initone = 0;
  if( db->init.busy ) return SQLITE_OK;
  rc = SQLITE_OK;
  db->init.busy = 1;
  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
    if( DbHasProperty(db, i, DB_SchemaLoaded) || i==1 ) continue;
    rc = sqlite3InitOne(db, i, pzErrMsg);
    if( rc ){
      sqlite3ResetInternalSchema(db, i);
    }
    called_initone = 1;
  }
#ifndef SQLITE_OMIT_TEMPDB
  if( rc==SQLITE_OK && db->nDb>1 && !DbHasProperty(db, 1, DB_SchemaLoaded) ){
    rc = sqlite3InitOne(db, 1, pzErrMsg);
    if( rc ){
      sqlite3ResetInternalSchema(db, 1);
    }
    called_initone = 1;
  }
#endif
  db->init.busy = 0;
  if( rc==SQLITE_OK && called_initone ){
    sqlite3CommitInternalChanges(db);
  }
  return rc; 
}
int sqlite3Init ( sqlite3 * db , char * * pzErrMsg ) { int i , rc ; int called_initone = 0 ; if ( db -> init . busy ) return SQLITE_OK ; rc = SQLITE_OK ; db -> init . busy = 1 ; for ( i = 0 ; rc == SQLITE_OK && i < db -> nDb ; i ++ ) { if ( DbHasProperty ( db , i , DB_SchemaLoaded ) || i == 1 ) continue ; rc = sqlite3InitOne ( db , i , pzErrMsg ) ; if ( rc ) { sqlite3ResetInternalSchema ( db , i ) ; } called_initone = 1 ; } #ifndef SQLITE_OMIT_TEMPDB if ( rc == SQLITE_OK && db -> nDb > 1 && ! DbHasProperty ( db , 1 , DB_SchemaLoaded ) ) { rc = sqlite3InitOne ( db , 1 , pzErrMsg ) ; if ( rc ) { sqlite3ResetInternalSchema ( db , 1 ) ; } called_initone = 1 ; } #endif db -> init . busy = 0 ; if ( rc == SQLITE_OK && called_initone ) { sqlite3CommitInternalChanges ( db ) ; } return rc ; }
Initialize all database files - the main database file, the file
used to store temporary tables, and any additional database files
created using ATTACH statements.
Initialize all database files - the main database file the file used to store temporary tables and any additional database files created using ATTACH statements .
/* Once all the other databases have been initialised, load the schema
  ** for the TEMP database. This is loaded last, as the TEMP database
  ** schema may contain references to objects in other databases.
  */