This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 5b52812af2574b418a2a163dd6891bf394ce06d7
Author: abmdocrt <yukang.lian2...@gmail.com>
AuthorDate: Thu Mar 7 17:45:40 2024 +0800

    Problem: When the old optimizer processes an INSERT INTO statement that 
contains two quotation marks, it results in only one quotation mark being 
written into the database. (#31890)
    
    Reason: During syntax parsing, the old optimizer interprets two quotation 
marks as a single quotation mark.
    Solution: Remove the logic that consolidates two quotation marks into one.
---
 fe/fe-core/src/main/jflex/sql_scanner.flex     |  2 +-
 regression-test/data/insert_p0/insert.out      |  3 +++
 regression-test/suites/insert_p0/insert.groovy | 16 ++++++++++++++++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/fe/fe-core/src/main/jflex/sql_scanner.flex 
b/fe/fe-core/src/main/jflex/sql_scanner.flex
index 175744532c0..5cc4a881604 100644
--- a/fe/fe-core/src/main/jflex/sql_scanner.flex
+++ b/fe/fe-core/src/main/jflex/sql_scanner.flex
@@ -757,7 +757,7 @@ EndOfLineComment = "--" 
!({HintContent}|{ContainsLineTerminator}) {LineTerminato
 
 {SingleQuoteStringLiteral} {
   return newToken(SqlParserSymbols.STRING_LITERAL,
-      escapeBackSlash(yytext().substring(1, 
yytext().length()-1)).replaceAll("''", "'"));
+      escapeBackSlash(yytext().substring(1, yytext().length()-1)));
 }
 
 {DoubleQuoteStringLiteral} {
diff --git a/regression-test/data/insert_p0/insert.out 
b/regression-test/data/insert_p0/insert.out
index b582f45123d..38a2a818ab5 100644
--- a/regression-test/data/insert_p0/insert.out
+++ b/regression-test/data/insert_p0/insert.out
@@ -202,3 +202,6 @@
 44980  113.8777        again   1987-04-09      2010-01-02T04:03:06     false   
-0.01   0E-10
 44980  113.8777        again   1987-04-09      2010-01-02T04:03:06     false   
-0.01   0E-10
 
+-- !select --
+3      replace(cdate,'-','')
+
diff --git a/regression-test/suites/insert_p0/insert.groovy 
b/regression-test/suites/insert_p0/insert.groovy
index 573d5d8366c..cd3ba176bc8 100644
--- a/regression-test/suites/insert_p0/insert.groovy
+++ b/regression-test/suites/insert_p0/insert.groovy
@@ -83,4 +83,20 @@ suite("insert") {
     sql "sync"
     qt_insert """ select * from mutable_datatype order by c_bigint, c_double, 
c_string, c_date, c_timestamp, c_boolean, c_short_decimal"""
 
+    def table = "insert_with_quote"
+    sql """ DROP TABLE IF EXISTS ${table} """
+    sql """
+        CREATE TABLE ${table} (
+            `id` int(11) NULL,
+            `dim1` string NULL
+        ) ENGINE=OLAP
+        UNIQUE KEY(`id`)
+        DISTRIBUTED BY HASH(`id`) BUCKETS 1
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+    sql """insert into ${table}(id,dim1) 
values(3,\'replace(cdate,\\\'-\\\',\\\'\\\')\')"""
+    qt_select """ select * from ${table} """
+
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to