SQLite

Check-in [32982067]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Ignore differences in Expr.op2 in sqlite3ExprCompare() in cases where it does not matter. Ticket [1d2a8efc6c3a595a].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 329820673a12ff6a6c8759f40989d4ccf272441064b0366a5f491695b55ad0e9
User & Date: drh 2019-10-31 13:16:26
Original Comment: Ignore differences in Expr.op2 in sqlite3ExprCompare() in cases where it does matter. Ticket [1d2a8efc6c3a595a].
Context
2019-10-31
17:13
Add a few simple TCL test cases for generated columns. (Full test coverage of the generated column logic is provided separately by TH3.) (check-in: acedb5c7 user: drh tags: trunk)
13:16
Ignore differences in Expr.op2 in sqlite3ExprCompare() in cases where it does not matter. Ticket [1d2a8efc6c3a595a]. (check-in: 32982067 user: drh tags: trunk)
12:30
Enhance the TreeView logic to show information about Expr.op2 for FUNCTION and COLUMN nodes. (check-in: aceeaf9e user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/expr.c.

5024
5025
5026
5027
5028
5029
5030
5031














5032
5033
5034
5035
5036
5037
5038
    if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
    if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
    if( pA->op!=TK_STRING
     && pA->op!=TK_TRUEFALSE
     && (combinedFlags & EP_Reduced)==0
    ){
      if( pA->iColumn!=pB->iColumn ) return 2;
      if( pA->op2!=pB->op2 && (pA->op!=TK_FUNCTION || iTab<0) ) return 2;














      if( pA->op!=TK_IN && pA->iTable!=pB->iTable && pA->iTable!=iTab ){
        return 2;
      }
    }
  }
  return 0;
}







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>







5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
    if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
    if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
    if( pA->op!=TK_STRING
     && pA->op!=TK_TRUEFALSE
     && (combinedFlags & EP_Reduced)==0
    ){
      if( pA->iColumn!=pB->iColumn ) return 2;
      if( pA->op2!=pB->op2 ){
        if( pA->op==TK_TRUTH ) return 2;
        if( pA->op==TK_FUNCTION && iTab<0 ){
          /* Ex: CREATE TABLE t1(a CHECK( a<julianday('now') ));
          **     INSERT INTO t1(a) VALUES(julianday('now')+10);
          ** Without this test, sqlite3ExprCodeAtInit() will run on the
          ** the julianday() of INSERT first, and remember that expression.
          ** Then sqlite3ExprCodeInit() will see the julianday() in the CHECK
          ** constraint as redundant, reusing the one from the INSERT, even
          ** though the julianday() in INSERT lacks the critical NC_IsCheck
          ** flag.  See ticket [830277d9db6c3ba1] (2019-10-30)
          */
          return 2;
        }
      }
      if( pA->op!=TK_IN && pA->iTable!=pB->iTable && pA->iTable!=iTab ){
        return 2;
      }
    }
  }
  return 0;
}

Added test/gencol1.test.























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# 2019-10-31
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# 
# Test cases for generated columns.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# ticket 830277d9db6c3ba1 on 2019-10-31
do_execsql_test gencol1-100 {
  CREATE TABLE t0(c0 AS(TYPEOF(c1)), c1);
  INSERT INTO t0(c1) VALUES(0);
  CREATE TABLE t1(x AS (typeof(y)), y);
  INSERT INTO t1 SELECT * FROM t0;
  SELECT * FROM t1;
} {integer 0}

finish_test