Skip to content

Commit 4b00182

Browse files
committed
oracle provider: by default skip additional geometry columns (on 64bit
Windows/Linux OCI crashes when there are more than three geometry columns)
1 parent f473521 commit 4b00182

7 files changed

Lines changed: 34 additions & 8 deletions

File tree

python/plugins/db_manager/db_plugins/oracle/connector.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ def __init__(self, uri, connName):
8484
'allowGeometrylessTables').lower() == "true"
8585
self.onlyExistingTypes = uri.param(
8686
'onlyExistingTypes').lower() == "true"
87+
self.includeGeoAttributes = uri.param(
88+
'includeGeoAttributes').lower() == "true"
8789

8890
# For refreshing
8991
self.populated = False

python/plugins/db_manager/db_plugins/oracle/plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ def connect(self, parent=None):
105105
settings.value("allowGeometrylessTables", False, type=bool)))
106106
uri.setParam('onlyExistingTypes', unicode(
107107
settings.value("onlyExistingTypes", False, type=bool)))
108+
uri.setParam('includeGeoAttributes', unicode(
109+
settings.value("includeGeoAttributes", False, type=bool)))
108110

109111
settings.endGroup()
110112

src/providers/oracle/qgsoracleconn.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ void QgsOracleConn::deleteConnection( QString theConnName )
678678
settings.remove( key + "/allowGeometrylessTables" );
679679
settings.remove( key + "/estimatedMetadata" );
680680
settings.remove( key + "/onlyExistingTypes" );
681+
settings.remove( key + "/includeGeoAttributes" );
681682
settings.remove( key + "/saveUsername" );
682683
settings.remove( key + "/savePassword" );
683684
settings.remove( key + "/save" );

src/providers/oracle/qgsoraclenewconnection.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ QgsOracleNewConnection::QgsOracleNewConnection( QWidget *parent, const QString&
5252
cb_allowGeometrylessTables->setChecked( settings.value( key + "/allowGeometrylessTables", false ).toBool() );
5353
cb_useEstimatedMetadata->setChecked( settings.value( key + "/estimatedMetadata", false ).toBool() );
5454
cb_onlyExistingTypes->setChecked( settings.value( key + "/onlyExistingTypes", true ).toBool() );
55+
cb_includeGeoAttributes->setChecked( settings.value( key + "/includeGeoAttributes", false ).toBool() );
5556

5657
if ( settings.value( key + "/saveUsername" ).toString() == "true" )
5758
{
@@ -126,6 +127,7 @@ void QgsOracleNewConnection::accept()
126127
settings.setValue( baseKey + "/allowGeometrylessTables", cb_allowGeometrylessTables->isChecked() );
127128
settings.setValue( baseKey + "/estimatedMetadata", cb_useEstimatedMetadata->isChecked() ? "true" : "false" );
128129
settings.setValue( baseKey + "/onlyExistingTypes", cb_onlyExistingTypes->isChecked() ? "true" : "false" );
130+
settings.setValue( baseKey + "/includeGeoAttributes", cb_includeGeoAttributes->isChecked() ? "true" : "false" );
129131
settings.setValue( baseKey + "/saveUsername", chkStoreUsername->isChecked() ? "true" : "false" );
130132
settings.setValue( baseKey + "/savePassword", chkStorePassword->isChecked() ? "true" : "false" );
131133
settings.setValue( baseKey + "/dboptions", txtOptions->text() );

src/providers/oracle/qgsoracleprovider.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ QgsOracleProvider::QgsOracleProvider( QString const & uri )
7070
mSrid = mUri.srid().toInt();
7171
mRequestedGeomType = mUri.wkbType();
7272
mUseEstimatedMetadata = mUri.useEstimatedMetadata();
73+
mIncludeGeoAttributes = mUri.hasParam( "includegeoattributes" ) ? mUri.param( "includegeoattributes" ) == "true" : false;
7374

7475
mConnection = QgsOracleConn::connectDb( mUri );
7576
if ( !mConnection )
@@ -605,11 +606,12 @@ bool QgsOracleProvider::loadFields()
605606
",t.char_used"
606607
",t.data_default"
607608
" FROM all_tab_columns t"
608-
" WHERE t.owner=%1 AND t.table_name=%2%3"
609+
" WHERE t.owner=%1 AND t.table_name=%2%3%4"
609610
" ORDER BY t.column_id" )
610611
.arg( quotedValue( mOwnerName ) )
611612
.arg( quotedValue( mTableName ) )
612613
.arg( mGeometryColumn.isEmpty() ? "" : QString( " AND t.column_name<>%1 " ).arg( quotedValue( mGeometryColumn ) ) )
614+
.arg( mIncludeGeoAttributes ? "" : " AND (t.data_type_owner<>'MDSYS' OR t.data_type<>'SDO_GEOMETRY')" )
613615
) )
614616
{
615617
while ( qry.next() )

src/providers/oracle/qgsoracleprovider.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ class QgsOracleProvider : public QgsVectorDataProvider
358358
/* Use estimated metadata. Uses fast table counts, geometry type and extent determination */
359359
bool mUseEstimatedMetadata;
360360

361+
/* Include additional geo attributes */
362+
bool mIncludeGeoAttributes;
363+
361364
struct OracleFieldNotFound {}; //! Exception to throw
362365

363366
struct OracleException

src/ui/qgsoraclenewconnectionbase.ui

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@
4545
<string>Connection Information</string>
4646
</property>
4747
<layout class="QGridLayout" name="gridLayout_1">
48+
<item row="9" column="0" colspan="2">
49+
<widget class="QCheckBox" name="chkStorePassword">
50+
<property name="text">
51+
<string>Save Password</string>
52+
</property>
53+
</widget>
54+
</item>
4855
<item row="13" column="0" colspan="3">
4956
<widget class="QCheckBox" name="cb_useEstimatedMetadata">
5057
<property name="toolTip">
@@ -187,13 +194,6 @@
187194
<item row="1" column="1" colspan="2">
188195
<widget class="QLineEdit" name="txtDatabase"/>
189196
</item>
190-
<item row="9" column="0" colspan="2">
191-
<widget class="QCheckBox" name="chkStorePassword">
192-
<property name="text">
193-
<string>Save Password</string>
194-
</property>
195-
</widget>
196-
</item>
197197
<item row="0" column="1" colspan="2">
198198
<widget class="QLineEdit" name="txtName">
199199
<property name="toolTip">
@@ -252,6 +252,19 @@
252252
</property>
253253
</widget>
254254
</item>
255+
<item row="15" column="0" colspan="3">
256+
<widget class="QCheckBox" name="cb_includeGeoAttributes">
257+
<property name="toolTip">
258+
<string/>
259+
</property>
260+
<property name="whatsThis">
261+
<string/>
262+
</property>
263+
<property name="text">
264+
<string>Include additional geometry attributes</string>
265+
</property>
266+
</widget>
267+
</item>
255268
</layout>
256269
</widget>
257270
</item>
@@ -275,6 +288,7 @@
275288
<tabstop>cb_allowGeometrylessTables</tabstop>
276289
<tabstop>cb_useEstimatedMetadata</tabstop>
277290
<tabstop>cb_onlyExistingTypes</tabstop>
291+
<tabstop>cb_includeGeoAttributes</tabstop>
278292
<tabstop>buttonBox</tabstop>
279293
</tabstops>
280294
<resources/>

0 commit comments

Comments
 (0)