Ensure ALTER TABLE respects the system table convention - "sqlite_*". (CVS 2115)

FossilOrigin-Name: f635b6aae661ac85eec49b197f3bb4b85172a457
This commit is contained in:
danielk1977 2004-11-19 08:41:34 +00:00
parent aacd732b11
commit 023f41762c
4 changed files with 33 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Update\sthe\ssqlite_sequence\stable\swhen\sa\stable\sis\srenamed\swith\sALTER_TABLE.\s(CVS\s2114)
D 2004-11-19T08:02:14
C Ensure\sALTER\sTABLE\srespects\sthe\ssystem\stable\sconvention\s-\s"sqlite_*".\s(CVS\s2115)
D 2004-11-19T08:41:34
F Makefile.in e747bb5ba34ccbdd81f79dcf1b2b33c02817c21d
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
@ -31,7 +31,7 @@ F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689
F src/auth.c 3b81f2a42f48a62c2c9c9b0eda31a157c681edea
F src/btree.c 49b09718cd988d1c7c981b03e94679bc10b5f711
F src/btree.h 861e40b759a195ba63819740e484390012cf81ab
F src/build.c 81422cd1c6a61a4d84fe438638fc3fec8d6c78cb
F src/build.c a43f3b8f452dbd28ad94fad788693f3fc2336908
F src/date.c 65536e7ea04fdde6e0551264fca15966966e171f
F src/delete.c be9d039b819f4a5d0fdfaeceace139ba189ef819
F src/expr.c 4ee3e47358c92a919062255b14057a7a8f641e01
@ -83,7 +83,7 @@ F src/vdbeaux.c c6da55e0096e141211f918837eca98e0be6400b4
F src/vdbemem.c 5876c8abf4374fef671f4fd8dc333ef3fc95a2f0
F src/where.c 4d28167e450255372b45abf1bc8cd5f0e9264d7b
F test/all.test 929bfa932b55e75c96fe2203f7650ba451c1862c
F test/alter.test 6337578f49c9dd4e429e5998ea361758b0400255
F test/alter.test 2b4478c4906e4d1504b1a121b4ffbc8d11043b53
F test/attach.test e305dd59a375e37c658c6d401f19f8a95880bf9a
F test/attach2.test 399128a7b3b209a339a8dbf53ca2ed42eb982d1a
F test/attach3.test 8a0309e284cf9aa1d7d6cc444989031881f7a21c
@ -259,7 +259,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25
F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c
P 0514107bff970ab1e5ce96c8b1fa13dcbf75cb71
R ee4ef14e815e9448c083988d455f742c
P 6e971868808e3c3f77fa521de626f1510ba9644a
R 68c792a11c68f51b905bff744f973114
U danielk1977
Z 9d9ed74db73894f86a8bcc71876d5ed3
Z 1838946384c9fba1d6f7f0adb4164bac

View File

@ -1 +1 @@
6e971868808e3c3f77fa521de626f1510ba9644a
f635b6aae661ac85eec49b197f3bb4b85172a457

View File

@ -22,7 +22,7 @@
** COMMIT
** ROLLBACK
**
** $Id: build.c,v 1.283 2004/11/19 08:02:14 danielk1977 Exp $
** $Id: build.c,v 1.284 2004/11/19 08:41:34 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -2959,6 +2959,19 @@ void sqlite3AlterRenameTable(
return;
}
/* Make sure it is not a system table being altered, or a reserved name
** that the table is being renamed to.
*/
if( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){
sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);
sqliteFree(zName);
return;
}
if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
sqliteFree(zName);
return;
}
#ifndef SQLITE_OMIT_AUTHORIZATION
/* Invoke the authorization callback. */
if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){

View File

@ -8,7 +8,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is testing the ALTER TABLE statement.
#
# $Id: alter.test,v 1.5 2004/11/19 08:02:14 danielk1977 Exp $
# $Id: alter.test,v 1.6 2004/11/19 08:41:34 danielk1977 Exp $
#
set testdir [file dirname $argv0]
@ -255,6 +255,16 @@ do_test alter-2.3 {
ALTER TABLE [<t2>] RENAME TO i3;
}
} {1 {there is already another table or index with this name: i3}}
do_test alter-2.4 {
catchsql {
ALTER TABLE SqLiTe_master RENAME TO master;
}
} {1 {table sqlite_master may not be altered}}
do_test alter-2.5 {
catchsql {
ALTER TABLE t3 RENAME TO sqlite_t3;
}
} {1 {object name reserved for internal use: sqlite_t3}}
# If this compilation does not include triggers, omit the alter-3.* tests.
ifcapable trigger {