aboutsummaryrefslogtreecommitdiff
path: root/src/select.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2008-09-13 01:20:14 +0000
committerdrh <drh@noemail.net>2008-09-13 01:20:14 +0000
commitf018cc2ef0aff505f598406bf7a2050df2630c3a (patch)
tree9e0b7d3130a71be068381cc5b47553e8b6fc3bb0 /src/select.c
parent8578611b951e7cf6402f24712c4ae5ffcc6072f2 (diff)
downloadsqlite-f018cc2ef0aff505f598406bf7a2050df2630c3a.tar.gz
sqlite-f018cc2ef0aff505f598406bf7a2050df2630c3a.zip
Fix issues with bizarrely quoted column names. Tickets #3370, #3371,
and #3372. (CVS 5696) FossilOrigin-Name: ced6bbd228b4a324ddb9c5ff15fd027811c8806a
Diffstat (limited to 'src/select.c')
-rw-r--r--src/select.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/select.c b/src/select.c
index f616c1bd9..e9d0abdcd 100644
--- a/src/select.c
+++ b/src/select.c
@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
-** $Id: select.c,v 1.472 2008/09/01 15:52:11 drh Exp $
+** $Id: select.c,v 1.473 2008/09/13 01:20:15 drh Exp $
*/
#include "sqliteInt.h"
@@ -204,15 +204,17 @@ static void setToken(Token *p, const char *z){
*/
static void setQuotedToken(Parse *pParse, Token *p, const char *z){
- /* Check if the string contains any " characters. If it does, then
- ** this function will malloc space to create a quoted version of
- ** the string in. Otherwise, save a call to sqlite3MPrintf() by
- ** just copying the pointer to the string.
+ /* Check if the string appears to be quoted using "..." or `...`
+ ** or [...] or '...' or if the string contains any " characters.
+ ** If it does, then record a version of the string with the special
+ ** characters escaped.
*/
const char *z2 = z;
- while( *z2 ){
- if( *z2=='"' ) break;
- z2++;
+ if( *z2!='[' && *z2!='`' && *z2!='\'' ){
+ while( *z2 ){
+ if( *z2=='"' ) break;
+ z2++;
+ }
}
if( *z2 ){
@@ -1078,7 +1080,7 @@ static void generateColumnNames(
if( pEList->a[i].zName ){
char *zName = pEList->a[i].zName;
sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, strlen(zName));
- }else if( p->op==TK_COLUMN && pTabList ){
+ }else if( (p->op==TK_COLUMN || p->op==TK_AGG_COLUMN) && pTabList ){
Table *pTab;
char *zCol;
int iCol = p->iColumn;