Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add further tests for RENAME COLUMN. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | alter-table-rename-column |
Files: | files | file ages | folders |
SHA3-256: |
82c4c10a96db76f39edf5f6d027294d4 |
User & Date: | dan 2018-08-20 20:01:01.997 |
Context
2018-08-21
| ||
08:29 | Minor changes to function tokenExpr() in order to claw back cycles lost to the rename-column change. (check-in: 479976955e user: dan tags: alter-table-rename-column) | |
2018-08-20
| ||
20:01 | Add further tests for RENAME COLUMN. (check-in: 82c4c10a96 user: dan tags: alter-table-rename-column) | |
16:16 | Ensure that it is not possible to rename columns of system tables, views or virtual tables. (check-in: 786b5991dc user: dan tags: alter-table-rename-column) | |
Changes
Changes to src/alter.c.
︙ | |||
874 875 876 877 878 879 880 | 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 | - + | */ zNew = sqlite3NameFromToken(db, pNew); if( !zNew ) goto exit_rename_column; assert( pNew->n>0 ); bQuote = sqlite3Isquote(pNew->z[0]); sqlite3NestedParse(pParse, "UPDATE \"%w\".%s SET " |
︙ | |||
953 954 955 956 957 958 959 | 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 | - + | /* ** If there is a RenameToken object associated with parse tree element ** pFrom, then remap that object over to pTo due to a transformation ** in the parse tree. */ void sqlite3MoveRenameToken(Parse *pParse, void *pTo, void *pFrom){ RenameToken *p; |
︙ | |||
1060 1061 1062 1063 1064 1065 1066 | 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | - - - + + + + + + + + - - - - - - - - - - - + + + - - - - - + + + + + | /* ** An error occured while parsing or otherwise processing a database ** object (either pParse->pNewTable, pNewIndex or pNewTrigger) as part of an ** ALTER TABLE RENAME COLUMN program. The error message emitted by the ** sub-routine is currently stored in pParse->zErrMsg. This function ** adds context to the error message and then stores it in pCtx. */ |
︙ | |||
1116 1117 1118 1119 1120 1121 1122 | 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 | - - - - - - + + + + + + - - + + | int NotUsed, sqlite3_value **argv ){ sqlite3 *db = sqlite3_context_db_handle(context); RenameCtx sCtx; const char *zSql = (const char*)sqlite3_value_text(argv[0]); int nSql = sqlite3_value_bytes(argv[0]); |
︙ | |||
1268 1269 1270 1271 1272 1273 1274 | 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 | + - - + + + + + - - + + - | rc = sqlite3ResolveExprNames(&sNC, sParse.pNewTrigger->pWhen); } for(pStep=sParse.pNewTrigger->step_list; rc==SQLITE_OK && pStep; pStep=pStep->pNext ){ if( pStep->pSelect ){ |
︙ | |||
1409 1410 1411 1412 1413 1414 1415 | 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 | - + | }else{ rc = SQLITE_NOMEM; } renameColumnFunc_done: if( rc!=SQLITE_OK ){ if( sParse.zErrMsg ){ |
︙ | |||
1434 1435 1436 1437 1438 1439 1440 | 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 | - + | /* ** Register built-in functions used to help implement ALTER TABLE */ void sqlite3AlterFunctions(void){ static FuncDef aAlterTableFuncs[] = { FUNCTION(sqlite_rename_table, 2, 0, 0, renameTableFunc), |
Changes to test/altercol.test.
︙ | |||
401 402 403 404 405 406 407 408 409 410 411 412 413 414 | 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | + + + + + + + + | 4 _x_ _xxx_ { { CREATE TABLE t1(a, b, _x_ INTEGER, PRIMARY KEY(_x_), CHECK(_x_>0)) } { CREATE TRIGGER ttt AFTER UPDATE ON t1 BEGIN INSERT INTO t1 VALUES(new.a, new.b, new._x_) ON CONFLICT (_x_) WHERE _x_>10 DO UPDATE SET _x_ = _x_+1; END } } 4 _x_ _xxx_ { { CREATE TABLE t1(a, b, _x_ INTEGER, PRIMARY KEY(_x_), CHECK(_x_>0)) } { CREATE TRIGGER ttt AFTER UPDATE ON t1 BEGIN INSERT INTO t1 VALUES(new.a, new.b, new._x_) ON CONFLICT (_x_) WHERE _x_>10 DO NOTHING; END } } } { do_rename_column_test 9.$tn $old $new $lSchema } #------------------------------------------------------------------------- # Test that views can be edited even if there are missing collation # sequences or user defined functions. |
︙ | |||
468 469 470 471 472 473 474 475 476 477 478 479 480 481 | 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | + + | #------------------------------------------------------------------------- # Test some error conditions: # # 1. Renaming a column of a system table, # 2. Renaming a column of a VIEW, # 3. Renaming a column of a virtual table. # 4. Renaming a column that does not exist. # 5. Renaming a column of a table that does not exist. # reset_db do_execsql_test 12.1.1 { CREATE TABLE t1(a, b); CREATE INDEX t1a ON t1(a); INSERT INTO t1 VALUES(1, 1), (2, 2), (3, 4); ANALYZE; |
︙ | |||
498 499 500 501 502 503 504 | 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 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 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 | - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | 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); } |
Added test/altermalloc2.test.
|