diff options
author | drh <> | 2021-07-30 20:09:08 +0000 |
---|---|---|
committer | drh <> | 2021-07-30 20:09:08 +0000 |
commit | e48f261ebfd36b4935c2d700269790239dac37e5 (patch) | |
tree | f7a4afa28eced5b46e3832cc77f051521fbbd458 /src | |
parent | 77441faff5f4d5cee08c747116fae97b48eeb9b0 (diff) | |
download | sqlite-e48f261ebfd36b4935c2d700269790239dac37e5.tar.gz sqlite-e48f261ebfd36b4935c2d700269790239dac37e5.zip |
If a generated column uses the optional keywords GENERATE ALWAYS, try to avoid
putting those keywords in the typename of the column.
[forum:/forumpost/ff3ffe09251c105b|Forum post ff3ffe09251c105b]
FossilOrigin-Name: 3c954863f45271a3518acf51fd685a641878811fb5cfcbdbad85154aeccdc902
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/build.c b/src/build.c index 5d2936f5b..43112a4cd 100644 --- a/src/build.c +++ b/src/build.c @@ -1389,6 +1389,24 @@ void sqlite3AddColumn(Parse *pParse, Token sName, Token sType){ return; } if( !IN_RENAME_OBJECT ) sqlite3DequoteToken(&sName); + + /* Because keywords GENERATE ALWAYS can be converted into indentifiers + ** by the parser, we can sometimes end up with a typename that ends + ** with "generated always". Check for this case and omit the surplus + ** text. */ + if( sType.n>=16 + && sqlite3_strnicmp(sType.z+(sType.n-6),"always",6)==0 + ){ + sType.n -= 6; + while( ALWAYS(sType.n>0) && sqlite3Isspace(sType.z[sType.n-1]) ) sType.n--; + if( sType.n>=9 + && sqlite3_strnicmp(sType.z+(sType.n-9),"generated",9)==0 + ){ + sType.n -= 9; + while( sType.n>0 && sqlite3Isspace(sType.z[sType.n-1]) ) sType.n--; + } + } + z = sqlite3DbMallocRaw(db, sName.n + sType.n + 2); if( z==0 ) return; if( IN_RENAME_OBJECT ) sqlite3RenameTokenMap(pParse, (void*)z, &sName); |