Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-12180

ST_GeomFromGeoJSON option argument appears to have no effect

    Details

      Description

      In MySQL 5.7, ST_GeomFromGeoJSON has an option argument (1-4):
      https://dev.mysql.com/doc/refman/5.7/en/spatial-geojson-functions.html#function_st-geomfromgeojson

      SET @j = '{ "type": "Point", "coordinates": [5.3, 15.0, 4.3]}';
      Query OK, 0 rows affected (0.00 sec)
       
      mysql [localhost] {msandbox} ((none)) > SELECT ST_AsText(ST_GeomFromGeoJSON(@j,5));
      ERROR 1411 (HY000): Incorrect option value: '5' for function st_geomfromgeojson
       
      mysql [localhost] {msandbox} ((none)) > SELECT ST_AsText(ST_GeomFromGeoJSON(@j,4));
      +-------------------------------------+
      | ST_AsText(ST_GeomFromGeoJSON(@j,4)) |
      +-------------------------------------+
      | POINT(5.3 15)                       |
      +-------------------------------------+
      1 row in set (0.01 sec)
       
      mysql [localhost] {msandbox} ((none)) > SELECT ST_AsText(ST_GeomFromGeoJSON(@j,1));
      ERROR 3073 (HY000): Unsupported number of coordinate dimensions in function st_geomfromgeojson: Found 3, expected 2
      

      In MariaDB, the option argument is accepted but appears to make no difference to anything. Is it intended that MariaDB match MySQL's behaviour? If so, this is a bug, if not, it needs to be documented what the argument does.

      SET @j = '{ "type": "Point", "coordinates": [5.3, 15.0, 4.3]}';
      Query OK, 0 rows affected (0.00 sec)
       
      mysql [localhost] {msandbox} ((none)) > SELECT ST_AsText(ST_GeomFromGeoJSON(@j,2));
      +-------------------------------------+
      | ST_AsText(ST_GeomFromGeoJSON(@j,2)) |
      +-------------------------------------+
      | POINT(5.3 15)                       |
      +-------------------------------------+
      1 row in set (0.00 sec)
       
      mysql [localhost] {msandbox} ((none)) > SELECT ST_AsText(ST_GeomFromGeoJSON(@j,1));
      +-------------------------------------+
      | ST_AsText(ST_GeomFromGeoJSON(@j,1)) |
      +-------------------------------------+
      | POINT(5.3 15)                       |
      +-------------------------------------+
      1 row in set (0.00 sec)
       
      mysql [localhost] {msandbox} ((none)) > SELECT ST_AsText(ST_GeomFromGeoJSON(@j,3));
      +-------------------------------------+
      | ST_AsText(ST_GeomFromGeoJSON(@j,3)) |
      +-------------------------------------+
      | POINT(5.3 15)                       |
      +-------------------------------------+
      1 row in set (0.00 sec)
       
      mysql [localhost] {msandbox} ((none)) > SELECT ST_AsText(ST_GeomFromGeoJSON(@j,4));
      +-------------------------------------+
      | ST_AsText(ST_GeomFromGeoJSON(@j,4)) |
      +-------------------------------------+
      | POINT(5.3 15)                       |
      +-------------------------------------+
      1 row in set (0.00 sec)
       
      mysql [localhost] {msandbox} ((none)) > SELECT ST_AsText(ST_GeomFromGeoJSON(@j,5));
      +-------------------------------------+
      | ST_AsText(ST_GeomFromGeoJSON(@j,5)) |
      +-------------------------------------+
      | POINT(5.3 15)                       |
      +-------------------------------------+
      1 row in set (0.00 sec)
       
      mysql [localhost] {msandbox} ((none)) > SELECT ST_AsText(ST_GeomFromGeoJSON(@j,6));
      +-------------------------------------+
      | ST_AsText(ST_GeomFromGeoJSON(@j,6)) |
      +-------------------------------------+
      | POINT(5.3 15)                       |
      +-------------------------------------+
      1 row in set (0.00 sec)
      

        Attachments

          Activity

            People

            • Assignee:
              holyfoot Alexey Botchkov
              Reporter:
              greenman Ian Gilfillan
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: