File: 41-fix_a_bug_in_the_NOT_NULL-IS_NULL_optimization.patch

package info (click to toggle)
sqlite3 3.40.1-2%2Bdeb12u2
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 148,736 kB
  • sloc: ansic: 270,747; tcl: 18,931; sh: 11,416; javascript: 8,930; yacc: 1,613; makefile: 1,521; cpp: 440; cs: 307; sql: 45
file content (58 lines) | stat: -rw-r--r-- 2,000 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Index: sqlite3/src/expr.c
==================================================================
--- sqlite3/src/expr.c
+++ sqlite3/src/expr.c
@@ -5279,15 +5279,15 @@
     case TK_ISNULL:
     case TK_NOTNULL: {
       assert( TK_ISNULL==OP_IsNull );   testcase( op==TK_ISNULL );
       assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );
       r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
-      sqlite3VdbeTypeofColumn(v, r1);
+      assert( regFree1==0 || regFree1==r1 );
+      if( regFree1 ) sqlite3VdbeTypeofColumn(v, r1);
       sqlite3VdbeAddOp2(v, op, r1, dest);
       VdbeCoverageIf(v, op==TK_ISNULL);
       VdbeCoverageIf(v, op==TK_NOTNULL);
-      testcase( regFree1==0 );
       break;
     }
     case TK_BETWEEN: {
       testcase( jumpIfNull==0 );
       exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfTrue, jumpIfNull);
@@ -5454,15 +5454,15 @@
       break;
     }
     case TK_ISNULL:
     case TK_NOTNULL: {
       r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
-      sqlite3VdbeTypeofColumn(v, r1);
+      assert( regFree1==0 || regFree1==r1 );
+      if( regFree1 ) sqlite3VdbeTypeofColumn(v, r1);
       sqlite3VdbeAddOp2(v, op, r1, dest);
       testcase( op==TK_ISNULL );   VdbeCoverageIf(v, op==TK_ISNULL);
       testcase( op==TK_NOTNULL );  VdbeCoverageIf(v, op==TK_NOTNULL);
-      testcase( regFree1==0 );
       break;
     }
     case TK_BETWEEN: {
       testcase( jumpIfNull==0 );
       exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfFalse, jumpIfNull);

Index: sqlite3/src/vdbe.c
==================================================================
--- sqlite3/src/vdbe.c
+++ sqlite3/src/vdbe.c
@@ -3545,10 +3545,11 @@
       }
     }else{
       zHdr += sqlite3PutVarint(zHdr, serial_type);
       if( pRec->n ){
         assert( pRec->z!=0 );
+        assert( pRec->z!=(const char*)sqlite3CtypeMap );
         memcpy(zPayload, pRec->z, pRec->n);
         zPayload += pRec->n;
       }
     }
     if( pRec==pLast ) break;