diff options
author | drh <> | 2025-03-05 18:18:17 +0000 |
---|---|---|
committer | drh <> | 2025-03-05 18:18:17 +0000 |
commit | bee4fb401eb2b8ef7138b3cea2a53b4e12f5e2ed (patch) | |
tree | e7f8197f898cc6ab70143395f5e0f7e4d4c285b3 /src | |
parent | c27c61586f632c7942afed5443a55126c01d0f01 (diff) | |
download | sqlite-bee4fb401eb2b8ef7138b3cea2a53b4e12f5e2ed.tar.gz sqlite-bee4fb401eb2b8ef7138b3cea2a53b4e12f5e2ed.zip |
Always ignore comments in the schema of a database, even if
SQLITE_DBCONFIG_ENABLE_COMMENTS is turned off.
FossilOrigin-Name: 373ae3f4de526c636c35db03d6b5c84526d6f144c1c3bebcbb257e52f563a203
Diffstat (limited to 'src')
-rw-r--r-- | src/alter.c | 7 | ||||
-rw-r--r-- | src/tokenize.c | 6 | ||||
-rw-r--r-- | src/vacuum.c | 2 |
3 files changed, 12 insertions, 3 deletions
diff --git a/src/alter.c b/src/alter.c index 819257166..f3108cbf9 100644 --- a/src/alter.c +++ b/src/alter.c @@ -1136,6 +1136,7 @@ static int renameParseSql( int bTemp /* True if SQL is from temp schema */ ){ int rc; + u64 flags; sqlite3ParseObjectInit(p, db); if( zSql==0 ){ @@ -1154,7 +1155,11 @@ static int renameParseSql( p->eParseMode = PARSE_MODE_RENAME; p->db = db; p->nQueryLoop = 1; + flags = db->flags; + testcase( (db->flags & SQLITE_Comments)==0 && strstr(zSql," /* ")!=0 ); + db->flags |= SQLITE_Comments; rc = sqlite3RunParser(p, zSql); + db->flags = flags; if( db->mallocFailed ) rc = SQLITE_NOMEM; if( rc==SQLITE_OK && NEVER(p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0) @@ -2050,7 +2055,7 @@ static void renameTableTest( u64 flags = db->flags; if( bNoDQS ) db->flags &= ~(SQLITE_DqsDML|SQLITE_DqsDDL); rc = renameParseSql(&sParse, zDb, db, zInput, bTemp); - db->flags |= (flags & (SQLITE_DqsDML|SQLITE_DqsDDL)); + db->flags = flags; if( rc==SQLITE_OK ){ if( isLegacy==0 && sParse.pNewTable && IsView(sParse.pNewTable) ){ NameContext sNC; diff --git a/src/tokenize.c b/src/tokenize.c index fe300ca52..e4d9f5371 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -692,7 +692,11 @@ int sqlite3RunParser(Parse *pParse, const char *zSql){ assert( n==6 ); tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed); #endif /* SQLITE_OMIT_WINDOWFUNC */ - }else if( tokenType==TK_COMMENT && (db->flags & SQLITE_Comments)!=0 ){ + }else if( tokenType==TK_COMMENT + && (db->init.busy || (db->flags & SQLITE_Comments)!=0) + ){ + /* Ignore SQL comments if either (1) we are reparsing the schema or + ** (2) SQLITE_DBCONFIG_ENABLE_COMMENTS is turned on (the default). */ zSql += n; continue; }else if( tokenType!=TK_QNUMBER ){ diff --git a/src/vacuum.c b/src/vacuum.c index e203f68c6..ae3af86b7 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -195,7 +195,7 @@ SQLITE_NOINLINE int sqlite3RunVacuum( saved_nChange = db->nChange; saved_nTotalChange = db->nTotalChange; saved_mTrace = db->mTrace; - db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks; + db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_Comments; db->mDbFlags |= DBFLAG_PreferBuiltin | DBFLAG_Vacuum; db->flags &= ~(u64)(SQLITE_ForeignKeys | SQLITE_ReverseOrder | SQLITE_Defensive | SQLITE_CountRows); |