Skip to content

Pipelining #3357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Don't prepare named statements twice
  • Loading branch information
abenhamdine committed Feb 19, 2022
commit a33084f10028a9b4725bd796afd9b06adfe7cc9a
4 changes: 4 additions & 0 deletions packages/pg/lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,15 @@
process.nextTick(() => {
this.activeQuery.handleError(queryError, this.connection)
this.readyForQuery = true
this._pulseQueryQueue()

Check failure on line 496 in packages/pg/lib/client.js

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎`
})
}
this.blocked = query.blocking
this.sentQueryQueue.push(query)
if (query.name) {
console.log(`we store that ${query.name} has been submitted`)
this.connection.submittedNamedStatements[query.name] = query.text
}
}

if (this.readyForQuery === true) {
Expand Down
2 changes: 2 additions & 0 deletions packages/pg/lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Connection extends EventEmitter {
this._keepAliveInitialDelayMillis = config.keepAliveInitialDelayMillis
this.lastBuffer = false
this.parsedStatements = {}
// to track preparation of statements submitted to server
this.submittedNamedStatements = {}
this.ssl = config.ssl || false
this._ending = false
this._emitMessage = false
Expand Down
6 changes: 6 additions & 0 deletions packages/pg/lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ class Query extends EventEmitter {
}

hasBeenParsed(connection) {
if (connection.submittedNamedStatements[this.name]) {
console.log(`-----------------------------------`)
console.log(`query.hasBeenParsed : This statement has already been prepared`)
console.log(`-----------------------------------`)
return true
}
return this.name && connection.parsedStatements[this.name]
}

Expand Down
Loading