Sha256: 0cd60e00636d14eb61dce8cf8728e0d963c8d1ce021f956637fe62b6864b83db
Contents?: true
Size: 887 Bytes
Versions: 37
Compression:
Stored size: 887 Bytes
Contents
CREATE OR REPLACE FUNCTION get_stream_messages( _stream_name varchar, _position bigint DEFAULT 0, _batch_size bigint DEFAULT 1000, _condition varchar DEFAULT NULL ) RETURNS SETOF message AS $$ DECLARE command text; BEGIN command := ' SELECT id::varchar, stream_name::varchar, type::varchar, position::bigint, global_position::bigint, data::varchar, metadata::varchar, time::timestamp FROM messages WHERE stream_name = $1 AND position >= $2'; if _condition is not null then command := command || ' AND %s'; command := format(command, _condition); end if; command := command || ' ORDER BY position ASC LIMIT $3'; -- RAISE NOTICE '%', command; RETURN QUERY EXECUTE command USING _stream_name, _position, _batch_size; END; $$ LANGUAGE plpgsql VOLATILE;
Version data entries
37 entries across 37 versions & 1 rubygems