pgcli icon indicating copy to clipboard operation
pgcli copied to clipboard

Raised notices are printed backwards

Open jelder opened this issue 1 year ago • 3 comments

Description

Messages logged by functions are printed in reverse order, with None between lines.

BEGIN;

CREATE FUNCTION demo() RETURNS VOID AS
$_$
BEGIN 
    RAISE NOTICE 'first';
    RAISE NOTICE 'second';
    RAISE NOTICE 'third';
END;
$_$
LANGUAGE plpgsql;

SELECT demo();

ROLLBACK;

pgcli result:

third
None
second
None
first
None

psql result:

SELECT demo();
NOTICE:  00000: first
LOCATION:  exec_stmt_raise, pl_exec.c:3923
NOTICE:  00000: second
LOCATION:  exec_stmt_raise, pl_exec.c:3923
NOTICE:  00000: third
LOCATION:  exec_stmt_raise, pl_exec.c:3923

Your environment

PostgreSQL 15.3

  • [X] Please provide your OS and version information. macOS Sonoma 14.1.1
  • [X] Please provide your CLI version. pgcli 4.0.1
  • [X] What is the output of pip freeze command. Installed via Homebrew
-bash: /usr/local/bin/pip: cannot execute: required file not found

jelder avatar Dec 01 '23 13:12 jelder

I don't see the exact error message you do from psql. Here's what I see and I am working to make the output similar to this.

Do you have any idea why your output would look different from mine?

postgres=# BEGIN; BEGIN postgres=# postgres=# CREATE FUNCTION demo() RETURNS VOID AS postgres-# $_$ postgres$# BEGIN postgres$# RAISE NOTICE 'first'; postgres$# RAISE NOTICE 'second'; postgres$# RAISE NOTICE 'third'; postgres$# END; postgres$# $_$ postgres-# LANGUAGE plpgsql; CREATE FUNCTION postgres=# postgres=# SELECT demo(); NOTICE: first NOTICE: second NOTICE: third demo

(1 row)

ERYoung11 avatar Feb 05 '24 03:02 ERYoung11

@jelder The PR has been merged. Does this solve your issue?

ERYoung11 avatar Feb 08 '24 16:02 ERYoung11

@jelder The PR has been merged. Does this solve your issue?

I still need to do a release, but for right now pgcli can be installed from main:

pip install git+https://github.com/dbcli/pgcli.git

j-bennet avatar Feb 08 '24 21:02 j-bennet