For infix functions (LIKE, GLOB, REGEXP, and MATCH) treat the left

operand as the first argument for the purposes of virtual table
function overloading, even though the left operand is really the
the second argument. (CVS 3324)

FossilOrigin-Name: 6e98373ca11c9d476f4c6b1841c6e006b7a49f29
This commit is contained in:
drh 2006-07-08 18:34:59 +00:00
parent e94b0c3920
commit 6a03a1c5f7
6 changed files with 40 additions and 20 deletions

View File

@ -1,5 +1,5 @@
C Add\stests\sand\sminor\sfixes\sto\sthe\sxFindFunction\smethod\sof\svirtual\stables.\s(CVS\s3323)
D 2006-07-08T18:09:15
C For\sinfix\sfunctions\s(LIKE,\sGLOB,\sREGEXP,\sand\sMATCH)\streat\sthe\sleft\noperand\sas\sthe\sfirst\sargument\sfor\sthe\spurposes\sof\svirtual\stable\nfunction\soverloading,\seven\sthough\sthe\sleft\soperand\sis\sreally\sthe\nthe\ssecond\sargument.\s(CVS\s3324)
D 2006-07-08T18:35:00
F Makefile.in 9c2a76055c305868cc5f5b73e29a252ff3632c0a
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -42,7 +42,7 @@ F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e
F src/delete.c 804384761144fe1a5035b99f4bd7d706976831bd
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
F src/expr.c acfc181c473ec87e332de04f60a1e8beaa5df877
F src/expr.c 3bd41e5aa93b3575e803eecedca80f4581aac791
F src/func.c f357a81bcdd83684cb198a8ad96be1c21e29f85c
F src/hash.c 449f3d6620193aa557f5d86cbc5cc6b87702b185
F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
@ -64,7 +64,7 @@ F src/os_win.c c6976ae50b61fb5b7dce399e578aa1865f02b84f
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c 2ae998a64f98bc2fa14893e08537365865a09519
F src/pager.h 43f32f3847421f7502cfbb66f4eb2302b8033818
F src/parse.y e0831a269fbbd21414bb367fd0b806569c934683
F src/parse.y 438e0f9408427a3f1776cd6f55771f3d43ff29b4
F src/pragma.c 27d5e395c5d950931c7ac4fe610e7c2993e2fa55
F src/prepare.c e477df44112e3ce167f048226432fca9d9cba6a0
F src/printf.c b179b6ed12f793e028dd169e2e2e2b2a37eedc63
@ -74,7 +74,7 @@ F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c 359551ab5cdd8f8fe5f3fe170fd330b108b08d7d
F src/sqlite.h.in 432848ac7f8d7e6fea727668acccec62bdd86cc4
F src/sqlite3ext.h c611255287e9a11ce4f1fe6251c2a0b9d32a828b
F src/sqliteInt.h ea16faa3efec989f82b8ef778aca2867440cb817
F src/sqliteInt.h 434b530013bd3093faa7c1c1a5817df81616f6ec
F src/table.c d8817f43a6c6bf139487db161760b9e1e02da3f1
F src/tclsqlite.c 0220791dc66d287a7f199568393f04f3db24364b
F src/test1.c 535294d7f21a4127082c4f7a57f225482df9cc36
@ -293,7 +293,7 @@ F test/vacuum.test 37f998b841cb335397c26d9bbc3457182af2565f
F test/vacuum2.test 5aea8c88a65cb29f7d175296e7c819c6158d838c
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
F test/view.test 16e2774fe35e47a07ac4471b7f0bcc948b1aa6d5
F test/vtab1.test 21df0e83d84833e3be632f9abcc21a841e9e2dd1
F test/vtab1.test c794695b32fe9428ef1087281374e2a1e6044df2
F test/vtab2.test bd6d6f3dc0403f42a63a63e3319e0a689d27dd4f
F test/vtab3.test f38d6d7d19f08bffdadce4d5b8cba078f8118587
F test/vtab4.test 4b4293341443839ef6dc02f8d9e614702a6c67ff
@ -375,7 +375,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P 12cc7af4b6b8b4f1a43d962fbafde8cba683a907
R 2fab828be3eb12f68e21ff1288415845
P 3c4233e074cb016e2422b2e8f867c99217e9b10e
R 80b3dd37ffe8ba579a452291981999c6
U drh
Z 993e9850eaafb9f5a52c01a397f141bb
Z f07a93792e01a08c48f4070b7ca89738

