Lines Matching refs:pTab

24   Table *pTab,    /* The table to be opened */
28 if( IsVirtual(pTab) ) return;
31 sqlite3TableLock(p, iDb, pTab->tnum, (opcode==OP_OpenWrite)?1:0, pTab->zName);
32 sqlite3VdbeAddOp3(v, opcode, iCur, pTab->tnum, iDb);
33 sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(pTab->nCol), P4_INT32);
34 VdbeComment((v, "%s", pTab->zName));
68 Table *pTab = pIdx->pTable;
76 pIdx->zColAff[n] = pTab->aCol[pIdx->aiColumn[n]].affinity;
87 ** string for table pTab. A column affinity string has one character
99 void sqlite3TableAffinityStr(Vdbe *v, Table *pTab){
107 if( !pTab->zColAff ){
112 zColAff = (char *)sqlite3DbMallocRaw(0, pTab->nCol+1);
118 for(i=0; i<pTab->nCol; i++){
119 zColAff[i] = pTab->aCol[i].affinity;
121 zColAff[pTab->nCol] = '\0';
123 pTab->zColAff = zColAff;
126 sqlite3VdbeChangeP4(v, -1, pTab->zColAff, P4_TRANSIENT);
130 ** Return non-zero if the table pTab in database iDb or any of its indices
133 ** a statement of the form "INSERT INTO <iDb, pTab> SELECT ..." can
136 static int readsTable(Parse *p, int iStartAddr, int iDb, Table *pTab){
141 VTable *pVTab = IsVirtual(pTab) ? sqlite3GetVTable(p->db, pTab) : 0;
150 if( tnum==pTab->tnum ){
153 for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){
172 ** Locate or create an AutoincInfo structure associated with table pTab
179 ** first use of table pTab. On 2nd and subsequent uses, the original
184 ** (1) Register to hold the name of the pTab table.
185 ** (2) Register to hold the maximum ROWID of pTab.
186 ** (3) Register to hold the rowid in sqlite_sequence of pTab
193 int iDb, /* Index of the database holding pTab */
194 Table *pTab /* The table we are writing to */
197 if( pTab->tabFlags & TF_Autoincrement ){
202 while( pInfo && pInfo->pTab!=pTab ){ pInfo = pInfo->pNext; }
208 pInfo->pTab = pTab;
243 sqlite3VdbeAddOp4(v, OP_String8, 0, memId-1, 0, p->pTab->zName, 0);
442 Table *pTab; /* The table to insert into. aka TABLE */
450 int baseCur = 0; /* VDBE Cursor number for pTab */
475 Trigger *pTrigger; /* List of triggers on pTab, if required */
490 pTab = sqlite3SrcListLookup(pParse, pTabList);
491 if( pTab==0 ){
494 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
498 if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, zDb) ){
506 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_INSERT, 0, &tmask);
507 isView = pTab->pSelect!=0;
519 /* If pTab is really a view, make sure it has been initialized.
520 ** ViewGetColumnNames() is a no-op if pTab is not a view (or virtual
523 if( sqlite3ViewGetColumnNames(pParse, pTab) ){
531 if( sqlite3IsReadOnly(pParse, pTab, tmask) ){
552 if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){
562 regAutoinc = autoIncBegin(pParse, iDb, pTab);
629 if( pTrigger || readsTable(pParse, addrSelect, iDb, pTab) ){
684 if( IsVirtual(pTab) ){
685 for(i=0; i<pTab->nCol; i++){
686 nHidden += (IsHiddenColumn(&pTab->aCol[i]) ? 1 : 0);
689 if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){
692 pTabList, 0, pTab->nCol-nHidden, nColumn);
709 ** key in the original table is pTab->iPKey.)
716 for(j=0; j<pTab->nCol; j++){
717 if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){
719 if( j==pTab->iPKey ){
725 if( j>=pTab->nCol ){
743 keyColumn = pTab->iPKey;
758 nIdx = sqlite3OpenTableAndIndices(pParse, pTab, baseCur, OP_OpenWrite);
799 pParse->nMem += pTab->nCol + 1;
800 if( IsVirtual(pTab) ){
810 int regCols = sqlite3GetTempRange(pParse, pTab->nCol+1);
837 assert( !IsVirtual(pTab) );
841 for(i=0; i<pTab->nCol; i++){
850 sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regCols+i+1);
865 sqlite3VdbeAddOp2(v, OP_Affinity, regCols+1, pTab->nCol);
866 sqlite3TableAffinityStr(v, pTab);
871 pTab, regCols-pTab->nCol-1, onError, endOfLoop);
873 sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1);
882 if( IsVirtual(pTab) ){
895 if( ALWAYS(pOp) && pOp->opcode==OP_Null && !IsVirtual(pTab) ){
908 if( !IsVirtual(pTab) ){
918 }else if( IsVirtual(pTab) ){
930 for(i=0; i<pTab->nCol; i++){
932 if( i==pTab->iPKey ){
941 if( IsHiddenColumn(&pTab->aCol[i]) ){
942 assert( IsVirtual(pTab) );
954 sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, iRegStore);
968 if( IsVirtual(pTab) ){
969 const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);
970 sqlite3VtabMakeWritable(pParse, pTab);
971 sqlite3VdbeAddOp4(v, OP_VUpdate, 1, pTab->nCol+2, regIns, pVTab, P4_VTAB);
977 sqlite3GenerateConstraintChecks(pParse, pTab, baseCur, regIns, aRegIdx,
980 sqlite3FkCheck(pParse, pTab, 0, regIns);
982 pParse, pTab, baseCur, regIns, aRegIdx, 0, appendFlag, isReplace==0
996 pTab, regData-2-pTab->nCol, onError, endOfLoop);
1012 if( !IsVirtual(pTab) && !isView ){
1015 for(idx=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){
1131 ** The calling routine must open a read/write cursor for pTab with
1132 ** cursor number "baseCur". All indices of pTab must also have open
1139 Table *pTab, /* the table into which we are inserting */
1140 int baseCur, /* Index of a read/write cursor pointing at pTab */
1163 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
1164 nCol = pTab->nCol;
1170 if( i==pTab->iPKey ){
1173 onError = pTab->aCol[i].notNull;
1180 if( onError==OE_Replace && pTab->aCol[i].pDflt==0 ){
1194 pTab->zName, pTab->aCol[i].zName);
1205 sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regData+i);
1215 if( pTab->pCheck && (pParse->db->flags & SQLITE_IgnoreChecks)==0 ){
1218 sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, SQLITE_JUMPIFNULL);
1235 onError = pTab->keyConf;
1283 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
1285 if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
1288 pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace
1290 }else if( pTab->pIndex ){
1292 sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0);
1313 for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){
1323 if( idx==pTab->iPKey ){
1374 char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
1396 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
1399 pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace
1425 Table *pTab, /* the table into which we are inserting */
1426 int baseCur, /* Index of a read/write cursor pointing at pTab */
1443 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
1444 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}
1454 sqlite3VdbeAddOp3(v, OP_MakeRecord, regData, pTab->nCol, regRec);
1455 sqlite3TableAffinityStr(v, pTab);
1456 sqlite3ExprCacheAffinityChange(pParse, regData, pTab->nCol);
1471 sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_TRANSIENT);
1485 Table *pTab, /* Table to be opened */
1494 if( IsVirtual(pTab) ) return 0;
1495 iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
1498 sqlite3OpenTable(pParse, baseCur, iDb, pTab, op);
1499 for(i=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
1501 assert( pIdx->pSchema==pTab->pSchema );