SQLite

Check-in [54110870]
Login

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

Overview
Comment:Avoid transforming TK_COLLATE or TK_UNLIKELY Expr nodes to TK_REFERENCE. Instead, transform the uppermost Expr node in the expression tree that is not of this type. Fix for [e1e07ef2].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 54110870487f78013ab1b554413c18baa2bdc07d979bc65c110f32d30c3b53fe
User & Date: drh 2019-06-16 14:56:41
References
2019-07-17
13:36 New ticket [1be72aab] CHECK constraint using COLLATE with CASE or BETWEEN. (artifact: 50f9f11e user: drh)
Context
2019-06-17
14:13
New sqlite3_db_config() options: SQLITE_DBCONFIG_LEGACY_ALTER_TABLE, SQLITE_DBCONFIG_DQS_DML, and SQLITE_DBCONFIG_DQS_DDL. (check-in: a61db8ff user: drh tags: trunk)
2019-06-16
14:56
Avoid transforming TK_COLLATE or TK_UNLIKELY Expr nodes to TK_REFERENCE. Instead, transform the uppermost Expr node in the expression tree that is not of this type. Fix for [e1e07ef2]. (check-in: 54110870 user: drh tags: trunk)
08:58
Avoid transforming TK_COLLATE or TK_UNLIKELY Expr nodes to TK_REFERENCE. Instead, transform the uppermost Expr node in the expression tree that is not of this type. Fix for [e1e07ef2]. (Closed-Leaf check-in: ba7870e2 user: dan tags: tkt-e1e07ef2)
2019-06-15
15:32
Fix minor problems in the test code in test_demovfs.c. (check-in: ca4ddfef user: dan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/expr.c.

3383
3384
3385
3386
3387
3388
3389
3390

3391
3392
3393
3394
3395
3396
3397
}

/*
** Convert a scalar expression node to a TK_REGISTER referencing
** register iReg.  The caller must ensure that iReg already contains
** the correct value for the expression.
*/
static void exprToRegister(Expr *p, int iReg){

  p->op2 = p->op;
  p->op = TK_REGISTER;
  p->iTable = iReg;
  ExprClearProperty(p, EP_Skip);
}

/*







|
>







3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
}

/*
** Convert a scalar expression node to a TK_REGISTER referencing
** register iReg.  The caller must ensure that iReg already contains
** the correct value for the expression.
*/
static void exprToRegister(Expr *pExpr, int iReg){
  Expr *p = sqlite3ExprSkipCollate(pExpr);
  p->op2 = p->op;
  p->op = TK_REGISTER;
  p->iTable = iReg;
  ExprClearProperty(p, EP_Skip);
}

/*

Changes to test/between.test.

115
116
117
118
119
120
121




















122
123
} {4 2 25 27 sort t1 i1zyx}
do_test between-1.5.3 {
  queryplan {
    SELECT * FROM t1 WHERE 26 BETWEEN y AND +z ORDER BY +w
  }
} {4 2 25 27 sort t1 *}






















finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
} {4 2 25 27 sort t1 i1zyx}
do_test between-1.5.3 {
  queryplan {
    SELECT * FROM t1 WHERE 26 BETWEEN y AND +z ORDER BY +w
  }
} {4 2 25 27 sort t1 *}

#-------------------------------------------------------------------------
reset_db
do_execsql_test between-2.0 {
  CREATE TABLE t1(x TEXT, y TEXT COLLATE nocase);
  INSERT INTO t1 VALUES('0', 'abc');
}

foreach {tn expr res} {
  1 "x                BETWEEN 1 AND '5'" 0
  2 "x COLLATE binary BETWEEN 1 AND '5'" 0
  3 "x COLLATE nocase BETWEEN 1 AND '5'" 0

  4 "y                  BETWEEN 'A' AND 'B'" 1
  5 "y COLLATE nocase   BETWEEN 'A' AND 'B'" 1
  6 "y COLLATE binary   BETWEEN 'A' AND 'B'" 0
  7 "(y COLLATE binary) BETWEEN 'A' AND 'B'" 0
} {
  set sql "SELECT $expr FROM t1"
  do_execsql_test between-2.1.$tn $sql $res
}

finish_test