/ Check-in [d634f8b2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Account for multi-byte characters in ALTER TABLE code. Fix for #1609. (CVS 2942)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d634f8b28abd7af4565c644bd7972b067caa0133
User & Date: danielk1977 2006-01-13 18:06:40
Context
2006-01-14
08:02
Fixes for OMIT_SUBQUERY builds: Disable where clause OR->IN optimization. Include EXISTS keyword (for new CREATE TABLE syntax). Test file fixes. (CVS 2943) check-in: 8e79a0c2 user: danielk1977 tags: trunk
2006-01-13
18:06
Account for multi-byte characters in ALTER TABLE code. Fix for #1609. (CVS 2942) check-in: d634f8b2 user: danielk1977 tags: trunk
17:12
Tweaks to make OP_Column run a fraction faster. (CVS 2941) check-in: 2d74cc22 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/build.c.

    18     18   **     CREATE INDEX
    19     19   **     DROP INDEX
    20     20   **     creating ID lists
    21     21   **     BEGIN TRANSACTION
    22     22   **     COMMIT
    23     23   **     ROLLBACK
    24     24   **
    25         -** $Id: build.c,v 1.379 2006/01/13 06:33:24 danielk1977 Exp $
           25  +** $Id: build.c,v 1.380 2006/01/13 18:06:40 danielk1977 Exp $
    26     26   */
    27     27   #include "sqliteInt.h"
    28     28   #include <ctype.h>
    29     29   
    30     30   /*
    31     31   ** This routine is called when a new SQL statement is beginning to
    32     32   ** be parsed.  Initialize the pParse structure as needed.
................................................................................
  1543   1543   #endif
  1544   1544       pParse->pNewTable = 0;
  1545   1545       db->nTable++;
  1546   1546       db->flags |= SQLITE_InternChanges;
  1547   1547   
  1548   1548   #ifndef SQLITE_OMIT_ALTERTABLE
  1549   1549       if( !p->pSelect ){
         1550  +      const unsigned char *zName = pParse->sNameToken.z;
  1550   1551         assert( !pSelect && pCons && pEnd );
  1551   1552         if( pCons->z==0 ) pCons = pEnd;
  1552         -      p->addColOffset = 13 + (pCons->z - pParse->sNameToken.z);
         1553  +      p->addColOffset = 13 + sqlite3utf8CharLen(zName, pCons->z - zName);
  1553   1554       }
  1554   1555   #endif
  1555   1556     }
  1556   1557   }
  1557   1558   
  1558   1559   #ifndef SQLITE_OMIT_VIEW
  1559   1560   /*

Changes to test/alter.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #*************************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is testing the ALTER TABLE statement.
    13     13   #
    14         -# $Id: alter.test,v 1.12 2006/01/03 00:33:50 drh Exp $
           14  +# $Id: alter.test,v 1.13 2006/01/13 18:06:40 danielk1977 Exp $
    15     15   #
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
    21     21   ifcapable !altertable {
................................................................................
   547    547       ALTER TABLE tbl1 RENAME TO tbl2;
   548    548       SELECT * FROM tbl2;
   549    549     } db2
   550    550   } {x y z}
   551    551   do_test alter-5.3 {
   552    552     db2 close
   553    553   } {}
          554  +
          555  +set ::tbl_name "abc\uABCDdef"
          556  +do_test alter-5.1 {
          557  +  string length $::tbl_name
          558  +} {7}
          559  +do_test alter-5.2 {
          560  +  execsql "
          561  +    CREATE TABLE ${tbl_name}(a, b, c);
          562  +  "
          563  +  execsql {
          564  +    SELECT sql FROM sqlite_master 
          565  +        WHERE oid = (SELECT max(oid) FROM sqlite_master);
          566  +  }
          567  +} "{CREATE TABLE ${::tbl_name}(a, b, c)}"
          568  +set ::tbl_name2 "abcXdef"
          569  +do_test alter-5.2 {
          570  +  execsql "
          571  +    ALTER TABLE $::tbl_name RENAME TO $::tbl_name2 
          572  +  "
          573  +  execsql {
          574  +    SELECT sql FROM sqlite_master 
          575  +        WHERE oid = (SELECT max(oid) FROM sqlite_master);
          576  +  }
          577  +} "{CREATE TABLE '${::tbl_name2}'(a, b, c)}"
          578  +do_test alter-5.3 {
          579  +  execsql "
          580  +    ALTER TABLE $::tbl_name2 RENAME TO $::tbl_name
          581  +  "
          582  +  execsql {
          583  +    SELECT sql FROM sqlite_master 
          584  +        WHERE oid = (SELECT max(oid) FROM sqlite_master);
          585  +  }
          586  +} "{CREATE TABLE '${::tbl_name}'(a, b, c)}"
          587  +set ::col_name ghi\1234\jkl
          588  +do_test alter-5.4 {
          589  +  execsql "
          590  +    ALTER TABLE $::tbl_name ADD COLUMN $::col_name VARCHAR
          591  +  "
          592  +  execsql {
          593  +    SELECT sql FROM sqlite_master 
          594  +        WHERE oid = (SELECT max(oid) FROM sqlite_master);
          595  +  }
          596  +} "{CREATE TABLE '${::tbl_name}'(a, b, c, $::col_name VARCHAR)}"
          597  +set ::col_name2 B\3421\A
          598  +do_test alter-5.5 {
          599  +  db close
          600  +  sqlite3 db test.db
          601  +  execsql "
          602  +    ALTER TABLE $::tbl_name ADD COLUMN $::col_name2
          603  +  "
          604  +  execsql {
          605  +    SELECT sql FROM sqlite_master 
          606  +        WHERE oid = (SELECT max(oid) FROM sqlite_master);
          607  +  }
          608  +} "{CREATE TABLE '${::tbl_name}'(a, b, c, $::col_name VARCHAR, $::col_name2)}"
          609  +do_test alter-5.6 {
          610  +  execsql "
          611  +    INSERT INTO ${::tbl_name} VALUES(1, 2, 3, 4, 5);
          612  +    SELECT $::col_name, $::col_name2 FROM $::tbl_name;
          613  +  "
          614  +} {4 5}
   554    615   
   555    616   finish_test
          617  +