Skip to content

PostgresNode.safe_psql(filename) does not detect syntax errors #52

Closed
@cbandy

Description

@cbandy

It took me some time to discover that a syntax error was being not being reported by node.safe_psql(filename='some.sql'). I tracked it down to behavior in psql. It seems worth raising, though I'm not certain it is something that testgres is necessarily responsible for handling.


$ psql --version
psql (PostgreSQL) 9.6.4

and/or

$ psql --version
psql (PostgreSQL) 10.4

psql reports errors differently depending on how input is passed:

  1. $ psql -h 127.0.0.1 -U cbandy -X -A -t -q -c 'whoops' -p 34751 postgres ; echo $?
    ERROR:  syntax error at or near "whoops"
    LINE 1: whoops
            ^
    1
    
  2. N.B. exit code is zero here:

    $ psql -h 127.0.0.1 -U cbandy -X -A -t -q -f <( echo 'whoops' ) -p 34751 postgres ; echo $?
    psql:/dev/fd/63:1: ERROR:  syntax error at or near "whoops"
    LINE 1: whoops
            ^
    0
    
  3. $ psql -h 127.0.0.1 -U cbandy -X -A -t -q -v ON_ERROR_STOP=1 -f <( echo 'whoops' ) -p 34751 
    postgres ; echo $?
    psql:/dev/fd/63:1: ERROR:  syntax error at or near "whoops"
    LINE 1: whoops
            ^
    3
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy