mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Avoid clownfeet in the names columns when the column names are quoted
in the original CREATE TABLE statement. FossilOrigin-Name: 980f7292afd45a8e73272e2139b55b99ab86167febec9fd0bf0356e8167b2ee9
This commit is contained in:
29
src/util.c
29
src/util.c
@@ -89,8 +89,11 @@ int sqlite3Strlen30(const char *z){
|
||||
** the column name if and only if the COLFLAG_HASTYPE flag is set.
|
||||
*/
|
||||
char *sqlite3ColumnType(Column *pCol, char *zDflt){
|
||||
if( (pCol->colFlags & COLFLAG_HASTYPE)==0 ) return zDflt;
|
||||
return pCol->zName + strlen(pCol->zName) + 1;
|
||||
if( pCol->colFlags & COLFLAG_HASTYPE ){
|
||||
return pCol->zName + strlen(pCol->zName) + 1;
|
||||
}else{
|
||||
return zDflt;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -266,6 +269,28 @@ void sqlite3DequoteExpr(Expr *p){
|
||||
sqlite3Dequote(p->u.zToken);
|
||||
}
|
||||
|
||||
/*
|
||||
** If the input token p is quoted, try to adjust the token to remove
|
||||
** the quotes. This is not always possible:
|
||||
**
|
||||
** "abc" -> abc
|
||||
** "ab""cd" -> (not possible because of the interior "")
|
||||
**
|
||||
** Remove the quotes if possible. This is a optimization. The overall
|
||||
** system should still return the correct answer even if this routine
|
||||
** is always a no-op.
|
||||
*/
|
||||
void sqlite3DequoteToken(Token *p){
|
||||
int i;
|
||||
if( p->n<2 ) return;
|
||||
if( !sqlite3Isquote(p->z[0]) ) return;
|
||||
for(i=1; i<p->n-1; i++){
|
||||
if( sqlite3Isquote(p->z[i]) ) return;
|
||||
}
|
||||
p->n -= 2;
|
||||
p->z++;
|
||||
}
|
||||
|
||||
/*
|
||||
** Generate a Token object from a string
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user