aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c
index fc0c2042b..8bcf1d261 100644
--- a/src/util.c
+++ b/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;
+ }
}
/*
@@ -267,6 +270,28 @@ void sqlite3DequoteExpr(Expr *p){
}
/*
+** 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
*/
void sqlite3TokenInit(Token *p, char *z){