/ Check-in [25281042]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Do not allow bytes 0x80 through 0xBF to be the first character of an identifer because no valid UTF-8 character can begin with those bytes. If we allowed an identifier to begin with one of those bytes, then the substr() function in ALTER TABLE will not work correctly. (CVS 4003)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 252810424d8c4dcd19b369d62027094df7cf0bcc
User & Date: drh 2007-05-15 09:00:15
Context
2007-05-15
11:55
A new approach for UTF-8 translation. (CVS 4004) check-in: 6c8ad279 user: drh tags: trunk
09:00
Do not allow bytes 0x80 through 0xBF to be the first character of an identifer because no valid UTF-8 character can begin with those bytes. If we allowed an identifier to begin with one of those bytes, then the substr() function in ALTER TABLE will not work correctly. (CVS 4003) check-in: 25281042 user: drh tags: trunk
07:14
Fix some test script errors in fuzz.test. (CVS 4002) check-in: 51eeae7b user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/tokenize.c.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
*************************************************************************
** An tokenizer for SQL
**
** This file contains C code that splits an SQL input string up into
** individual tokens and sends those tokens one-by-one over to the
** parser for analysis.
**
** $Id: tokenize.c,v 1.127 2007/05/08 13:58:28 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include <stdlib.h>

/*
................................................................................
        if( c ) i++;
        return i;
      }
      /* Otherwise fall through to the next case */
    }
#endif
    default: {
      if( !IdChar(*z) ){
        break;
      }
      for(i=1; IdChar(z[i]); i++){}
      *tokenType = keywordCode((char*)z, i);
      return i;
    }
  }







|







 







|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
*************************************************************************
** An tokenizer for SQL
**
** This file contains C code that splits an SQL input string up into
** individual tokens and sends those tokens one-by-one over to the
** parser for analysis.
**
** $Id: tokenize.c,v 1.128 2007/05/15 09:00:15 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include <stdlib.h>

/*
................................................................................
        if( c ) i++;
        return i;
      }
      /* Otherwise fall through to the next case */
    }
#endif
    default: {
      if( !IdChar(*z) || (*z & 0xc0)==0x80 ){
        break;
      }
      for(i=1; IdChar(z[i]); i++){}
      *tokenType = keywordCode((char*)z, i);
      return i;
    }
  }

Changes to test/alter.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
698
699
700
701
702
703
704




705









706
#    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.22 2007/05/15 03:56:50 drh Exp $
#

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

# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
ifcapable !altertable {
................................................................................
  execsql {
    ALTER TABLE t11 ADD COLUMN abc;
  }
  catchsql {
    ALTER TABLE t11 ADD COLUMN abc;
  }
} {1 {duplicate column name: abc}}














finish_test







|







 







>
>
>
>
|
>
>
>
>
>
>
>
>
>

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
#    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.23 2007/05/15 09:00:16 drh Exp $
#

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

# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
ifcapable !altertable {
................................................................................
  execsql {
    ALTER TABLE t11 ADD COLUMN abc;
  }
  catchsql {
    ALTER TABLE t11 ADD COLUMN abc;
  }
} {1 {duplicate column name: abc}}
do_test alter-11.2 {
  sqlite3_exec db {CREATE TABLE t11b("%81%82%83" text)}
  execsql {
    ALTER TABLE t11b ADD COLUMN abc;
  }
  catchsql {
    ALTER TABLE t11b ADD COLUMN abc;
  }
} {1 {duplicate column name: abc}}
do_test alter-11.3 {
  set v [sqlite3_exec db {CREATE TABLE t11c(%81%82%83 text)}]
  set v [string range $v 0 20]\175
} {1 {unrecognized token}}

finish_test