Skip to content
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

Raised notices are printed backwards #1443

Open
3 tasks done
jelder opened this issue Dec 1, 2023 · 3 comments
Open
3 tasks done

Raised notices are printed backwards #1443

jelder opened this issue Dec 1, 2023 · 3 comments

Comments

@jelder
Copy link

jelder commented Dec 1, 2023

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

  • Please provide your OS and version information.
    macOS Sonoma 14.1.1
  • Please provide your CLI version.
    pgcli 4.0.1
  • What is the output of pip freeze command.
    Installed via Homebrew
-bash: /usr/local/bin/pip: cannot execute: required file not found
ERYoung11 added a commit to ERYoung11/pgcli that referenced this issue Feb 5, 2024
@ERYoung11
Copy link
Contributor

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)

j-bennet pushed a commit that referenced this issue Feb 6, 2024
* Fix - Raised notices are printed backwards #1443

* updated changelog

* removed a print

* fixed up syntax error

* removing unneeded Nones from output

* rem var due to github recommendation

* adjusting if statements.
@ERYoung11
Copy link
Contributor

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

@j-bennet
Copy link
Contributor

j-bennet commented Feb 8, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants