Update code to connect to Oracle Database 23ai Cloud Free Database

This commit is contained in:
Sharad Chandran R 2024-05-02 21:59:44 +05:30
parent ea431d3451
commit 622c44a2da
5 changed files with 18 additions and 20 deletions

View File

@ -36,31 +36,31 @@ const errors = require('../../errors');
*/
class Capabilities {
constructor(protocolVersion) {
this.protocolVersion = protocolVersion;
constructor(nscon) {
this.protocolVersion = nscon.sAtts.version;
this.ttcFieldVersion = constants.TNS_CCAP_FIELD_VERSION_MAX;
this.supports12cLogon = true;
this.supportsOob = false;
this.nCharsetId = constants.TNS_CHARSET_UTF16;
this.compileCaps = Buffer.alloc(constants.TNS_CCAP_MAX);
this.runtimeCaps = Buffer.alloc(constants.TNS_RCAP_MAX);
this.initCompileCaps();
this.initCompileCaps(nscon);
this.initRuntimeCaps();
this.maxStringSize = 0;
}
adjustForServerCompileCaps(serverCaps) {
adjustForServerCompileCaps(serverCaps, nscon) {
if (serverCaps[constants.TNS_CCAP_FIELD_VERSION] < this.ttcFieldVersion) {
this.ttcFieldVersion = serverCaps[constants.TNS_CCAP_FIELD_VERSION];
this.compileCaps[constants.TNS_CCAP_FIELD_VERSION] =
this.ttcFieldVersion;
}
if (this.ttcFieldVersion < constants.TNS_CCAP_FIELD_VERSION_23_4 ||
!(serverCaps[constants.TNS_CCAP_TTC4] &
constants.TNS_CCAP_END_OF_REQUEST)) {
// TTIDONE used only from 23.4 onwards
if ((this.ttcFieldVersion < constants.TNS_CCAP_FIELD_VERSION_23_4
&& nscon.endOfRequestSupport)) {
// endOfRequestSupport used only from 23.4 onwards and not for 23.3
this.compileCaps[constants.TNS_CCAP_TTC4]
^= constants.TNS_CCAP_END_OF_REQUEST;
nscon.endOfRequestSupport = false;
}
}
@ -72,7 +72,7 @@ class Capabilities {
}
}
initCompileCaps() {
initCompileCaps(nscon) {
this.compileCaps[constants.TNS_CCAP_SQL_VERSION] =
constants.TNS_CCAP_SQL_VERSION_MAX;
this.compileCaps[constants.TNS_CCAP_LOGON_TYPES] =
@ -110,8 +110,10 @@ class Capabilities {
this.compileCaps[constants.TNS_CCAP_CLIENT_FN] =
constants.TNS_CCAP_CLIENT_FN_MAX;
this.compileCaps[constants.TNS_CCAP_TTC4] =
constants.TNS_CCAP_INBAND_NOTIFICATION |
constants.TNS_CCAP_END_OF_REQUEST;
constants.TNS_CCAP_INBAND_NOTIFICATION;
if (nscon.endOfRequestSupport) {
this.compileCaps[constants.TNS_CCAP_TTC4] |= constants.TNS_CCAP_END_OF_REQUEST;
}
this.compileCaps[constants.TNS_CCAP_CTB_FEATURE_BACKPORT] =
constants.TNS_CCAP_CTB_IMPLICIT_POOL;
this.compileCaps[constants.TNS_CCAP_TTC5] =

View File

@ -76,12 +76,7 @@ class ProtocolMessage extends Message {
const serverCompileCaps = buf.readBytesWithLength();
if (serverCompileCaps) {
this.serverCompileCaps = Buffer.from(serverCompileCaps);
buf.caps.adjustForServerCompileCaps(this.serverCompileCaps);
// use endOfRequestSupport only from 23.4 onwards
if (buf.caps.ttcFieldVersion < constants.TNS_CCAP_FIELD_VERSION_23_4) {
this.connection.nscon.endOfRequestSupport = false;
}
buf.caps.adjustForServerCompileCaps(this.serverCompileCaps, this.connection.nscon);
// Set the maximum OSON field name size
if (buf.caps.ttcFieldVersion >= constants.TNS_CCAP_FIELD_VERSION_23_1) {

View File

@ -49,7 +49,7 @@ class Protocol {
* Compile and Runtime capabilities negotiated with Server
* @type {object}
*/
this.caps = new Capabilities(conn.nscon.sAtts.version);
this.caps = new Capabilities(conn.nscon);
this.writeBuf = new WritePacket(conn.nscon, this.caps, this);
this.readBuf = new ReadPacket(conn.nscon, this.caps);
this.callTimeout = 0;

View File

@ -107,8 +107,8 @@ module.exports = {
NSGRAW: 0x1000, // I/O is direct to/from transport
TNS_VERSION_DESIRED: 319,
TNS_VERSION_MINIMUM: 300,
TNS_VERSION_MIN_UUID: 319,
TNS_VERSION_MIN_DATA_FLAGS: 318,
TNS_VERSION_MIN_END_OF_RESPONSE: 319,
TNS_UUID_OFFSET: 45,
/* Accept Packet */

View File

@ -360,7 +360,8 @@ class NetworkSession {
break;
case constants.NSPTAC: /* ACCEPT */
Packet.AcceptPacket(packet, this.sAtts);
if (packet.flags & constants.TNS_ACCEPT_FLAG_HAS_END_OF_REQUEST) {
if (this.sAtts.version >= constants.TNS_VERSION_MIN_END_OF_RESPONSE
&& (packet.flags & constants.TNS_ACCEPT_FLAG_HAS_END_OF_REQUEST)) {
this.endOfRequestSupport = true;
}
if (packet.flags & constants.TNS_ACCEPT_FLAG_FAST_AUTH) {