summaryrefslogtreecommitdiff
path: root/sql/item_geofunc.cc
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2017-08-06 16:27:37 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2017-08-06 16:27:37 +0400
commit11948d75862941e2780e550cbc5411895e1cc1c7 (patch)
treeccbadb2308209c3c2ac7081ac67f777df23cff7e /sql/item_geofunc.cc
parent6d51817d2cd79edbc15328bef532a5375f184219 (diff)
downloadmariadb-git-11948d75862941e2780e550cbc5411895e1cc1c7.tar.gz
MDEV-12180 ST_GeomFromGeoJSON option argument appears to have no effect.
Implement the 'option' argument for the ST_GeomFromGeoJSON.
Diffstat (limited to 'sql/item_geofunc.cc')
-rw-r--r--sql/item_geofunc.cc23
1 files changed, 20 insertions, 3 deletions
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 560d822bea7..8c9b61d98a1 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -131,13 +131,27 @@ String *Item_func_geometry_from_json::val_str(String *str)
Geometry_buffer buffer;
String *js= args[0]->val_str_ascii(&tmp_js);
uint32 srid= 0;
+ longlong options= 0;
json_engine_t je;
if ((null_value= args[0]->null_value))
return 0;
- if ((arg_count == 2) && !args[1]->null_value)
- srid= (uint32)args[1]->val_int();
+ if (arg_count > 1 && !args[1]->null_value)
+ {
+ options= args[1]->val_int();
+ if (options > 4 || options < 1)
+ {
+ String *sv= args[1]->val_str(&tmp_js);
+ my_error(ER_WRONG_VALUE_FOR_TYPE, MYF(0),
+ "option", sv->c_ptr(), "ST_GeometryFromJSON");
+ null_value= 1;
+ return 0;
+ }
+ }
+
+ if ((arg_count == 3) && !args[2]->null_value)
+ srid= (uint32)args[2]->val_int();
str->set_charset(&my_charset_bin);
if (str->reserve(SRID_SIZE, 512))
@@ -148,7 +162,7 @@ String *Item_func_geometry_from_json::val_str(String *str)
json_scan_start(&je, js->charset(), (const uchar *) js->ptr(),
(const uchar *) js->end());
- if ((null_value= !Geometry::create_from_json(&buffer, &je, str)))
+ if ((null_value= !Geometry::create_from_json(&buffer, &je, options==1, str)))
{
int code= 0;
@@ -163,6 +177,9 @@ String *Item_func_geometry_from_json::val_str(String *str)
case Geometry::GEOJ_POLYGON_NOT_CLOSED:
code= ER_GEOJSON_NOT_CLOSED;
break;
+ case Geometry::GEOJ_DIMENSION_NOT_SUPPORTED:
+ my_error(ER_GIS_INVALID_DATA, MYF(0), "ST_GeometryFromJSON");
+ break;
default:
report_json_error_ex(js, &je, func_name(), 0, Sql_condition::WARN_LEVEL_WARN);
return NULL;