Index: src/vdbe.c ================================================================== --- src/vdbe.c +++ src/vdbe.c @@ -41,11 +41,11 @@ ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** 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.529 2006/01/13 17:12:01 danielk1977 Exp $ +** $Id: vdbe.c,v 1.530 2006/01/15 14:11:49 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" #include #include "vdbeInt.h" @@ -663,12 +663,11 @@ break; } /* Opcode: String8 * * P3 ** -** P3 points to a nul terminated UTF-8 string that is P1 character long -** (not counting the nul terminator). This opcode is transformed +** P3 points to a nul terminated UTF-8 string. This opcode is transformed ** into an OP_String before it is executed for the first time. */ case OP_String8: { /* same as TK_STRING */ assert( pOp->p3!=0 ); pOp->opcode = OP_String; @@ -685,20 +684,20 @@ if( pOp->p3type==P3_DYNAMIC ){ sqliteFree(pOp->p3); } pOp->p3type = P3_DYNAMIC; pOp->p3 = pTos->z; - pOp->p1 *= 2; + pOp->p1 = pTos->n; break; } #endif /* Otherwise fall through to the next case, OP_String */ } /* Opcode: String P1 * P3 ** -** The string value P3 of length P1 is pushed onto the stack. +** The string value P3 of length P1 (bytes) is pushed onto the stack. */ case OP_String: { pTos++; assert( pOp->p3!=0 ); pTos->flags = MEM_Str|MEM_Static|MEM_Term; Index: test/alter.test ================================================================== --- test/alter.test +++ test/alter.test @@ -9,11 +9,11 @@ # #************************************************************************* # This file implements regression tests for SQLite library. The # focus of this script is testing the ALTER TABLE statement. # -# $Id: alter.test,v 1.14 2006/01/14 08:02:28 danielk1977 Exp $ +# $Id: alter.test,v 1.15 2006/01/15 14:11:49 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -549,65 +549,74 @@ } db2 } {x y z} do_test alter-5.3 { db2 close } {} + +foreach tblname [execsql { + SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite%' +}] { + execsql "DROP TABLE \"$tblname\"" +} set ::tbl_name "abc\uABCDdef" -do_test alter-5.1 { +do_test alter-6.1 { string length $::tbl_name } {7} -do_test alter-5.2 { +do_test alter-6.2 { execsql " CREATE TABLE ${tbl_name}(a, b, c); " set ::oid [execsql {SELECT max(oid) FROM sqlite_master}] execsql { SELECT sql FROM sqlite_master WHERE oid = $::oid; } } "{CREATE TABLE ${::tbl_name}(a, b, c)}" +execsql " + SELECT * FROM ${::tbl_name} +" set ::tbl_name2 "abcXdef" -do_test alter-5.2 { +do_test alter-6.3 { execsql " ALTER TABLE $::tbl_name RENAME TO $::tbl_name2 " execsql { SELECT sql FROM sqlite_master WHERE oid = $::oid; } } "{CREATE TABLE '${::tbl_name2}'(a, b, c)}" -do_test alter-5.3 { +do_test alter-6.4 { execsql " ALTER TABLE $::tbl_name2 RENAME TO $::tbl_name " execsql { SELECT sql FROM sqlite_master WHERE oid = $::oid; } } "{CREATE TABLE '${::tbl_name}'(a, b, c)}" set ::col_name ghi\1234\jkl -do_test alter-5.4 { +do_test alter-6.5 { execsql " ALTER TABLE $::tbl_name ADD COLUMN $::col_name VARCHAR " execsql { SELECT sql FROM sqlite_master WHERE oid = $::oid; } } "{CREATE TABLE '${::tbl_name}'(a, b, c, $::col_name VARCHAR)}" set ::col_name2 B\3421\A -do_test alter-5.5 { +do_test alter-6.6 { db close sqlite3 db test.db execsql " ALTER TABLE $::tbl_name ADD COLUMN $::col_name2 " execsql { SELECT sql FROM sqlite_master WHERE oid = $::oid; } } "{CREATE TABLE '${::tbl_name}'(a, b, c, $::col_name VARCHAR, $::col_name2)}" -do_test alter-5.6 { +do_test alter-6.7 { execsql " INSERT INTO ${::tbl_name} VALUES(1, 2, 3, 4, 5); SELECT $::col_name, $::col_name2 FROM $::tbl_name; " } {4 5} finish_test