Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 99a9c90b5c | |||
| f7954140be | |||
| 48d046261a | |||
| df5e297ed8 | |||
| 1fa64dfbfa | |||
| ded6c1934e | |||
| 92ed5bd646 |
@@ -474,7 +474,7 @@ TESTOPTS = --verbose=file --output=test-out.txt
|
||||
|
||||
# Extra compiler options for various shell tools
|
||||
#
|
||||
SHELL_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5
|
||||
SHELL_OPT += -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5
|
||||
SHELL_OPT += -DSQLITE_ENABLE_EXPLAIN_COMMENTS
|
||||
SHELL_OPT += -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
|
||||
SHELL_OPT += -DSQLITE_ENABLE_STMTVTAB
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
C Change\sthe\s(machine-generated)\skeywordhash.h\sfile\sto\sincrease\sthe\sscope\sof\sthe\ntables\sused\sfor\skeyword\smatching,\sso\sthat\sthe\stables\sare\saccessible\sto\nfunctions\sother\sthen\skeywordCode().
|
||||
D 2017-07-06T16:33:14.765
|
||||
C Fix\san\sobsolete\scomment\son\sthe\ssqlite3_namelist()\sfunction\simplementation.
|
||||
D 2017-07-07T14:54:38.736
|
||||
F Makefile.in 081e48dfe7f995d57ce1a88ddf4d2917b4349158648a6cd45b42beae30de3a12
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc 4ebb1d257cac7fb1bcb4ba59278416d410ff1c4bf59447a9c37a415f3516056a
|
||||
@@ -372,7 +372,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f
|
||||
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
|
||||
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
|
||||
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
|
||||
F main.mk b57f019e6cd9d8770b019726c544098fe38f3b5db997d2af739352bbd7c7a14c
|
||||
F main.mk 0288de0e6b44c2fa709b354d4fab5bce423259cc1653c35305c6e50d23ec561a
|
||||
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
|
||||
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
|
||||
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
|
||||
@@ -407,7 +407,7 @@ F src/fkey.c 5ff2c895fe087756d8085dc1a9bc229b5670e2a65c3929dd87c71e43649af333
|
||||
F src/func.c 7647140a8624c66cc6e34bdf8005a92390253d6272e87c7901dc8065b563d435
|
||||
F src/global.c 8a6ab6b4d91effb96ffa81b39f0d70c862abca157f8aaa194600a4a8b7923344
|
||||
F src/hash.c a12580e143f10301ed5166ea4964ae2853d3905a511d4e0c44497245c7ce1f7a
|
||||
F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4
|
||||
F src/hash.h f650e8a7d2cc7585cb741246188ca5c96ed6b72aa1df4ede80f094ea6f2d7eee
|
||||
F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
|
||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||
F src/insert.c bb70abf32c7c926745eb550938db9132309584a667a44c2db0e5fa3207600391
|
||||
@@ -449,15 +449,15 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
|
||||
F src/resolve.c d1e69759e7a79c156c692793f5d16f82f9a60ce5e82efd95e4374b2423034946
|
||||
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
|
||||
F src/select.c c9f7b7196e196e93979665680d055a789938b8e025556097bf484b184c0dd576
|
||||
F src/shell.c a2b148e4ca8eb81b96e1050207c83d4a16ea6bf9182374faee4dd2a43628c291
|
||||
F src/sqlite.h.in 651cba56f8df64ff4418aa981cdfd5bc2d65e5fef95c1671f9826f1a164a5fa3
|
||||
F src/shell.c 6e1c9307c754a149409b6a517615a1f0673a299e2a5e47897b62f6cd28193e1b
|
||||
F src/sqlite.h.in 51170f66b6fe5ab8d74caf40a790ea738c34ec0ffc58fca49e00ecf3b070976c
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28
|
||||
F src/sqliteInt.h 7a7cd6f682471cce4afe64216f71fd64c622712aeb9d947c33c38337a7cf19a9
|
||||
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
|
||||
F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1
|
||||
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
|
||||
F src/tclsqlite.c 2c29b0b76e91edfd1b43bf135c32c8674710089197327682b6b7e6af88062c3d
|
||||
F src/tclsqlite.c c2390f9f84b036b1a8fbbec84eac924f4094bbf055531e878cd0a987d5464754
|
||||
F src/test1.c 1c0726cdf7389ed053a9b9aa0dc3c63f3b9bbc607a25decae6549682008510b3
|
||||
F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5
|
||||
F src/test3.c b8434949dfb8aff8dfa082c8b592109e77844c2135ed3c492113839b6956255b
|
||||
@@ -508,7 +508,7 @@ F src/test_windirent.c 17f91f5f2aa1bb7328abb49414c363b5d2a9d3ff
|
||||
F src/test_windirent.h 5d67483a55442e31e1bde0f4a230e6e932ad5906
|
||||
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
|
||||
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
|
||||
F src/tokenize.c 1003d6d90c6783206c711f0a9397656fa5b055209f4d092caa43bb3bf5215db5
|
||||
F src/tokenize.c d0700eb5615c38dc4dd0ad50c8243c3b89f6efcca14ea1527e5ec1c409b90b66
|
||||
F src/treeview.c 6cf8d7fe9e63fae57dad1bb57f6615e14eac0c527e43d868e805042cae8ed1f7
|
||||
F src/trigger.c d1cae560bfacc8bfb3a072d73658245c1714c0389097da69b4cb23877a082d7e
|
||||
F src/update.c c443935c652af9365e033f756550b5032d02e1b06eb2cb890ed7511ae0c051dc
|
||||
@@ -1628,7 +1628,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P efb4aab0caa4145732a5438cc2a193bc12c455b4007220564d240e75900ea8ad
|
||||
R 77ecc187246c1c337a58790c9818d2e8
|
||||
P 907fd3aab6205ac042d60c6455418a99b45efe954b3510597d54462cdbd12bfd
|
||||
R f10a1db0e6d806f6f5461a0acced2455
|
||||
U drh
|
||||
Z a448086e00aa693e2477a7bd0d12a0df
|
||||
Z a145f3b426efc1ed167334c57e8208b8
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
c5ed5ebdf660501fde7cc8aefaaaeae2a68e5899a64ac93f26684842a235281d
|
||||
f4229857a10d4f605ba67e18786c9ddf60be6c1c8a817631c40404adfdbb67cc
|
||||
+1
-1
@@ -91,6 +91,6 @@ void sqlite3HashClear(Hash*);
|
||||
/*
|
||||
** Number of entries in a hash table
|
||||
*/
|
||||
/* #define sqliteHashCount(H) ((H)->count) // NOT USED */
|
||||
#define sqliteHashCount(H) ((H)->count)
|
||||
|
||||
#endif /* SQLITE_HASH_H */
|
||||
|
||||
+63
@@ -3599,6 +3599,64 @@ static void open_db(ShellState *p, int keepAlive){
|
||||
}
|
||||
}
|
||||
|
||||
#if HAVE_READLINE || HAVE_EDITLINE
|
||||
/*
|
||||
** Readline completion callbacks
|
||||
*/
|
||||
static char *readline_completion_generator(const char *text, int state){
|
||||
static char **azCompletions = 0;
|
||||
static int iCompletion = 0;
|
||||
char *zRet;
|
||||
if( state==0 ){
|
||||
sqlite3_free(azCompletions);
|
||||
sqlite3_exec(globalDb, "PRAGMA page_count", 0, 0, 0); /* Load the schema */
|
||||
azCompletions = sqlite3_namelist(globalDb, text, -1, 0);
|
||||
iCompletion = 0;
|
||||
}
|
||||
zRet = azCompletions[iCompletion++];
|
||||
if( zRet==0 ){
|
||||
sqlite3_free(azCompletions);
|
||||
azCompletions = 0;
|
||||
}else{
|
||||
zRet = strdup(zRet);
|
||||
}
|
||||
return zRet;
|
||||
}
|
||||
static char **readline_completion(const char *zText, int iStart, int iEnd){
|
||||
rl_attempted_completion_over = 1;
|
||||
return rl_completion_matches(zText, readline_completion_generator);
|
||||
}
|
||||
|
||||
#elif HAVE_LINENOISE
|
||||
/*
|
||||
** Linenoise completion callback
|
||||
*/
|
||||
static void linenoise_completion(const char *zLine, linenoiseCompletions *lc){
|
||||
int nLine = (int)strlen(zLine);
|
||||
int i, n, iStart;
|
||||
char **az;
|
||||
char zBuf[1000];
|
||||
if( nLine>sizeof(zBuf)-30 ) return;
|
||||
if( zLine[0]=='.' ) return;
|
||||
for(i=nLine-1; i>=0 && (isalnum(zLine[i]) || zLine[i]=='_'); i--){}
|
||||
if( i==nLine-1 ) return;
|
||||
iStart = i+1;
|
||||
sqlite3_exec(globalDb, "PRAGMA page_count", 0, 0, 0); /* Load the schema */
|
||||
az = sqlite3_namelist(globalDb, &zLine[iStart], -1, &n);
|
||||
if( n>0 ){
|
||||
qsort(az, n, sizeof(az[0]),(int(*)(const void*,const void*))sqlite3_stricmp);
|
||||
memcpy(zBuf, zLine, iStart);
|
||||
for(i=0; az[i]; i++){
|
||||
n = (int)strlen(az[i]);
|
||||
if( iStart+n+1 >= sizeof(zBuf) ) continue;
|
||||
memcpy(zBuf+iStart, az[i], n+1);
|
||||
linenoiseAddCompletion(lc, zBuf);
|
||||
}
|
||||
}
|
||||
sqlite3_free(az);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Do C-language style dequoting.
|
||||
**
|
||||
@@ -7636,6 +7694,11 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
|
||||
}
|
||||
}
|
||||
if( zHistory ){ shell_read_history(zHistory); }
|
||||
#if HAVE_READLINE || HAVE_EDITLINE
|
||||
rl_attempted_completion_function = readline_completion;
|
||||
#elif HAVE_LINENOISE
|
||||
linenoiseSetCompletionCallback(linenoise_completion);
|
||||
#endif
|
||||
rc = process_input(&data, 0);
|
||||
if( zHistory ){
|
||||
shell_stifle_history(100);
|
||||
|
||||
@@ -8469,6 +8469,48 @@ int sqlite3_preupdate_depth(sqlite3 *);
|
||||
int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);
|
||||
#endif
|
||||
|
||||
/*
|
||||
** CAPI3REF: List Of Symbolic Names
|
||||
**
|
||||
** ^The sqlite3_namelist(D,P,F,N) interface returns a list of symbolic names
|
||||
** and keywords that might appear in valid SQL statements for [connection]
|
||||
** D and that all begin with the prefix P. ^The F parameter is a bitmask
|
||||
** that determines the kinds of symbolic names and keywords that are found
|
||||
** in the list. ^Matching against the prefix P is performed using
|
||||
** [sqlite3_strnicmp()] and is thus case insensitive for ASCII characters.
|
||||
** ^If the pointer N is not NULL, then the number of matching names is
|
||||
** stored in *N.
|
||||
**
|
||||
** ^The value returned by sqlite3_namelist() is stored in memory obtained
|
||||
** from [sqlite3_malloc()] and must be released by the caller using
|
||||
** [sqlite3_free()]. ^The sqlite3_namelist() interface returns NULL if a
|
||||
** memory allocation error occurs.
|
||||
**
|
||||
** ^Elements of the list are unique but are in no particular order.
|
||||
**
|
||||
** This interface is intended to facilitate tab-completion for interactive
|
||||
** interfaces for SQLite.
|
||||
*/
|
||||
char **sqlite3_namelist(sqlite3 *db, const char *zPrefix, int typeMask, int*);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Symbolic Name Typemask Values
|
||||
**
|
||||
** ^These bitmask values are used to determine the kinds of symbolic names
|
||||
** and keywords that are returned by [sqlite3_namelist()]. The third
|
||||
** parameter to [sqlite3_namelist()] should be an OR-ed combination of
|
||||
** one or more of the following value.
|
||||
*/
|
||||
#define SQLITE_NAMETYPE_KEYWORD 0x0001
|
||||
#define SQLITE_NAMETYPE_SCHEMA 0x0002
|
||||
#define SQLITE_NAMETYPE_TABLE 0x0004
|
||||
#define SQLITE_NAMETYPE_INDEX 0x0008
|
||||
#define SQLITE_NAMETYPE_TRIGGER 0x0010
|
||||
#define SQLITE_NAMETYPE_FUNCTION 0x0020
|
||||
#define SQLITE_NAMETYPE_MODULE 0x0040
|
||||
#define SQLITE_NAMETYPE_COLLATION 0x0080
|
||||
#define SQLITE_NAMETYPE_COLUMN 0x0100
|
||||
|
||||
/*
|
||||
** CAPI3REF: Low-level system error code
|
||||
**
|
||||
|
||||
+42
-15
@@ -1850,14 +1850,13 @@ static int SQLITE_TCLAPI DbObjCmd(
|
||||
"complete", "copy", "enable_load_extension",
|
||||
"errorcode", "eval", "exists",
|
||||
"function", "incrblob", "interrupt",
|
||||
"last_insert_rowid", "nullvalue", "onecolumn",
|
||||
"preupdate", "profile", "progress",
|
||||
"rekey", "restore", "rollback_hook",
|
||||
"status", "timeout", "total_changes",
|
||||
"trace", "trace_v2", "transaction",
|
||||
"unlock_notify", "update_hook", "version",
|
||||
"wal_hook",
|
||||
0
|
||||
"last_insert_rowid", "namelist", "nullvalue",
|
||||
"onecolumn", "preupdate", "profile",
|
||||
"progress", "rekey", "restore",
|
||||
"rollback_hook", "status", "timeout",
|
||||
"total_changes", "trace", "trace_v2",
|
||||
"transaction", "unlock_notify", "update_hook",
|
||||
"version", "wal_hook", 0
|
||||
};
|
||||
enum DB_enum {
|
||||
DB_AUTHORIZER, DB_BACKUP, DB_BUSY,
|
||||
@@ -1866,13 +1865,13 @@ static int SQLITE_TCLAPI DbObjCmd(
|
||||
DB_COMPLETE, DB_COPY, DB_ENABLE_LOAD_EXTENSION,
|
||||
DB_ERRORCODE, DB_EVAL, DB_EXISTS,
|
||||
DB_FUNCTION, DB_INCRBLOB, DB_INTERRUPT,
|
||||
DB_LAST_INSERT_ROWID, DB_NULLVALUE, DB_ONECOLUMN,
|
||||
DB_PREUPDATE, DB_PROFILE, DB_PROGRESS,
|
||||
DB_REKEY, DB_RESTORE, DB_ROLLBACK_HOOK,
|
||||
DB_STATUS, DB_TIMEOUT, DB_TOTAL_CHANGES,
|
||||
DB_TRACE, DB_TRACE_V2, DB_TRANSACTION,
|
||||
DB_UNLOCK_NOTIFY, DB_UPDATE_HOOK, DB_VERSION,
|
||||
DB_WAL_HOOK,
|
||||
DB_LAST_INSERT_ROWID, DB_NAMELIST, DB_NULLVALUE,
|
||||
DB_ONECOLUMN, DB_PREUPDATE, DB_PROFILE,
|
||||
DB_PROGRESS, DB_REKEY, DB_RESTORE,
|
||||
DB_ROLLBACK_HOOK, DB_STATUS, DB_TIMEOUT,
|
||||
DB_TOTAL_CHANGES, DB_TRACE, DB_TRACE_V2,
|
||||
DB_TRANSACTION, DB_UNLOCK_NOTIFY, DB_UPDATE_HOOK,
|
||||
DB_VERSION, DB_WAL_HOOK,
|
||||
};
|
||||
/* don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler */
|
||||
|
||||
@@ -2665,6 +2664,34 @@ static int SQLITE_TCLAPI DbObjCmd(
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
** $db namelist PREFIX MASK
|
||||
*/
|
||||
case DB_NAMELIST: {
|
||||
const char *zPrefix;
|
||||
int mask;
|
||||
char **azList;
|
||||
int nList, i;
|
||||
if( objc!=4 ){
|
||||
Tcl_WrongNumArgs(interp, 2, objv, "PREFIX MASK");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
zPrefix = Tcl_GetString(objv[2]);
|
||||
if( Tcl_GetIntFromObj(interp, objv[3], &mask) ) return TCL_ERROR;
|
||||
azList = sqlite3_namelist(pDb->db, zPrefix, mask, &nList);
|
||||
if( azList ){
|
||||
Tcl_Obj *pList = Tcl_NewListObj(nList, 0);
|
||||
for(i=0; azList[i]; i++){
|
||||
Tcl_ListObjAppendElement(interp, pList,
|
||||
Tcl_NewStringObj(azList[i],-1));
|
||||
}
|
||||
assert( i==nList );
|
||||
sqlite3_free(azList);
|
||||
Tcl_SetObjResult(interp, pList);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
** $db nullvalue ?STRING?
|
||||
**
|
||||
|
||||
+149
@@ -614,3 +614,152 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
|
||||
assert( nErr==0 || pParse->rc!=SQLITE_OK );
|
||||
return nErr;
|
||||
}
|
||||
|
||||
/* An instance of the following object is used to accumulate a list
|
||||
** of names for the sqlite3_namelist() interface
|
||||
*/
|
||||
struct NameAccum {
|
||||
Hash x; /* Hash table of all names */
|
||||
const char *zPrefix; /* All names must start with this prefix */
|
||||
int nPrefix; /* Size of the prefix in bytes */
|
||||
};
|
||||
|
||||
/*
|
||||
** Examine zName to see if it belongs on the list (if it has a matching
|
||||
** prefix) and add it to the list if it belongs. nName is the length
|
||||
** of the name in bytes, or -1 if zName is zero-terminated.
|
||||
*/
|
||||
static void addName(struct NameAccum *p, const char *zName, int nName){
|
||||
char *zCopy;
|
||||
char *zOld;
|
||||
if( nName<0 ) nName = sqlite3Strlen30(zName);
|
||||
if( nName<p->nPrefix ) return;
|
||||
if( sqlite3StrNICmp(p->zPrefix, zName, p->nPrefix)!=0 ) return;
|
||||
zCopy = sqlite3_mprintf("%.*s", nName, zName);
|
||||
zOld = sqlite3HashInsert(&p->x, zCopy, zCopy);
|
||||
sqlite3_free(zOld);
|
||||
}
|
||||
|
||||
/*
|
||||
** Return a list of text words or identifiers that might appear in an
|
||||
** SQL statement. The typeMask parameter is a bitmask that determines
|
||||
** specifically what kinds of names should be returned. All names
|
||||
** returned must begin with zPrefix.
|
||||
**
|
||||
** The returned list is from a single memory allocation. The caller owns
|
||||
** the allocation and should release it using sqlite3_free() when it has
|
||||
** finished using the list.
|
||||
**
|
||||
** The returned list is an array of pointers to strings. The list is
|
||||
** terminated by a single NULL pointer.
|
||||
*/
|
||||
char **sqlite3_namelist(
|
||||
sqlite3 *db, /* Database from which to extract names */
|
||||
const char *zPrefix, /* Only extract names matching this prefix */
|
||||
int typeMask, /* Mask of the types of names to extract */
|
||||
int *pCount /* Write the number of names here */
|
||||
){
|
||||
struct NameAccum x;
|
||||
int i, n, nEntry;
|
||||
HashElem *j;
|
||||
char **azAns;
|
||||
char *zFree;
|
||||
x.zPrefix = zPrefix;
|
||||
x.nPrefix = sqlite3Strlen30(zPrefix);
|
||||
sqlite3HashInit(&x.x);
|
||||
if( typeMask & SQLITE_NAMETYPE_KEYWORD ){
|
||||
for(i=0; i<ArraySize(aKWOffset); i++){
|
||||
addName(&x, zKWText + aKWOffset[i], aKWLen[i]);
|
||||
}
|
||||
}
|
||||
if( typeMask & SQLITE_NAMETYPE_FUNCTION ){
|
||||
for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){
|
||||
FuncDef *p;
|
||||
for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash){
|
||||
addName(&x, p->zName, -1);
|
||||
}
|
||||
}
|
||||
for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){
|
||||
FuncDef *p = (FuncDef*)sqliteHashData(j);
|
||||
addName(&x, p->zName, -1);
|
||||
}
|
||||
}
|
||||
if( typeMask & SQLITE_NAMETYPE_COLLATION ){
|
||||
for(j=sqliteHashFirst(&db->aCollSeq); j; j=sqliteHashNext(j)){
|
||||
CollSeq *p = (CollSeq*)sqliteHashData(j);
|
||||
addName(&x, p->zName, -1);
|
||||
}
|
||||
}
|
||||
if( typeMask & SQLITE_NAMETYPE_MODULE ){
|
||||
for(j=sqliteHashFirst(&db->aModule); j; j=sqliteHashNext(j)){
|
||||
Module *p = (Module*)sqliteHashData(j);
|
||||
addName(&x, p->zName, -1);
|
||||
}
|
||||
}
|
||||
if( typeMask & (SQLITE_NAMETYPE_SCHEMA|
|
||||
SQLITE_NAMETYPE_TABLE|
|
||||
SQLITE_NAMETYPE_INDEX|
|
||||
SQLITE_NAMETYPE_TRIGGER|
|
||||
SQLITE_NAMETYPE_COLUMN) ){
|
||||
int iDb;
|
||||
for(iDb=0; iDb<db->nDb; iDb++){
|
||||
Db *pDb = &db->aDb[iDb];
|
||||
if( typeMask & SQLITE_NAMETYPE_SCHEMA ){
|
||||
addName(&x, pDb->zDbSName, -1);
|
||||
}
|
||||
if( typeMask & (SQLITE_NAMETYPE_TABLE|SQLITE_NAMETYPE_COLUMN) ){
|
||||
for(j=sqliteHashFirst(&pDb->pSchema->tblHash); j; j=sqliteHashNext(j)){
|
||||
Table *p = (Table*)sqliteHashData(j);
|
||||
if( typeMask & SQLITE_NAMETYPE_TABLE ){
|
||||
addName(&x, p->zName, -1);
|
||||
}
|
||||
if( typeMask & SQLITE_NAMETYPE_COLUMN ){
|
||||
int k;
|
||||
for(k=0; k<p->nCol; k++){
|
||||
addName(&x, p->aCol[k].zName, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( typeMask & SQLITE_NAMETYPE_INDEX ){
|
||||
for(j=sqliteHashFirst(&pDb->pSchema->idxHash); j; j=sqliteHashNext(j)){
|
||||
Index *p = (Index*)sqliteHashData(j);
|
||||
addName(&x, p->zName, -1);
|
||||
}
|
||||
}
|
||||
if( typeMask & SQLITE_NAMETYPE_TRIGGER ){
|
||||
for(j=sqliteHashFirst(&pDb->pSchema->trigHash); j; j=sqliteHashNext(j)){
|
||||
Trigger *p = (Trigger*)sqliteHashData(j);
|
||||
addName(&x, p->zName, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if( typeMask & SQLITE_NAMETYPE_COLUMN ){
|
||||
addName(&x, "rowid", -1);
|
||||
}
|
||||
}
|
||||
nEntry = sqliteHashCount(&x.x);
|
||||
if( pCount ) *pCount = nEntry;
|
||||
n = 0;
|
||||
for(j=sqliteHashFirst(&x.x); j; j=sqliteHashNext(j)){
|
||||
n += sqlite3Strlen30((const char*)sqliteHashData(j));
|
||||
}
|
||||
zFree = sqlite3_malloc( (nEntry+1)*sizeof(char*) + n + nEntry );
|
||||
azAns = (char**)zFree;
|
||||
if( zFree ){
|
||||
memset(zFree, 0, (nEntry+1)*sizeof(char*) + n + nEntry );
|
||||
zFree += (nEntry+1)*sizeof(char*);
|
||||
for(i=0, j=sqliteHashFirst(&x.x); j; i++, j=sqliteHashNext(j)){
|
||||
const char *zName = (const char*)sqliteHashData(j);
|
||||
azAns[i] = zFree;
|
||||
n = sqlite3Strlen30(zName);
|
||||
memcpy(zFree, zName, n+1);
|
||||
zFree += n+1;
|
||||
}
|
||||
}
|
||||
for(j=sqliteHashFirst(&x.x); j; j=sqliteHashNext(j)){
|
||||
sqlite3_free(sqliteHashData(j));
|
||||
}
|
||||
sqlite3HashClear(&x.x);
|
||||
return azAns;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user