diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/alter.c | 20 | ||||
-rw-r--r-- | src/build.c | 33 | ||||
-rw-r--r-- | src/vdbe.c | 5 |
3 files changed, 28 insertions, 30 deletions
diff --git a/src/alter.c b/src/alter.c index 6758315d1..77109c783 100644 --- a/src/alter.c +++ b/src/alter.c @@ -12,7 +12,7 @@ ** This file contains C code routines that used to generate VDBE code ** that implements the ALTER TABLE command. ** -** $Id: alter.c,v 1.12 2005/12/16 01:06:17 drh Exp $ +** $Id: alter.c,v 1.13 2005/12/21 14:43:12 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -385,7 +385,6 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ char *zCol; /* Null-terminated column definition */ Column *pCol; /* The new column */ Expr *pDflt; /* Default value for the new column */ - Vdbe *v; if( pParse->nErr ) return; pNew = pParse->pNewTable; @@ -469,23 +468,6 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ } /* -** Generate code to make sure the file format number is at least minFormat. -** The generated code will increase the file format number if necessary. -*/ -void sqlite3MinimumFileFormat(Parse *pParse, int iDb, int minFormat){ - Vdbe *v; - v = sqlite3GetVdbe(pParse); - if( v ){ - sqlite3VdbeAddOp(v, OP_ReadCookie, iDb, 1); - sqlite3VdbeAddOp(v, OP_Integer, minFormat, 0); - sqlite3VdbeAddOp(v, OP_Ge, 0, sqlite3VdbeCurrentAddr(v)+3); - sqlite3VdbeAddOp(v, OP_Integer, minFormat, 0); - sqlite3VdbeAddOp(v, OP_SetCookie, iDb, 1); - } -} - - -/* ** This function is called by the parser after the table-name in ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument ** pSrc is the full-name of the table being altered. diff --git a/src/build.c b/src/build.c index f771fb689..297478197 100644 --- a/src/build.c +++ b/src/build.c @@ -22,7 +22,7 @@ ** COMMIT ** ROLLBACK ** -** $Id: build.c,v 1.359 2005/12/21 03:16:43 drh Exp $ +** $Id: build.c,v 1.360 2005/12/21 14:43:12 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -2259,12 +2259,8 @@ void sqlite3CreateIndex( /* Check to see if we should honor DESC requests on index columns */ - if( pDb->file_format>=4 || (pDb->descIndex && db->init.busy) ){ -#if 0 + if( pDb->file_format>=4 || (!pDb->descIndex && !db->init.busy) ){ sortOrderMask = -1; /* Honor DESC */ -#else - sortOrderMask = 0; -#endif }else{ sortOrderMask = 0; /* Ignore DESC */ } @@ -2396,10 +2392,6 @@ void sqlite3CreateIndex( v = sqlite3GetVdbe(pParse); if( v==0 ) goto exit_create_index; - /* Make sure the file_format is at least 4 if we have DESC indices. */ - if( descSeen ){ - sqlite3MinimumFileFormat(pParse, iDb, 4); - } /* Create the rootpage for the index */ @@ -2407,6 +2399,11 @@ void sqlite3CreateIndex( sqlite3VdbeAddOp(v, OP_CreateIndex, iDb, 0); sqlite3VdbeAddOp(v, OP_MemStore, iMem, 0); + /* Make sure the file_format is at least 4 if we have DESC indices. */ + if( descSeen ){ + sqlite3MinimumFileFormat(pParse, iDb, 4); + } + /* Gather the complete text of the CREATE INDEX statement into ** the zStmt variable */ @@ -2479,6 +2476,22 @@ exit_create_index: } /* +** Generate code to make sure the file format number is at least minFormat. +** The generated code will increase the file format number if necessary. +*/ +void sqlite3MinimumFileFormat(Parse *pParse, int iDb, int minFormat){ + Vdbe *v; + v = sqlite3GetVdbe(pParse); + if( v ){ + sqlite3VdbeAddOp(v, OP_ReadCookie, iDb, 1); + sqlite3VdbeAddOp(v, OP_Integer, minFormat, 0); + sqlite3VdbeAddOp(v, OP_Ge, 0, sqlite3VdbeCurrentAddr(v)+3); + sqlite3VdbeAddOp(v, OP_Integer, minFormat, 0); + sqlite3VdbeAddOp(v, OP_SetCookie, iDb, 1); + } +} + +/* ** Fill the Index.aiRowEst[] array with default information - information ** to be used when we have not run the ANALYZE command. ** diff --git a/src/vdbe.c b/src/vdbe.c index 4cedcd5c2..111c8ee15 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.506 2005/12/16 15:24:29 danielk1977 Exp $ +** $Id: vdbe.c,v 1.507 2005/12/21 14:43:12 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -2422,6 +2422,9 @@ case OP_SetCookie: { /* no-push */ /* When the schema cookie changes, record the new cookie internally */ pDb->schema_cookie = pTos->i; db->flags |= SQLITE_InternChanges; + }else if( pOp->p2==1 ){ + /* Record changes in the file format */ + pDb->file_format = pTos->i; } assert( (pTos->flags & MEM_Dyn)==0 ); pTos--; |