Postgresql – NOTIFY vs. pg_notify

postgresql

I write a DB LISTENing program something like as shown here (Example 3)==> https://www.postgresql.org/docs/9.1/static/libpq-example.html

I have a problem with pg_notify such that;

NOTIFY channel

==> works fine, C program catches the signal

whereas

SELECT pg_notify('channel','This is a test'); 

==> Program can't catch anything.

Any idea?
Note: My Version is PostgreSQL 10.5

Best Answer

In NOTIFY Channel, 'Channel' is treated as an SQL identifier, and will automatically be transformed to lower case if not surrounded by double quotes, like NOTIFY "Channel". This is usual PostgreSQL behavior. The arguments to pg_notify are strings, not SQL identifiers, so they are case-preserved.