aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/alter.c9
-rw-r--r--src/build.c18
2 files changed, 12 insertions, 15 deletions
diff --git a/src/alter.c b/src/alter.c
index 0ca68c04f..5780d2df0 100644
--- a/src/alter.c
+++ b/src/alter.c
@@ -135,9 +135,7 @@ void sqlite3AlterRenameTable(
const char *zTabName; /* Original name of the table */
Vdbe *v;
VTable *pVTab = 0; /* Non-zero if this is a v-tab with an xRename() */
- u32 savedDbFlags; /* Saved value of db->mDbFlags */
- savedDbFlags = db->mDbFlags;
if( NEVER(db->mallocFailed) ) goto exit_rename_table;
assert( pSrc->nSrc==1 );
assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );
@@ -146,7 +144,6 @@ void sqlite3AlterRenameTable(
if( !pTab ) goto exit_rename_table;
iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
zDb = db->aDb[iDb].zDbSName;
- db->mDbFlags |= DBFLAG_PreferBuiltin;
/* Get a NULL terminated version of the new table name. */
zName = sqlite3NameFromToken(db, pName);
@@ -287,7 +284,6 @@ void sqlite3AlterRenameTable(
exit_rename_table:
sqlite3SrcListDelete(db, pSrc);
sqlite3DbFree(db, zName);
- db->mDbFlags = savedDbFlags;
}
/*
@@ -408,11 +404,9 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);
if( zCol ){
char *zEnd = &zCol[pColDef->n-1];
- u32 savedDbFlags = db->mDbFlags;
while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){
*zEnd-- = '\0';
}
- db->mDbFlags |= DBFLAG_PreferBuiltin;
/* substr() operations on characters, but addColOffset is in bytes. So we
** have to use printf() to translate between these units: */
assert( !IsVirtual(pTab) );
@@ -425,7 +419,6 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
zTab
);
sqlite3DbFree(db, zCol);
- db->mDbFlags = savedDbFlags;
}
v = sqlite3GetVdbe(pParse);
@@ -1506,7 +1499,7 @@ static void renameColumnFunc(
sqlite3WalkSelect(&sWalker, pSelect);
}
if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
- }else if( IsOrdinaryTable(sParse.pNewTable) ){
+ }else if( ALWAYS(IsOrdinaryTable(sParse.pNewTable)) ){
/* A regular table */
int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName);
FKey *pFKey;
diff --git a/src/build.c b/src/build.c
index 10a15189b..a0d164336 100644
--- a/src/build.c
+++ b/src/build.c
@@ -285,20 +285,22 @@ void sqlite3FinishCoding(Parse *pParse){
/*
** Run the parser and code generator recursively in order to generate
** code for the SQL statement given onto the end of the pParse context
-** currently under construction. When the parser is run recursively
-** this way, the final OP_Halt is not appended and other initialization
-** and finalization steps are omitted because those are handling by the
-** outermost parser.
+** currently under construction. Notes:
**
-** Not everything is nestable. This facility is designed to permit
-** INSERT, UPDATE, and DELETE operations against the schema table. Use
-** care if you decide to try to use this routine for some other purposes.
+** * The final OP_Halt is not appended and other initialization
+** and finalization steps are omitted because those are handling by the
+** outermost parser.
+**
+** * Built-in SQL functions always take precedence over application-defined
+** SQL functions. In other words, it is not possible to override a
+** built-in function.
*/
void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
va_list ap;
char *zSql;
char *zErrMsg = 0;
sqlite3 *db = pParse->db;
+ u32 savedDbFlags = db->mDbFlags;
char saveBuf[PARSE_TAIL_SZ];
if( pParse->nErr ) return;
@@ -317,7 +319,9 @@ void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
pParse->nested++;
memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ);
memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);
+ db->mDbFlags |= DBFLAG_PreferBuiltin;
sqlite3RunParser(pParse, zSql, &zErrMsg);
+ db->mDbFlags = savedDbFlags;
sqlite3DbFree(db, zErrMsg);
sqlite3DbFree(db, zSql);
memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ);