@@ -223,6 +223,18 @@ int fuzz_invariant(
223
223
return SQLITE_OK ;
224
224
}
225
225
226
+ #ifdef SQLITE_ALLOW_ROWID_IN_VIEW
227
+ /*
228
+ ** Return TRUE if the i-th column of pStmt might be a ROWID value.
229
+ */
230
+ static int column_might_be_rowid (sqlite3_stmt * pStmt , int i ){
231
+ const char * zColName = sqlite3_column_name (pStmt , i );
232
+ if ( sqlite3_strlike ("%rowid%" ,zColName ,0 )== 0 ) return 1 ;
233
+ if ( sqlite3_strlike ("%oid%" ,zColName ,0 )== 0 ) return 1 ;
234
+ return 0 ;
235
+ }
236
+ #endif /* SQLITE_ALLOW_ROWID_IN_VIEW */
237
+
226
238
227
239
/*
228
240
** Generate SQL used to test a statement invariant.
@@ -297,9 +309,7 @@ static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){
297
309
continue ;
298
310
}
299
311
#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
300
- if ( sqlite3_strlike ("%rowid%" ,zColName ,0 )== 0
301
- || sqlite3_strlike ("%oid%" ,zColName ,0 )== 0
302
- ){
312
+ if ( column_might_be_rowid (pBase ,i ) ){
303
313
/* ROWID values are unreliable if SQLITE_ALLOW_ROWID_IN_VIEW is used */
304
314
continue ;
305
315
}
@@ -332,6 +342,11 @@ static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){
332
342
333
343
/*
334
344
** Return true if and only if v1 and is the same as v2.
345
+ **
346
+ ** When compiled with SQLITE_ALLOW_ROWID_IN_VIEW, and if either
347
+ ** v1 or v2 has a column name that indicates that it is a rowid
348
+ ** then a NULL value in the rowid column will compare equal to
349
+ ** an integer value in the other.
335
350
*/
336
351
static int sameValue (
337
352
sqlite3_stmt * pS1 , int i1 , /* Value to text on the left */
@@ -346,6 +361,20 @@ static int sameValue(
346
361
|| (t1 == SQLITE_FLOAT && t2 == SQLITE_INTEGER )
347
362
){
348
363
/* Comparison of numerics is ok */
364
+ #ifdef SQLITE_ALLOW_ROWID_IN_VIEW
365
+ }else
366
+ if ( t1 == SQLITE_INTEGER
367
+ && t2 == SQLITE_NULL
368
+ && column_might_be_rowid (pS2 ,i2 )
369
+ ){
370
+ return 1 ;
371
+ }else
372
+ if ( t2 == SQLITE_INTEGER
373
+ && t1 == SQLITE_NULL
374
+ && column_might_be_rowid (pS1 ,i1 )
375
+ ){
376
+ return 1 ;
377
+ #endif /* SQLITE_ALLOW_ROWID_IN_VIEW */
349
378
}else {
350
379
return 0 ;
351
380
}
0 commit comments