mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 07:47:07 +00:00
Limit notification payload sizes to 8 Kb
This commit is contained in:
@@ -153,15 +153,23 @@ CREATE FUNCTION public.notify() RETURNS trigger
|
||||
AS $$
|
||||
DECLARE
|
||||
channel text := TG_ARGV[0];
|
||||
payload text;
|
||||
BEGIN
|
||||
PERFORM pg_notify(channel, json_build_object(
|
||||
payload := json_build_object(
|
||||
'tstamp', CURRENT_TIMESTAMP,
|
||||
'operation', TG_OP,
|
||||
'schema', TG_TABLE_SCHEMA,
|
||||
'table', TG_TABLE_NAME,
|
||||
'old', row_to_json(OLD),
|
||||
'new', row_to_json(NEW)
|
||||
)::text);
|
||||
)::text;
|
||||
|
||||
IF octet_length(payload) < 8000 THEN
|
||||
PERFORM pg_notify(channel, payload);
|
||||
ELSE
|
||||
-- We need to find another solution
|
||||
RAISE INFO 'Payload over limit';
|
||||
END IF;
|
||||
RETURN NULL;
|
||||
END;
|
||||
$$;
|
||||
@@ -193,7 +201,8 @@ SET default_table_access_method = heap;
|
||||
CREATE TABLE public.projects (
|
||||
pid text NOT NULL,
|
||||
name text NOT NULL,
|
||||
schema text NOT NULL
|
||||
schema text NOT NULL,
|
||||
meta jsonb DEFAULT '{}'::jsonb NOT NULL
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user