1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-16 23:02:26 +03:00

Use the 2-argument version of substr() in the SQL contained in the

VACUUM and ALTER TABLE commands.  Ticket #2737. (CVS 4499)

FossilOrigin-Name: 82b08a3dc2366007bcac4d9e451ef61c8c018fa5
This commit is contained in:
drh
2007-10-20 20:58:57 +00:00
parent 979aeaa395
commit a21a929e81
4 changed files with 15 additions and 15 deletions

View File

@@ -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.32 2007/08/29 14:06:23 danielk1977 Exp $
** $Id: alter.c,v 1.33 2007/10/20 20:58:57 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -378,7 +378,7 @@ void sqlite3AlterRenameTable(
"name = CASE "
"WHEN type='table' THEN %Q "
"WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN "
"'sqlite_autoindex_' || %Q || substr(name,%d+18,10) "
"'sqlite_autoindex_' || %Q || substr(name,%d+18) "
"ELSE name END "
"WHERE tbl_name=%Q AND "
"(type='table' OR type='index' OR type='trigger');",
@@ -515,7 +515,7 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
}
sqlite3NestedParse(pParse,
"UPDATE %Q.%s SET "
"sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d,length(sql)) "
"sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) "
"WHERE type = 'table' AND name = %Q",
zDb, SCHEMA_TABLE(iDb), pNew->addColOffset, zCol, pNew->addColOffset+1,
zTab

View File

@@ -14,7 +14,7 @@
** Most of the code in this file may be omitted by defining the
** SQLITE_OMIT_VACUUM macro.
**
** $Id: vacuum.c,v 1.73 2007/08/29 12:31:28 danielk1977 Exp $
** $Id: vacuum.c,v 1.74 2007/10/20 20:58:57 drh Exp $
*/
#include "sqliteInt.h"
#include "vdbeInt.h"
@@ -136,17 +136,17 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
** in the temporary database.
*/
rc = execExecSql(db,
"SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14,100000000) "
"SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14) "
" FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'"
" AND rootpage>0"
);
if( rc!=SQLITE_OK ) goto end_of_vacuum;
rc = execExecSql(db,
"SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14,100000000)"
"SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14)"
" FROM sqlite_master WHERE sql LIKE 'CREATE INDEX %' ");
if( rc!=SQLITE_OK ) goto end_of_vacuum;
rc = execExecSql(db,
"SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21,100000000) "
"SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21) "
" FROM sqlite_master WHERE sql LIKE 'CREATE UNIQUE INDEX %'");
if( rc!=SQLITE_OK ) goto end_of_vacuum;