/ Check-in [bc4bb943]
Login

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

Overview
Comment:Fix ALTER TABLE so that it can run even if the schema contains unknown collation sequences.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bc4bb9433fed519386511796cce475d74100b8ed707cdbffd8cbdf683b0faf35
User & Date: dan 2020-10-12 15:27:50
Context
2020-10-12
16:54
Add options --data-only and --nosys to the ".dump" command in the CLI. (check-in: 57123b14 user: drh tags: trunk)
15:27
Fix ALTER TABLE so that it can run even if the schema contains unknown collation sequences. (check-in: bc4bb943 user: dan tags: trunk)
14:56
Add the --nosys option to the .schema command in the CLI. (check-in: b72ee694 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/build.c.

1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
*/
void sqlite3AddCollateType(Parse *pParse, Token *pToken){
  Table *p;
  int i;
  char *zColl;              /* Dequoted name of collation sequence */
  sqlite3 *db;

  if( (p = pParse->pNewTable)==0 ) return;
  i = p->nCol-1;
  db = pParse->db;
  zColl = sqlite3NameFromToken(db, pToken);
  if( !zColl ) return;

  if( sqlite3LocateCollSeq(pParse, zColl) ){
    Index *pIdx;







|







1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
*/
void sqlite3AddCollateType(Parse *pParse, Token *pToken){
  Table *p;
  int i;
  char *zColl;              /* Dequoted name of collation sequence */
  sqlite3 *db;

  if( (p = pParse->pNewTable)==0 || IN_RENAME_OBJECT ) return;
  i = p->nCol-1;
  db = pParse->db;
  zColl = sqlite3NameFromToken(db, pToken);
  if( !zColl ) return;

  if( sqlite3LocateCollSeq(pParse, zColl) ){
    Index *pIdx;

Changes to test/altertab.test.

672
673
674
675
676
677
678
679


































680

  COMMIT;
  PRAGMA integrity_check;
} {ok}
do_execsql_test 22.1 {
  ALTER TABLE t1 ADD COLUMN c INT DEFAULT 78;
  SELECT * FROM t1;
} {1 2 78 a b 78}



































finish_test









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

>
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
  COMMIT;
  PRAGMA integrity_check;
} {ok}
do_execsql_test 22.1 {
  ALTER TABLE t1 ADD COLUMN c INT DEFAULT 78;
  SELECT * FROM t1;
} {1 2 78 a b 78}

#-------------------------------------------------------------------------
reset_db
db collate compare64 compare64

do_execsql_test 23.1 {
  CREATE TABLE gigo(a text);
  CREATE TABLE idx(x text COLLATE compare64);
  CREATE VIEW v1 AS SELECT * FROM idx WHERE x='abc';
}
db close
sqlite3 db test.db

do_execsql_test 23.2 {
  alter table gigo rename to ggiiggoo;
  alter table idx rename to idx2;
}

do_execsql_test 23.3 {
  SELECT sql FROM sqlite_master;
} {
  {CREATE TABLE "ggiiggoo"(a text)} 
  {CREATE TABLE "idx2"(x text COLLATE compare64)}
  {CREATE VIEW v1 AS SELECT * FROM "idx2" WHERE x='abc'}
}

do_execsql_test 23.4 {
  ALTER TABLE idx2 RENAME x TO y;
  SELECT sql FROM sqlite_master;
} {
  {CREATE TABLE "ggiiggoo"(a text)} 
  {CREATE TABLE "idx2"(y text COLLATE compare64)}
  {CREATE VIEW v1 AS SELECT * FROM "idx2" WHERE y='abc'}
}

finish_test