ext/pdo_sqlite/sqlite/src/prepare.c
/*
** This is the callback routine for the code that initializes the
** database.  See sqlite3Init() below for additional information.
** This routine is also called from the OP_ParseSchema opcode of the VDBE.
**
** Each callback contains the following information:
**
**     argv[0] = name of thing being created
**     argv[1] = root page number for table or index. 0 for trigger or view.
**     argv[2] = SQL text for the CREATE statement.
**
*/
This is the callback routine for the code that initializes the
database.  See sqlite3Init() below for additional information.
This routine is also called from the OP_ParseSchema opcode of the VDBE.

Each callback contains the following information.

argv[0] = name of thing being created
argv[1] = root page number for table or index. 0 for trigger or view.
argv[2] = SQL text for the CREATE statement.
This is the callback routine for the code that initializes the database . See sqlite3Init () below for additional information . This routine is also called from the OP_ParseSchema opcode of the VDBE . Each callback contains the following information . argv [ 0 ] = name of thing being created argv [ 1 ] = root page number for table or index . 0 for trigger or view . argv [ 2 ] = SQL text for the CREATE statement .
int sqlite3InitCallback(void *pInit, int argc, char **argv, char **azColName){
  InitData *pData = (InitData*)pInit;
  sqlite3 *db = pData->db;
  int iDb = pData->iDb;
  pData->rc = SQLITE_OK;
  DbClearProperty(db, iDb, DB_Empty);
  if( sqlite3MallocFailed() ){
    corruptSchema(pData, 0);
    return SQLITE_NOMEM;
  }
  assert( argc==3 );
  if( argv==0 ) return 0;   
  if( argv[1]==0 ){
    corruptSchema(pData, 0);
    return 1;
  }
  assert( iDb>=0 && iDb<db->nDb );
  if( argv[2] && argv[2][0] ){
    char *zErr;
    int rc;
    assert( db->init.busy );
    db->init.iDb = iDb;
    db->init.newTnum = atoi(argv[1]);
    rc = sqlite3_exec(db, argv[2], 0, 0, &zErr);
    db->init.iDb = 0;
    assert( rc!=SQLITE_OK || zErr==0 );
    if( SQLITE_OK!=rc ){
      pData->rc = rc;
      if( rc==SQLITE_NOMEM ){
        sqlite3FailedMalloc();
      }else if( rc!=SQLITE_INTERRUPT ){
        corruptSchema(pData, zErr);
      }
      sqlite3_free(zErr);
      return 1;
    }
  }else{
    Index *pIndex;
    pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zName);
    if( pIndex==0 || pIndex->tnum!=0 ){
      ;
    }else{
      pIndex->tnum = atoi(argv[1]);
    }
  }
  return 0;
}
int sqlite3InitCallback ( void * pInit , int argc , char * * argv , char * * azColName ) { InitData * pData = ( InitData * ) pInit ; sqlite3 * db = pData -> db ; int iDb = pData -> iDb ; pData -> rc = SQLITE_OK ; DbClearProperty ( db , iDb , DB_Empty ) ; if ( sqlite3MallocFailed ( ) ) { corruptSchema ( pData , 0 ) ; return SQLITE_NOMEM ; } assert ( argc == 3 ) ; if ( argv == 0 ) return 0 ; if ( argv [ 1 ] == 0 ) { corruptSchema ( pData , 0 ) ; return 1 ; } assert ( iDb >= 0 && iDb < db -> nDb ) ; if ( argv [ 2 ] && argv [ 2 ] [ 0 ] ) { char * zErr ; int rc ; assert ( db -> init . busy ) ; db -> init . iDb = iDb ; db -> init . newTnum = atoi ( argv [ 1 ] ) ; rc = sqlite3_exec ( db , argv [ 2 ] , 0 , 0 , & zErr ) ; db -> init . iDb = 0 ; assert ( rc != SQLITE_OK || zErr == 0 ) ; if ( SQLITE_OK != rc ) { pData -> rc = rc ; if ( rc == SQLITE_NOMEM ) { sqlite3FailedMalloc ( ) ; } else if ( rc != SQLITE_INTERRUPT ) { corruptSchema ( pData , zErr ) ; } sqlite3_free ( zErr ) ; return 1 ; } } else { Index * pIndex ; pIndex = sqlite3FindIndex ( db , argv [ 0 ] , db -> aDb [ iDb ] . zName ) ; if ( pIndex == 0 || pIndex -> tnum != 0 ) { ; } else { pIndex -> tnum = atoi ( argv [ 1 ] ) ; } } return 0 ; }
This is the callback routine for the code that initializes the
database.
This is the callback routine for the code that initializes the database .
/* Might happen if EMPTY_RESULT_CALLBACKS are on */ /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
    ** But because db->init.busy is set to 1, no VDBE code is generated
    ** or executed.  All the parser does is build the internal data
    ** structures that describe the table, index, or view.
    */ /* If the SQL column is blank it means this is an index that
    ** was created to be the PRIMARY KEY or to fulfill a UNIQUE
    ** constraint for a CREATE TABLE.  The index should have already
    ** been created when we processed the CREATE TABLE.  All we have
    ** to do here is record the root page number for that index.
    */ /* This can occur if there exists an index on a TEMP table which
      ** has the same name as another index on a permanent index.  Since
      ** the permanent table is hidden by the TEMP table, we can also
      ** safely ignore the index on the permanent table.
      */ /* Do Nothing */