Re: Row pattern recognition

Henson Choi <assam258@gmail.com>

From: Henson Choi <assam258@gmail.com>
To: Tatsuo Ishii <ishii@postgresql.org>, jian.universality@gmail.com
Cc: zsolt.parragi@percona.com, er@xs4all.nl, sjjang112233@gmail.com, vik@postgresfriends.org, jacob.champion@enterprisedb.com, david.g.johnston@gmail.com, peter@eisentraut.org, li.evan.chao@gmail.com, pgsql-hackers@postgresql.org
Date: 2026-06-22T07:07:43Z
Lists: pgsql-hackers

Attachments

Hi Tatsuo, Jian,

Please find attached (coverage.tgz) the code coverage analysis for the RPR
branch.

* Measurement setup
- Target: PostgreSQL RPR branch, modified-lines basis (RPR-base..RPR diff)
- Build: gcc --enable-coverage with --with-llvm (LLVM JIT module included;
both C and C++ instrumented)
- Tests: make check-world (regression + TAP + contrib; no forced JIT
settings)

* Results
- Modified-line coverage: 2,608 / 2,702 (96.5%)
- Functions: 172 / 173 (99.4%)
- Breakdown of the 94 uncovered lines:
  - Reachable (coverable by tests): 28 lines
  - Unreachable (defensive / dead code): 66 lines
    - worth cleaning up (Assert / remove / coverage-exclude): 22 lines
    - best kept as idiomatic guards (enum default, pg_unreachable(),
      public windowapi.h relpos guards): 44 lines

* Projected coverage (modified-lines basis)
- Current:                                              96.5%  (2,608 /
2,702)
- After adding the proposed tests (+28 reachable):      97.6%  (2,636 /
2,702)
- After also cleaning up only the lines worth changing
  (-22; the 44 idiomatic guards are kept on purpose):   98.4%  (2,636 /
2,680)
- If every unreachable line were removed (not advised
  for the idiomatic guards):                            ~100%  (no residual
uncovered lines)

* Picking a target -- your input would help
The analysis points to three possible levels:
  (a) tests only             -> 97.6%   (add tests for the 28 reachable
lines)
  (b) tests + safe cleanups  -> 98.4%   (also Assert/remove the 22
worth-fixing lines;
                                         keep the 44 idiomatic guards as-is)
  (c) full cleanup           -> ~100%   (also rework the idiomatic guards
-- usually undesirable)
My own inclination sits somewhere between (a) and (b): add all the
reachable-line tests, and
clean up only the most clear-cut lines (e.g. the arithmetic-underflow
Assert conversions and
the dead _equalRPRPattern body), while deciding the remaining defensive
lines case by case
rather than touching all 22 at once. I'd value your view on how far to take
this.

One caveat: this reachable/unreachable classification was produced with AI
assistance, so it
may be wrong in places. When I actually write the test cases I will
scrutinize each item
individually and verify it against a coverage build before proposing
anything.

* What the report contains
Each uncovered line carries a collapsible box stating:
- Reachable / Unreachable classification + confidence
- Reachable: the concrete SQL test that covers it
- Unreachable: the reason it cannot execute, and the recommended source
change
Consecutive lines on the same straight-line flow (no branch in between) are
merged into one box.

* How to view
  tar xzf coverage.tgz
  # open coverage/index.html in a browser
  #  -> pick a file -> expand the collapsible box under each red
(uncovered) line

* Contents
- coverage/index.html  : per-file coverage overview
- coverage/html/       : per-file detail (source + uncovered-line analysis)
- coverage/untested.md : checklist of uncovered lines

Please review. Feel free to reply with any questions.

Best regards,
Henson

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Adjust cross-version upgrade tests for seg_out() fix

  2. Rationalize error comments in partition split/merge tests

  3. Add fast path for foreign key constraint checks

  4. Fix assorted pretty-trivial memory leaks in the backend.

  5. Add temporal FOREIGN KEY contraints

  6. Add trailing commas to enum definitions

  7. Remove obsolete executor cleanup code