Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Return an error if the user attempts to rename a view. Related to (but not a fix for) #2831. (CVS 4623) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
19d56d997f50be81ac2baace16b7e7a1 |
User & Date: | danielk1977 2007-12-13 08:15:31.000 |
Context
2007-12-13
| ||
17:50 | Additional test cases for tkt2822. Fix a related bug in printf(). (CVS 4624) (check-in: 8f184e40ff user: drh tags: trunk) | |
08:15 | Return an error if the user attempts to rename a view. Related to (but not a fix for) #2831. (CVS 4623) (check-in: 19d56d997f user: danielk1977 tags: trunk) | |
07:58 | Adjust the test suite to account for recent changes related to #2822. Most changes are related to English language error messages only. (CVS 4622) (check-in: 2f88b9b3e3 user: danielk1977 tags: trunk) | |
Changes
Changes to src/alter.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that used to generate VDBE code ** that implements the ALTER TABLE command. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that used to generate VDBE code ** that implements the ALTER TABLE command. ** ** $Id: alter.c,v 1.34 2007/12/13 08:15:31 danielk1977 Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** The code in this file only exists if we are not omitting the ** ALTER TABLE logic from the build. |
︙ | ︙ | |||
315 316 317 318 319 320 321 322 323 324 325 326 327 328 | if( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){ sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName); goto exit_rename_table; } if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto exit_rename_table; } #ifndef SQLITE_OMIT_AUTHORIZATION /* Invoke the authorization callback. */ if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){ goto exit_rename_table; } #endif | > > > > > > > | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | if( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){ sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName); goto exit_rename_table; } if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto exit_rename_table; } #ifndef SQLITE_OMIT_VIEW if( pTab->pSelect ){ sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab->zName); goto exit_rename_table; } #endif #ifndef SQLITE_OMIT_AUTHORIZATION /* Invoke the authorization callback. */ if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){ goto exit_rename_table; } #endif |
︙ | ︙ |
Changes to test/alter.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2004 November 10 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #************************************************************************* # This file implements regression tests for SQLite library. The # focus of this script is testing the ALTER TABLE statement. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2004 November 10 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #************************************************************************* # This file implements regression tests for SQLite library. The # focus of this script is testing the ALTER TABLE statement. # # $Id: alter.test,v 1.28 2007/12/13 08:15:31 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # If SQLITE_OMIT_ALTERTABLE is defined, omit this file. ifcapable !altertable { |
︙ | ︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 | # attached database. # alter-1.9.*: Tests for ALTER TABLE when their is whitespace between the # table name and left parenthesis token. i.e: # "CREATE TABLE abc (a, b, c);" # alter-2.*: Test error conditions and messages. # alter-3.*: Test ALTER TABLE on tables that have TRIGGERs attached to them. # alter-4.*: Test ALTER TABLE on tables that have AUTOINCREMENT fields. # # Create some tables to rename. Be sure to include some TEMP tables # and some tables with odd names. # do_test alter-1.1 { ifcapable tempdb { | > > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # attached database. # alter-1.9.*: Tests for ALTER TABLE when their is whitespace between the # table name and left parenthesis token. i.e: # "CREATE TABLE abc (a, b, c);" # alter-2.*: Test error conditions and messages. # alter-3.*: Test ALTER TABLE on tables that have TRIGGERs attached to them. # alter-4.*: Test ALTER TABLE on tables that have AUTOINCREMENT fields. # ... # alter-12.*: Test ALTER TABLE on views. # # Create some tables to rename. Be sure to include some TEMP tables # and some tables with odd names. # do_test alter-1.1 { ifcapable tempdb { |
︙ | ︙ | |||
754 755 756 757 758 759 760 | sqlite3_exec db {SELECT [%81%82%83] AS xyz, abc FROM t11c} } {0 {xyz abc 5 6}} do_test alter-11.10 { sqlite3_exec db {SELECT "%81%82%83" AS xyz, abc FROM t11c} } {0 {xyz abc 5 6}} } | > > > > | > > > > > > > > > > > > > > > > > > > > > | 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | sqlite3_exec db {SELECT [%81%82%83] AS xyz, abc FROM t11c} } {0 {xyz abc 5 6}} do_test alter-11.10 { sqlite3_exec db {SELECT "%81%82%83" AS xyz, abc FROM t11c} } {0 {xyz abc 5 6}} } do_test alter-12.1 { execsql { CREATE TABLE t12(a, b, c); CREATE VIEW v1 AS SELECT * FROM t12; } } {} do_test alter-12.2 { catchsql { ALTER TABLE v1 RENAME TO v2; } } {1 {view v1 may not be altered}} do_test alter-12.3 { execsql { SELECT * FROM v1; } } {} do_test alter-12.4 { db close sqlite3 db test.db execsql { SELECT * FROM v1; } } {} do_test alter-12.5 { catchsql { ALTER TABLE v1 ADD COLUMN new_column; } } {1 {Cannot add a column to a view}} finish_test |