Skip to content

Fix dangerous intarray function#602

Merged
AndersAstrand merged 2 commits intopercona:mainfrom
AndersAstrand:fix-dangerous-intarray-function
Jan 12, 2026
Merged

Fix dangerous intarray function#602
AndersAstrand merged 2 commits intopercona:mainfrom
AndersAstrand:fix-dangerous-intarray-function

Conversation

@AndersAstrand
Copy link
Contributor

#592 got me looking at this function and it had some weirdness to it.

This is a better version of the function I think, but maybe the pfree() is unnecessary?

This was just an unsafe alias for a function.
Instead of using unsafe libc functions (strcat) and cropping the
integers (givin snprintf a buffer too small for any integer) we use
postgres StringInfo as god intended.
@AndersAstrand AndersAstrand force-pushed the fix-dangerous-intarray-function branch from 1c6490b to e3121b8 Compare January 8, 2026 15:50
@AndersAstrand
Copy link
Contributor Author

AndersAstrand commented Jan 8, 2026

We can of course keep using a buffer in the stack if we really think this is performance critical. It would be simple to do. I think StringInfo feels like the postgres way to do this though. I would probably prefer to analyze what context this is used in if so. Maybe we can just return the buffer if it's palloced instead of copying it at the end.

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.32%. Comparing base (966bf24) to head (e3121b8).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pg_stat_monitor.c 83.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #602      +/-   ##
==========================================
- Coverage   85.61%   85.32%   -0.30%     
==========================================
  Files           3        3              
  Lines        1342     1342              
  Branches      215      215              
==========================================
- Hits         1149     1145       -4     
- Misses         91       93       +2     
- Partials      102      104       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AndersAstrand AndersAstrand merged commit fef78a8 into percona:main Jan 12, 2026
20 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants