mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Fix a bug with explicit collation sequences attached to a column reference expression that is on the right-hand-side of a binary comparison operator. (CVS 4187)
FossilOrigin-Name: 7b69968618bfc19f0c1ab25c5f16c9fdff5af094
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
||||
C Test\sthat\san\sexplicit\scollation\ssequence\soverrides\san\simplicit\sone\sattached\sto\sa\s'new'\sreference\s(it\sdoes).\sNo\scode\schanges.\s(CVS\s4186)
|
||||
D 2007-07-26T10:16:30
|
||||
C Fix\sa\sbug\swith\sexplicit\scollation\ssequences\sattached\sto\sa\scolumn\sreference\sexpression\sthat\sis\son\sthe\sright-hand-side\sof\sa\sbinary\scomparison\soperator.\s(CVS\s4187)
|
||||
D 2007-07-30T14:40:48
|
||||
F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
|
||||
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@@ -149,7 +149,7 @@ F src/vdbeblob.c bb30b3e387c35ba869949494b2736aff97159470
|
||||
F src/vdbefifo.c 3ca8049c561d5d67cbcb94dc909ae9bb68c0bf8f
|
||||
F src/vdbemem.c ca4d3994507cb0a9504820293af69f5c778b4abd
|
||||
F src/vtab.c 60dc6d881c3049ec0e9f780e6beb953dbd78673d
|
||||
F src/where.c 12387641659605318ae03d87f0687f223dfc9568
|
||||
F src/where.c c7e13b81ff8777e402d047a695fbf322e67c89e1
|
||||
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
|
||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||
F test/all.test 56bc526a6cbb262c5b678dd606de8c92ae39705e
|
||||
@@ -200,7 +200,7 @@ F test/collate2.test 701d9651c5707024fd86a20649af9ea55e2c0eb8
|
||||
F test/collate3.test 947a77f5b8227e037a7094d0e338a5504f155cc4
|
||||
F test/collate4.test daf498e294dcd596b961d425c3f2dda117e4717e
|
||||
F test/collate5.test 8fb4e7e0241839356bd8710f437c32efb47bfff8
|
||||
F test/collate6.test c747a7a09bddbd8004555344a4a44927c0cd13ab
|
||||
F test/collate6.test 8be65a182abaac8011a622131486dafb8076e907
|
||||
F test/collate7.test e23677b1fd271505302643a98178952bb65b6f21
|
||||
F test/collate8.test 7ed2461305ac959886a064dc1e3cf15e155a183f
|
||||
F test/colmeta.test 6505c73ab58796afcb7c89ba9f429d573fbc6e53
|
||||
@@ -523,7 +523,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
||||
P b88af1827bec3e8a32450dd0a073ffc3b12a5939
|
||||
R 5056595a62d026054125efdb6ec1cdbf
|
||||
P a443b07ed659223401ee7acaf613d0b04f33fc89
|
||||
R 458aee226dfdf7a5afbe0d8e6376ba28
|
||||
U danielk1977
|
||||
Z 03f5264ace9236f38e705bca5549a9ae
|
||||
Z 5c9d36c082816d37f3d3ebee8a2c3d87
|
||||
|
@@ -1 +1 @@
|
||||
a443b07ed659223401ee7acaf613d0b04f33fc89
|
||||
7b69968618bfc19f0c1ab25c5f16c9fdff5af094
|
14
src/where.c
14
src/where.c
@@ -16,7 +16,7 @@
|
||||
** so is applicable. Because this module is responsible for selecting
|
||||
** indices, you might also think of this module as the "query optimizer".
|
||||
**
|
||||
** $Id: where.c,v 1.253 2007/06/11 12:56:15 drh Exp $
|
||||
** $Id: where.c,v 1.254 2007/07/30 14:40:48 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -383,10 +383,22 @@ static int allowedOp(int op){
|
||||
/*
|
||||
** Commute a comparision operator. Expressions of the form "X op Y"
|
||||
** are converted into "Y op X".
|
||||
**
|
||||
** If a collation sequence is associated with either the left or right
|
||||
** side of the comparison, it remains associated with the same side after
|
||||
** the commutation. So "Y collate NOCASE op X" becomes
|
||||
** "X collate NOCASE op Y". This is because any collation sequence on
|
||||
** the left hand side of a comparison overrides any collation sequence
|
||||
** attached to the right. For the same reason the EP_ExpCollate flag
|
||||
** is not commuted.
|
||||
*/
|
||||
static void exprCommute(Expr *pExpr){
|
||||
u16 expRight = (pExpr->pRight->flags & EP_ExpCollate);
|
||||
u16 expLeft = (pExpr->pLeft->flags & EP_ExpCollate);
|
||||
assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );
|
||||
SWAP(CollSeq*,pExpr->pRight->pColl,pExpr->pLeft->pColl);
|
||||
pExpr->pRight->flags = (pExpr->pRight->flags & ~EP_ExpCollate) | expLeft;
|
||||
pExpr->pLeft->flags = (pExpr->pLeft->flags & ~EP_ExpCollate) | expRight;
|
||||
SWAP(Expr*,pExpr->pRight,pExpr->pLeft);
|
||||
if( pExpr->op>=TK_GT ){
|
||||
assert( TK_LT==TK_GT+2 );
|
||||
|
@@ -12,7 +12,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is collation sequences in concert with triggers.
|
||||
#
|
||||
# $Id: collate6.test,v 1.3 2007/07/26 10:16:30 danielk1977 Exp $
|
||||
# $Id: collate6.test,v 1.4 2007/07/30 14:40:48 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -136,5 +136,18 @@ do_test collate6-2.3 {
|
||||
}
|
||||
} {}
|
||||
|
||||
# At one point the 6-3.2 (but not 6-3.1) was causing an assert() to fail.
|
||||
#
|
||||
do_test collate6-3.1 {
|
||||
execsql {
|
||||
SELECT 1 FROM sqlite_master WHERE name COLLATE nocase = 'hello';
|
||||
}
|
||||
} {}
|
||||
do_test collate6-3.2 {
|
||||
execsql {
|
||||
SELECT 1 FROM sqlite_master WHERE 'hello' = name COLLATE nocase;
|
||||
}
|
||||
} {}
|
||||
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user