mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-14 09:58:17 +00:00
sync up our in tree sqlite with the 3.3.13 official release. Commit to follow to finish this process on the windows build.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4351 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -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.268 2006/08/24 15:18:25 drh Exp $
|
||||
** $Id: expr.c,v 1.275 2007/02/07 13:09:46 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <ctype.h>
|
||||
@@ -49,6 +49,24 @@ char sqlite3ExprAffinity(Expr *pExpr){
|
||||
return pExpr->affinity;
|
||||
}
|
||||
|
||||
/*
|
||||
** Set the collating sequence for expression pExpr to be the collating
|
||||
** sequence named by pToken. Return a pointer to the revised expression.
|
||||
** The collating sequence is marked as "explicit" using the EP_ExpCollate
|
||||
** flag. An explicit collating sequence will override implicit
|
||||
** collating sequences.
|
||||
*/
|
||||
Expr *sqlite3ExprSetColl(Parse *pParse, Expr *pExpr, Token *pName){
|
||||
CollSeq *pColl;
|
||||
if( pExpr==0 ) return 0;
|
||||
pColl = sqlite3LocateCollSeq(pParse, (char*)pName->z, pName->n);
|
||||
if( pColl ){
|
||||
pExpr->pColl = pColl;
|
||||
pExpr->flags |= EP_ExpCollate;
|
||||
}
|
||||
return pExpr;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the default collation sequence for the expression pExpr. If
|
||||
** there is no default collation type, return 0.
|
||||
@@ -158,9 +176,20 @@ static int binaryCompareP1(Expr *pExpr1, Expr *pExpr2, int jumpIfNull){
|
||||
** type.
|
||||
*/
|
||||
static CollSeq* binaryCompareCollSeq(Parse *pParse, Expr *pLeft, Expr *pRight){
|
||||
CollSeq *pColl = sqlite3ExprCollSeq(pParse, pLeft);
|
||||
if( !pColl ){
|
||||
pColl = sqlite3ExprCollSeq(pParse, pRight);
|
||||
CollSeq *pColl;
|
||||
assert( pLeft );
|
||||
assert( pRight );
|
||||
if( pLeft->flags & EP_ExpCollate ){
|
||||
assert( pLeft->pColl );
|
||||
pColl = pLeft->pColl;
|
||||
}else if( pRight->flags & EP_ExpCollate ){
|
||||
assert( pRight->pColl );
|
||||
pColl = pRight->pColl;
|
||||
}else{
|
||||
pColl = sqlite3ExprCollSeq(pParse, pLeft);
|
||||
if( !pColl ){
|
||||
pColl = sqlite3ExprCollSeq(pParse, pRight);
|
||||
}
|
||||
}
|
||||
return pColl;
|
||||
}
|
||||
@@ -205,8 +234,18 @@ Expr *sqlite3Expr(int op, Expr *pLeft, Expr *pRight, const Token *pToken){
|
||||
if( pToken ){
|
||||
assert( pToken->dyn==0 );
|
||||
pNew->span = pNew->token = *pToken;
|
||||
}else if( pLeft && pRight ){
|
||||
sqlite3ExprSpan(pNew, &pLeft->span, &pRight->span);
|
||||
}else if( pLeft ){
|
||||
if( pRight ){
|
||||
sqlite3ExprSpan(pNew, &pLeft->span, &pRight->span);
|
||||
if( pRight->flags && EP_ExpCollate ){
|
||||
pNew->flags |= EP_ExpCollate;
|
||||
pNew->pColl = pRight->pColl;
|
||||
}
|
||||
}
|
||||
if( pLeft->flags && EP_ExpCollate ){
|
||||
pNew->flags |= EP_ExpCollate;
|
||||
pNew->pColl = pLeft->pColl;
|
||||
}
|
||||
}
|
||||
return pNew;
|
||||
}
|
||||
@@ -890,23 +929,26 @@ static int lookupName(
|
||||
/* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */
|
||||
pExpr->iColumn = j==pTab->iPKey ? -1 : j;
|
||||
pExpr->affinity = pTab->aCol[j].affinity;
|
||||
pExpr->pColl = sqlite3FindCollSeq(db, ENC(db), zColl,-1, 0);
|
||||
if( pItem->jointype & JT_NATURAL ){
|
||||
/* If this match occurred in the left table of a natural join,
|
||||
** then skip the right table to avoid a duplicate match */
|
||||
pItem++;
|
||||
i++;
|
||||
if( (pExpr->flags & EP_ExpCollate)==0 ){
|
||||
pExpr->pColl = sqlite3FindCollSeq(db, ENC(db), zColl,-1, 0);
|
||||
}
|
||||
if( (pUsing = pItem->pUsing)!=0 ){
|
||||
/* If this match occurs on a column that is in the USING clause
|
||||
** of a join, skip the search of the right table of the join
|
||||
** to avoid a duplicate match there. */
|
||||
int k;
|
||||
for(k=0; k<pUsing->nId; k++){
|
||||
if( sqlite3StrICmp(pUsing->a[k].zName, zCol)==0 ){
|
||||
pItem++;
|
||||
i++;
|
||||
break;
|
||||
if( i<pSrcList->nSrc-1 ){
|
||||
if( pItem[1].jointype & JT_NATURAL ){
|
||||
/* If this match occurred in the left table of a natural join,
|
||||
** then skip the right table to avoid a duplicate match */
|
||||
pItem++;
|
||||
i++;
|
||||
}else if( (pUsing = pItem[1].pUsing)!=0 ){
|
||||
/* If this match occurs on a column that is in the USING clause
|
||||
** of a join, skip the search of the right table of the join
|
||||
** to avoid a duplicate match there. */
|
||||
int k;
|
||||
for(k=0; k<pUsing->nId; k++){
|
||||
if( sqlite3StrICmp(pUsing->a[k].zName, zCol)==0 ){
|
||||
pItem++;
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -945,7 +987,9 @@ static int lookupName(
|
||||
cnt++;
|
||||
pExpr->iColumn = iCol==pTab->iPKey ? -1 : iCol;
|
||||
pExpr->affinity = pTab->aCol[iCol].affinity;
|
||||
pExpr->pColl = sqlite3FindCollSeq(db, ENC(db), zColl,-1, 0);
|
||||
if( (pExpr->flags & EP_ExpCollate)==0 ){
|
||||
pExpr->pColl = sqlite3FindCollSeq(db, ENC(db), zColl,-1, 0);
|
||||
}
|
||||
pExpr->pTab = pTab;
|
||||
break;
|
||||
}
|
||||
@@ -1045,7 +1089,7 @@ static int lookupName(
|
||||
n = sizeof(Bitmask)*8-1;
|
||||
}
|
||||
assert( pMatch->iCursor==pExpr->iTable );
|
||||
pMatch->colUsed |= 1<<n;
|
||||
pMatch->colUsed |= ((Bitmask)1)<<n;
|
||||
}
|
||||
|
||||
lookupname_end:
|
||||
@@ -1180,7 +1224,7 @@ static int nameResolverStep(void *pArg, Expr *pExpr){
|
||||
}else{
|
||||
is_agg = pDef->xFunc==0;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_AUTHORIZER
|
||||
#ifndef SQLITE_OMIT_AUTHORIZATION
|
||||
if( pDef ){
|
||||
auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0);
|
||||
if( auth!=SQLITE_OK ){
|
||||
@@ -2207,6 +2251,7 @@ static int analyzeAggregate(void *pArg, Expr *pExpr){
|
||||
|
||||
|
||||
switch( pExpr->op ){
|
||||
case TK_AGG_COLUMN:
|
||||
case TK_COLUMN: {
|
||||
/* Check to see if the column is in one of the tables in the FROM
|
||||
** clause of the aggregate query */
|
||||
|
Reference in New Issue
Block a user