I have been playing with PostgreSQL's notification system and cannot for the life of my figure out why pg_notify(text, text) never works. This feature is not overly documented and I cannot find many examples of it being used in the wild so I figured nobody would mind me asking here.
Running the following works exactly as expected:
LISTEN my_channel;
NOTIFY my_channel, 'my message text';
Using the pg_notify() function however returns a null value and no notification is ever sent. No error is given either. An example of the use is:
SELECT pg_notify('my_channel', 'my message text');
I could use the NOTIFY function however my goal is to streamline the notification into a query like so:
select pg_notify(get_player_error_channel(username)::TEXT, 'test'::TEXT)
from player;
I assume I must be missing something ridiculous but I have had zero luck figuring out the reason for this. The page discussing NOTIFY can be found here: http://www.postgresql.org/docs/9.0/static/sql-notify.html
On it, it mentions this about pg_notify(), which makes me assume there would be nothing drastically different.
pg_notify To send a notification you can also use the function pg_notify(text, text). The function takes the channel name as the first argument and the payload as the second. The function is much easier to use than the NOTIFY command if you need to work with non-constant channel names and payloads.
Thanks as always for the assistance
Edit: Database version is: "PostgreSQL 9.0.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.2.4, 32-bit"