fix some parser bug
This commit is contained in:
		| @ -1009,7 +1009,7 @@ int ObParser::parse(const ObString &query, | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   const ObString stmt(len, query.ptr()); | ||||
|   ObString stmt(len, query.ptr()); | ||||
|   memset(&parse_result, 0, sizeof(ParseResult)); | ||||
|   parse_result.is_multi_values_parser_ = (INS_MULTI_VALUES == parse_mode); | ||||
|   parse_result.is_fp_ = (FP_MODE == parse_mode | ||||
| @ -1057,7 +1057,7 @@ int ObParser::parse(const ObString &query, | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   if (parse_result.is_fp_ || parse_result.is_dynamic_sql_) { | ||||
|   if (OB_SUCC(ret) && (parse_result.is_fp_ || parse_result.is_dynamic_sql_)) { | ||||
|     int64_t new_length = parse_result.is_fp_ ? stmt.length() + 1 : stmt.length() * 2; | ||||
|     char *buf = (char *)parse_malloc(new_length, parse_result.malloc_pool_); | ||||
|     if (OB_UNLIKELY(NULL == buf)) { | ||||
| @ -1068,6 +1068,18 @@ int ObParser::parse(const ObString &query, | ||||
|       parse_result.no_param_sql_buf_len_ = new_length; | ||||
|     } | ||||
|   } | ||||
|   //compatible mysql, mysql allow use the "--" | ||||
|   if (OB_SUCC(ret) && lib::is_mysql_mode() && stmt.case_compare("--") == 0) { | ||||
|     const char *line_str = "-- "; | ||||
|     char *buf = (char *)parse_malloc(strlen(line_str), parse_result.malloc_pool_); | ||||
|     if (OB_UNLIKELY(NULL == buf)) { | ||||
|       ret = OB_ALLOCATE_MEMORY_FAILED; | ||||
|       LOG_ERROR("no memory for parser"); | ||||
|     } else { | ||||
|       MEMCPY(buf, line_str, strlen(line_str)); | ||||
|       stmt.assign_ptr(buf, strlen(line_str)); | ||||
|     } | ||||
|   } | ||||
|   if (OB_SUCC(ret) && OB_ISNULL(parse_result.charset_info_)) { | ||||
|     ret = OB_ERR_UNEXPECTED; | ||||
|     LOG_WARN("charset info is null", K(ret), | ||||
| @ -1107,7 +1119,7 @@ int ObParser::parse(const ObString &query, | ||||
|         } | ||||
|       } | ||||
|     } else { | ||||
|       ObPLParser pl_parser(*(ObIAllocator*)(parse_result.malloc_pool_), connection_collation_); | ||||
|       ObPLParser pl_parser(*(ObIAllocator*)(parse_result.malloc_pool_), connection_collation_, sql_mode_); | ||||
|       if (OB_FAIL(pl_parser.parse(stmt, stmt, parse_result, is_pl_inner_parse))) { | ||||
|         LOG_WARN("failed to parse stmt as pl", K(stmt), K(ret)); | ||||
|         // may create ddl func, try it. | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 wangt1xiuyi
					wangt1xiuyi