Allow DML RETURNING of RAW data

This commit is contained in:
Christopher Jones 2018-03-27 16:54:55 +11:00
parent 00a25dcfd0
commit 0985b5d02f
10 changed files with 76 additions and 85 deletions

View File

@ -437,12 +437,6 @@ bool njsConnection::PrepareAndBind(njsBaton *baton)
for (uint32_t i = 0; i < baton->numBindVars; i++) {
int status;
njsVariable *var = &baton->bindVars[i];
if (stmtInfo.isReturning && var->bindDir == NJS_BIND_OUT &&
var->varTypeNum == DPI_ORACLE_TYPE_RAW) {
baton->error = njsMessages::Get(errBufferReturningInvalid);
baton->ClearAsyncData();
return false;
}
if (var->name.empty())
status = dpiStmt_bindByPos(baton->dpiStmtHandle, var->pos,
var->dpiVarHandle);

View File

@ -62,7 +62,6 @@ static const char *errMsg[] = {
"NJS-025: overflow when calculating results area size", // errResultsTooLarge
"NJS-026: maxRows must be greater than zero", // errInvalidmaxRows
"NJS-027: unexpected SQL parsing error", // errSQLSyntaxError
"NJS-028: raw database type is not supported with DML Returning statements", // errBufferReturningInvalid
"NJS-029: invalid object from JavaScript", // errInvalidJSObject
"NJS-030: connection cannot be released because Lob operations are in progress", // errBusyConnLOB
"NJS-031: connection cannot be released because ResultSet operations are in progress", // errBusyConnRS

View File

@ -65,7 +65,6 @@ typedef enum {
errResultsTooLarge,
errInvalidmaxRows,
errSQLSyntaxError,
errBufferReturningInvalid,
errInvalidJSObject,
errBusyConnLOB,
errBusyConnRS,

View File

@ -117,8 +117,8 @@ describe('98.binding_DMLReturningInto.js', function() {
if(bindType === oracledb.STRING) {
compareStrErrMsg(dbColType, err);
} else {
// NJS-028: RAW database type is not supported with DML Returning statements
(err.message).should.startWith('NJS-028:');
// oracledb.BUFFER
compareBufErrMsg(dbColType, err);
}
cb();
}
@ -130,6 +130,14 @@ describe('98.binding_DMLReturningInto.js', function() {
], callback);
};
var compareBufErrMsg = function(element, err) {
if (element === "RAW" || element === "BLOB") {
should.not.exist(err);
} else {
(err.message).should.startWith('ORA-00932:');
}
};
var compareStrErrMsg = function(element, err) {
if(element === "BLOB" && (connection.oracleServerVersion < 1202000100)) {
// ORA-00932: inconsistent datatypes: expected CHAR got BLOB
@ -273,7 +281,7 @@ describe('98.binding_DMLReturningInto.js', function() {
doTest(table_name, dbColType, content, bindType, nullBind, done);
});
it('98.1.14 oracledb.BUFFER <--> DB: CHAR', function(done) {
it.skip('98.1.14 oracledb.BUFFER <--> DB: CHAR', function(done) {
index++;
var table_name = tableNamePre + index;
var content = assist.createBuffer(100);
@ -283,7 +291,7 @@ describe('98.binding_DMLReturningInto.js', function() {
doTest(table_name, dbColType, content, bindType, nullBind, done);
});
it('98.1.15 oracledb.BUFFER <--> DB: NCHAR', function(done) {
it.skip('98.1.15 oracledb.BUFFER <--> DB: NCHAR', function(done) {
index++;
var table_name = tableNamePre + index;
var content = assist.createBuffer(100);
@ -293,7 +301,7 @@ describe('98.binding_DMLReturningInto.js', function() {
doTest(table_name, dbColType, content, bindType, nullBind, done);
});
it('98.1.16 oracledb.BUFFER <--> DB: VARCHAR2', function(done) {
it.skip('98.1.16 oracledb.BUFFER <--> DB: VARCHAR2', function(done) {
index++;
var table_name = tableNamePre + index;
var content = assist.createBuffer(100);
@ -515,7 +523,7 @@ describe('98.binding_DMLReturningInto.js', function() {
doTest(table_name, dbColType, content, bindType, nullBind, done);
});
it('98.2.14 oracledb.BUFFER <--> DB: CHAR', function(done) {
it.skip('98.2.14 oracledb.BUFFER <--> DB: CHAR', function(done) {
index++;
var table_name = tableNamePre + index;
var content = null;
@ -525,7 +533,7 @@ describe('98.binding_DMLReturningInto.js', function() {
doTest(table_name, dbColType, content, bindType, nullBind, done);
});
it('98.2.15 oracledb.BUFFER <--> DB: NCHAR', function(done) {
it.skip('98.2.15 oracledb.BUFFER <--> DB: NCHAR', function(done) {
index++;
var table_name = tableNamePre + index;
var content = null;
@ -535,7 +543,7 @@ describe('98.binding_DMLReturningInto.js', function() {
doTest(table_name, dbColType, content, bindType, nullBind, done);
});
it('98.2.16 oracledb.BUFFER <--> DB: VARCHAR2', function(done) {
it.skip('98.2.16 oracledb.BUFFER <--> DB: VARCHAR2', function(done) {
index++;
var table_name = tableNamePre + index;
var content = null;

View File

@ -525,7 +525,7 @@ describe('82.blobDMLBindAsBuffer.js', function() {
);
}); // 82.1.17
it('82.1.18 Negative: RETURNING INTO with bind type BUFFER', function(done) {
it('82.1.18 RETURNING INTO with bind type BUFFER', function(done) {
var id = insertID++;
var contentLength = 400;
var specialStr = "82.1.18";
@ -533,20 +533,27 @@ describe('82.blobDMLBindAsBuffer.js', function() {
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
var sql = "INSERT INTO nodb_dml_blob_1 (id, blob) VALUES (:i, :c) RETURNING blob INTO :lobbv";
connection.execute(
sql,
{
i: id,
c: { val: content, type: oracledb.BUFFER, dir: oracledb.BIND_IN },
lobbv: { type: oracledb.BUFFER, dir: oracledb.BIND_OUT, maxSize: contentLength }
async.series([
function(cb) {
connection.execute(
sql,
{
i: id,
c: { val: content, type: oracledb.BUFFER, dir: oracledb.BIND_IN },
lobbv: { type: oracledb.BUFFER, dir: oracledb.BIND_OUT, maxSize: contentLength }
},
function(err, result) {
should.not.exist(err);
should.strictEqual(result.rowsAffected, 1);
cb();
}
);
},
function(err) {
should.exist(err);
// NJS-028: RAW database type is not supported with DML Returning statements
(err.message).should.startWith('NJS-028:');
done();
function(cb) {
checkInsertResult(id, content, specialStr, cb);
}
);
], done);
}); // 82.1.18
it('82.1.19 Negative: RETURNING INTO with autocommit on', function(done) {

View File

@ -73,13 +73,16 @@ describe('137. blobDMLReturningMultipleRowsAsBuffer.js', function() {
});
describe('137.1 BLOB DML returning multiple rows as buffer', function() {
var tabsize = 10;
before(function(done) {
async.series([
function(cb) {
sql.executeSql(connection, blob_table_create, {}, {}, cb);
},
function(cb) {
insertData(10, cb);
insertData(tabsize, cb);
}
], done);
});
@ -88,7 +91,7 @@ describe('137. blobDMLReturningMultipleRowsAsBuffer.js', function() {
});
it('137.1.1 BLOB DML returning multiple rows as buffer', function(done) {
updateReturning_buffer(done);
updateReturning_buffer(tabsize, done);
});
});
@ -128,7 +131,7 @@ describe('137. blobDMLReturningMultipleRowsAsBuffer.js', function() {
], cb);
};
var updateReturning_buffer = function(callback) {
var updateReturning_buffer = function(tabsize, callback) {
var sql_update = "UPDATE " + tableName + " set num = num+10 RETURNING num, blob into :num, :lobou";
connection.execute(
sql_update,
@ -136,9 +139,14 @@ describe('137. blobDMLReturningMultipleRowsAsBuffer.js', function() {
num: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
lobou: { type: oracledb.BUFFER, dir: oracledb.BIND_OUT }
},
function(err) {
should.exist(err);
should.strictEqual((err.message), "NJS-028: raw database type is not supported with DML Returning statements");
function(err, result) {
should.not.exist(err);
for (var i = 0; i < tabsize; i++) {
var outnum = result.outBinds.num[i];
var outbuf = Number( result.outBinds.lobou[i] );
should.strictEqual(outbuf, i+1);
should.strictEqual(outnum, i+11);
}
callback();
}
);

View File

@ -150,7 +150,7 @@ describe('42. dataTypeRaw.js', function() {
});
});
describe('42.3 DML Returning - Currently not support RAW', function() {
describe('42.3 DML Returning', function() {
before('create table', function(done) {
assist.createTable(connection, tableName, done);
@ -181,10 +181,9 @@ describe('42. dataTypeRaw.js', function() {
},
{ autoCommit: true },
function(err, result) {
should.exist(err);
(err.message).should.startWith('NJS-028:');
// NJS-028: raw database type is not supported with DML Returning statements
should.not.exist(result);
should.not.exist(err);
should.strictEqual(result.outBinds.rid[0], seq);
should.deepEqual(result.outBinds.rc[0], bindValue);
done();
}
);
@ -205,9 +204,9 @@ describe('42. dataTypeRaw.js', function() {
],
{ autoCommit: true },
function(err, result) {
should.exist(err);
(err.message).should.startWith('NJS-028:');
should.not.exist(result);
should.not.exist(err);
should.strictEqual(result.outBinds[0][0], seq);
should.deepEqual(result.outBinds[1][0], bindValue);
done();
}
);
@ -224,13 +223,13 @@ describe('42. dataTypeRaw.js', function() {
n : seq,
c : { type: oracledb.BUFFER, val: bindValue, dir: oracledb.BIND_IN },
rid : { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
rc : { type: oracledb.BUFFER, dir: oracledb.BIND_OUT, maxSize: size * 2 } // should be size
rc : { type: oracledb.BUFFER, dir: oracledb.BIND_OUT, maxSize: size}
},
{ autoCommit: true },
function(err, result) {
should.exist(err);
(err.message).should.startWith('NJS-028:');
should.not.exist(result);
should.not.exist(err);
should.strictEqual(result.outBinds.rid[0], seq);
should.deepEqual(result.outBinds.rc[0], bindValue);
done();
}
);
@ -251,15 +250,15 @@ describe('42. dataTypeRaw.js', function() {
},
{ autoCommit: true },
function(err, result) {
should.exist(err);
(err.message).should.startWith('NJS-028:');
should.not.exist(result);
should.not.exist(err);
should.strictEqual(result.outBinds.rid[0], seq);
should.deepEqual(result.outBinds.rc[0], bindValue);
done();
}
);
}); // 42.3.4
it('42.3.6 DELETE statement with single row matching', function(done) {
it('42.3.5 DELETE statement with single row matching', function(done) {
var seq = 1;
connection.execute(
@ -271,15 +270,14 @@ describe('42. dataTypeRaw.js', function() {
],
{ autoCommit: true },
function(err, result) {
should.exist(err);
(err.message).should.startWith('NJS-028:');
should.not.exist(result);
should.not.exist(err);
should.strictEqual(result.outBinds[0][0], seq);
done();
}
);
});
it('42.3.7 DELETE statement with multiple rows matching', function(done) {
it('42.3.6 DELETE statement with multiple rows matching', function(done) {
var seq = 1;
connection.execute(
@ -291,9 +289,8 @@ describe('42. dataTypeRaw.js', function() {
},
{ autoCommit: true },
function(err, result) {
should.exist(err);
(err.message).should.startWith('NJS-028:');
should.not.exist(result);
should.not.exist(err);
should.deepEqual(result.outBinds.rid, [2, 3]);
done();
}
);

View File

@ -365,25 +365,6 @@ describe('6. dmlReturning.js', function(){
);
});
it('6.1.12 Negative test - data type is not supported with DML Returning statments', function(done) {
var sql = "UPDATE nodb_dmlreturn SET name = 'Leslie Lin' WHERE id = :id RETURNING name INTO :rn ";
var bindVar =
{
id: 1002,
rn: { type: oracledb.BUFFER, dir: oracledb.BIND_OUT }
};
connection.execute(sql, bindVar, function(err, result) {
should.exist(err);
// NJS-028: raw database type is not supported with DML Returning statements
(err.message).should.startWith('NJS-028:');
should.not.exist(result);
done();
});
});
}); // 6.1
describe('6.2 DATE and TIMESTAMP data', function() {

View File

@ -177,7 +177,6 @@ Overview of node-oracledb functional tests
6.1.9 DELETE statement with Array binding
6.1.10 Stress test - support 4k varchars
6.1.11 Negative test - throws correct error message
6.1.12 Negative test - data type is not supported with DML Returning statments
6.2 DATE and TIMESTAMP data
6.2.1 INSERT statement, single row matched, Object binding, no bind in data
6.2.2 INSERT statement with JavaScript date bind in
@ -733,8 +732,8 @@ Overview of node-oracledb functional tests
42.3.2 INSERT statement with ARRAY binding
42.3.3 INSERT statement with exact maxSize restriction
42.3.4 UPDATE statement
42.3.6 DELETE statement with single row matching
42.3.7 DELETE statement with multiple rows matching
42.3.5 DELETE statement with single row matching
42.3.6 DELETE statement with multiple rows matching
42.4 in PL/SQL, the maximum size is 32767
42.4.1 works well when the length of data is less than maxSize
42.4.2 works well when the length of data is exactly 32767
@ -1717,7 +1716,7 @@ Overview of node-oracledb functional tests
82.1.15 bind value and type mismatch
82.1.16 mixing named with positional binding
82.1.17 bind with invalid BLOB
82.1.18 Negative: RETURNING INTO with bind type BUFFER
82.1.18 RETURNING INTO with bind type BUFFER
82.1.19 Negative: RETURNING INTO with autocommit on
82.1.20 works with bind in maxSize smaller than buffer size
82.2 BLOB, UPDATE

View File

@ -204,9 +204,9 @@ describe('126. longrawDMLBind.js', function() {
}); // 126.2
describe('126.3 RETURNING INTO', function() {
describe.skip('126.3 RETURNING INTO', function() {
it('126.3.1 do not support in returning into', function(done) {
it('126.3.1 works with data size 64K - 1', function(done) {
var insertedStr = random.getRandomLengthString(100);
var updateStr = random.getRandomLengthString(65535);
var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr);
@ -297,8 +297,7 @@ describe('126. longrawDMLBind.js', function() {
sql,
bindVar,
function(err) {
should.exist(err);
should.strictEqual(err.message, "NJS-028: raw database type is not supported with DML Returning statements");
should.not.exist(err);
callback();
}
);