Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix issues with ALTER TABLE RENAME COLUMN associated with OOM errors. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | alter-table-rename-column |
Files: | files | file ages | folders |
SHA3-256: |
0b28dd5c2e4908d5e49eaedd359492e4 |
User & Date: | drh 2018-08-13 13:43:11.223 |
Context
2018-08-13
| ||
15:09 | Fix legacy comments on Token. Begin commenting the new ALTER TABLE RENAME COLUMN code. Fix a memory leak in the sqlite_rename_column() SQL function. (check-in: 32edc89203 user: drh tags: alter-table-rename-column) | |
13:43 | Fix issues with ALTER TABLE RENAME COLUMN associated with OOM errors. (check-in: 0b28dd5c2e user: drh tags: alter-table-rename-column) | |
2018-08-11
| ||
20:46 | Add the "atrc" test program. "Atrc" is short for "ALTER TABLE RENAME COLUMN". See the header comment on the program itself for further information. (check-in: ed64a55a22 user: drh tags: alter-table-rename-column) | |
Changes
Changes to src/alter.c.
︙ | ︙ | |||
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 | memset(&sParse, 0, sizeof(sParse)); sParse.eParseMode = PARSE_MODE_RENAME_COLUMN; sParse.db = db; sParse.nQueryLoop = 1; rc = sqlite3RunParser(&sParse, zSql, &zErr); assert( sParse.pNewTable==0 || sParse.pNewIndex==0 ); if( rc==SQLITE_OK && sParse.pNewTable==0 && sParse.pNewIndex==0 ){ rc = SQLITE_CORRUPT_BKPT; } if( rc==SQLITE_OK ){ zQuot = sqlite3_mprintf("\"%w\"", zNew); if( zQuot==0 ){ rc = SQLITE_NOMEM; }else{ nQuot = sqlite3Strlen30(zQuot); } } if( rc!=SQLITE_OK ){ if( zErr ){ sqlite3_result_error(context, zErr, -1); }else{ sqlite3_result_error_code(context, rc); } sqlite3DbFree(db, zErr); | > < | | 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 | memset(&sParse, 0, sizeof(sParse)); sParse.eParseMode = PARSE_MODE_RENAME_COLUMN; sParse.db = db; sParse.nQueryLoop = 1; rc = sqlite3RunParser(&sParse, zSql, &zErr); assert( sParse.pNewTable==0 || sParse.pNewIndex==0 ); if( db->mallocFailed ) rc = SQLITE_NOMEM; if( rc==SQLITE_OK && sParse.pNewTable==0 && sParse.pNewIndex==0 ){ rc = SQLITE_CORRUPT_BKPT; } if( rc==SQLITE_OK ){ zQuot = sqlite3_mprintf("\"%w\"", zNew); if( zQuot==0 ){ rc = SQLITE_NOMEM; }else{ nQuot = sqlite3Strlen30(zQuot); } } if( rc!=SQLITE_OK ){ if( zErr ){ sqlite3_result_error(context, zErr, -1); }else{ sqlite3_result_error_code(context, rc); } sqlite3DbFree(db, zErr); goto renameColumnFunc_done; } if( bQuote ){ zNew = zQuot; nNew = nQuot; } |
︙ | ︙ | |||
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 | sqlite3DbFree(db, pBest); } sqlite3_result_text(context, zOut, -1, SQLITE_TRANSIENT); sqlite3DbFree(db, zOut); } if( sParse.pVdbe ){ sqlite3VdbeFinalize(sParse.pVdbe); } sqlite3DeleteTable(db, sParse.pNewTable); if( sParse.pNewIndex ) sqlite3FreeIndex(db, sParse.pNewIndex); renameTokenFree(db, sParse.pRename); sqlite3ParserReset(&sParse); | > | 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 | sqlite3DbFree(db, pBest); } sqlite3_result_text(context, zOut, -1, SQLITE_TRANSIENT); sqlite3DbFree(db, zOut); } renameColumnFunc_done: if( sParse.pVdbe ){ sqlite3VdbeFinalize(sParse.pVdbe); } sqlite3DeleteTable(db, sParse.pNewTable); if( sParse.pNewIndex ) sqlite3FreeIndex(db, sParse.pNewIndex); renameTokenFree(db, sParse.pRename); sqlite3ParserReset(&sParse); |
︙ | ︙ |
Changes to src/parse.y.
︙ | ︙ | |||
1307 1308 1309 1310 1311 1312 1313 | if( (hasCollate || sortOrder!=SQLITE_SO_UNDEFINED) && pParse->db->init.busy==0 ){ sqlite3ErrorMsg(pParse, "syntax error after column name \"%.*s\"", pIdToken->n, pIdToken->z); } sqlite3ExprListSetName(pParse, p, pIdToken, 1); | | | 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 | if( (hasCollate || sortOrder!=SQLITE_SO_UNDEFINED) && pParse->db->init.busy==0 ){ sqlite3ErrorMsg(pParse, "syntax error after column name \"%.*s\"", pIdToken->n, pIdToken->z); } sqlite3ExprListSetName(pParse, p, pIdToken, 1); if( IN_RENAME_COLUMN && p ){ sqlite3RenameToken(pParse, (void*)(p->a[p->nExpr-1].zName), pIdToken); } return p; } } // end %include eidlist_opt(A) ::= . {A = 0;} |
︙ | ︙ |