View File

@ -1 +1 @@
3c4233e074cb016e2422b2e8f867c99217e9b10e
6e98373ca11c9d476f4c6b1841c6e006b7a49f29

View File

@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.263 2006/07/08 17:06:44 drh Exp $
** $Id: expr.c,v 1.264 2006/07/08 18:35:00 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -1675,7 +1675,16 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){
assert( pDef!=0 );
nExpr = sqlite3ExprCodeExprList(pParse, pList);
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( nExpr>0 ){
if( nExpr>=2 && (pExpr->flags & EP_InfixFunc) ){
/* For infix functions GLOB, LIKE, REGEXP, and MATCH, check
** the second argument to the function which is operand to
** left of the function name. Users normally consider the
** left operand to be the first argument, even though it is
** really the second argument to the underlying function. */
pDef = sqlite3VtabOverloadFunction(pDef, nExpr, pList->a[1].pExpr);
}else if( nExpr>0 ){
/* For normal functions, go by the first argument - the first
** argument after the "(" that follows the function name */
pDef = sqlite3VtabOverloadFunction(pDef, nExpr, pList->a[0].pExpr);
}
#endif

View File

@ -14,7 +14,7 @@
** the parser. Lemon will also generate a header file containing
** numeric codes for all of the tokens.
**
** @(#) $Id: parse.y,v 1.204 2006/06/16 08:01:04 danielk1977 Exp $
** @(#) $Id: parse.y,v 1.205 2006/07/08 18:35:00 drh Exp $
*/
// All token codes are small integers with #defines that begin with "TK_"
@ -706,6 +706,7 @@ expr(A) ::= expr(X) likeop(OP) expr(Y) escape(E). [LIKE_KW] {
A = sqlite3ExprFunction(pList, &OP.eOperator);
if( OP.not ) A = sqlite3Expr(TK_NOT, A, 0, 0);
sqlite3ExprSpan(A, &X->span, &Y->span);
if( A ) A->flags |= EP_InfixFunc;
}
expr(A) ::= expr(X) ISNULL|NOTNULL(E). {

View File

@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.518 2006/07/08 17:06:44 drh Exp $
** @(#) $Id: sqliteInt.h,v 1.519 2006/07/08 18:35:00 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@ -988,7 +988,7 @@ struct AggInfo {
struct Expr {
u8 op; /* Operation performed by this node */
char affinity; /* The affinity of the column or 0 if not a column */
u8 flags; /* Various flags. See below */
u16 flags; /* Various flags. See below */
CollSeq *pColl; /* The collation type of the column or 0 */
Expr *pLeft, *pRight; /* Left and right subnodes */
ExprList *pList; /* A list of expressions used as function arguments
@ -1016,6 +1016,7 @@ struct Expr {
#define EP_Distinct 0x10 /* Aggregate function with DISTINCT keyword */
#define EP_VarSelect 0x20 /* pSelect is correlated, not constant */
#define EP_Dequoted 0x40 /* True if the string has been dequoted */
#define EP_InfixFunc 0x80 /* True for an infix function: LIKE, GLOB, etc */
/*
** These macros can be used to test, set, or clear bits in the

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is creating and dropping virtual tables.
#
# $Id: vtab1.test,v 1.34 2006/07/08 18:09:15 drh Exp $
# $Id: vtab1.test,v 1.35 2006/07/08 18:35:00 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -848,14 +848,23 @@ proc ::echo_glob_overload {a b} {
}
do_test vtab1.11-2 {
execsql {
SELECT a like b FROM e
SELECT a like 'b' FROM e
}
} {0 0}
do_test vtab1.11-3 {
execsql {
SELECT a glob b FROM e
SELECT a glob '2' FROM e
}
} {{1 ?} {2 3}}
} {{1 2} {2 2}}
do_test vtab1.11-4 {
execsql {
SELECT glob('2',a) FROM e
}
} {0 1}
do_test vtab1.11-5 {
execsql {
SELECT glob(a,'2') FROM e
}
} {{2 1} {2 2}}
finish_test