oci: Use OCIBindByPos2 to accommodate data longer than USHRT_MAX
OCIBindByPos2 is only needed when using execBatch(), binding data that is longer than USHRT_MAX works for exec() so this is left unchanged. Change-Id: Ifdcf91939d184f225d24c13052ea0b81611ecf91 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
fd87c8da82
commit
ec23d96c86
@ -1318,7 +1318,7 @@ struct QOCIBatchColumn
|
||||
ub4 maxLen;
|
||||
ub4 recordCount;
|
||||
char* data;
|
||||
ub2* lengths;
|
||||
ub4* lengths;
|
||||
sb2* indicators;
|
||||
ub4 maxarr_len;
|
||||
ub4 curelep;
|
||||
@ -1392,7 +1392,7 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVector<QVariant> &boundValues, b
|
||||
QOCIBatchColumn &col = columns[i];
|
||||
col.recordCount = boundValues.at(i).toList().count();
|
||||
|
||||
col.lengths = new ub2[col.recordCount];
|
||||
col.lengths = new ub4[col.recordCount];
|
||||
col.indicators = new sb2[col.recordCount];
|
||||
col.maxarr_len = col.recordCount;
|
||||
col.curelep = col.recordCount;
|
||||
@ -1556,7 +1556,7 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVector<QVariant> &boundValues, b
|
||||
|
||||
|
||||
// binding the column
|
||||
r = OCIBindByPos(
|
||||
r = OCIBindByPos2(
|
||||
d->sql, &bindColumn.bindh, d->err, i + 1,
|
||||
bindColumn.data,
|
||||
bindColumn.maxLen,
|
||||
|
@ -128,6 +128,8 @@ private slots:
|
||||
void mysql_outValues();
|
||||
void oraClob_data() { generic_data("QOCI"); }
|
||||
void oraClob();
|
||||
void oraClobBatch_data() { generic_data("QOCI"); }
|
||||
void oraClobBatch();
|
||||
void oraLong_data() { generic_data("QOCI"); }
|
||||
void oraLong();
|
||||
void oraOCINumber_data() { generic_data("QOCI"); }
|
||||
@ -810,6 +812,28 @@ void tst_QSqlQuery::oraClob()
|
||||
QVERIFY( q.value( 1 ).toByteArray() == loong.toLatin1() );
|
||||
}
|
||||
|
||||
void tst_QSqlQuery::oraClobBatch()
|
||||
{
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const QString clobBatch(qTableName("clobBatch", __FILE__, db));
|
||||
tst_Databases::safeDropTables(db, { clobBatch });
|
||||
QSqlQuery q(db);
|
||||
QVERIFY_SQL(q, exec("create table " + clobBatch + "(cl clob)"));
|
||||
|
||||
const QString longString(USHRT_MAX + 1, QLatin1Char('A'));
|
||||
QVERIFY_SQL(q, prepare("insert into " + clobBatch + " (cl) values(:cl)"));
|
||||
const QVariantList vars = { longString };
|
||||
q.addBindValue(vars);
|
||||
QVERIFY_SQL(q, execBatch());
|
||||
|
||||
QVERIFY_SQL(q, exec("select cl from " + clobBatch));
|
||||
QVERIFY(q.next());
|
||||
QCOMPARE(q.value(0).toString().count(), longString.size());
|
||||
QVERIFY(q.value(0).toString() == longString);
|
||||
}
|
||||
|
||||
void tst_QSqlQuery::storedProceduresIBase()
|
||||
{
|
||||
QFETCH( QString, dbName );
|
||||
|
Loading…
x
Reference in New Issue
Block a user