pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: pg_stat_statements: Fix handling of duplicate constant locations 2+ messages / 1 participants [nested] [flat]
* pgsql: pg_stat_statements: Fix handling of duplicate constant locations @ 2025-10-29 11:35 Álvaro Herrera <alvherre@kurilemu.de> 0 siblings, 0 replies; 2+ messages in thread From: Álvaro Herrera @ 2025-10-29 11:35 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org pg_stat_statements: Fix handling of duplicate constant locations Two or more constants can have the same location. We handled this correctly for non squashed constants, but failed to do it if squashed (resulting in out-of-bounds memory access), because the code structure became broken by commit 0f65f3eec478: we failed to update 'last_loc' correctly when skipping these squashed constants. The simplest fix seems to be to get rid of 'last_loc' altogether -- in hindsight, it's quite pointless. Also, when ignoring a constant because of this, make sure to fulfill fill_in_constant_lengths's duty of setting its length to -1. Lastly, we can use == instead of <= because the locations have been sorted beforehand, so the < case cannot arise. Co-authored-by: Sami Imseih <samimseih@gmail.com> Co-authored-by: Dmitry Dolgov <9erthalion6@gmail.com> Reported-by: Konstantin Knizhnik <knizhnik@garret.ru> Backpatch-through: 18 Discussion: https://www.postgresql.org/message-id/2b91e358-0d99-43f7-be44-d2d4dbce37b3%40garret.ru Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/16edc1b94fc2db6e6a376471e280b50a418907c2 Modified Files -------------- contrib/pg_stat_statements/expected/squashing.out | 80 +++++++++++++++++++++++ contrib/pg_stat_statements/pg_stat_statements.c | 33 +++++----- contrib/pg_stat_statements/sql/squashing.sql | 26 ++++++++ 3 files changed, 123 insertions(+), 16 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: pg_stat_statements: Fix handling of duplicate constant locations @ 2025-10-29 11:35 Álvaro Herrera <alvherre@kurilemu.de> 0 siblings, 0 replies; 2+ messages in thread From: Álvaro Herrera @ 2025-10-29 11:35 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org pg_stat_statements: Fix handling of duplicate constant locations Two or more constants can have the same location. We handled this correctly for non squashed constants, but failed to do it if squashed (resulting in out-of-bounds memory access), because the code structure became broken by commit 0f65f3eec478: we failed to update 'last_loc' correctly when skipping these squashed constants. The simplest fix seems to be to get rid of 'last_loc' altogether -- in hindsight, it's quite pointless. Also, when ignoring a constant because of this, make sure to fulfill fill_in_constant_lengths's duty of setting its length to -1. Lastly, we can use == instead of <= because the locations have been sorted beforehand, so the < case cannot arise. Co-authored-by: Sami Imseih <samimseih@gmail.com> Co-authored-by: Dmitry Dolgov <9erthalion6@gmail.com> Reported-by: Konstantin Knizhnik <knizhnik@garret.ru> Backpatch-through: 18 Discussion: https://www.postgresql.org/message-id/2b91e358-0d99-43f7-be44-d2d4dbce37b3%40garret.ru Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b1635c166698a2b70aa3f397d0f7ca6844872dce Modified Files -------------- contrib/pg_stat_statements/expected/squashing.out | 80 +++++++++++++++++++++++ contrib/pg_stat_statements/pg_stat_statements.c | 33 +++++----- contrib/pg_stat_statements/sql/squashing.sql | 26 ++++++++ 3 files changed, 123 insertions(+), 16 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-10-29 11:35 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2025-10-29 11:35 pgsql: pg_stat_statements: Fix handling of duplicate constant locations Álvaro Herrera <alvherre@kurilemu.de> 2025-10-29 11:35 pgsql: pg_stat_statements: Fix handling of duplicate constant locations Álvaro Herrera <alvherre@kurilemu.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox