Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-05

Postgresql listen/notify

6 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd
to Leonardo M. Ramé: Hi, does sql-db allows to capture PostgreSql notify events?. If yes, how?. Leonardo M.…
Leonardo M. Ram? wrote
Hi, does sql-db allows to capture PostgreSql notify events?. If yes, how?.

Indirectly. You have to set it up using the TPQConnection.Handle since this has long-term persistence, and have to make direct API calls *not* ExecuteDirect() since that uses a temporary handle. It works, but is sensitive to transient network failures etc.: the server end can forget, so it's wise to have a fallback mechanism.

I don't know whether it should be treated as a candidate for an extension to the sql-db API, since as far as I know there's something comparable (implemented very differently) on Firebird but nothing else.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Unknown author
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 13 lines
Leonardo M. Ram? wrote: > Hi, does sql-db allows to capture PostgreSql notify events?. If yes, > how?. Indirectly. You have to set it up using the TPQConnection.Handle since this has long-term persistence, and have to make direct API calls *not* ExecuteDirect() since that uses a temporary handle. It works, but is sensitive to transient network failures etc.: the server end can forget, so it's wise to have a fallback mechanism. I don't know whether it should be treated as a candidate for an extension to the sql-db API, since as far as I know there's something comparable (implemented very differently) on Firebird but nothing else.

Well, that and a backup/restore API for those engines supporting it.

Michael.

Reply by email

Mark Morgan Lloyd
to Marco van de Voort
Marco van de Voort wrote 7 lines
On Tue, May 08, 2012 at 08:01:45AM +0000, Mark Morgan Lloyd wrote: > I don't know whether it should be treated as a candidate for an > extension to the sql-db API, since as far as I know there's something > comparable (implemented very differently) on Firebird but nothing else. If it is table or row change notifications, MSSQL has it since iirc version 2005.

It's not, PostgreSQL would probably call those triggers. It's a general notification mechanism which can be used between programs connected to the same database irrespective of what they're doing with tables, see http://www.postgresql.org/docs/8.2/static/sql-notify.html (I've intentionally referenced a fairly old version there, since recent changes have added an additional parameter etc.).

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email