/ Check-in [b266924b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:In setQuotedToken(), only make a malloced copy if the argument contains one or more " characters. (CVS 4941)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b266924b8975b69bdb9ab45cf462e41436f89cc2
User & Date: danielk1977 2008-03-31 17:41:18
Context
2008-03-31
18:19
Factor constant subexpressions out of loops. (CVS 4942) check-in: 2126db39 user: drh tags: trunk
17:41
In setQuotedToken(), only make a malloced copy if the argument contains one or more " characters. (CVS 4941) check-in: b266924b user: danielk1977 tags: trunk
2008-03-29
23:25
Minor cleanup: Use size_t for struct size cast (CVS 4940) check-in: 618df68b user: mlcreech tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/select.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
201
202
203
204
205
206
207














208
209
210
211


212
213




214
215
216
217
218
219
220
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.422 2008/03/27 17:59:02 danielk1977 Exp $
*/
#include "sqliteInt.h"


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
................................................................................
/*
** 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(Parse *pParse, Token *p, const char *z){














  p->z = (u8 *)sqlite3MPrintf(0, "\"%w\"", z);
  p->dyn = 1;
  if( p->z ){
    p->n = strlen((char *)p->z);


  }else{
    pParse->db->mallocFailed = 1;




  }
}

/*
** Create an expression node for an identifier with the name of zName
*/
Expr *sqlite3CreateIdExpr(Parse *pParse, const char *zName){







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
|
|
>
>

<
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222

223
224
225
226
227

228
229
230
231
232
233
234
235
236
237
238
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.423 2008/03/31 17:41:18 danielk1977 Exp $
*/
#include "sqliteInt.h"


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
................................................................................
/*
** 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(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.
  */
  const char *z2 = z;
  while( *z2 ){
    if( *z2=='"' ) break;
    z2++;
  }

  if( *z2 ){
    /* String contains " characters - copy and quote the string. */
    p->z = (u8 *)sqlite3MPrintf(pParse->db, "\"%w\"", z);

    if( p->z ){
      p->n = strlen((char *)p->z);
      p->dyn = 1;
    }
  }else{

    /* String contains no " characters - copy the pointer. */
    p->z = (u8*)z;
    p->n = (z2 - z);
    p->dyn = 0;
  }
}

/*
** Create an expression node for an identifier with the name of zName
*/
Expr *sqlite3CreateIdExpr(Parse *pParse, const char *zName){