summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2021-05-30 05:42:35 +0400
committerRucha Deodhar <rucha.deodhar@mariadb.com>2022-05-31 12:08:54 +0530
commit6b6d745b9eab64c6c1a3c13c11afe38c6761df69 (patch)
tree11087dc4a65e8553bb5317f4627e5f3bbe76114d
parent05d049bdbe6814aee8f011fbd0d915f9d82a30ee (diff)
downloadmariadb-git-6b6d745b9eab64c6c1a3c13c11afe38c6761df69.tar.gz
let numeric in the DEMAULT.
-rw-r--r--mysql-test/suite/json/r/json_table.result4
-rw-r--r--mysql-test/suite/json/t/json_table.test4
-rw-r--r--sql/sql_yacc.yy23
3 files changed, 26 insertions, 5 deletions
diff --git a/mysql-test/suite/json/r/json_table.result b/mysql-test/suite/json/r/json_table.result
index 4619240ba00..155b8c53b29 100644
--- a/mysql-test/suite/json/r/json_table.result
+++ b/mysql-test/suite/json/r/json_table.result
@@ -57,14 +57,14 @@ Jeans {"color": "blue", "price": 50} blue
select * from t1 right join json_table(t1.item_props,'$' columns( color varchar(100) path '$.color')) as T on 1;
ERROR 42S22: Unknown column 't1.item_props' in 'JSON_TABLE argument'
DROP TABLE t1;
-select * from JSON_TABLE( '[ {"xa": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}, {"a":3}]', '$[*]' COLUMNS( a INT PATH '$.a' default '101' on empty, NESTED PATH '$.b[*]' COLUMNS (b INT PATH '$'))) as jt;
+select * from JSON_TABLE( '[ {"xa": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}, {"a":3}]', '$[*]' COLUMNS( a INT PATH '$.a' default 101 on empty, NESTED PATH '$.b[*]' COLUMNS (b INT PATH '$'))) as jt;
a b
101 11
101 111
2 22
2 222
3 NULL
-select * from JSON_TABLE( '[ {"xa": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}, {"a":3}]', '$[*]' COLUMNS( a INT PATH '$.a' default '202' on error, NESTED PATH '$.b[*]' COLUMNS (b INT PATH '$'))) as jt;
+select * from JSON_TABLE( '[ {"xa": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}, {"a":3}]', '$[*]' COLUMNS( a INT PATH '$.a' default 202 on error, NESTED PATH '$.b[*]' COLUMNS (b INT PATH '$'))) as jt;
a b
NULL 11
NULL 111
diff --git a/mysql-test/suite/json/t/json_table.test b/mysql-test/suite/json/t/json_table.test
index dbb9f43ab17..f6e8c93e443 100644
--- a/mysql-test/suite/json/t/json_table.test
+++ b/mysql-test/suite/json/t/json_table.test
@@ -30,9 +30,9 @@ select * from t1 right join json_table(t1.item_props,'$' columns( color varchar(
DROP TABLE t1;
-select * from JSON_TABLE( '[ {"xa": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}, {"a":3}]', '$[*]' COLUMNS( a INT PATH '$.a' default '101' on empty, NESTED PATH '$.b[*]' COLUMNS (b INT PATH '$'))) as jt;
+select * from JSON_TABLE( '[ {"xa": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}, {"a":3}]', '$[*]' COLUMNS( a INT PATH '$.a' default 101 on empty, NESTED PATH '$.b[*]' COLUMNS (b INT PATH '$'))) as jt;
-select * from JSON_TABLE( '[ {"xa": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}, {"a":3}]', '$[*]' COLUMNS( a INT PATH '$.a' default '202' on error, NESTED PATH '$.b[*]' COLUMNS (b INT PATH '$'))) as jt;
+select * from JSON_TABLE( '[ {"xa": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}, {"a":3}]', '$[*]' COLUMNS( a INT PATH '$.a' default 202 on error, NESTED PATH '$.b[*]' COLUMNS (b INT PATH '$'))) as jt;
select * from JSON_TABLE( '[ {"a": [1, 2], "b": [11,111]}, {"a": 2, "b": [22,222]}, {"a":3}]', '$[*]' COLUMNS( a INT PATH '$.a' default '101' on empty, NESTED PATH '$.b[*]' COLUMNS (b INT PATH '$'))) as jt;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 28ab93362c8..172ea82b1a6 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1313,6 +1313,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
TEXT_STRING
NCHAR_STRING
json_text_literal
+ json_text_literal_or_num
%type <lex_str_ptr>
opt_table_alias_clause
@@ -11570,6 +11571,26 @@ json_text_literal:
}
;
+json_text_literal_or_num:
+ json_text_literal
+ | NUM
+ {
+ Lex->json_table->m_text_literal_cs= NULL;
+ }
+ | LONG_NUM
+ {
+ Lex->json_table->m_text_literal_cs= NULL;
+ }
+ | DECIMAL_NUM
+ {
+ Lex->json_table->m_text_literal_cs= NULL;
+ }
+ | FLOAT_NUM
+ {
+ Lex->json_table->m_text_literal_cs= NULL;
+ }
+ ;
+
join_table_list:
derived_table_list { MYSQL_YYABORT_UNLESS($$=$1); }
;
@@ -11684,7 +11705,7 @@ json_on_response:
{
$$.m_response= Json_table_column::RESPONSE_NULL;
}
- | DEFAULT json_text_literal
+ | DEFAULT json_text_literal_or_num
{
$$.m_response= Json_table_column::RESPONSE_DEFAULT;
$$.m_default= $2;