Socket
Socket
Sign inDemoInstall

@sap/hana-client

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sap/hana-client - npm Package Compare versions

Comparing version 2.7.23 to 2.7.26

149

extension/Stream.js

@@ -107,4 +107,6 @@ 'use strict';

checkParameter('resultset', resultset);
Readable.call(this, { objectMode: true });
var opts = getLobStreamOptions(options);
Readable.call(this, opts);
this.resultset = resultset;

@@ -119,12 +121,6 @@ this.columnInfo = this.resultset.getColumnInfo();

this.offset = 0;
this.readSize = DEFAULT_READ_SIZE;
this.noPause = opts.noPause;
this.valueAsString = false;
if (options) {
if (isInteger(options.readSize) && options.readSize > 0) {
this.readSize = options.readSize;
}
if (typeof options.valueAsString === "boolean") {
this.valueAsString = options.valueAsString;
}
if (typeof opts.valueAsString === "boolean") {
this.valueAsString = opts.valueAsString;
}

@@ -135,3 +131,3 @@ };

HanaLobStream.prototype._read = function () {
HanaLobStream.prototype._read = function (bufferSize) {
if (this.resultset.isNull(this.columnIndex)) {

@@ -143,22 +139,32 @@ this.push(null);

var stream = this;
var bufferSize = this.isString ? (this.readSize + 1) * 4 : this.readSize;
stream.bufferSize = bufferSize;
var buffer = createBuffer(bufferSize);
this.pause();
this.resultset.getData(this.columnIndex, this.offset, buffer, 0, this.readSize, function (err, bytesRetrieved) {
if (!this.noPause) {
this.pause();
}
this.resultset.getData(this.columnIndex, this.offset, buffer, 0, bufferSize, function (err, bytesRetrieved) {
if (err === undefined) {
stream.offset += bytesRetrieved;
if (stream.isString) { // For CLOB/NCLOB, bytesRetrieved is number of characters.
if (stream.isString) {
if (bytesRetrieved > 0) {
let firstNullChar = buffer.indexOf(0);
let newBuffer = createBuffer(firstNullChar);
buffer.copy(newBuffer, 0, 0, firstNullChar);
if (stream.valueAsString) {
stream.push(newBuffer.toString('utf8'));
let nullChar = buffer.indexOf(0);
if (nullChar === 0) {
stream.push(null);
} else {
stream.push(newBuffer);
let newBuffer = buffer;
if (nullChar > 0) {
newBuffer = buffer.slice(0, nullChar);
}
let str = newBuffer.toString('utf8');
stream.offset += str.length;
if (stream.valueAsString) {
stream.push(str);
} else {
stream.push(newBuffer);
}
if (bytesRetrieved < stream.bufferSize) {
stream.push(null);
}
}
if (bytesRetrieved < stream.readSize) {
stream.push(null);
}
} else {

@@ -168,7 +174,6 @@ stream.push(null);

} else { // LOB
stream.offset += bytesRetrieved;
if (bytesRetrieved > 0) {
if (bytesRetrieved < stream.readSize) {
let buffer2 = createBuffer(bytesRetrieved);
buffer.copy(buffer2, 0, 0, bytesRetrieved);
stream.push(buffer2);
if (bytesRetrieved < stream.bufferSize) {
stream.push(buffer.slice(0, bytesRetrieved));
stream.push(null);

@@ -189,3 +194,5 @@ } else {

}
stream.resume();
if (!stream.noPause) {
stream.resume();
}
});

@@ -201,4 +208,6 @@ };

checkParameter('statement', statement);
Readable.call(this, { objectMode: true });
var opts = getLobStreamOptions(options);
Readable.call(this, opts);
this.statement = statement;

@@ -213,12 +222,6 @@ this.paramInfo = this.statement.getParameterInfo();

this.offset = 0;
this.readSize = DEFAULT_READ_SIZE;
this.noPause = opts.noPause;
this.valueAsString = false;
if (options) {
if (isInteger(options.readSize) && options.readSize > 0) {
this.readSize = options.readSize;
}
if (typeof options.valueAsString === "boolean") {
this.valueAsString = options.valueAsString;
}
if (typeof opts.valueAsString === "boolean") {
this.valueAsString = opts.valueAsString;
}

@@ -229,7 +232,16 @@ };

HanaParameterLobStream.prototype._read = function () {
HanaParameterLobStream.prototype._read = function (bufferSize) {
if (this.statement.isParameterNull(this.paramIndex)) {
this.push(null);
return;
}
var stream = this;
var bufferSize = this.readSize;
stream.bufferSize = bufferSize;
var buffer = createBuffer(bufferSize);
this.pause();
if (!this.noPause) {
this.pause();
}
this.statement.getData(this.paramIndex, this.offset, buffer, 0, bufferSize, function (err, bytesRetrieved) {

@@ -242,17 +254,18 @@ if (err === undefined) {

stream.push(null);
return;
}
let bytes = (nullChar > 0) ? nullChar : bytesRetrieved;
let newBuffer = createBuffer(bytes);
buffer.copy(newBuffer, 0, 0, bytes);
let str = newBuffer.toString('utf8');
stream.offset += str.length;
if (stream.valueAsString) {
stream.push(str);
} else {
stream.push(newBuffer);
let newBuffer = buffer;
if (nullChar > 0) {
newBuffer = buffer.slice(0, nullChar);
}
let str = newBuffer.toString('utf8');
stream.offset += str.length;
if (stream.valueAsString) {
stream.push(str);
} else {
stream.push(newBuffer);
}
if (bytesRetrieved < stream.bufferSize) {
stream.push(null);
}
}
if (bytesRetrieved < stream.readSize) {
stream.push(null);
}
} else {

@@ -264,6 +277,4 @@ stream.push(null);

if (bytesRetrieved > 0) {
if (bytesRetrieved < stream.readSize) {
var buffer2 = createBuffer(bytesRetrieved);
buffer.copy(buffer2, 0, 0, bytesRetrieved);
stream.push(buffer2);
if (bytesRetrieved < stream.bufferSize) {
stream.push(buffer.slice(0, bytesRetrieved));
stream.push(null);

@@ -284,3 +295,5 @@ } else {

}
stream.resume();
if (!stream.noPause) {
stream.resume();
}
});

@@ -703,3 +716,17 @@ };

function getLobStreamOptions(options) {
var opts = {};
Object.assign(opts, options);
opts.objectMode = false;
if (isInteger(opts.readSize) && opts.readSize > 0) {
opts.highWaterMark = opts.readSize;
}
opts.noPause = false;
if (options && 'noPause' in options && (typeof options.noPause === 'boolean')) {
opts.noPause = options.noPause;
}
return opts;
}
var MAX_READ_SIZE = Math.pow(2, 18);
var DEFAULT_READ_SIZE = Math.pow(2, 11) * 100;
{
"name": "@sap/hana-client",
"version": "2.7.23",
"version": "2.7.26",
"lockfileVersion": 1,

@@ -5,0 +5,0 @@ "requires": true,

@@ -5,3 +5,3 @@ {

"description": "Official SAP HANA Node.js Driver",
"version": "2.7.23",
"version": "2.7.26",
"dependencies": {

@@ -8,0 +8,0 @@ "debug": "3.1.0"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc