postgresql-client
Advanced tools
Comparing version 1.9.1 to 1.9.2
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -10,2 +13,4 @@ exports.Connection = void 0; | ||
const BindParam_1 = require("./BindParam"); | ||
const debug_1 = __importDefault(require("debug")); | ||
const debug = debug_1.default('pgc:intlcon'); | ||
class Connection extends SafeEventEmitter_1.SafeEventEmitter { | ||
@@ -85,2 +90,3 @@ constructor(arg0, arg1) { | ||
return; | ||
debug('[%s] closing', this.processID); | ||
this._closing = true; | ||
@@ -91,7 +97,10 @@ // @ts-ignore | ||
return new Promise((resolve, reject) => { | ||
debug('[%s] waiting active queries', this.processID); | ||
const timer = setInterval(() => { | ||
if (this._intlCon.refCount <= 0 || Date.now() > startTime + terminateWait) { | ||
clearInterval(timer); | ||
if (this._intlCon.refCount > 0) | ||
if (this._intlCon.refCount > 0) { | ||
debug('[%s] terminate', this.processID); | ||
this.emit('terminate'); | ||
} | ||
this._close() | ||
@@ -118,2 +127,3 @@ .then(resolve) | ||
this._intlCon.assertConnected(); | ||
debug('[%s] query | %s', this.processID, sql); | ||
const typeMap = (options === null || options === void 0 ? void 0 : options.typeMap) || DataTypeMap_1.GlobalTypeMap; | ||
@@ -136,2 +146,3 @@ const paramTypes = (_a = options === null || options === void 0 ? void 0 : options.params) === null || _a === void 0 ? void 0 : _a.map(prm => prm instanceof BindParam_1.BindParam ? prm.oid : typeMap.determine(prm) || definitions_1.DataTypeOIDs.varchar); | ||
async prepare(sql, options) { | ||
debug('[%s] prepare', this.processID); | ||
return await PreparedStatement_1.PreparedStatement.prepare(this, sql, options); | ||
@@ -138,0 +149,0 @@ } |
@@ -62,2 +62,4 @@ "use strict"; | ||
async _fetchRows() { | ||
if (this._closed) | ||
throw new Error(`Can not fetch from closed cursor "${this._portal.name}"`); | ||
const portal = this._portal; | ||
@@ -64,0 +66,0 @@ await this._taskQueue.enqueue(async () => { |
@@ -138,3 +138,3 @@ "use strict"; | ||
try { | ||
debug('[%s] execute | %s', this.processID, sql.substring(0, 30)); | ||
debug('[%s] execute | %s', this.processID, sql); | ||
const startTime = Date.now(); | ||
@@ -141,0 +141,0 @@ const result = { |
@@ -53,3 +53,4 @@ "use strict"; | ||
intlCon.removeAllListeners(); | ||
intlCon.on('close', () => this._pool.destroy(intlCon, () => 0)); | ||
intlCon.once('close', () => this._pool.destroy(intlCon, () => 0)); | ||
intlCon._refCount = 0; | ||
} | ||
@@ -56,0 +57,0 @@ }, |
@@ -18,2 +18,3 @@ "use strict"; | ||
this._name = name; | ||
debug('[%s] constructor', this.name); | ||
} | ||
@@ -20,0 +21,0 @@ get connection() { |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -12,2 +15,4 @@ exports.PreparedStatement = void 0; | ||
const putil_varhelpers_1 = require("putil-varhelpers"); | ||
const debug_1 = __importDefault(require("debug")); | ||
const debug = debug_1.default('pgc:statement'); | ||
let statementCounter = 0; | ||
@@ -22,3 +27,3 @@ let portalCounter = 0; | ||
this._connection = connection; | ||
this._name = 'S_' + (statementCounter++); | ||
this._name = 'S_' + (++statementCounter); | ||
this._sql = sql; | ||
@@ -68,2 +73,3 @@ this._paramTypes = paramTypes; | ||
} | ||
debug('[%s] prepared | %s', statement.name, sql); | ||
} | ||
@@ -90,2 +96,3 @@ finally { | ||
async execute(options = {}) { | ||
debug('[%s] execute', this.name); | ||
const intoCon = common_1.getIntlConnection(this.connection); | ||
@@ -104,3 +111,5 @@ const transactionCommand = this.sql.match(/^(\bBEGIN\b|\bCOMMIT\b|\bROLLBACK\b)/i) && | ||
async close() { | ||
if (--this._refCount > 0) | ||
--this._refCount; | ||
debug('[%s] close | refCount = %d', this.name, this._refCount); | ||
if (this._refCount > 0) | ||
return; | ||
@@ -116,2 +125,3 @@ const intoCon = common_1.getIntlConnection(this.connection); | ||
const intoCon = common_1.getIntlConnection(this.connection); | ||
debug('[%s] _execute', this.name); | ||
intoCon.ref(); | ||
@@ -201,2 +211,3 @@ try { | ||
} | ||
debug('[%s] closed'); | ||
this.emit('close'); | ||
@@ -203,0 +214,0 @@ } |
{ | ||
"name": "postgresql-client", | ||
"description": "Professional PostgreSQL client for JavaScript and TypeScript", | ||
"version": "1.9.1", | ||
"version": "1.9.2", | ||
"author": "Panates", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186500
4808