aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authordan <Dan Kennedy>2024-01-20 16:18:04 +0000
committerdan <Dan Kennedy>2024-01-20 16:18:04 +0000
commit3eae6664a00961baf3d011229794cd98371aa9cf (patch)
treeca27af420556088a868ac97298cb50cd4c71489b /src/util.c
parent4c43f1881e86893c22ead7a72be6b14bbcd051eb (diff)
downloadsqlite-3eae6664a00961baf3d011229794cd98371aa9cf.tar.gz
sqlite-3eae6664a00961baf3d011229794cd98371aa9cf.zip
Allow "_" characters to appear following any digit in an integer or real SQL literal.
FossilOrigin-Name: 401650aaccbc99246bd4e1ff37a28b78f528178aee2f294d87b9f7fecd7432bb
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 207b901ba..24eff14e9 100644
--- a/src/util.c
+++ b/src/util.c
@@ -312,6 +312,27 @@ void sqlite3DequoteExpr(Expr *p){
}
/*
+** Expression p is a QINTEGER or QFLOAT (quoted integer or float). Dequote
+** the value in p->u.zToken and set the type to INTEGER or FLOAT. "Quoted"
+** integers or floats are those that contain '_' characters that must
+** be removed before further processing.
+*/
+void sqlite3DequoteNumber(Expr *p){
+ if( p ){
+ const char *pIn = p->u.zToken;
+ char *pOut = p->u.zToken;
+ assert( p->op==TK_QNUMBER );
+ p->op = TK_INTEGER;
+ do {
+ if( *pIn!=SQLITE_DIGIT_SEPARATOR ){
+ *pOut++ = *pIn;
+ if( *pIn=='e' || *pIn=='E' || *pIn=='.' ) p->op = TK_FLOAT;
+ }
+ }while( *pIn++ );
+ }
+}
+
+/*
** If the input token p is quoted, try to adjust the token to remove
** the quotes. This is not always possible:
**