1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-08 03:22:21 +03:00

Add the {quote: StrAccum} object

for accumulating strings.  Revamp xprintf to use
the new object.  Rewrite the group_concat() function to use the new object.
Productize and test the group_concat() function. (CVS 4578)

FossilOrigin-Name: 221aee72be040769e8026b91648f03c6366a8821
This commit is contained in:
drh
2007-11-28 22:36:40 +00:00
parent 26b7994a97
commit ade8648301
8 changed files with 231 additions and 179 deletions

View File

@@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.620 2007/11/27 02:38:01 drh Exp $
** @(#) $Id: sqliteInt.h,v 1.621 2007/11/28 22:36:41 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@@ -363,6 +363,7 @@ typedef struct NameContext NameContext;
typedef struct Parse Parse;
typedef struct Select Select;
typedef struct SrcList SrcList;
typedef struct StrAccum StrAccum;
typedef struct Table Table;
typedef struct TableLock TableLock;
typedef struct Token Token;
@@ -1573,6 +1574,20 @@ struct DbFixer {
const Token *pName; /* Name of the container - used for error messages */
};
/*
** An objected used to accumulate the text of a string where we
** do not necessarily know how big the string will be in the end.
*/
struct StrAccum {
char *zBase; /* A base allocation. Not from malloc. */
char *zText; /* The string collected so far */
int nChar; /* Length of the string so far */
int nAlloc; /* Amount of space allocated in zText */
u8 mallocFailed; /* Becomes true if any memory allocation fails */
u8 useMalloc; /* True if zText is enlargable using realloc */
u8 tooBig; /* Becomes true if string size exceeds limits */
};
/*
** A pointer to this structure is used to communicate information
** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback.
@@ -1879,6 +1894,10 @@ int sqlite3ApiExit(sqlite3 *db, int);
void sqlite3AbortOtherActiveVdbes(sqlite3 *, Vdbe *);
int sqlite3OpenTempDatabase(Parse *);
void sqlite3StrAccumAppend(StrAccum*,const char*,int);
char *sqlite3StrAccumFinish(StrAccum*);
void sqlite3StrAccumReset(StrAccum*);
/*
** The interface to the LEMON-generated parser