Repository navigation
Fix infinite loop in replaceStringInfoString - #1750
Merged
Merged
Conversation
leborchuk
approved these changes
May 18, 2026
leborchuk
left a comment
Contributor
There was a problem hiding this comment.
There is no replace String Info in https://github.com/postgres/postgres/blob/master/src/common/stringinfo.c so we need to implement our own solution
yjhjstz
force-pushed
the
string_replace_fix
branch
from
May 18, 2026 18:23
4dc5dd0 to
28a4066
Compare
reshke
reviewed
May 19, 2026
yjhjstz
force-pushed
the
string_replace_fix
branch
from
May 21, 2026 13:41
28a4066 to
6c4a8d7
Compare
Smyatkin-Maxim
force-pushed
the
string_replace_fix
branch
from
July 13, 2026 16:53
6c4a8d7 to
639bfd7
Compare
tuhaihe
reviewed
Jul 14, 2026
The function had a few problems: - replace ="a" and replacement="ab" would give an infinite loop leading to OOM. We have a similar case in pg_dump: replace="range", replacement="multirange" - Copying the whole string each time there is a match - Empty replace pattern also leads to infinite loop We can still do better: for example count number of matches and do a single allocation, or even run the replacement inplace. But it's probably not worth it.
tuhaihe
force-pushed
the
string_replace_fix
branch
from
July 14, 2026 03:34
7c57076 to
39bb89c
Compare
leborchuk
pushed a commit
that referenced
this pull request
Aug 31, 2026
The function had a few problems: - replace ="a" and replacement="ab" would give an infinite loop leading to OOM. We have a similar case in pg_dump: replace="range", replacement="multirange" - Copying the whole string each time there is a match - Empty replace pattern also leads to infinite loop We can still do better: for example count number of matches and do a single allocation, or even run the replacement inplace. But it's probably not worth it.
Alena0704
pushed a commit
to open-gpdb/cloudberry
that referenced
this pull request
Sep 3, 2026
The function had a few problems: - replace ="a" and replacement="ab" would give an infinite loop leading to OOM. We have a similar case in pg_dump: replace="range", replacement="multirange" - Copying the whole string each time there is a match - Empty replace pattern also leads to infinite loop We can still do better: for example count number of matches and do a single allocation, or even run the replacement inplace. But it's probably not worth it.
Alena0704
pushed a commit
to open-gpdb/cloudberry
that referenced
this pull request
Sep 3, 2026
The function had a few problems: - replace ="a" and replacement="ab" would give an infinite loop leading to OOM. We have a similar case in pg_dump: replace="range", replacement="multirange" - Copying the whole string each time there is a match - Empty replace pattern also leads to infinite loop We can still do better: for example count number of matches and do a single allocation, or even run the replacement inplace. But it's probably not worth it.
Alena0704
pushed a commit
to open-gpdb/cloudberry
that referenced
this pull request
Sep 3, 2026
The function had a few problems: - replace ="a" and replacement="ab" would give an infinite loop leading to OOM. We have a similar case in pg_dump: replace="range", replacement="multirange" - Copying the whole string each time there is a match - Empty replace pattern also leads to infinite loop We can still do better: for example count number of matches and do a single allocation, or even run the replacement inplace. But it's probably not worth it.
Alena0704
pushed a commit
to open-gpdb/cloudberry
that referenced
this pull request
Sep 3, 2026
The function had a few problems: - replace ="a" and replacement="ab" would give an infinite loop leading to OOM. We have a similar case in pg_dump: replace="range", replacement="multirange" - Copying the whole string each time there is a match - Empty replace pattern also leads to infinite loop We can still do better: for example count number of matches and do a single allocation, or even run the replacement inplace. But it's probably not worth it.
Alena0704
pushed a commit
to open-gpdb/cloudberry
that referenced
this pull request
Sep 3, 2026
The function had a few problems: - replace ="a" and replacement="ab" would give an infinite loop leading to OOM. We have a similar case in pg_dump: replace="range", replacement="multirange" - Copying the whole string each time there is a match - Empty replace pattern also leads to infinite loop We can still do better: for example count number of matches and do a single allocation, or even run the replacement inplace. But it's probably not worth it.
Alena0704
pushed a commit
to open-gpdb/cloudberry
that referenced
this pull request
Sep 3, 2026
The function had a few problems: - replace ="a" and replacement="ab" would give an infinite loop leading to OOM. We have a similar case in pg_dump: replace="range", replacement="multirange" - Copying the whole string each time there is a match - Empty replace pattern also leads to infinite loop We can still do better: for example count number of matches and do a single allocation, or even run the replacement inplace. But it's probably not worth it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The function had a few problems:
We can still do better: for example count number of matches and do a single allocation, or even run the replacement inplace. But it's probably not worth it.
What does this PR do?
Type of Change
Breaking Changes
Test Plan
make installcheckmake -C src/test installcheck-cbdb-parallelImpact
Performance:
User-facing changes:
Dependencies:
Checklist
Additional Context
CI Skip Instructions