/ 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 Unified Diffs Show Whitespace Changes Patch

Changes to src/build.c.

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
....
1543
1544
1545
1546
1547
1548
1549

1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**
** $Id: build.c,v 1.379 2006/01/13 06:33:24 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Initialize the pParse structure as needed.
................................................................................
#endif
    pParse->pNewTable = 0;
    db->nTable++;
    db->flags |= SQLITE_InternChanges;

#ifndef SQLITE_OMIT_ALTERTABLE
    if( !p->pSelect ){

      assert( !pSelect && pCons && pEnd );
      if( pCons->z==0 ) pCons = pEnd;
      p->addColOffset = 13 + (pCons->z - pParse->sNameToken.z);
    }
#endif
  }
}

#ifndef SQLITE_OMIT_VIEW
/*







|







 







>


|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
....
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**
** $Id: build.c,v 1.380 2006/01/13 18:06:40 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Initialize the pParse structure as needed.
................................................................................
#endif
    pParse->pNewTable = 0;
    db->nTable++;
    db->flags |= SQLITE_InternChanges;

#ifndef SQLITE_OMIT_ALTERTABLE
    if( !p->pSelect ){
      const unsigned char *zName = pParse->sNameToken.z;
      assert( !pSelect && pCons && pEnd );
      if( pCons->z==0 ) pCons = pEnd;
      p->addColOffset = 13 + sqlite3utf8CharLen(zName, pCons->z - zName);
    }
#endif
  }
}

#ifndef SQLITE_OMIT_VIEW
/*

Changes to test/alter.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
547
548
549
550
551
552
553
554





























































555

#    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.12 2006/01/03 00:33:50 drh Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
ifcapable !altertable {
................................................................................
    ALTER TABLE tbl1 RENAME TO tbl2;
    SELECT * FROM tbl2;
  } db2
} {x y z}
do_test alter-5.3 {
  db2 close
} {}






























































finish_test








|







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
#    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.13 2006/01/13 18:06:40 danielk1977 Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
ifcapable !altertable {
................................................................................
    ALTER TABLE tbl1 RENAME TO tbl2;
    SELECT * FROM tbl2;
  } db2
} {x y z}
do_test alter-5.3 {
  db2 close
} {}

set ::tbl_name "abc\uABCDdef"
do_test alter-5.1 {
  string length $::tbl_name
} {7}
do_test alter-5.2 {
  execsql "
    CREATE TABLE ${tbl_name}(a, b, c);
  "
  execsql {
    SELECT sql FROM sqlite_master 
        WHERE oid = (SELECT max(oid) FROM sqlite_master);
  }
} "{CREATE TABLE ${::tbl_name}(a, b, c)}"
set ::tbl_name2 "abcXdef"
do_test alter-5.2 {
  execsql "
    ALTER TABLE $::tbl_name RENAME TO $::tbl_name2 
  "
  execsql {
    SELECT sql FROM sqlite_master 
        WHERE oid = (SELECT max(oid) FROM sqlite_master);
  }
} "{CREATE TABLE '${::tbl_name2}'(a, b, c)}"
do_test alter-5.3 {
  execsql "
    ALTER TABLE $::tbl_name2 RENAME TO $::tbl_name
  "
  execsql {
    SELECT sql FROM sqlite_master 
        WHERE oid = (SELECT max(oid) FROM sqlite_master);
  }
} "{CREATE TABLE '${::tbl_name}'(a, b, c)}"
set ::col_name ghi\1234\jkl
do_test alter-5.4 {
  execsql "
    ALTER TABLE $::tbl_name ADD COLUMN $::col_name VARCHAR
  "
  execsql {
    SELECT sql FROM sqlite_master 
        WHERE oid = (SELECT max(oid) FROM sqlite_master);
  }
} "{CREATE TABLE '${::tbl_name}'(a, b, c, $::col_name VARCHAR)}"
set ::col_name2 B\3421\A
do_test alter-5.5 {
  db close
  sqlite3 db test.db
  execsql "
    ALTER TABLE $::tbl_name ADD COLUMN $::col_name2
  "
  execsql {
    SELECT sql FROM sqlite_master 
        WHERE oid = (SELECT max(oid) FROM sqlite_master);
  }
} "{CREATE TABLE '${::tbl_name}'(a, b, c, $::col_name VARCHAR, $::col_name2)}"
do_test alter-5.6 {
  execsql "
    INSERT INTO ${::tbl_name} VALUES(1, 2, 3, 4, 5);
    SELECT $::col_name, $::col_name2 FROM $::tbl_name;
  "
} {4 5}

finish_test