pgadmin-org / pgadmin4

pgAdmin is the most popular and feature rich Open Source administration and development platform for PostgreSQL, the most advanced Open Source database in the world.
https://www.pgadmin.org
Other
2.43k stars 638 forks source link

Notices from query n are shown in messages from query n+1 (RM #3094) #1657

Closed dpage closed 2 years ago

dpage commented 6 years ago

Issue migrated from Redmine: https://redmine.postgresql.org/issues/3094 Originally created by John admin at 2018-02-08 13:09:23 UTC.

In some cases the display of notices is delayed so the notices appear only after executing the next query.

Steps to reproduce: Connect to a PostgreSQL 10 server, select a database and open the query tool. Execute the following code twice:

DROP TABLE IF EXISTS test;

CREATE TABLE test (
    id serial NOT NULL PRIMARY KEY,
    text text NOT NULL);

DO $$
BEGIN
    RAISE NOTICE 'Hello, world! Now is %', NOW();
END $$;

SELECT NOW();

Actual result:

From Help/About: Version2.1 CopyrightCopyright 2013 - 2018, The pgAdmin Development Team Python Version2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] Flask Version0.12.2 Application ModeDesktop

dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-1 Originally created by Harshal Dhumal at 2018-02-14 10:39:38 UTC.

Redmine ticket header update:

Name Old Value New Value
Sprint changed EDB Sprint 8
dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-2 Originally created by Murtuza Zabuawala at 2018-02-15 13:57:01 UTC.

Redmine ticket header update:

Name Old Value New Value
Status changed New In Progress
Assigned To changed Murtuza Zabuawala
dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-3 Originally created by Murtuza Zabuawala at 2018-02-19 10:35:12 UTC.

Redmine ticket header update:

Name Old Value New Value
Status changed In Progress New
Assigned To changed Murtuza Zabuawala
dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-4 Originally created by Khushboo Vashi at 2018-02-21 10:20:20 UTC.

Redmine ticket header update:

Name Old Value New Value
Status changed New In Progress
Assigned To changed Khushboo Vashi
dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-5 Originally created by Neil French at 2018-02-22 10:10:33 UTC.

I'm noticing the same in OSX V2.1, when executing a batch with multiple statements the messages returned by the second statement onwards are kept over to the next execution and appear before the first message from the new batch.

Steps to reproduce:

Compile the following function which raises a notice:

create or replace function noticetest (vIn varchar) returns varchar as $$ begin raise notice 'You said %', vIn; return vIn; end $$ language plpgsql;

Then in a Query Tool window, execute the following statements in a single execution:

select noticetest('One'); select noticetest('Two');

Observe the Messages pane, which displays the output:

NOTICE: You said One

Successfully run. Total query runtime: 91 msec. 1 rows affected.

Only the first message is shown in the window, the notice raised from the second statement is not shown. Now execute the following statement in the same execution:

select noticetest('Three'); select noticetest('Four');

And observe the Messages pane:

NOTICE: You said Two NOTICE: You said Three

Successfully run. Total query runtime: 75 msec. 1 rows affected.

The missing message from the first execution appears along with only the notice raised in the first statement of the second batch executed. Finally, execute a single statement:

The messages pane shows:

select noticetest('Five');

NOTICE: You said Four NOTICE: You said Five

Successfully run. Total query runtime: 67 msec. 1 rows affected.

Again the same behaviour as before. It seems that PgAdmin doesn't fully read the message array from each multi-statement execution, only the first but then somehow catches up prior to the next execution, falling behind again if there's multiple statements.

As the results window only shows the last result set, I use notices a fair bit for dba functions that are frequently executed in batch to keep track of the non-critical success state of individual operations. It'd be nice if I could see the outcome of notices raised without having to execute a second batch.

The workaround currently is to execute a separate statement after the main batch e.g.:

select '';

.. and observe the message output in that execution.

dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-6 Originally created by Khushboo Vashi at 2018-02-26 11:22:00 UTC.

Sent the patch. https://www.postgresql.org/message-id/CAFOhELc=u6tk1n0g0g_Kkna1f5dx4_Qpr=Eeycv39NPbj6u+Ww@mail.gmail.com

dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-7 Originally created by Khushboo Vashi at 2018-02-26 14:19:49 UTC.

Applied in changeset commit:08b3ccc01a4d57e8ea3657f8882a53dcd1b99386.

Redmine ticket header update:

Name Old Value New Value
Status changed In Progress In Testing
Done Ratio changed 0 90
dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-8 Originally created by Dave Page at 2018-02-26 15:33:49 UTC.

Redmine ticket header update:

Name Old Value New Value
Fixed Version changed 3.0
dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-9 Originally created by Dave Page at 2018-02-26 16:33:49 UTC.

Applied in changeset commit:bcdb8eb27582eda1d04650e3fa0417be2abc44aa.

dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-10 Originally created by Dave Page at 2018-02-26 16:34:57 UTC.

Initial patch reverted as it re-introduced bug #1523.

Redmine ticket header update:

Name Old Value New Value
Status changed In Testing In Progress
Done Ratio changed 90 0
dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-11 Originally created by Khushboo Vashi at 2018-02-28 10:33:22 UTC.

Redmine ticket header update:

Name Old Value New Value
Sprint changed EDB Sprint 8 EDB Sprint 9
dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-12 Originally created by Khushboo Vashi at 2018-02-28 11:52:24 UTC.

Patch sent. https://www.postgresql.org/message-id/CAFOhELfXSuAK3YpXRA=mJXgUjuwsi4s=e80wEm70YsHfuMNyMA@mail.gmail.com

dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-13 Originally created by Khushboo Vashi at 2018-03-07 13:38:31 UTC.

Applied in changeset commit:d3c303e4559966de038263f7a2c5e0969947aae9.

Redmine ticket header update:

Name Old Value New Value
Status changed In Progress In Testing
Done Ratio changed 0 90
dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-14 Originally created by Khushboo Vashi at 2018-03-14 09:43:05 UTC.

Redmine ticket header update:

Name Old Value New Value
Sprint changed EDB Sprint 9 EDB Sprint 10
dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-15 Originally created by Murtuza Zabuawala at 2018-03-28 09:37:05 UTC.

Redmine ticket header update:

Name Old Value New Value
Sprint changed EDB Sprint 10 EDB Sprint 11
dpage commented 6 years ago

Comment migrated from Redmine: https://redmine.postgresql.org/issues/3094#note-16 Originally created by Fahar Abbas at 2018-03-30 06:28:08 UTC.

Tested on MAC OS 10.12(Python 3.6)

commit 61eb94a23c043930034d66a18ea1189343f0ee8a

Redmine ticket header update:

Name Old Value New Value
Status changed In Testing Resolved
Done Ratio changed 90 100
dpage commented 2 years ago

Issue closed on Redmine.