@tdengine/websocket 3.2.0 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/example/all_type_query.js +26 -22
- package/lib/example/all_type_stmt.js +22 -20
- package/lib/example/basicBatchTmq.js +14 -14
- package/lib/example/basicSchemaless.js +11 -11
- package/lib/example/basicSql.js +10 -10
- package/lib/example/basicStmt.js +3 -3
- package/lib/example/basicTmq.js +8 -9
- package/lib/index.d.ts +0 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -7
- package/lib/src/client/wsClient.d.ts +2 -2
- package/lib/src/client/wsClient.d.ts.map +1 -1
- package/lib/src/client/wsClient.js +60 -37
- package/lib/src/client/wsConnector.d.ts.map +1 -1
- package/lib/src/client/wsConnector.js +40 -14
- package/lib/src/client/wsConnectorPool.d.ts.map +1 -1
- package/lib/src/client/wsConnectorPool.js +29 -14
- package/lib/src/client/wsEventCallback.d.ts.map +1 -1
- package/lib/src/client/wsEventCallback.js +6 -4
- package/lib/src/client/wsResponse.d.ts.map +1 -1
- package/lib/src/client/wsResponse.js +6 -2
- package/lib/src/common/config.d.ts +2 -2
- package/lib/src/common/config.d.ts.map +1 -1
- package/lib/src/common/config.js +5 -5
- package/lib/src/common/constant.d.ts.map +1 -1
- package/lib/src/common/constant.js +27 -27
- package/lib/src/common/log.d.ts +1 -1
- package/lib/src/common/log.d.ts.map +1 -1
- package/lib/src/common/log.js +9 -7
- package/lib/src/common/reqid.d.ts.map +1 -1
- package/lib/src/common/reqid.js +7 -7
- package/lib/src/common/taosResult.d.ts.map +1 -1
- package/lib/src/common/taosResult.js +46 -27
- package/lib/src/common/ut8Helper.d.ts.map +1 -1
- package/lib/src/common/ut8Helper.js +8 -8
- package/lib/src/common/utils.d.ts.map +1 -1
- package/lib/src/common/utils.js +17 -16
- package/lib/src/common/wsError.d.ts.map +1 -1
- package/lib/src/common/wsError.js +3 -3
- package/lib/src/common/wsOptions.d.ts +1 -1
- package/lib/src/index.d.ts +3 -3
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/sql/wsProto.d.ts.map +1 -1
- package/lib/src/sql/wsRows.d.ts +3 -3
- package/lib/src/sql/wsRows.d.ts.map +1 -1
- package/lib/src/sql/wsRows.js +4 -2
- package/lib/src/sql/wsSql.d.ts +5 -5
- package/lib/src/sql/wsSql.d.ts.map +1 -1
- package/lib/src/sql/wsSql.js +15 -16
- package/lib/src/stmt/FieldBindParams.d.ts.map +1 -1
- package/lib/src/stmt/wsColumnInfo.d.ts.map +1 -1
- package/lib/src/stmt/wsParams1.d.ts.map +1 -1
- package/lib/src/stmt/wsParams1.js +50 -24
- package/lib/src/stmt/wsParams2.d.ts.map +1 -1
- package/lib/src/stmt/wsParams2.js +30 -15
- package/lib/src/stmt/wsParamsBase.d.ts.map +1 -1
- package/lib/src/stmt/wsParamsBase.js +5 -3
- package/lib/src/stmt/wsProto.d.ts.map +1 -1
- package/lib/src/stmt/wsProto.js +22 -11
- package/lib/src/stmt/wsStmt.d.ts.map +1 -1
- package/lib/src/stmt/wsStmt1.d.ts +5 -5
- package/lib/src/stmt/wsStmt1.d.ts.map +1 -1
- package/lib/src/stmt/wsStmt1.js +14 -14
- package/lib/src/stmt/wsStmt2.d.ts +1 -1
- package/lib/src/stmt/wsStmt2.d.ts.map +1 -1
- package/lib/src/stmt/wsStmt2.js +18 -14
- package/lib/src/stmt/wsTableInfo.d.ts.map +1 -1
- package/lib/src/tmq/config.d.ts.map +1 -1
- package/lib/src/tmq/config.js +2 -2
- package/lib/src/tmq/constant.d.ts.map +1 -1
- package/lib/src/tmq/constant.js +28 -28
- package/lib/src/tmq/tmqResponse.d.ts.map +1 -1
- package/lib/src/tmq/tmqResponse.js +30 -16
- package/lib/src/tmq/wsTmq.d.ts +2 -2
- package/lib/src/tmq/wsTmq.d.ts.map +1 -1
- package/lib/src/tmq/wsTmq.js +32 -30
- package/lib/test/bulkPulling/cloud.tmq.test.js +11 -11
- package/lib/test/bulkPulling/decimal.test.js +50 -26
- package/lib/test/bulkPulling/log.test.js +8 -8
- package/lib/test/bulkPulling/queryTables.test.js +255 -49
- package/lib/test/bulkPulling/schemaless.test.js +34 -34
- package/lib/test/bulkPulling/sql.test.js +108 -69
- package/lib/test/bulkPulling/stmt1.func.test.js +96 -96
- package/lib/test/bulkPulling/stmt1.type.test.js +124 -48
- package/lib/test/bulkPulling/stmt2.func.test.js +116 -112
- package/lib/test/bulkPulling/stmt2.type.test.js +124 -48
- package/lib/test/bulkPulling/tmq.test.js +225 -31
- package/lib/test/bulkPulling/utils.test.js +2 -2
- package/lib/test/bulkPulling/wsConnectPool.test.js +18 -18
- package/lib/test/utils.d.ts.map +1 -1
- package/lib/test/utils.js +129 -129
- package/package.json +1 -1
- package/readme.md +1 -0
- package/lib/src/stmt/wsParams.d.ts +0 -41
- package/lib/src/stmt/wsParams.d.ts.map +0 -1
- package/lib/src/stmt/wsParams.js +0 -428
- package/lib/test/bulkPulling/stmt.func.test.d.ts +0 -2
- package/lib/test/bulkPulling/stmt.func.test.d.ts.map +0 -1
- package/lib/test/bulkPulling/stmt.func.test.js +0 -493
- package/lib/test/bulkPulling/stmt.type.test.d.ts +0 -2
- package/lib/test/bulkPulling/stmt.type.test.d.ts.map +0 -1
- package/lib/test/bulkPulling/stmt.type.test.js +0 -316
package/lib/src/sql/wsSql.js
CHANGED
|
@@ -18,12 +18,12 @@ const wsStmt2_1 = require("../stmt/wsStmt2");
|
|
|
18
18
|
class WsSql {
|
|
19
19
|
constructor(wsConfig) {
|
|
20
20
|
let url = (0, utils_1.getUrl)(wsConfig);
|
|
21
|
-
this._wsClient = new wsClient_1.WsClient(url, wsConfig.getTimeOut());
|
|
22
21
|
this.wsConfig = wsConfig;
|
|
22
|
+
this._wsClient = new wsClient_1.WsClient(url, wsConfig.getTimeOut());
|
|
23
23
|
}
|
|
24
24
|
static async open(wsConfig) {
|
|
25
25
|
if (!wsConfig.getUrl()) {
|
|
26
|
-
throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_INVALID_URL,
|
|
26
|
+
throw new wsError_1.WebSocketInterfaceError(wsError_1.ErrorCode.ERR_INVALID_URL, "invalid url, password or username needed.");
|
|
27
27
|
}
|
|
28
28
|
let wsSql = new WsSql(wsConfig);
|
|
29
29
|
let database = wsConfig.getDb();
|
|
@@ -34,15 +34,12 @@ class WsSql {
|
|
|
34
34
|
await wsSql.exec(`use ${database}`);
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
await wsSql.exec(
|
|
37
|
+
await wsSql.exec("use information_schema");
|
|
38
38
|
}
|
|
39
39
|
let timezone = wsConfig.getTimezone();
|
|
40
40
|
if (timezone && timezone.length > 0) {
|
|
41
41
|
await wsSql._wsClient.setOptionConnection(constant_1.TSDB_OPTION_CONNECTION.TSDB_OPTION_CONNECTION_TIMEZONE, timezone);
|
|
42
42
|
}
|
|
43
|
-
else {
|
|
44
|
-
await wsSql._wsClient.setOptionConnection(constant_1.TSDB_OPTION_CONNECTION.TSDB_OPTION_CONNECTION_TIMEZONE, null);
|
|
45
|
-
}
|
|
46
43
|
return wsSql;
|
|
47
44
|
}
|
|
48
45
|
catch (e) {
|
|
@@ -50,7 +47,7 @@ class WsSql {
|
|
|
50
47
|
if (wsSql) {
|
|
51
48
|
await wsSql.close();
|
|
52
49
|
}
|
|
53
|
-
throw
|
|
50
|
+
throw e;
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
53
|
state() {
|
|
@@ -66,18 +63,18 @@ class WsSql {
|
|
|
66
63
|
await this._wsClient.close();
|
|
67
64
|
}
|
|
68
65
|
async schemalessInsert(lines, protocol, precision, ttl, reqId) {
|
|
69
|
-
let data =
|
|
66
|
+
let data = "";
|
|
70
67
|
if (!lines || lines.length == 0 || !protocol) {
|
|
71
|
-
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS,
|
|
68
|
+
throw new wsError_1.TaosResultError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "WsSchemaless Insert params is error!");
|
|
72
69
|
}
|
|
73
70
|
lines.forEach((element, index) => {
|
|
74
71
|
data += element;
|
|
75
72
|
if (index < lines.length - 1) {
|
|
76
|
-
data +=
|
|
73
|
+
data += "\n";
|
|
77
74
|
}
|
|
78
75
|
});
|
|
79
76
|
let queryMsg = {
|
|
80
|
-
action:
|
|
77
|
+
action: "insert",
|
|
81
78
|
args: {
|
|
82
79
|
req_id: reqid_1.ReqId.getReqID(reqId),
|
|
83
80
|
protocol: protocol,
|
|
@@ -93,7 +90,9 @@ class WsSql {
|
|
|
93
90
|
try {
|
|
94
91
|
let precision = constant_1.PrecisionLength["ms"];
|
|
95
92
|
if (this.wsConfig.getDb()) {
|
|
96
|
-
let sql = "select `precision` from information_schema.ins_databases where name = '" +
|
|
93
|
+
let sql = "select `precision` from information_schema.ins_databases where name = '" +
|
|
94
|
+
this.wsConfig.getDb() +
|
|
95
|
+
"'";
|
|
97
96
|
let result = await this.exec(sql);
|
|
98
97
|
let data = result.getData();
|
|
99
98
|
if (data && data[0] && data[0][0]) {
|
|
@@ -109,12 +108,12 @@ class WsSql {
|
|
|
109
108
|
}
|
|
110
109
|
catch (e) {
|
|
111
110
|
log_1.default.error(`stmtInit failed, code: ${e.code}, message: ${e.message}`);
|
|
112
|
-
throw
|
|
111
|
+
throw e;
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
|
-
throw
|
|
114
|
+
throw new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_CONNECTION_CLOSED, "stmt connect closed");
|
|
116
115
|
}
|
|
117
|
-
async exec(sql, reqId, action =
|
|
116
|
+
async exec(sql, reqId, action = "binary_query") {
|
|
118
117
|
try {
|
|
119
118
|
let bigintReqId = BigInt(reqid_1.ReqId.getReqID(reqId));
|
|
120
119
|
let wsQueryResponse = await this._wsClient.sendBinaryMsg(bigintReqId, action, (0, utils_1.getBinarySql)(constant_1.BinaryQueryMessage, bigintReqId, BigInt(0), sql));
|
|
@@ -171,7 +170,7 @@ class WsSql {
|
|
|
171
170
|
async query(sql, reqId) {
|
|
172
171
|
try {
|
|
173
172
|
let bigintReqId = BigInt(reqid_1.ReqId.getReqID(reqId));
|
|
174
|
-
let wsQueryResponse = await this._wsClient.sendBinaryMsg(bigintReqId,
|
|
173
|
+
let wsQueryResponse = await this._wsClient.sendBinaryMsg(bigintReqId, "binary_query", (0, utils_1.getBinarySql)(constant_1.BinaryQueryMessage, bigintReqId, BigInt(0), sql));
|
|
175
174
|
return new wsRows_1.WSRows(this._wsClient, wsQueryResponse);
|
|
176
175
|
}
|
|
177
176
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldBindParams.d.ts","sourceRoot":"","sources":["../../../src/stmt/FieldBindParams.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FieldBindParams.d.ts","sourceRoot":"","sources":["../../../src/stmt/FieldBindParams.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAe;IACxB,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;gBAEb,MAAM,EAAE,GAAG,EAAE,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM;CAQvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsColumnInfo.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsColumnInfo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wsColumnInfo.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsColumnInfo.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;IACnB,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAK;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;gBAEpB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,EAAE,EACjB,WAAW,CAAC,EAAE,MAAM,EAAE,EACtB,UAAU,GAAE,MAAU;CAW7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsParams1.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsParams1.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wsParams1.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsParams1.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE9D,qBAAa,eAAgB,SAAQ,cAAe,YAAW,YAAY;gBAC3D,SAAS,CAAC,EAAE,MAAM;IAI9B,MAAM,IAAI,IAAI;IAId,WAAW,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI;IAI7C,SAAS,CACL,MAAM,EAAE,GAAG,EAAE,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACnB,IAAI;IA0BP,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE;IAwG1B,OAAO,CAAC,kBAAkB;IAkD1B,OAAO,CAAC,qBAAqB;IA8E7B,OAAO,CAAC,0BAA0B;IAkClC,OAAO,CAAC,iBAAiB;IAmFzB,OAAO,CAAC,iBAAiB;CAY5B"}
|
|
@@ -21,7 +21,9 @@ class Stmt1BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
21
21
|
if (!params || params.length == 0) {
|
|
22
22
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "StmtBindParams params is invalid!");
|
|
23
23
|
}
|
|
24
|
-
if (dataType === "number" ||
|
|
24
|
+
if (dataType === "number" ||
|
|
25
|
+
dataType === "bigint" ||
|
|
26
|
+
dataType === "boolean") {
|
|
25
27
|
this._params.push(this.encodeDigitColumns(params, dataType, typeLen, columnType));
|
|
26
28
|
}
|
|
27
29
|
else {
|
|
@@ -40,10 +42,11 @@ class Stmt1BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
40
42
|
//computing bitmap length
|
|
41
43
|
let bitMapLen = (0, taosResult_1.bitmapLen)(params.length);
|
|
42
44
|
//Computing the length of data
|
|
43
|
-
let arrayBuffer = new ArrayBuffer(bitMapLen +
|
|
45
|
+
let arrayBuffer = new ArrayBuffer(bitMapLen +
|
|
46
|
+
constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.TIMESTAMP] * params.length);
|
|
44
47
|
//bitmap get data range
|
|
45
48
|
let bitmapBuffer = new DataView(arrayBuffer);
|
|
46
|
-
//skip bitmap get data range
|
|
49
|
+
//skip bitmap get data range
|
|
47
50
|
let dataBuffer = new DataView(arrayBuffer, bitMapLen);
|
|
48
51
|
if (this._rows > 0) {
|
|
49
52
|
if (this._rows !== params.length) {
|
|
@@ -58,11 +61,11 @@ class Stmt1BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
58
61
|
if (params[i] instanceof Date) {
|
|
59
62
|
let date = params[i];
|
|
60
63
|
//node only support milliseconds, need fill 0
|
|
61
|
-
if (this.precisionLength == constant_1.PrecisionLength[
|
|
64
|
+
if (this.precisionLength == constant_1.PrecisionLength["us"]) {
|
|
62
65
|
let ms = date.getTime() * 1000;
|
|
63
66
|
dataBuffer.setBigInt64(i * 8, BigInt(ms), true);
|
|
64
67
|
}
|
|
65
|
-
else if (this.precisionLength == constant_1.PrecisionLength[
|
|
68
|
+
else if (this.precisionLength == constant_1.PrecisionLength["ns"]) {
|
|
66
69
|
let ns = date.getTime() * 1000 * 1000;
|
|
67
70
|
dataBuffer.setBigInt64(i * 8, BigInt(ns), true);
|
|
68
71
|
}
|
|
@@ -70,9 +73,10 @@ class Stmt1BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
70
73
|
dataBuffer.setBigInt64(i * 8, BigInt(date.getTime()), true);
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
|
-
else if (typeof params[i] ==
|
|
76
|
+
else if (typeof params[i] == "bigint" ||
|
|
77
|
+
typeof params[i] == "number") {
|
|
74
78
|
let data;
|
|
75
|
-
if (typeof params[i] ==
|
|
79
|
+
if (typeof params[i] == "number") {
|
|
76
80
|
data = BigInt(params[i]);
|
|
77
81
|
}
|
|
78
82
|
else {
|
|
@@ -80,20 +84,22 @@ class Stmt1BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
80
84
|
}
|
|
81
85
|
//statistical bits of digit
|
|
82
86
|
let digit = this.countBigintDigits(data);
|
|
83
|
-
//check digit same table Precision
|
|
84
|
-
if (this.precisionLength == constant_1.PrecisionLength[
|
|
87
|
+
//check digit same table Precision
|
|
88
|
+
if (this.precisionLength == constant_1.PrecisionLength["ns"]) {
|
|
85
89
|
if (this.precisionLength <= digit) {
|
|
86
90
|
dataBuffer.setBigInt64(i * 8, data, true);
|
|
87
91
|
}
|
|
88
92
|
else {
|
|
89
|
-
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SeTimestampColumn params precisionLength is invalid! param:=" +
|
|
93
|
+
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SeTimestampColumn params precisionLength is invalid! param:=" +
|
|
94
|
+
params[i]);
|
|
90
95
|
}
|
|
91
96
|
}
|
|
92
97
|
else if (this.precisionLength == digit) {
|
|
93
98
|
dataBuffer.setBigInt64(i * 8, data, true);
|
|
94
99
|
}
|
|
95
100
|
else {
|
|
96
|
-
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SeTimestampColumn params is invalid! param:=" +
|
|
101
|
+
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SeTimestampColumn params is invalid! param:=" +
|
|
102
|
+
params[i]);
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
}
|
|
@@ -105,9 +111,13 @@ class Stmt1BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
this._dataTotalLen += arrayBuffer.byteLength;
|
|
108
|
-
this._params.push(new wsColumnInfo_1.ColumnInfo([
|
|
114
|
+
this._params.push(new wsColumnInfo_1.ColumnInfo([
|
|
115
|
+
constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.TIMESTAMP] *
|
|
116
|
+
params.length,
|
|
117
|
+
arrayBuffer,
|
|
118
|
+
], constant_1.TDengineTypeCode.TIMESTAMP, constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.TIMESTAMP], this._rows));
|
|
109
119
|
}
|
|
110
|
-
encodeDigitColumns(params, dataType =
|
|
120
|
+
encodeDigitColumns(params, dataType = "number", typeLen, columnType) {
|
|
111
121
|
let bitMapLen = (0, taosResult_1.bitmapLen)(params.length);
|
|
112
122
|
let arrayBuffer = new ArrayBuffer(typeLen * params.length + bitMapLen);
|
|
113
123
|
let bitmapBuffer = new DataView(arrayBuffer);
|
|
@@ -154,22 +164,27 @@ class Stmt1BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
154
164
|
if (!(0, utils_1.isEmpty)(params[i])) {
|
|
155
165
|
//save param length offset 4byte
|
|
156
166
|
paramsLenView.setInt32(offset, dataLength, true);
|
|
157
|
-
if (typeof params[i] ==
|
|
167
|
+
if (typeof params[i] == "string") {
|
|
158
168
|
//string TextEncoder
|
|
159
169
|
let encode = new TextEncoder();
|
|
160
170
|
let value = encode.encode(params[i]).buffer;
|
|
161
171
|
data.push(value);
|
|
162
172
|
//add offset length
|
|
163
|
-
dataLength +=
|
|
173
|
+
dataLength +=
|
|
174
|
+
value.byteLength +
|
|
175
|
+
constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.SMALLINT];
|
|
164
176
|
}
|
|
165
177
|
else if (params[i] instanceof ArrayBuffer) {
|
|
166
178
|
//input arraybuffer, save not need encode
|
|
167
179
|
let value = params[i];
|
|
168
|
-
dataLength +=
|
|
180
|
+
dataLength +=
|
|
181
|
+
value.byteLength +
|
|
182
|
+
constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.SMALLINT];
|
|
169
183
|
data.push(value);
|
|
170
184
|
}
|
|
171
185
|
else {
|
|
172
|
-
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "getColumString params is invalid! param_type:=" +
|
|
186
|
+
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "getColumString params is invalid! param_type:=" +
|
|
187
|
+
typeof params[i]);
|
|
173
188
|
}
|
|
174
189
|
}
|
|
175
190
|
else {
|
|
@@ -180,11 +195,14 @@ class Stmt1BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
180
195
|
}
|
|
181
196
|
}
|
|
182
197
|
this._dataTotalLen += paramsLenBuffer.byteLength + dataLength;
|
|
183
|
-
return new wsColumnInfo_1.ColumnInfo([
|
|
198
|
+
return new wsColumnInfo_1.ColumnInfo([
|
|
199
|
+
dataLength,
|
|
200
|
+
this.getBinaryColumnArrayBuffer(data, paramsLenView.buffer, dataLength),
|
|
201
|
+
], columnType, 0, this._rows);
|
|
184
202
|
}
|
|
185
203
|
//splicing encode params to arraybuffer
|
|
186
204
|
getBinaryColumnArrayBuffer(data, paramsLenBuffer, dataLength) {
|
|
187
|
-
//create arraybuffer
|
|
205
|
+
//create arraybuffer
|
|
188
206
|
let paramsBuffer = new ArrayBuffer(paramsLenBuffer.byteLength + dataLength);
|
|
189
207
|
//get length data range
|
|
190
208
|
const paramsUint8 = new Uint8Array(paramsBuffer);
|
|
@@ -223,7 +241,7 @@ class Stmt1BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
223
241
|
let offset = constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT] * i;
|
|
224
242
|
if (!(0, utils_1.isEmpty)(params[i])) {
|
|
225
243
|
indexView.setInt32(offset, dataLength, true);
|
|
226
|
-
if (typeof params[i] ==
|
|
244
|
+
if (typeof params[i] == "string") {
|
|
227
245
|
let codes = [];
|
|
228
246
|
let strNcharParams = params[i];
|
|
229
247
|
for (let j = 0; j < params[i].length; j++) {
|
|
@@ -237,15 +255,20 @@ class Stmt1BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
237
255
|
ncharView.setUint32(j * 4, codes[j], true);
|
|
238
256
|
}
|
|
239
257
|
data.push(ncharBuffer);
|
|
240
|
-
dataLength +=
|
|
258
|
+
dataLength +=
|
|
259
|
+
codes.length * 4 +
|
|
260
|
+
constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.SMALLINT];
|
|
241
261
|
}
|
|
242
262
|
else if (params[i] instanceof ArrayBuffer) {
|
|
243
263
|
let value = params[i];
|
|
244
|
-
dataLength +=
|
|
264
|
+
dataLength +=
|
|
265
|
+
value.byteLength +
|
|
266
|
+
constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.SMALLINT];
|
|
245
267
|
data.push(value);
|
|
246
268
|
}
|
|
247
269
|
else {
|
|
248
|
-
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "getColumString params is invalid! param_type:=" +
|
|
270
|
+
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "getColumString params is invalid! param_type:=" +
|
|
271
|
+
typeof params[i]);
|
|
249
272
|
}
|
|
250
273
|
}
|
|
251
274
|
else {
|
|
@@ -256,7 +279,10 @@ class Stmt1BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
256
279
|
}
|
|
257
280
|
}
|
|
258
281
|
this._dataTotalLen += indexBuffer.byteLength + dataLength;
|
|
259
|
-
return new wsColumnInfo_1.ColumnInfo([
|
|
282
|
+
return new wsColumnInfo_1.ColumnInfo([
|
|
283
|
+
dataLength,
|
|
284
|
+
this.getBinaryColumnArrayBuffer(data, indexView.buffer, dataLength),
|
|
285
|
+
], constant_1.TDengineTypeCode.NCHAR, 0, this._rows);
|
|
260
286
|
}
|
|
261
287
|
countBigintDigits(numeral) {
|
|
262
288
|
if (numeral === 0n) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsParams2.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsParams2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wsParams2.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsParams2.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAI9D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,eAAgB,SAAQ,cAAe,YAAW,YAAY;IACvE,OAAO,CAAC,OAAO,CAAuB;IACtC,SAAS,CAAC,UAAU,EAAE,MAAM,CAAK;gBAE7B,WAAW,CAAC,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAMjC,SAAS,CACL,MAAM,EAAE,GAAG,EAAE,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACnB,IAAI;IA6DP,WAAW,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI;IA0B7C,MAAM,IAAI,IAAI;IA0Dd,OAAO,CAAC,gBAAgB;IAmDxB,OAAO,CAAC,kBAAkB;IAwD1B,OAAO,CAAC,qBAAqB;CA2ChC"}
|
|
@@ -25,8 +25,18 @@ class Stmt2BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
25
25
|
if (this._fieldParams) {
|
|
26
26
|
if (this.paramsCount > 0) {
|
|
27
27
|
if (this._fieldParams[this.paramIndex]) {
|
|
28
|
-
if (this._fieldParams[this.paramIndex].dataType !==
|
|
29
|
-
|
|
28
|
+
if (this._fieldParams[this.paramIndex].dataType !==
|
|
29
|
+
dataType ||
|
|
30
|
+
this._fieldParams[this.paramIndex].columnType !==
|
|
31
|
+
columnType) {
|
|
32
|
+
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, `StmtBindParams params type is not match! ${this.paramIndex} ${this.paramsCount} ${json_bigint_1.default.stringify({
|
|
33
|
+
dataType,
|
|
34
|
+
columnType,
|
|
35
|
+
})} vs ${json_bigint_1.default.stringify({
|
|
36
|
+
dataType: this._fieldParams[this.paramIndex].dataType,
|
|
37
|
+
columnType: this._fieldParams[this.paramIndex]
|
|
38
|
+
.columnType,
|
|
39
|
+
})}`);
|
|
30
40
|
}
|
|
31
41
|
this._fieldParams[this.paramIndex].params.push(...params);
|
|
32
42
|
}
|
|
@@ -46,7 +56,10 @@ class Stmt2BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
46
56
|
}
|
|
47
57
|
}
|
|
48
58
|
mergeParams(bindParams) {
|
|
49
|
-
if (!bindParams ||
|
|
59
|
+
if (!bindParams ||
|
|
60
|
+
!bindParams._fieldParams ||
|
|
61
|
+
bindParams._fieldParams.length === 0 ||
|
|
62
|
+
!this._fieldParams) {
|
|
50
63
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "StmtBindParams params is invalid!");
|
|
51
64
|
}
|
|
52
65
|
this.paramIndex = 0;
|
|
@@ -89,17 +102,17 @@ class Stmt2BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
89
102
|
}
|
|
90
103
|
}
|
|
91
104
|
}
|
|
92
|
-
encodeVarColumns(params, dataType =
|
|
105
|
+
encodeVarColumns(params, dataType = "number", typeLen, columnType) {
|
|
93
106
|
let isNull = [];
|
|
94
107
|
let dataLengths = [];
|
|
95
108
|
// TotalLength(4) + Type (4) + Num(4) + IsNull(1) * size + haveLength(1) + BufferLength(4) + 4 * v.length + totalLength
|
|
96
109
|
// 17 + (5 * params.length) + totalLength;
|
|
97
|
-
let totalLength = 17 +
|
|
110
|
+
let totalLength = 17 + 5 * params.length;
|
|
98
111
|
const bytes = [];
|
|
99
112
|
for (let i = 0; i < params.length; i++) {
|
|
100
113
|
if (!(0, utils_1.isEmpty)(params[i])) {
|
|
101
114
|
isNull.push(0);
|
|
102
|
-
if (typeof params[i] ==
|
|
115
|
+
if (typeof params[i] == "string") {
|
|
103
116
|
let encoder = new TextEncoder().encode(params[i]);
|
|
104
117
|
let length = encoder.length;
|
|
105
118
|
totalLength += length;
|
|
@@ -114,7 +127,8 @@ class Stmt2BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
114
127
|
bytes.push(...new Uint8Array(value));
|
|
115
128
|
}
|
|
116
129
|
else {
|
|
117
|
-
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "getColumString params is invalid! param_type:=" +
|
|
130
|
+
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "getColumString params is invalid! param_type:=" +
|
|
131
|
+
typeof params[i]);
|
|
118
132
|
}
|
|
119
133
|
}
|
|
120
134
|
else {
|
|
@@ -125,9 +139,9 @@ class Stmt2BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
125
139
|
const dataBuffer = new Uint8Array(bytes).buffer;
|
|
126
140
|
return new wsColumnInfo_1.ColumnInfo([totalLength, dataBuffer], columnType, typeLen, this._rows, isNull, dataLengths, 1);
|
|
127
141
|
}
|
|
128
|
-
encodeDigitColumns(params, dataType =
|
|
142
|
+
encodeDigitColumns(params, dataType = "number", typeLen, columnType) {
|
|
129
143
|
let isNull = [];
|
|
130
|
-
// TotalLength(4) + Type (4) + Num(4) + IsNull(1) * size + haveLength(1) + BufferLength(4) + size * dataLen
|
|
144
|
+
// TotalLength(4) + Type (4) + Num(4) + IsNull(1) * size + haveLength(1) + BufferLength(4) + size * dataLen
|
|
131
145
|
let dataLength = 17 + (typeLen + 1) * params.length;
|
|
132
146
|
let arrayBuffer = new ArrayBuffer(typeLen * params.length);
|
|
133
147
|
let dataBuffer = new DataView(arrayBuffer);
|
|
@@ -138,7 +152,7 @@ class Stmt2BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
138
152
|
}
|
|
139
153
|
else {
|
|
140
154
|
isNull.push(1);
|
|
141
|
-
if (dataType ===
|
|
155
|
+
if (dataType === "bigint") {
|
|
142
156
|
this.writeDataToBuffer(dataBuffer, BigInt(0), dataType, typeLen, columnType, i);
|
|
143
157
|
}
|
|
144
158
|
else {
|
|
@@ -157,18 +171,19 @@ class Stmt2BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
157
171
|
if (params[i] instanceof Date) {
|
|
158
172
|
let date = params[i];
|
|
159
173
|
//node only support milliseconds, need fill 0
|
|
160
|
-
if (this.precisionLength == constant_1.PrecisionLength[
|
|
174
|
+
if (this.precisionLength == constant_1.PrecisionLength["us"]) {
|
|
161
175
|
timeStamp = BigInt(date.getTime() * 1000);
|
|
162
176
|
}
|
|
163
|
-
else if (this.precisionLength == constant_1.PrecisionLength[
|
|
177
|
+
else if (this.precisionLength == constant_1.PrecisionLength["ns"]) {
|
|
164
178
|
timeStamp = BigInt(date.getTime() * 1000 * 1000);
|
|
165
179
|
}
|
|
166
180
|
else {
|
|
167
181
|
timeStamp = BigInt(date.getTime());
|
|
168
182
|
}
|
|
169
183
|
}
|
|
170
|
-
else if (typeof params[i] ==
|
|
171
|
-
|
|
184
|
+
else if (typeof params[i] == "bigint" ||
|
|
185
|
+
typeof params[i] == "number") {
|
|
186
|
+
if (typeof params[i] == "number") {
|
|
172
187
|
timeStamp = BigInt(params[i]);
|
|
173
188
|
}
|
|
174
189
|
else {
|
|
@@ -182,7 +197,7 @@ class Stmt2BindParams extends wsParamsBase_1.StmtBindParams {
|
|
|
182
197
|
timeStamps.push(null);
|
|
183
198
|
}
|
|
184
199
|
}
|
|
185
|
-
return this.encodeDigitColumns(timeStamps,
|
|
200
|
+
return this.encodeDigitColumns(timeStamps, "bigint", typeLen, columnType);
|
|
186
201
|
}
|
|
187
202
|
}
|
|
188
203
|
exports.Stmt2BindParams = Stmt2BindParams;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsParamsBase.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsParamsBase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wsParamsBase.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsParamsBase.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C,MAAM,WAAW,YAAY;IACzB,MAAM,IAAI,IAAI,CAAC;IACf,SAAS,CACL,MAAM,EAAE,GAAG,EAAE,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACnB,IAAI,CAAC;IACR,WAAW,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;CACjD;AAED,8BAAsB,cAAc;IAChC,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAyB;IACnE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;IACzC,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;IACjC,SAAS,CAAC,aAAa,EAAE,MAAM,CAAK;IACpC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAK;IAClC,SAAS,CAAC,KAAK,SAAK;IACpB,SAAS,CAAC,UAAU,SAAK;gBAEb,SAAS,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;IAcpD,QAAQ,CAAC,MAAM,IAAI,IAAI;IAEvB,QAAQ,CAAC,SAAS,CACd,MAAM,EAAE,GAAG,EAAE,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf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 +5,7 @@ const constant_1 = require("../common/constant");
|
|
|
5
5
|
const wsError_1 = require("../common/wsError");
|
|
6
6
|
class StmtBindParams {
|
|
7
7
|
constructor(precision, paramsCount) {
|
|
8
|
-
this.precisionLength = constant_1.PrecisionLength[
|
|
8
|
+
this.precisionLength = constant_1.PrecisionLength["ms"];
|
|
9
9
|
this._dataTotalLen = 0;
|
|
10
10
|
this.paramsCount = 0;
|
|
11
11
|
this._rows = 0;
|
|
@@ -24,7 +24,9 @@ class StmtBindParams {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
addBindFieldParams(fieldParams) {
|
|
27
|
-
if (!fieldParams ||
|
|
27
|
+
if (!fieldParams ||
|
|
28
|
+
!fieldParams.params ||
|
|
29
|
+
fieldParams.params.length == 0) {
|
|
28
30
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "StmtBindParams params is invalid!");
|
|
29
31
|
}
|
|
30
32
|
if (!this._fieldParams) {
|
|
@@ -152,7 +154,7 @@ class StmtBindParams {
|
|
|
152
154
|
}
|
|
153
155
|
this.addParams(params, constant_1.TDengineTypeName[9], constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.TIMESTAMP], constant_1.TDengineTypeCode.TIMESTAMP);
|
|
154
156
|
}
|
|
155
|
-
writeDataToBuffer(dataBuffer, params, dataType =
|
|
157
|
+
writeDataToBuffer(dataBuffer, params, dataType = "number", typeLen, columnType, i) {
|
|
156
158
|
if (typeof params == dataType) {
|
|
157
159
|
switch (columnType) {
|
|
158
160
|
case constant_1.TDengineTypeCode.BOOL: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsProto.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsProto.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,g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gB,EAAE,MAAM,GACzB,WAAW,CA2Nb"}
|
package/lib/src/stmt/wsProto.js
CHANGED
|
@@ -113,7 +113,7 @@ function stmt2BinaryBlockEncode(reqId, stmtTableInfoList, stmt_id, toBeBindTable
|
|
|
113
113
|
totalColSize: 0,
|
|
114
114
|
tableNameSizeList: new Array(listLength),
|
|
115
115
|
tagSizeList: new Array(listLength),
|
|
116
|
-
colSizeList: new Array(listLength)
|
|
116
|
+
colSizeList: new Array(listLength),
|
|
117
117
|
};
|
|
118
118
|
const hasTableName = toBeBindTableNameIndex != null && toBeBindTableNameIndex >= 0;
|
|
119
119
|
const hasTags = toBeBindTagCount > 0;
|
|
@@ -150,10 +150,12 @@ function stmt2BinaryBlockEncode(reqId, stmtTableInfoList, stmt_id, toBeBindTable
|
|
|
150
150
|
result.totalColSize += size;
|
|
151
151
|
}
|
|
152
152
|
let totalSize = result.totalTableNameSize + result.totalTagSize + result.totalColSize;
|
|
153
|
-
let toBeBindTableNameCount =
|
|
154
|
-
totalSize +=
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
let toBeBindTableNameCount = toBeBindTableNameIndex != null && toBeBindTableNameIndex >= 0 ? 1 : 0;
|
|
154
|
+
totalSize +=
|
|
155
|
+
stmtTableInfoList.length *
|
|
156
|
+
(toBeBindTableNameCount * 2 +
|
|
157
|
+
(toBeBindTagCount > 0 ? 1 : 0) * 4 +
|
|
158
|
+
(toBeBindColCount > 0 ? 1 : 0) * 4);
|
|
157
159
|
let headerSize = 28; // Fixed header size
|
|
158
160
|
let msgHeaderSize = 30; // Fixed msg header size
|
|
159
161
|
const buffer = new ArrayBuffer(headerSize + msgHeaderSize + totalSize);
|
|
@@ -177,11 +179,13 @@ function stmt2BinaryBlockEncode(reqId, stmtTableInfoList, stmt_id, toBeBindTable
|
|
|
177
179
|
offset += constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT];
|
|
178
180
|
view.setInt32(offset, toBeBindColCount, true);
|
|
179
181
|
offset += constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT];
|
|
180
|
-
view.setInt32(offset, toBeBindTableNameCount > 0 ?
|
|
182
|
+
view.setInt32(offset, toBeBindTableNameCount > 0 ? 0x1c : 0, true);
|
|
181
183
|
offset += constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT];
|
|
182
184
|
if (toBeBindTagCount) {
|
|
183
185
|
if (toBeBindTableNameCount > 0) {
|
|
184
|
-
view.setInt32(offset, headerSize +
|
|
186
|
+
view.setInt32(offset, headerSize +
|
|
187
|
+
result.totalTableNameSize +
|
|
188
|
+
2 * stmtTableInfoList.length, true);
|
|
185
189
|
}
|
|
186
190
|
else {
|
|
187
191
|
view.setInt32(offset, headerSize, true);
|
|
@@ -194,7 +198,8 @@ function stmt2BinaryBlockEncode(reqId, stmtTableInfoList, stmt_id, toBeBindTable
|
|
|
194
198
|
if (toBeBindColCount > 0) {
|
|
195
199
|
let skipSize = 0;
|
|
196
200
|
if (toBeBindTableNameCount > 0) {
|
|
197
|
-
skipSize +=
|
|
201
|
+
skipSize +=
|
|
202
|
+
result.totalTableNameSize + 2 * stmtTableInfoList.length;
|
|
198
203
|
}
|
|
199
204
|
if (toBeBindTagCount > 0) {
|
|
200
205
|
skipSize += result.totalTagSize + 4 * stmtTableInfoList.length;
|
|
@@ -207,7 +212,9 @@ function stmt2BinaryBlockEncode(reqId, stmtTableInfoList, stmt_id, toBeBindTable
|
|
|
207
212
|
}
|
|
208
213
|
offset += constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT];
|
|
209
214
|
if (toBeBindTableNameCount > 0) {
|
|
210
|
-
let dataOffset = offset +
|
|
215
|
+
let dataOffset = offset +
|
|
216
|
+
result.tableNameSizeList.length *
|
|
217
|
+
constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.SMALLINT];
|
|
211
218
|
for (let i = 0; i < listLength; i++) {
|
|
212
219
|
view.setInt16(offset, result.tableNameSizeList[i], true);
|
|
213
220
|
offset += constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.SMALLINT];
|
|
@@ -225,7 +232,9 @@ function stmt2BinaryBlockEncode(reqId, stmtTableInfoList, stmt_id, toBeBindTable
|
|
|
225
232
|
offset = dataOffset;
|
|
226
233
|
}
|
|
227
234
|
if (toBeBindTagCount > 0) {
|
|
228
|
-
let dataOffset = offset +
|
|
235
|
+
let dataOffset = offset +
|
|
236
|
+
result.tagSizeList.length *
|
|
237
|
+
constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT];
|
|
229
238
|
for (let i = 0; i < listLength; i++) {
|
|
230
239
|
view.setInt32(offset, result.tagSizeList[i], true);
|
|
231
240
|
offset += constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT];
|
|
@@ -243,7 +252,9 @@ function stmt2BinaryBlockEncode(reqId, stmtTableInfoList, stmt_id, toBeBindTable
|
|
|
243
252
|
}
|
|
244
253
|
// ColumnDataLength
|
|
245
254
|
if (toBeBindColCount > 0) {
|
|
246
|
-
let dataOffset = offset +
|
|
255
|
+
let dataOffset = offset +
|
|
256
|
+
result.colSizeList.length *
|
|
257
|
+
constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT];
|
|
247
258
|
for (let i = 0; i < listLength; i++) {
|
|
248
259
|
view.setInt32(offset, result.colSizeList[i], true);
|
|
249
260
|
offset += constant_1.TDengineTypeLength[constant_1.TDengineTypeCode.INT];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsStmt.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsStmt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,MAAM;IACnB,SAAS,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"wsStmt.d.ts","sourceRoot":"","sources":["../../../src/stmt/wsStmt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,MAAM;IACnB,SAAS,IAAI,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACvC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO,CAAC,WAAW,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,YAAY,IAAI,cAAc,CAAC;IAC/B,IAAI,CAAC,WAAW,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,eAAe,IAAI,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { WsClient } from
|
|
2
|
-
import { StmtBindParams } from
|
|
3
|
-
import { WsStmt } from
|
|
4
|
-
import { Stmt1BindParams } from
|
|
5
|
-
import { WSRows } from
|
|
1
|
+
import { WsClient } from "../client/wsClient";
|
|
2
|
+
import { StmtBindParams } from "./wsParamsBase";
|
|
3
|
+
import { WsStmt } from "./wsStmt";
|
|
4
|
+
import { Stmt1BindParams } from "./wsParams1";
|
|
5
|
+
import { WSRows } from "../sql/wsRows";
|
|
6
6
|
export declare class WsStmt1 implements WsStmt {
|
|
7
7
|
private _wsClient;
|
|
8
8
|
private _stmt_id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsStmt1.d.ts","sourceRoot":"","sources":["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