Skip to content

Removed redundant MAX statement in the PostgreSQL append to stream function #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export const appendToStreamSQL = rawSql(
v_transaction_id := pg_current_xact_id();

IF v_expected_stream_position IS NULL THEN
SELECT COALESCE(max(stream_position), 0) INTO v_expected_stream_position
SELECT COALESCE(stream_position, 0) INTO v_expected_stream_position
FROM ${streamsTable.name}
WHERE stream_id = v_stream_id AND partition = v_partition;
WHERE stream_id = v_stream_id AND partition = v_partition AND is_archived = FALSE;
END IF;

v_next_stream_position := v_expected_stream_position + array_upper(v_messages_data, 1);
Expand Down
Loading