Bug report #18900

[Oracle] Mixing SDO_GEOMETRY Point definition

Added by René-Luc ReLuc over 6 years ago. Updated over 6 years ago.

Status:Closed
Priority:High
Assignee:Nyall Dawson
Category:Data Provider/Oracle
Affected QGIS version:2.18.19 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:26732

Description

If a layer has mixed SDO_GEOMETRY Point definition, SDO_POINT_TYPE or SDO_ELEM_INFO_ARRAY and SDO_ORDINATE_ARRAY, QOciSpatial replaced points defined by SDO_POINT_TYPE by the preceding point defined with SDO_ELEM_INFO_ARRAY and SDO_ORDINATE_ARRAY. It seems that QOCISpatialResultPrivate.sdoobj is not well cleared between rows.

In qsql_ocispatial:2524 the length of SDO_ELEM_INFO_ARRAY is read:

  int nElems;
  if ( !getArraySize( sdoobj->elem_info, nElems ) )
  {
    qWarning() << "could not determine element info array size";
    return false;
  }

nElems has to be equal to 0, if the point has been defined with SDO_POINT_TYPE. But it is not if a preceding Point has been defined with SDO_ELEM_INFO_ARRAY and SDO_ORDINATE_ARRAY like that:
CREATE TABLE QGIS.POINT_DATA ( "pk" INTEGER PRIMARY KEY, GEOM SDO_GEOMETRY);
INSERT INTO QGIS.POINT_DATA ("pk", GEOM)
 SELECT 1, SDO_GEOMETRY( 2001,4326,SDO_POINT_TYPE(1, 2, NULL), NULL, NULL) from dual
  UNION ALL SELECT 2, SDO_GEOMETRY( 3001,4326,SDO_POINT_TYPE(1, 2, 3), NULL, NULL) from dual
  UNION ALL SELECT 3, SDO_GEOMETRY( 3005,4326,NULL, sdo_elem_info_array (1,1,1, 4,1,1), sdo_ordinate_array (1,2,3, 4,5,6)) from dual
  UNION ALL SELECT 4, SDO_GEOMETRY( 2005,4326,NULL, sdo_elem_info_array (1,1,1, 3,1,1), sdo_ordinate_array (1,2, 3,4)) from dual
  UNION ALL SELECT 5, SDO_GEOMETRY( 3005,4326,NULL, sdo_elem_info_array (1,1,2), sdo_ordinate_array (1,2,3, 4,5,6)) from dual
  UNION ALL SELECT 6, SDO_GEOMETRY( 2001,4326,NULL, sdo_elem_info_array (1,1,1), sdo_ordinate_array (1,2)) from dual
  UNION ALL SELECT 7, SDO_GEOMETRY( 2001,4326, SDO_POINT_TYPE(3, 4, NULL), NULL, NULL) from dual
  UNION ALL SELECT 8, SDO_GEOMETRY( 2001,4326,NULL, sdo_elem_info_array (1,1,1), sdo_ordinate_array (5,6)) from dual;

In this case, the 7th Point will be the same has the 6th.

A pull request has been created to test and fix this issue: https://github.com/qgis/QGIS/pull/6923

Associated revisions

Revision 849278a2
Added by René-Luc ReLuc over 6 years ago

[BUGFIX][Oracle] Mixing SDO_GEOMETRY Point definition

Fixes #18900

In `sdoobj`, the `elem_info` array size is not the right way to defined the way
to read Point coordinate. The right way is to check the
sdoind attributes, like in Mapserver.

The way Mapserver defined check point coordinate: https://github.com/mapserver/mapserver/blob/fd04328a89e75ac963f15867d9d90a50d47513c1/maporaclespatial.c#L1588

Revision d29317c3
Added by René-Luc ReLuc over 6 years ago

[BUGFIX][Oracle] Mixing SDO_GEOMETRY Point definition

Fixes #18900

In `sdoobj`, the `elem_info` array size is not the right way to defined the way
to read Point coordinate. The right way is to check the
sdoind attributes, like in Mapserver.

The way Mapserver defined check point coordinate: https://github.com/mapserver/mapserver/blob/fd04328a89e75ac963f15867d9d90a50d47513c1/maporaclespatial.c#L1588

(cherry-picked from 4017690)

History

#1 Updated by René-Luc ReLuc over 6 years ago

  • Pull Request or Patch supplied changed from No to Yes

#2 Updated by René-Luc ReLuc over 6 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

Also available in: Atom PDF