Skip to content

Multi-query is atomic?! #1717

@vitaly-t

Description

@vitaly-t

Opening this issue, following this: multi-query is atomic?

This was originally posted against pg-promise, but quick tests revealed that's how node-postgres works, surprisingly. And I am totally caught up by this revelation myself. I was sure that when executing a multi-query string the operation wasn't atomic, but turns out that it is.

Steps to reproduce

Execute something like this with a single call to the query method:

INSERT INTO table VALUES(1, 2);INSERT INTO table VALUES(3, 4);bla-bla

Expected results

Two records are inserted, and then an error is thrown, about the invalid bla-bla query.

Actual results

The two inserted records are rolled back, following the last-query error, even though we do not use any transaction 😮

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