Skip to content

Commit 19c68c7

Browse files
committed
fix: AWS Redshift requires a portal name to honor fetchSize
1 parent 91bdbbd commit 19c68c7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const prepare = require('./pg').prepareValue
44
const EventEmitter = require('events').EventEmitter
55
const util = require('util')
66

7+
var nextUniqueID = 1; // concept borrowed from org.postgresql.core.v3.QueryExecutorImpl
8+
79
function Cursor (text, values, config) {
810
EventEmitter.call(this)
911

@@ -16,12 +18,14 @@ function Cursor (text, values, config) {
1618
this._result = new Result(this._conf.rowMode)
1719
this._cb = null
1820
this._rows = null
21+
this._portal = null;
1922
}
2023

2124
util.inherits(Cursor, EventEmitter)
2225

2326
Cursor.prototype.submit = function (connection) {
2427
this.connection = connection
28+
this._portal = 'C_' + (nextUniqueID++);
2529

2630
const con = connection
2731

@@ -30,12 +34,13 @@ Cursor.prototype.submit = function (connection) {
3034
}, true)
3135

3236
con.bind({
37+
portal: this._portal,
3338
values: this.values
3439
}, true)
3540

3641
con.describe({
3742
type: 'P',
38-
name: '' // use unamed portal
43+
name: this._portal // AWS Redshift requires a portal name
3944
}, true)
4045

4146
con.flush()
@@ -132,7 +137,7 @@ Cursor.prototype._getRows = function (rows, cb) {
132137
this._cb = cb
133138
this._rows = []
134139
const msg = {
135-
portal: '',
140+
portal: this._portal,
136141
rows: rows
137142
}
138143
this.connection.execute(msg, true)

0 commit comments

Comments
 (0)