-C fix\slinking\sfailure\son\sOS/2\sthat\shappens\swith\sthe\samalgamation\sand\sthe\shigh\smemory\soption\senabled\s(CVS\s4110)
-D 2007-06-22T20:17:38
+C When\sexpanding\s'*'\sin\sthe\sresult\sset\sof\sa\sSELECT,\squote\sthe\sexpanded\sidentifiers.\sFix\sfor\s#2450.\s(CVS\s4111)
+D 2007-06-24T06:32:18
F Makefile.in 7f7485a4cc039476a42e534b3f26ec90e2f9753e
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/parse.y ad2ce25665be7f7303137f774a4e3e72e0d036ff
F src/pragma.c 0d25dad58bdfd6789943a10f1b9663c2eb85b96d
F src/prepare.c 87c23644986b5e41a58bc76f05abebd899e00089
-F src/printf.c deaef57ea97557b8b53313d5c793fa4236036a0e
+F src/printf.c 9b3048d270e8bb2f8b910b491ac3aadece6cfab2
F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
-F src/select.c 33a258fc9c9dccb28ae2d3a02f1e1148d6433148
+F src/select.c 2ee53f929fe3755a35de1fb937f22e2e60f7d3e5
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c 4b0fc3c76a9f23a1c963e01703c0fbbca1b5c34d
F src/sqlite.h.in 6f290b660b2e7c3359968bb4b344ec31a1178746
F test/tkt2339.test 7016415bda86af1406a27260ac46f44885617606
F test/tkt2391.test ab7a11be7402da8b51a5be603425367aa0684567
F test/tkt2409.test f130054aedff681883466ad04332bd3f7db51a02
+F test/tkt2450.test 77ed94863f2049c1420288ddfea2d41e5e0971d6
F test/trace.test 75ffc1b992c780d054748a656e3e7fd674f18567
F test/trans.test 9e6e7b886ea8093239801b5af0981ff784d9c541
F test/trigger1.test b361161cf20614024cc1e52ea0bdec250776b2ae
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 12327ca049e62922bfb3c2a14e42554fd58265e8
-R c4f5686bdc00846759c01fbdffa7f82b
-U pweilbacher
-Z bbe405d266119d64ef43df21e50d3180
+P f35e20e19633d7b114fdf145820ca5d61b5aa925
+R 0028662710d587da4e5d82de686d252d
+U danielk1977
+Z 13d4831b99a0601e7fdfc2a1c76b4c67
-f35e20e19633d7b114fdf145820ca5d61b5aa925
\ No newline at end of file
+d5b7224f37db1729dd042d48765d7a79247e1bde
\ No newline at end of file
#define etTOKEN 13 /* a pointer to a Token structure */
#define etSRCLIST 14 /* a pointer to a SrcList */
#define etPOINTER 15 /* The %p conversion */
+#define etSQLESCAPE3 16 /* %w -> Strings with '\"' doubled */
/*
{ 'z', 0, 6, etDYNSTRING, 0, 0 },
{ 'q', 0, 4, etSQLESCAPE, 0, 0 },
{ 'Q', 0, 4, etSQLESCAPE2, 0, 0 },
+ { 'w', 0, 4, etSQLESCAPE3, 0, 0 },
{ 'c', 0, 0, etCHARX, 0, 0 },
{ 'o', 8, 0, etRADIX, 0, 2 },
{ 'u', 10, 0, etRADIX, 0, 0 },
if( precision>=0 && precision<length ) length = precision;
break;
case etSQLESCAPE:
- case etSQLESCAPE2: {
+ case etSQLESCAPE2:
+ case etSQLESCAPE3: {
int i, j, n, ch, isnull;
int needQuote;
+ char q = ((xtype==etSQLESCAPE3)?'"':'\''); /* Quote character */
char *escarg = va_arg(ap,char*);
isnull = escarg==0;
if( isnull ) escarg = (xtype==etSQLESCAPE2 ? "NULL" : "(NULL)");
for(i=n=0; (ch=escarg[i])!=0; i++){
- if( ch=='\'' ) n++;
+ if( ch==q ) n++;
}
needQuote = !isnull && xtype==etSQLESCAPE2;
n += i + 1 + needQuote*2;
bufpt = buf;
}
j = 0;
- if( needQuote ) bufpt[j++] = '\'';
+ if( needQuote ) bufpt[j++] = q;
for(i=0; (ch=escarg[i])!=0; i++){
bufpt[j++] = ch;
- if( ch=='\'' ) bufpt[j++] = ch;
+ if( ch==q ) bufpt[j++] = ch;
}
- if( needQuote ) bufpt[j++] = '\'';
+ if( needQuote ) bufpt[j++] = q;
bufpt[j] = 0;
length = j;
/* The precision is ignored on %q and %Q */
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
-** $Id: select.c,v 1.351 2007/06/15 15:31:50 drh Exp $
+** $Id: select.c,v 1.352 2007/06/24 06:32:18 danielk1977 Exp $
*/
#include "sqliteInt.h"
p->dyn = 0;
}
+/*
+** Set the token to the double-quoted and escaped version of the string pointed
+** to by z. For example;
+**
+** {a"bc} -> {"a""bc"}
+*/
+static void setQuotedToken(Token *p, const char *z){
+ p->z = (u8 *)sqlite3MPrintf("\"%w\"", z);
+ p->dyn = 1;
+ if( p->z ){
+ p->n = strlen((char *)p->z);
+ }
+}
+
/*
** Create an expression node for an identifier with the name of zName
*/
}
pRight = sqlite3Expr(TK_ID, 0, 0, 0);
if( pRight==0 ) break;
- setToken(&pRight->token, zName);
+ setQuotedToken(&pRight->token, zName);
if( zTabName && (longNames || pTabList->nSrc>1) ){
Expr *pLeft = sqlite3Expr(TK_ID, 0, 0, 0);
pExpr = sqlite3Expr(TK_DOT, pLeft, pRight, 0);
if( pExpr==0 ) break;
- setToken(&pLeft->token, zTabName);
+ setQuotedToken(&pLeft->token, zTabName);
setToken(&pExpr->span, sqlite3MPrintf("%s.%s", zTabName, zName));
pExpr->span.dyn = 1;
pExpr->token.z = 0;
}else{
pExpr = pRight;
pExpr->span = pExpr->token;
+ pExpr->span.dyn = 0;
}
if( longNames ){
pNew = sqlite3ExprListAppend(pNew, pExpr, &pExpr->span);
sqlite3ErrorMsg(pParse, "too many columns in result set");
rc = SQLITE_ERROR;
}
+ if( sqlite3MallocFailed() ){
+ rc = SQLITE_NOMEM;
+ }
return rc;
}
--- /dev/null
+# 2007 June 24
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file is to test that ticket #2450 has been fixed.
+#
+# $Id: tkt2450.test,v 1.1 2007/06/24 06:32:18 danielk1977 Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt2450-1 {
+ execsql {
+ CREATE TABLE "t a" ("""cb""");
+ INSERT INTO "t a" ("""cb""") VALUES (1);
+ SELECT """cb""" FROM "t a";
+ }
+} {1}
+
+do_test tkt2450-2 {
+ execsql {
+ SELECT * FROM "t a";
+ }
+} {1}
+
+do_test tkt2450-3 {
+ execsql {
+ SELECT "t a".* FROM "t a";
+ }
+} {1}
+
+do_test tkt2450-3 {
+ execsql {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(2);
+ SELECT * FROM "t a", t1;
+ }
+} {1 2}
+
+finish_test