/ Check-in [a7dae59a]
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:Fix harmless compiler warnings in the ALTER TABLE logic. Rephrase an error message to use active voice.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | alter-table-rename-column
Files: files | file ages | folders
SHA3-256: a7dae59a7e7b187fa2e9457bbb4b01cfe3d48bbdf59c3f8f7b4156bcde3bda98
User & Date: drh 2018-08-23 19:32:04
Context
2018-08-23
20:09
Add the "atrc" test program to the Makefiles. Fix a typo in the instructions in the header comment of the atrc program. check-in: 2130a407 user: drh tags: alter-table-rename-column
19:32
Fix harmless compiler warnings in the ALTER TABLE logic. Rephrase an error message to use active voice. check-in: a7dae59a user: drh tags: alter-table-rename-column
18:50
The Expr.iColumn field must also be initialized in tokenExpr(). check-in: 772985f1 user: drh tags: alter-table-rename-column
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/alter.c.

809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
....
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
#ifndef SQLITE_OMIT_VIRTUALTABLE
  if( IsVirtual(pTab) ){
    zType = "virtual table";
  }
#endif
  if( zType ){
    sqlite3ErrorMsg(
        pParse, "columns of %s %s may not be renamed", zType, pTab->zName
    );
    return 1;
  }
  return 0;
}
#else /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */
# define isRealTable(x,y) (0)
................................................................................
*/
static void renameColumnParseError(
  sqlite3_context *pCtx, 
  sqlite3_value *pType,
  sqlite3_value *pObject,
  Parse *pParse
){
  const char *zT = sqlite3_value_text(pType);
  const char *zN = sqlite3_value_text(pObject);
  char *zErr;

  zErr = sqlite3_mprintf("error processing %s %s: %s", zT, zN, pParse->zErrMsg);
  sqlite3_result_error(pCtx, zErr, -1);
  sqlite3_free(zErr);
}








|







 







|
|







809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
....
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
#ifndef SQLITE_OMIT_VIRTUALTABLE
  if( IsVirtual(pTab) ){
    zType = "virtual table";
  }
#endif
  if( zType ){
    sqlite3ErrorMsg(
        pParse, "cannot rename columns of %s \"%s\"", zType, pTab->zName
    );
    return 1;
  }
  return 0;
}
#else /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */
# define isRealTable(x,y) (0)
................................................................................
*/
static void renameColumnParseError(
  sqlite3_context *pCtx, 
  sqlite3_value *pType,
  sqlite3_value *pObject,
  Parse *pParse
){
  const char *zT = (const char*)sqlite3_value_text(pType);
  const char *zN = (const char*)sqlite3_value_text(pObject);
  char *zErr;

  zErr = sqlite3_mprintf("error processing %s %s: %s", zT, zN, pParse->zErrMsg);
  sqlite3_result_error(pCtx, zErr, -1);
  sqlite3_free(zErr);
}

Changes to test/altercol.test.

499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
...
631
632
633
634
635
636
637
638

do_execsql_test 12.2.1 {
  CREATE VIEW v1 AS SELECT * FROM t1;
  CREATE VIEW v2(c, d) AS SELECT * FROM t1;
}
do_catchsql_test 12.2.2 {
  ALTER TABLE v1 RENAME a TO z;
} {1 {columns of view v1 may not be renamed}}
do_catchsql_test 12.2.3 {
  ALTER TABLE v2 RENAME c TO y;
} {1 {columns of view v2 may not be renamed}}

ifcapable fts5 {
  do_execsql_test 12.3.1 {
    CREATE VIRTUAL TABLE ft USING fts5(a, b, c);
  }
  do_catchsql_test 12.3.2 {
    ALTER TABLE ft RENAME a TO z;
................................................................................
  SELECT 
  sqlite_rename_column(sql, type, object, db, tbl, icol, znew, bquote)
  FROM ddd;
} {{} {} {}}


finish_test








|


|







 







<
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
...
631
632
633
634
635
636
637


do_execsql_test 12.2.1 {
  CREATE VIEW v1 AS SELECT * FROM t1;
  CREATE VIEW v2(c, d) AS SELECT * FROM t1;
}
do_catchsql_test 12.2.2 {
  ALTER TABLE v1 RENAME a TO z;
} {1 {cannot rename columns of view "v1"}}
do_catchsql_test 12.2.3 {
  ALTER TABLE v2 RENAME c TO y;
} {1 {cannot rename columns of view "v2"}}

ifcapable fts5 {
  do_execsql_test 12.3.1 {
    CREATE VIRTUAL TABLE ft USING fts5(a, b, c);
  }
  do_catchsql_test 12.3.2 {
    ALTER TABLE ft RENAME a TO z;
................................................................................
  SELECT 
  sqlite_rename_column(sql, type, object, db, tbl, icol, znew, bquote)
  FROM ddd;
} {{} {} {}}


finish_test