Skip to content

Commit

Permalink
[oracle] Remove meaningless conditional and improve user input handling
Browse files Browse the repository at this point in the history
(cherry-pick from commit 4ab377b)

Author :     Björn Harrtell <bjorn@wololo.org>
Date :       Wed Oct 31 14:45:37 2018 +0100
  • Loading branch information
bjornharrtell authored and rldhont committed Nov 2, 2018
1 parent 8a8a741 commit 0e066db
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions src/providers/oracle/ocispatial/qsql_ocispatial.cpp
Expand Up @@ -415,28 +415,23 @@ void QOCISpatialResultPrivate::setStatementAttributes()

int r = OCI_SUCCESS;

if ( prefetchRows >= 0 )
{
r = OCIAttrSet( sql,
OCI_HTYPE_STMT,
&prefetchRows,
0,
OCI_ATTR_PREFETCH_ROWS,
err );
if ( r != OCI_SUCCESS )
qOraWarning( "Couldn't set OCI_ATTR_PREFETCH_ROWS: ", err );
}
if ( prefetchMem >= 0 )
{
r = OCIAttrSet( sql,
OCI_HTYPE_STMT,
&prefetchMem,
0,
OCI_ATTR_PREFETCH_MEMORY,
err );
if ( r != OCI_SUCCESS )
qOraWarning( "Couldn't set OCI_ATTR_PREFETCH_MEMORY: ", err );
}
r = OCIAttrSet( sql,
OCI_HTYPE_STMT,
&prefetchRows,
0,
OCI_ATTR_PREFETCH_ROWS,
err );
if ( r != OCI_SUCCESS )
qOraWarning( "Couldn't set OCI_ATTR_PREFETCH_ROWS: ", err );
r = OCIAttrSet( sql,
OCI_HTYPE_STMT,
&prefetchMem,
0,
OCI_ATTR_PREFETCH_MEMORY,
err );
if ( r != OCI_SUCCESS )
qOraWarning( "QOCISpatialResultPrivate::setStatementAttributes:"
" Couldn't set OCI_ATTR_PREFETCH_MEMORY: ", err );
}

int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError *err, int pos,
Expand Down Expand Up @@ -3379,15 +3374,19 @@ static void qParseOpts( const QString &options, QOCISpatialDriverPrivate *d )
bool ok;
if ( opt == QLatin1String( "OCI_ATTR_PREFETCH_ROWS" ) )
{
d->prefetchRows = val.toInt( &ok );
int intVal = val.toInt( &ok );
if ( !ok )
d->prefetchRows = QOCISPATIAL_PREFETCH_ROWS;
else if ( intVal >= 0 )
d->prefetchRows = static_cast<ub4>( intVal );
}
else if ( opt == QLatin1String( "OCI_ATTR_PREFETCH_MEMORY" ) )
{
d->prefetchMem = val.toInt( &ok );
int intVal = val.toInt( &ok );
if ( !ok )
d->prefetchMem = QOCISPATIAL_PREFETCH_MEM;
else if ( intVal >= 0 )
d->prefetchMem = static_cast<ub4>( intVal );
}
else
{
Expand Down

0 comments on commit 0e066db

Please sign in to comment.