Replace uuid_nil() with explicit nil UUID constant '00000000-0000-0000-0000-000000000000'::uuid as uuid_nil() function doesn't exist in PostgreSQL's uuid-ossp extension
···3737 channel_name TEXT NOT NULL,
3838 channel_args TEXT NOT NULL,
3939 commit_interval INTERVAL,
4040- after_message_id UUID DEFAULT uuid_nil() REFERENCES mq_msgs(id) ON DELETE SET DEFAULT
4040+ after_message_id UUID DEFAULT '00000000-0000-0000-0000-000000000000'::uuid REFERENCES mq_msgs(id) ON DELETE SET DEFAULT
4141);
42424343-- Insert dummy message so that the 'nil' UUID can be referenced
4444-INSERT INTO mq_msgs (id, channel_name, channel_args, after_message_id) VALUES (uuid_nil(), '', '', NULL);
4444+INSERT INTO mq_msgs (id, channel_name, channel_args, after_message_id) VALUES ('00000000-0000-0000-0000-000000000000'::uuid, '', '', NULL);
45454646-- Internal helper function to check that a UUID is neither NULL nor NIL
4747CREATE FUNCTION mq_uuid_exists(
4848 id UUID
4949) RETURNS BOOLEAN AS $$
5050- SELECT id IS NOT NULL AND id != uuid_nil()
5050+ SELECT id IS NOT NULL AND id != '00000000-0000-0000-0000-000000000000'::uuid
5151$$ LANGUAGE SQL IMMUTABLE;
52525353-- Index for polling
5454-CREATE INDEX ON mq_msgs(channel_name, channel_args, attempt_at) WHERE id != uuid_nil() AND NOT mq_uuid_exists(after_message_id);
5454+CREATE INDEX ON mq_msgs(channel_name, channel_args, attempt_at) WHERE id != '00000000-0000-0000-0000-000000000000'::uuid AND NOT mq_uuid_exists(after_message_id);
5555-- Index for adding messages
5656-CREATE INDEX ON mq_msgs(channel_name, channel_args, created_at, id) WHERE id != uuid_nil() AND after_message_id IS NOT NULL;
5656+CREATE INDEX ON mq_msgs(channel_name, channel_args, created_at, id) WHERE id != '00000000-0000-0000-0000-000000000000'::uuid AND after_message_id IS NOT NULL;
57575858-- Index for ensuring strict message order
5959CREATE UNIQUE INDEX mq_msgs_channel_name_channel_args_after_message_id_idx ON mq_msgs(channel_name, channel_args, after_message_id);
···7676 WHERE channel_name = from_channel_name
7777 AND channel_args = from_channel_args
7878 AND after_message_id IS NOT NULL
7979- AND id != uuid_nil()
7979+ AND id != '00000000-0000-0000-0000-000000000000'::uuid
8080 ORDER BY created_at DESC, id DESC
8181 LIMIT 1
8282 ),
8383- uuid_nil()
8383+ '00000000-0000-0000-0000-000000000000'::uuid
8484 )
8585$$ LANGUAGE SQL STABLE;
8686···8989RETURNS TABLE(name TEXT, args TEXT) AS $$
9090 SELECT channel_name, channel_args
9191 FROM mq_msgs
9292- WHERE id != uuid_nil()
9292+ WHERE id != '00000000-0000-0000-0000-000000000000'::uuid
9393 AND attempt_at <= NOW()
9494 AND (channel_names IS NULL OR channel_name = ANY(channel_names))
9595 AND NOT mq_uuid_exists(after_message_id)
···121121 FROM mq_active_channels(channel_names, batch_size) AS active_channels
122122 INNER JOIN LATERAL (
123123 SELECT * FROM mq_msgs
124124- WHERE mq_msgs.id != uuid_nil()
124124+ WHERE mq_msgs.id != '00000000-0000-0000-0000-000000000000'::uuid
125125 AND mq_msgs.attempt_at <= NOW()
126126 AND mq_msgs.channel_name = active_channels.name
127127 AND mq_msgs.channel_args = active_channels.args
···152152 NULL::INTERVAL,
153153 MIN(mq_msgs.attempt_at) - NOW()
154154 FROM mq_msgs
155155- WHERE mq_msgs.id != uuid_nil()
155155+ WHERE mq_msgs.id != '00000000-0000-0000-0000-000000000000'::uuid
156156 AND NOT mq_uuid_exists(mq_msgs.after_message_id)
157157 AND (channel_names IS NULL OR mq_msgs.channel_name = ANY(channel_names));
158158 END IF;
···234234 PERFORM pg_notify(CONCAT('mq_', channel_name), '')
235235 FROM mq_msgs
236236 WHERE id = ANY(msg_ids)
237237- AND after_message_id = uuid_nil()
237237+ AND after_message_id = '00000000-0000-0000-0000-000000000000'::uuid
238238 GROUP BY channel_name;
239239240240 IF FOUND THEN