clean_up_topic
SQL 0.1.1 · Source cbff27b8a34e1384384018680e46c20d5c610cc9.
Signature
postgremq.clean_up_topic(p_topic character varying)
RETURNS void
The signature, defaults, and result above were extracted from the installed PostgreSQL catalog.
Discard a topic's payloads and deliveries
Deletes every payload on the topic and cascading delivery rows, then prunes unused group state. Topic and queue declarations remain. Any topic message referenced by the DLQ prevents this operation.
Transactions and errors
PMQ03: retained DLQ references. Destructive transaction can remove in-flight work and lock many rows. Group pruning can raise serialization failure under stronger isolation. No batch limit or notification stream accompanies this purge.
All calls require the applicable caller privileges. See SQL errors for driver failures and uncertain outcomes.
Example
Run in psql with ON_ERROR_STOP and fresh reference-* names. ROLLBACK removes the fixtures.
BEGIN;
SELECT postgremq.create_topic('reference-events');
SELECT postgremq.create_queue('reference-jobs', 'reference-events', 2, false);
SELECT postgremq.publish_message('reference-events', '{"number":1}'::jsonb) AS id \gset ref_
SELECT postgremq.clean_up_topic('reference-events');
ROLLBACK;
The fixture topic and queue remain, while their payload and delivery are removed within this transaction.
Related: Topology, SQL conventions.