Skip to content

Prepared statements are not prepared if rolled back #600

@IvanSanchez

Description

@IvanSanchez

In one of my apps, I have the following scenario:

  • Start a transaction
  • Run prepared statement A, ignoring errors
  • Run prepared statement B, ignoring errors
  • Run prepared statement C, ignoring errors
  • End the transaction, letting PostgreSQL roll back automatically if it needs to
  • Wait a few seconds, then do the whole thing again.

The problem is: if a transaction block like this fails in prep statement A the first time the loop runs, then statements B and C will not exist in PostgreSQL, but node-postgres will assume they exist.

I've written down an example of this behaviour in a gist: https://gist.github.com/IvanSanchez/229feee233e59b32d76b

I expect node-postgres to somehow not assume that a prepared statement has been prepared if a rollback happened.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions