Lines Matching defs:pTable

199   if( pIndex->pTable->pIndex==pIndex ){
200 pIndex->pTable->pIndex = pIndex->pNext;
203 for(p=pIndex->pTable->pIndex; p && p->pNext!=pIndex; p=p->pNext){}
321 void sqliteDeleteTable(sqlite *db, Table *pTable){
326 if( pTable==0 ) return;
330 for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
332 assert( pIndex->iDb==pTable->iDb || (pTable->iDb==0 && pIndex->iDb==1) );
339 for(pFKey=pTable->pFKey; pFKey; pFKey=pNextFKey){
341 assert( pTable->iDb<db->nDb );
342 assert( sqliteHashFind(&db->aDb[pTable->iDb].aFKey,
349 for(i=0; i<pTable->nCol; i++){
350 sqliteFree(pTable->aCol[i].zName);
351 sqliteFree(pTable->aCol[i].zDflt);
352 sqliteFree(pTable->aCol[i].zType);
354 sqliteFree(pTable->zName);
355 sqliteFree(pTable->aCol);
356 sqliteSelectDelete(pTable->pSelect);
357 sqliteFree(pTable);
433 Table *pTable;
502 pTable = sqliteFindTable(db, zName, 0);
504 if( pTable!=0 && (pTable->iDb==iDb || !db->init.busy) ){
515 pTable = sqliteMalloc( sizeof(Table) );
516 if( pTable==0 ){
520 pTable->zName = zName;
521 pTable->nCol = 0;
522 pTable->aCol = 0;
523 pTable->iPKey = -1;
524 pTable->pIndex = 0;
525 pTable->iDb = iDb;
527 pParse->pNewTable = pTable;
1052 ** The Table structure pTable is really a VIEW. Fill in the names of
1053 ** the columns of the view in the pTable structure. Return the number
1056 int sqliteViewGetColumnNames(Parse *pParse, Table *pTable){
1062 assert( pTable );
1067 if( pTable->nCol>0 ) return 0;
1079 if( pTable->nCol<0 ){
1080 sqliteErrorMsg(pParse, "view %s is circularly defined", pTable->zName);
1086 assert( pTable->pSelect ); /* If nCol==0, then pTable must be a VIEW */
1087 pSel = pTable->pSelect;
1100 pTable->nCol = -1;
1103 assert( pTable->aCol==0 );
1104 pTable->nCol = pSelTab->nCol;
1105 pTable->aCol = pSelTab->aCol;
1109 DbSetProperty(pParse->db, pTable->iDb, DB_UnresetViews);
1111 pTable->nCol = 0;
1121 ** Clear the column names from the VIEW pTable.
1128 static void sqliteViewResetColumnNames(Table *pTable){
1131 assert( pTable!=0 && pTable->pSelect!=0 );
1132 for(i=0, pCol=pTable->aCol; i<pTable->nCol; i++, pCol++){
1137 sqliteFree(pTable->aCol);
1138 pTable->aCol = 0;
1139 pTable->nCol = 0;
1179 Table *pTable;
1186 pTable = sqliteTableFromToken(pParse, pName);
1187 if( pTable==0 ) return;
1188 iDb = pTable->iDb;
1193 const char *zTab = SCHEMA_TABLE(pTable->iDb);
1194 const char *zDb = db->aDb[pTable->iDb].zName;
1211 if( sqliteAuthCheck(pParse, code, pTable->zName, 0, zDb) ){
1214 if( sqliteAuthCheck(pParse, SQLITE_DELETE, pTable->zName, 0, zDb) ){
1219 if( pTable->readOnly ){
1220 sqliteErrorMsg(pParse, "table %s may not be dropped", pTable->zName);
1224 if( isView && pTable->pSelect==0 ){
1225 sqliteErrorMsg(pParse, "use DROP TABLE to delete table %s", pTable->zName);
1228 if( !isView && pTable->pSelect ){
1229 sqliteErrorMsg(pParse, "use DROP VIEW to delete view %s", pTable->zName);
1250 sqliteBeginWriteOperation(pParse, 0, pTable->iDb);
1253 pTrigger = pTable->pTrigger;
1255 assert( pTrigger->iDb==pTable->iDb || pTrigger->iDb==1 );
1260 pTrigger = pTable->pTrigger;
1265 sqliteOpenMasterTable(v, pTable->iDb);
1267 sqliteVdbeChangeP3(v, base+1, pTable->zName, 0);
1270 if( pTable->iDb!=1 ){
1273 sqliteVdbeChangeP3(v, base+1, pTable->zName, 0);
1276 if( pTable->iDb==0 ){
1281 sqliteVdbeAddOp(v, OP_Destroy, pTable->tnum, pTable->iDb);
1282 for(pIdx=pTable->pIndex; pIdx; pIdx=pIdx->pNext){
1295 sqliteUnlinkAndDeleteTable(db, pTable);
1315 assert( pIdx!=0 && pIdx->pTable!=0 );
1316 pTab = pIdx->pTable;
1465 ** and pTable is the name of the table that is to be indexed. Both will
1467 ** UNIQUE constraint. If pTable and pIndex are NULL, use pParse->pNewTable
1478 SrcList *pTable, /* Name of the table to index. Use pParse->pNewTable if 0 */
1489 DbFixer sFix; /* For assigning database names to pTable */
1496 && sqliteFixSrcList(&sFix, pTable)
1504 if( pTable!=0 ){
1506 assert( pTable->nSrc==1 );
1507 pTab = sqliteSrcListLookup(pParse, pTable);
1604 pIndex->pTable = pTab;
1664 if( db->init.busy && pTable!=0 ){
1678 ** If pTable==0 it means this index is generated as a primary key
1692 if( pTable!=0 ){
1702 if( pTable ){
1716 if( pTable ){
1739 if( pTable!=0 ){
1751 sqliteSrcListDelete(pTable);
1785 Table *pTab = pIndex->pTable;
1882 ** points to the table name and the pTable points to the database name.
1884 ** come from pTable (if pDatabase is NULL) or from pDatabase.
1885 ** SrcList.a[].zDatabase is filled with the database name from pTable,
1899 SrcList *sqliteSrcListAppend(SrcList *pList, Token *pTable, Token *pDatabase){
1920 if( pDatabase && pTable ){
1922 pDatabase = pTable;
1923 pTable = pTemp;
1925 if( pTable ){
1927 sqliteSetNString(pz, pTable->z, pTable->n, 0);