Opened 9 years ago

Closed 8 years ago

#5376 closed defect (fixed)

OGR OCI: UpdateLayerExtents() perfomed also for NON-geometric tables

Reported by: giorgiomugnaini Owned by: warmerdam
Priority: normal Milestone: 1.11.2
Component: default Version: 1.11.0
Severity: major Keywords: ogrocidatasource, oci
Cc: Even Rouault, ilucena


In SyncToDisk(), UpdateLayerExtents() is performed, regardless the table has geometry field or not.

Therefore during UpdateLayerExtents(), spurious insertions in sdo_geometry_metadata_table are performed, because of the following fragment:

        sDimUpdate.Appendf( strlen(poFeatureDefn->GetName()) + 100,
                            "('%s', '%s', ",
                            pszGeomName );

        sDimUpdate.Append( "MDSYS.SDO_DIM_ARRAY(" );
                           dfXMin, dfXMax, dfXRes );
                           dfYMin, dfYMax, dfYRes );

        if( nDimension == 3 )
                               dfZMin, dfZMax, dfZRes );

        if( nSRID == -1 )
            sDimUpdate.Append( "), NULL)" );
            sDimUpdate.Appendf( 100, "), %d)", nSRID );

Change History (8)

comment:1 by giorgiomugnaini, 9 years ago

After the first time, the spurious insertions generate SQL exception, because the violation of uniqueness constraint in sdo_geometry_metadata_table as in the following example:

ERROR 1: ORA-13223: duplicate entry for MY_TABLE_DATA.(null) in SDO_GEOM_METAD
ORA-06512: at "MDSYS.MD", line 1723
ORA-06512: at "MDSYS.MDERR", line 17
ORA-06512: at "MDSYS.SDO_GEOM_TRIG_INS1", line 48
ORA-04088: error during execution of trigger 'MDSYS.SDO_GEOM_TRIG_INS1'
)), NULL)

comment:2 by giorgiomugnaini, 8 years ago

Version: unspecified1.11.0

comment:3 by giorgiomugnaini, 8 years ago

The OciDataSource has been created specifying two tables (one only having a geometry field) as in the following case

 ... = OGRSFDriverRegistrar::Open( "OCI:user:passwd@db:TABLE_WITH_GEOMETRY,MY_TABLE_DATA" ,TRUE )


  • TABLE_WITH_GEOMETRY : table having a geometry field;
  • MY_TABLE_DATA : table without geometry field.

comment:4 by giorgiomugnaini, 8 years ago

It is interesting to observe that OGR seems to believe that table MY_TABLE_DATA has a fictitious geometry field:


insted of no geometry, i.e.

pszGeomName = NULL

comment:5 by giorgiomugnaini, 8 years ago

Cc: Even Rouault ilucena added
Keywords: ogrocidatasource oci added
Severity: normalmajor

comment:6 by Even Rouault, 8 years ago

Resolution: fixed
Status: newclosed

Should be fixed with trunk r27826, branches/1.11 r27827 "OCI: initialize member variable to avoid UpdateLayerExtents() to be called randomly on non spatial tables (#5376)"

comment:7 by giorgiomugnaini, 8 years ago

Resolution: fixed
Status: closedreopened

Thank you Rouault, in fact this attribute was not initialized. But a problem is still present in my point of view.

If we examine UpdateLayerExtents() ( row 1360 in ogrocitablelayer.cpp) we read:

void OGROCITableLayer::UpdateLayerExtents()

    if( !bExtentUpdated )

I think that bExtentUpdated should be false for non-spatial tables, otherwise the spurious writing on USER_SDO_GEOM_METADATA will be performed.

In the constructor OGROCITableLayer::OGROCITableLayer() (at row 70):

   poFeatureDefn = ReadTableDefinition( pszTableName );

I suggest to add the following correction after row 70:

  if( !pszGeomName ) ///<pszGeomName  is null for non-spatial tables
     bExtentUpdated = false;

What do you think about such proprosal?

comment:8 by Even Rouault, 8 years ago

Milestone: 1.11.2
Resolution: fixed
Status: reopenedclosed

Doh, I initialized the value to the opposite value I intended to ! trunk r27830, branches/1.11 r27831 "OCI: fix previous commit. bExtentUpdated should be initialized to false (#5376)"

Note: See TracTickets for help on using tickets.