@@ -1367,9 +1367,13 @@ void sqlite3GenerateConstraintChecks(
13671367 sqlite3 * db ; /* Database connection */
13681368 int i ; /* loop counter */
13691369 int ix ; /* Index loop counter */
1370+ #if !defined(SQLITE_BUILDING_FOR_COMDB2 )
13701371 int nCol ; /* Number of columns */
1372+ #endif /* !defined(SQLITE_BUILDING_FOR_COMDB2) */
13711373 int onError ; /* Conflict resolution strategy */
1374+ #if !defined(SQLITE_BUILDING_FOR_COMDB2 )
13721375 int addr1 ; /* Address of jump instruction */
1376+ #endif /* !defined(SQLITE_BUILDING_FOR_COMDB2) */
13731377 int seenReplace = 0 ; /* True if REPLACE is used to resolve INT PK conflict */
13741378 int nPkField ; /* Number of fields in PRIMARY KEY. 1 for ROWID tables */
13751379 Index * pUpIdx = 0 ; /* Index to which to apply the upsert */
@@ -1391,8 +1395,10 @@ void sqlite3GenerateConstraintChecks(
13911395 v = sqlite3GetVdbe (pParse );
13921396 assert ( v != 0 );
13931397 assert ( pTab -> pSelect == 0 ); /* This table is not a VIEW */
1398+ #if !defined(SQLITE_BUILDING_FOR_COMDB2 )
13941399 nCol = pTab -> nCol ;
1395-
1400+ #endif /* !defined(SQLITE_BUILDING_FOR_COMDB2) */
1401+
13961402 /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for
13971403 ** normal rowid tables. nPkField is the number of key fields in the
13981404 ** pPk index or 1 for a rowid table. In other words, nPkField is the
@@ -1409,6 +1415,7 @@ void sqlite3GenerateConstraintChecks(
14091415 VdbeModuleComment ((v , "BEGIN: GenCnstCks(%d,%d,%d,%d,%d)" ,
14101416 iDataCur , iIdxCur , regNewData , regOldData , pkChng ));
14111417
1418+ #if !defined(SQLITE_BUILDING_FOR_COMDB2 )
14121419 /* Test all NOT NULL constraints.
14131420 */
14141421 for (i = 0 ; i < nCol ; i ++ ){
@@ -1504,6 +1511,7 @@ void sqlite3GenerateConstraintChecks(
15041511 pParse -> iSelfTab = 0 ;
15051512 }
15061513#endif /* !defined(SQLITE_OMIT_CHECK) */
1514+ #endif /* !defined(SQLITE_BUILDING_FOR_COMDB2) */
15071515
15081516 /* UNIQUE and PRIMARY KEY constraints should be handled in the following
15091517 ** order:
@@ -1719,7 +1727,6 @@ void sqlite3GenerateConstraintChecks(
17191727 VdbeNoopComment ((v , "uniqueness check for %s" , pIdx -> zName ));
17201728 iThisCur = iIdxCur + ix ;
17211729
1722-
17231730 /* Skip partial indices for which the WHERE clause is not true */
17241731 if ( pIdx -> pPartIdxWhere ){
17251732 sqlite3VdbeAddOp2 (v , OP_Null , 0 , aRegIdx [ix ]);
@@ -1768,6 +1775,12 @@ void sqlite3GenerateConstraintChecks(
17681775 continue ;
17691776 }
17701777
1778+ /* Skip non-target indices */
1779+ if ( pUpIdx && pUpIdx != pIdx ) {
1780+ sqlite3VdbeResolveLabel (v , addrUniqueOk );
1781+ continue ;
1782+ }
1783+
17711784 /* Find out what action to take in case there is a uniqueness conflict */
17721785 onError = pIdx -> onError ;
17731786#if defined(SQLITE_BUILDING_FOR_COMDB2 )
0 commit comments