Обсуждение: BUG #13994: Documentation of pg_notify is incorrect.

Поиск
Список
Период
Сортировка

BUG #13994: Documentation of pg_notify is incorrect.

От
junkmesend@gmail.com
Дата:
The following bug has been logged on the website:

Bug reference:      13994
Logged by:          Peter McGeeney
Email address:      junkmesend@gmail.com
PostgreSQL version: 9.5.1
Operating system:   Windows 8.1
Description:

The documentation at

http://www.postgresql.org/docs/9.5/static/sql-notify.html

Recommends the command...

SELECT pg_notify('fo' || 'o', 'pay' || 'load');

which doesn't work but

PERFORM pg_notify('fo' || 'o', 'pay' || 'load');

does work, as explained here.

http://stackoverflow.com/questions/5412474/using-pg-notify-in-postgresql-trigger-function?lq=1

Please note that this is nothing to do with the uppercase issue with
pg_notify here...

http://www.postgresql.org/message-id/201103031520.p23FKxFJ049037@wwwmaster.postgresql.org

Many thanks

Pete

Re: BUG #13994: Documentation of pg_notify is incorrect.

От
David Gould
Дата:
On Sun, 28 Feb 2016 23:20:40 +0000
junkmesend@gmail.com wrote:

> The following bug has been logged on the website:
>
> Bug reference:      13994
> Logged by:          Peter McGeeney
> Email address:      junkmesend@gmail.com
> PostgreSQL version: 9.5.1
> Operating system:   Windows 8.1
> Description:
>
> The documentation at
>
> http://www.postgresql.org/docs/9.5/static/sql-notify.html
>
> Recommends the command...
>
> SELECT pg_notify('fo' || 'o', 'pay' || 'load');
>
> which doesn't work but
>
> PERFORM pg_notify('fo' || 'o', 'pay' || 'load');
>
> does work, as explained here.
>
> http://stackoverflow.com/questions/5412474/using-pg-notify-in-postgresql-trigger-function?lq=1

This is working as documented. The trigger function is using language
plpgsql, but the psql session is sql. SELECT works differently in plpgsql
than in sql. Specifically it requires a destination for the result.
Otherwise use PERFORM.

See the fine manual:

http://www.postgresql.org/docs/9.5/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-SQL-NORESULT

-dg

--
David Gould              510 282 0869         daveg@sonic.net
If simplicity worked, the world would be overrun with insects.

Re: BUG #13994: Documentation of pg_notify is incorrect.

От
Joe Conway
Дата:
On 02/28/2016 03:20 PM, junkmesend@gmail.com wrote:
> http://www.postgresql.org/docs/9.5/static/sql-notify.html
>=20
> Recommends the command...
>=20
> SELECT pg_notify('fo' || 'o', 'pay' || 'load');

Which works fine:
postgres=3D# SELECT pg_notify('fo' || 'o', 'pay' || 'load');
 pg_notify
-----------

(1 row)

> PERFORM pg_notify('fo' || 'o', 'pay' || 'load');
>=20
> does work, as explained here.
>=20
> http://stackoverflow.com/questions/5412474/using-pg-notify-in-postgresql-=
trigger-function?lq=3D1

You are confusing SQL statement syntax with PL/pgSQL function syntax. See:

http://www.postgresql.org/docs/9.5/static/plpgsql-statements.html#PLPGSQL-S=
TATEMENTS-SQL-NORESULT

Joe

--=20
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development