pgcli icon indicating copy to clipboard operation
pgcli copied to clipboard

Notices limited to the last 50 ones

Open pogman-code opened this issue 5 years ago • 1 comments

Description

Given the following call

BEGIN;

 CREATE FUNCTION count_to_hundred() RETURNS VOID AS
 $_$
 BEGIN 
     FOR i IN 1..100
     LOOP
         RAISE NOTICE '%', i;
     END LOOP;

     RETURN;
 END;
 $_$
 LANGUAGE plpgsql;


 SELECT count_to_hundred();

 ROLLBACK;

You would expect NOTICE: XXX to be printed from 1 to 100, but it start from 51 and ends at 100.

Your environment

$ uname -srvom
Linux 3.16.0-9-amd64 #1 SMP Debian 3.16.68-2 (2019-06-17) x86_64 GNU/Linux

$ pgcli --version
Version: 2.2.0

$ pip3 freeze
cli-helpers==1.2.1
click==7.1.1
configobj==5.0.6
humanize==2.2.0
pgcli==2.2.0
pgspecial==1.11.9
prompt-toolkit==2.0.10
psycopg2==2.8.5
Pygments==2.6.1
setproctitle==1.1.10
six==1.14.0
sqlparse==0.3.1
tabulate==0.8.7
terminaltables==3.1.0
wcwidth==0.1.9

From my understanding it might come from psycopg2 limiting the number of notices: https://www.psycopg.org/docs/connection.html#connection.notices

There is a workaround that if connection.notices is overriden, is it possible to have more than 50 in pgcli then?

pogman-code avatar Apr 06 '20 10:04 pogman-code

Thank you for researching this to find the limitation. I hadn't run into this limitation myself.

I'm happy to accept a PR if you're willing to take a stab at it.

Relevant code: https://github.com/dbcli/pgcli/blob/master/pgcli/pgexecute.py#L262

amjith avatar Apr 20 '20 23:04 amjith