From: dan Date: Tue, 23 Mar 2021 22:15:34 +0000 (+0000) Subject: Fix a problem with renaming a column when there is a quoted string immediately follow... X-Git-Tag: version-3.36.0~291 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d14ffe63d23b8285c10c9e931947dd9ea7189cf;p=thirdparty%2Fsqlite.git Fix a problem with renaming a column when there is a quoted string immediately following the column name somewhere in the schema. FossilOrigin-Name: 4719fae6262aa3563f3df6aca0170c6d847bb18ab7b0e6e7609a0e7b6f0c6b1b --- diff --git a/manifest b/manifest index 1f0951cf59..f94a77c76a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\sALWAYS()\son\sa\sbranch\sthat\sis\salways\staken. -D 2021-03-23T21:02:24.414 +C Fix\sa\sproblem\swith\srenaming\sa\scolumn\swhen\sthere\sis\sa\squoted\sstring\simmediately\sfollowing\sthe\scolumn\sname\ssomewhere\sin\sthe\sschema. +D 2021-03-23T22:15:34.247 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -476,7 +476,7 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a -F src/alter.c 842bb68d8fe651a9c997a30ca212f892b9f293a1e6446d748aa2de6e78345f15 +F src/alter.c effc10185c8f9621cf926cb190925c0f001eaec9d9f63a3be863064e1a1459dc F src/analyze.c 01c6c6765cb4d40b473b71d85535093730770bb186f2f473abac25f07fcdee5c F src/attach.c 9cbe761e464025694df8e6f6ee4d9f41432c3a255ca9443ccbb4130eeb87cf72 F src/auth.c 08954fdc4cc2da5264ba5b75cfd90b67a6fc7d1710a02ccf917c38eadec77853 @@ -647,7 +647,7 @@ F test/alter3.test e487958dec7932453e0b83baf21d6b1e71d5e7d9a55bc20eadfa62a51ddff F test/alter4.test dfd6086faf461b27ca2d2999848dcd207edf23352fc1592d0005c0844f3f08cf F test/alterauth.test 63442ba61ceb0c1eeb63aac1f4f5cebfa509d352276059d27106ae256bafc959 F test/alterauth2.test 381b1ab603c9ef96314a3158528ea17f7964449385a28eeaf8191120b2e24a8d -F test/altercol.test 91f4eb0023d90beee000c06d45f521e07a2444d013b83381c62e88d5f209560f +F test/altercol.test b11fa1b131e80ab5b6ecfb3b725fb0419c14ca6efba5adb57aeabfc9baa0c8f3 F test/altercorrupt.test 584d707a80e106952d6382790c8919bcf9f0db678ed3a1c09fd98b7f9d1d3a10 F test/alterdropcol.test 596623cb8a72d9570bfb8417b0f302810efe007873796f03c17a9e9ff28dade1 F test/alterdropcol2.test 527fce683b200d620f560f666c44ae33e22728e990a10a48a543280dfd4b4d41 @@ -1911,7 +1911,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d3ade8c7fe58e05af9d44a79478776b050a680c1338188f2d4b222b937e682ea -R 396e0963e55984487083361a6d3ebe20 -U drh -Z 1ec6cd7cb2ecaa9b39417e5a93e0851c +P 0646d2260c523d368e3f6bc3d110a9011d35ce83bd6751ad412d8fd9a253cb7a +R 75703139a1c6f783bd6039643f5533c3 +U dan +Z 84f11d909f7072b783f563a5bbd21dcb diff --git a/manifest.uuid b/manifest.uuid index 14b9a2daad..5d2c296296 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0646d2260c523d368e3f6bc3d110a9011d35ce83bd6751ad412d8fd9a253cb7a \ No newline at end of file +4719fae6262aa3563f3df6aca0170c6d847bb18ab7b0e6e7609a0e7b6f0c6b1b \ No newline at end of file diff --git a/src/alter.c b/src/alter.c index 6a0818f651..8997698488 100644 --- a/src/alter.c +++ b/src/alter.c @@ -1150,15 +1150,11 @@ static int renameEditSql( ** ALTER TABLE statement was quoted (bQuote==1), then set zNew to ** point to zQuot so that all substitutions are made using the ** quoted version of the new column name. */ - zQuot = sqlite3MPrintf(db, "\"%w\"", zNew); + zQuot = sqlite3MPrintf(db, "\"%w\" ", zNew); if( zQuot==0 ){ return SQLITE_NOMEM; }else{ - nQuot = sqlite3Strlen30(zQuot); - } - if( bQuote ){ - zNew = zQuot; - nNew = nQuot; + nQuot = sqlite3Strlen30(zQuot)-1; } assert( nQuot>=nNew ); @@ -1185,12 +1181,13 @@ static int renameEditSql( RenameToken *pBest = renameColumnTokenNext(pRename); if( zNew ){ - if( sqlite3IsIdChar(*pBest->t.z) ){ + if( bQuote==0 && sqlite3IsIdChar(*pBest->t.z) ){ nReplace = nNew; zReplace = zNew; }else{ nReplace = nQuot; zReplace = zQuot; + if( pBest->t.z[pBest->t.n]=='"' ) nReplace++; } }else{ /* Dequote the double-quoted token. Then requote it again, this time diff --git a/test/altercol.test b/test/altercol.test index f2063e45ca..d0c5c40ea6 100644 --- a/test/altercol.test +++ b/test/altercol.test @@ -848,5 +848,16 @@ do_execsql_test 22.0 { PRAGMA integrity_check; } {ok} +reset_db +do_execsql_test 23.0 { + CREATE TABLE t1('a'"b",c); + CREATE INDEX i1 ON t1('a'); + INSERT INTO t1 VALUES(1,2), (3,4); + ALTER TABLE t1 RENAME COLUMN a TO x; + PRAGMA integrity_check; + SELECT sql FROM sqlite_schema WHERE name='t1'; + +} {ok {CREATE TABLE t1("x" "b",c)}} + finish_test