Skip to content

Commit c7c495b

Browse files
committed
Internal changes to improve protocol handling between the database and the client
1 parent 2fd69c6 commit c7c495b

File tree

7 files changed

+27
-24
lines changed

7 files changed

+27
-24
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Thin Mode Changes
5959
#) Improved overall pool connection creation time by caching information
6060
during the first connection establishment.
6161

62+
#) Internal changes to improve protocol handling between the database and
63+
the client.
64+
6265
Thick Mode Changes
6366
++++++++++++++++++
6467

lib/thin/protocol/capabilities.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ class Capabilities {
8989
this.compileCaps[constants.TNS_CCAP_DBF_VERSION] =
9090
constants.TNS_CCAP_DBF_VERSION_MAX;
9191
this.compileCaps[constants.TNS_CCAP_LOB] =
92-
constants.TNS_CCAP_LOB_UB8_SIZE | constants.TNS_CCAP_LOB_ENCS | constants.TNS_CCAP_LOB_PREFETCH;
92+
constants.TNS_CCAP_LOB_UB8_SIZE | constants.TNS_CCAP_LOB_ENCS
93+
| constants.TNS_CCAP_LOB_PREFETCH | constants.TNS_CCAP_LOB_TEMP_SIZE
94+
| constants.TNS_CCAP_LOB_12C | constants.TNS_CCAP_LOB_PREFETCH_DATA;
9395
this.compileCaps[constants.TNS_CCAP_UB2_DTY] = 1;
9496
this.compileCaps[constants.TNS_CCAP_LOB2] =
9597
constants.TNS_CCAP_LOB2_QUASI | constants.TNS_CCAP_LOB2_2GB_PREFETCH;

lib/thin/protocol/constants.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,10 @@ module.exports = {
650650
TNS_CCAP_KEEP_OUT_ORDER: 0x80,
651651
TNS_CCAP_LOB_UB8_SIZE: 0x01,
652652
TNS_CCAP_LOB_ENCS: 0x02,
653+
TNS_CCAP_LOB_PREFETCH_DATA: 0x04,
654+
TNS_CCAP_LOB_TEMP_SIZE: 0x08,
653655
TNS_CCAP_LOB_PREFETCH: 0x40,
656+
TNS_CCAP_LOB_12C: 0x80,
654657
TNS_CCAP_DRCP: 0x10,
655658
TNS_CCAP_ZLNP: 0x04,
656659
TNS_CCAP_INBAND_NOTIFICATION: 0x04,

lib/thin/protocol/messages/base.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ class Message {
6969
buf.skipUB2(); // array elem error
7070
buf.skipUB2(); // array elem error
7171
this.errorInfo.cursorId = buf.readUB2(); // cursor id
72-
this.errorInfo.pos = buf.readUB2(); // error position
72+
const errorPos = buf.readSB2(); // error position
7373
buf.skipUB1(); // sql type (19c and earlier)
7474
buf.skipUB1(); // fatal ?
75-
buf.skipUB2(); // flags
76-
buf.skipUB2(); // user cursor options
75+
buf.skipUB1(); // flags
76+
buf.skipUB1(); // user cursor options
7777
buf.skipUB1(); // UPI parameter
7878
buf.skipUB1(); // warning flag
7979
this.errorInfo.rowID = buf.readRowID(); // rowid
@@ -138,8 +138,13 @@ class Message {
138138
buf.skipUB4(); // sql type
139139
buf.skipUB4(); // server checksum
140140
}
141+
142+
// error message
141143
if (this.errorInfo.num !== 0) {
142144
this.errorOccurred = true;
145+
if (errorPos >= 0) {
146+
this.errorInfo.pos = errorPos;
147+
}
143148
this.errorInfo.message = buf.readStr(constants.CSFRM_IMPLICIT);
144149
/*
145150
* Remove ending newline from ORA error message
@@ -154,7 +159,7 @@ class Message {
154159

155160
processWarningInfo(buf) {
156161
this.errorInfo.num = buf.readUB2(); // error number
157-
const numBytes = buf.readUB2(); // length of error message
162+
const numBytes = buf.readUB2(); // length of error message
158163
buf.skipUB2(); // flags
159164
if (this.errorInfo.num != 0 && numBytes > 0) {
160165
this.errorInfo.message = buf.readStr(constants.CSFRM_IMPLICIT);

lib/thin/protocol/messages/dataType.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const dataTypes = [
8181
[constants.TNS_DATA_TYPE_LONG_RAW, constants.TNS_DATA_TYPE_LONG_RAW, constants.TNS_TYPE_REP_UNIVERSAL],
8282
[constants.TNS_DATA_TYPE_UB2, constants.TNS_DATA_TYPE_UB2, constants.TNS_TYPE_REP_UNIVERSAL],
8383
[constants.TNS_DATA_TYPE_UB4, constants.TNS_DATA_TYPE_UB4, constants.TNS_TYPE_REP_UNIVERSAL],
84-
[constants.TNS_DATA_TYPE_SB1, constants.TNS_DATA_TYPE_SB1, constants.TNS_TYPE_REP_UNIVERSAL],
84+
[constants.TNS_DATA_TYPE_SB1, constants.TNS_DATA_TYPE_SB1, constants.TNS_TYPE_REP_ORACLE],
8585
[constants.TNS_DATA_TYPE_SB2, constants.TNS_DATA_TYPE_SB2, constants.TNS_TYPE_REP_UNIVERSAL],
8686
[constants.TNS_DATA_TYPE_SB4, constants.TNS_DATA_TYPE_SB4, constants.TNS_TYPE_REP_UNIVERSAL],
8787
[constants.TNS_DATA_TYPE_SWORD, constants.TNS_DATA_TYPE_SWORD, constants.TNS_TYPE_REP_UNIVERSAL],

lib/thin/protocol/messages/lobOp.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class LobOpMessage extends Message {
169169
processReturnParameter(buf) {
170170
let lobArray;
171171
let locator;
172-
let temp16;
172+
let temp8;
173173
let numBytes;
174174
if (this.sourceLobImpl !== null) {
175175
numBytes = this.sourceLobImpl._locator.length;
@@ -184,15 +184,14 @@ class LobOpMessage extends Message {
184184
locator.copy(this.destLobImpl._locator);
185185
}
186186
if (this.operation === constants.TNS_LOB_OP_CREATE_TEMP) {
187-
buf.skipUB2();
188-
}
189-
if (this.sendAmount) {
187+
buf.skipUB2(); // skip character set
188+
buf.skipBytes(3); // skip trailing flags, amount
189+
} else if (this.sendAmount) {
190190
this.amount = buf.readSB8();
191191
}
192-
if (this.operation === constants.TNS_LOB_OP_CREATE_TEMP
193-
|| this.operation === constants.TNS_LOB_OP_IS_OPEN) {
194-
temp16 = buf.readUB2();
195-
this.boolFlag = temp16 > 0;
192+
if (this.operation === constants.TNS_LOB_OP_IS_OPEN) {
193+
temp8 = buf.readUB1();
194+
this.boolFlag = temp8 > 0;
196195
}
197196
}
198197

lib/thin/protocol/messages/withData.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,7 @@ class MessageWithData extends Message {
177177
const dataType = buf.readUInt8();
178178
buf.skipUB1(); // flags
179179
const precision = buf.readInt8();
180-
let scale;
181-
if (dataType === constants.TNS_DATA_TYPE_NUMBER ||
182-
dataType === constants.TNS_DATA_TYPE_INTERVAL_DS ||
183-
dataType === constants.TNS_DATA_TYPE_TIMESTAMP ||
184-
dataType === constants.TNS_DATA_TYPE_TIMESTAMP_LTZ ||
185-
dataType === constants.TNS_DATA_TYPE_TIMESTAMP_TZ) {
186-
scale = buf.readSB2();
187-
} else {
188-
scale = buf.readInt8();
189-
}
180+
const scale = buf.readInt8();
190181
const maxSize = buf.readUB4();
191182
buf.skipUB4(); // max number of array elements
192183
buf.skipUB8(); // cont flags

0 commit comments

Comments
 (0)