Skip to content

fix: return correct values from FOUND_ROWS() - #27312

Merged
XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
Lundomn:agent/fix-found-rows
Aug 25, 2026
Merged

XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
Lundomn:agent/fix-found-rows

Conversation

@Lundomn

@Lundomn Lundomn commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #27304

What this PR does / why we need it:

Fixes FOUND_ROWS() so it returns the previous result-set row count instead of a hard-coded zero. Ordinary SELECT statements, including prepared execution, record the number of rows returned to the client.

Implements SQL_CALC_FOUND_ROWS counting before the top-level LIMIT/OFFSET while preserving nested LIMIT semantics. Counting is owned by the coordinator across parallel and multi-CN execution, and LIMIT 0, cached prepared statements, implicit sql_select_limit, ordered regular-index access, Top-to-Scan messaging, and FORCE INDEX FOR ORDER BY no longer truncate or overwrite the complete count. FOUND_ROWS() expressions are kept on the coordinator so remote projections read the correct session state.

Adds focused unit and distributed regressions for plain and prepared SELECT, LIMIT 0, OFFSET, empty results, derived tables, CTEs, repeated prepared execution, ordered indexes, remote projections, session row limits, failed queries, and status statements. The relevant frontend, proxy, executor, compiler, planner, function, and process packages pass locally, including focused race tests and single-node and multi-CN end-to-end verification.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@gouhongshen gouhongshen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex automated review

The prior LIMIT-0, coordinator ownership, nested-limit, and prepared-reset findings are addressed. Three independent correctness gaps remain: ordered-index pushdown can truncate the counted stream, remote projections lack FOUND_ROWS state, and implicit sql_select_limit is not counted as pagination.

P1 - SQL_CALC_FOUND_ROWS still permits ordered-index Top-K pushdown (pkg/sql/plan/query_builder.go:3387)

The new guard disables only two pushdown hints, but createQuery still runs applyIndices and handleMessages afterward. For a nonunique secondary index with equality on its indexed prefix and ORDER BY primary key, applyRegularIndexTopSort installs IndexReaderParam.Limit. The reader converts this to an ordered limit and storage truncates the sorted index stream before the coordinator Limit drains it, so three qualifying rows with LIMIT 1 can publish FOUND_ROWS()=1 instead of 3. SQL_CALC_FOUND_ROWS must count the result without LIMIT (MySQL SELECT documentation).

P1 - FOUND_ROWS() evaluates as zero in remote table-scan projections (pkg/sql/plan/function/func_unary.go:7076)

FOUND_ROWS() now reads process-local SessionInfo, but compileProjection can embed this projection directly into a remote TableScan. BuildProcessInfo and pipeline.SessionInfo do not serialize FoundRows, so remote processes receive zero. On a multi-CN query, after a prior SQL_CALC_FOUND_ROWS statement, SELECT FOUND_ROWS(), id FROM t can therefore return 0 for the function column. This is separate from the coordinator-only Limit counting fix because no Limit operator is involved in this evaluation path.

P2 - Treat implicit sql_select_limit as a FOUND_ROWS owner (pkg/sql/compile/compile2.go:82)

statementHasSQLCalcFoundRowsPagination only detects an AST LIMIT. A query without explicit LIMIT is later capped by the session sql_select_limit in compileSteps, but no owner is selected, so recordLastFoundRows falls back to the capped output count. With SET sql_select_limit=1 and three matching rows, SELECT SQL_CALC_FOUND_ROWS ... followed by SELECT FOUND_ROWS() returns 1 instead of 3. MySQL documents sql_select_limit as a row cap and SQL_CALC_FOUND_ROWS as counting rows disregarding LIMIT (server variables, SELECT).

@aunjgr aunjgr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head 1e8529d. Three correctness blockers remain. [P1] SQL_CALC_FOUND_ROWS disables generic scan-limit hints, but createQuery still runs applyIndices; regular-index ordered Top-K can install IndexReaderParam.Limit and truncate the storage stream before the coordinator owner drains it, publishing the limited count. The index rewrite must not carry a semantic row cap for this query mode. [P1] FOUND_ROWS reads process-local SessionInfo, but BuildProcessInfo and pipeline.SessionInfo do not serialize FoundRows. A projection pushed into a remote scan therefore evaluates the previous count as zero; either serialize the state across every remote hop or keep this session function on the coordinator. [P2] statementHasSQLCalcFoundRowsPagination only recognizes an AST LIMIT. A finite session sql_select_limit is materialized later, after ownership selection, so SQL_CALC_FOUND_ROWS without explicit LIMIT records the capped output rather than the uncapped cardinality. Establish an owner for the implicit cap and add regular-index, multi-CN remote-projection, and sql_select_limit regressions.

@gouhongshen gouhongshen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex automated review

The prior blockers on regular-index Top-K truncation, coordinator evaluation of FOUND_ROWS(), and implicit sql_select_limit ownership are fixed in this head, with focused tests; the outer-derived/CTE and prepared-reset cases are also covered. Aptend’s current shared-process/local-remote ownership concern remains unresolved and is omitted as a duplicate. A distinct specialized-index truncation remains blocking, plus one non-blocking legacy-migration compatibility gap.

P1 - SQL_CALC_FOUND_ROWS still truncates specialized index candidates (pkg/sql/plan/query_builder.go:3387)

This guard disables only generic table-scan and left-join LIMIT pushdown, then applyIndices still runs vector/full-text rewrites. For a supported HNSW query such as SELECT SQL_CALC_FOUND_ROWS id FROM t ORDER BY l2_distance(v, ...) LIMIT 1, apply_indices_vector.go:150-167 derives candidateLimit=1 and apply_indices_hnsw.go:199-203 stores it in IndexReaderParam.Limit; hnsw_search.go:274-279 uses that as the ANN search limit, so the coordinator can count only the one emitted candidate instead of all rows before LIMIT. The same omission exists for a single full-text stream (apply_indices_fulltext.go:419-422 and :570-572 set the TVF limit, which fulltext.go:432 and :320-327 enforce). This is distinct from the regular-index Top-K issue fixed here: these plugin TVFs own the candidate budget. Disable these rewrites for SQL_CALC_FOUND_ROWS or provide an exhaustive counting path, and add coverage.

P2 - FOUND_ROWS state is lost when migration targets a pre-v22 CN (pkg/proxy/conn_migration.go:168)

The proxy now unconditionally puts info.FoundRows in MigrateConnToRequest, but target-protocol negotiation is only performed for typed variable migration. The existing path explicitly supports raw migration to pre-v22 targets (lines 108-121 and 134-147); those targets use the older protobuf/session code, ignore the unknown FoundRows field, and do not restore lastFoundRows. After a successful SELECT SQL_CALC_FOUND_ROWS followed by migration to such a target, FOUND_ROWS() therefore returns the target’s default 0. Gate migration on a target that can consume this state or preserve it through a compatibility mechanism.

@gouhongshen gouhongshen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex automated review

Follow-up review of head d357fa5 (delta since previously reviewed 3688730: a rebase onto current main plus one new authored commit, 'fix: preserve found rows across index rewrites and migration'; the rebase conflict-resolution delta only moved the FoundRows proto fields to unused numbers — MigrateConnFromResponse=15, MigrateConnToRequest=13, verified free against main).

Disposition of prior blockers:

  • My P1 (specialized-index truncation, blocking): FIXED. d357fa5 skips both vector-rewrite entry points under builder.sqlCalcFoundRows (applyIndicesForProject and applyIndicesForSort; applyVectorIndexForSortContext has no other callers), and the fulltext rewrites drop every internal cap under the flag: TVF internalLimit/Offset nil'd, synthesized relevance-sort limit nil'd (both join and covered paths), and the join candidate limit nil'd via the extracted buildFullTextCandidateLimit. Semantic pagination is preserved because projNode/sortNode keep their Limit fields, and the owner machinery (findFoundRowsOwnerNode + compileSort's owner branch building full Order + coordinator Offset/Limit with drain-and-count) counts the complete stream; nested derived-table LIMITs also survive via the untouched projNode.Limit, matching MySQL semantics. MsgTopValue receive on the scan is non-blocking, so the un-sent message under the owner path is harmless. New unit tests cover vector (both anchors), fulltext internal sort/TVF, and the join candidate path.
  • My P2 (FOUND_ROWS lost migrating to pre-v22 target, non-blocking): FIXED as a fail-closed gate — the proxy now negotiates the target protocol whenever FoundRows != 0 and rejects pre-v22 targets with an explicit error, consistent with the existing typed-variable migration contract (client_conn.go retries other CNs); zero FoundRows migrations are unaffected. Tests cover both branches.
  • Round-3 blockers (regular-index ordered Top-K pushdown, remote-projection FOUND_ROWS evaluation, implicit sql_select_limit ownership): confirmed fixed at the prior head and unchanged here.
  • aptend's round-1 findings (LIMIT 0 fast path, parallel/local ownership races, prepared Reset) and XuPeng-SH's nested-LIMIT ownership finding: fixed in earlier rounds, still fixed.

Verification: ran focused suites with the repo CGo wrapper — pkg/sql/plan (SQLCalcFoundRows/FoundRows), pkg/proxy (Migrate/FoundRows), pkg/sql/colexec/limit+offset and pkg/vm/process (-race -count=5), pkg/sql/compile and pkg/frontend (FoundRows and Migrate filters): all pass. BVT found_rows.sql/result expectations match MySQL semantics. One non-blocking nit remains (dead helper), reported below.

non-blocking - statementHasSQLCalcFoundRowsPagination is dead production code (pkg/sql/compile/compile2.go:75)

statementHasSQLCalcFoundRowsPagination (pkg/sql/compile/compile2.go:75) is referenced only by its own unit test (pkg/sql/compile/compile2_test.go:103-107); ownership selection now uses findFoundRowsOwnerNode plus the statementHasSQLCalcFoundRows fallback in compileSteps. This is a leftover from an earlier iteration and can be deleted with its test, or repurposed if the pagination check was meant to gate something. Non-blocking: no behavioral impact.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previously reported LIMIT 0, coordinator ownership, remote projection, index-truncation, and migration-state issues appear fixed on this head. One independent ownership blocker remains.

[P1] Do not select a nested LIMIT as the result-set owner when the outer SELECT has no explicit pagination — pkg/sql/compile/compile.go:1226-1229,1391-1396.

compileQuery unconditionally calls findFoundRowsOwnerNode for every SQL_CALC_FOUND_ROWS statement. The breadth-first search returns the first LIMIT/OFFSET anywhere below the final step, even when that pagination belongs only to a derived table/CTE. The existing statementHasSQLCalcFoundRowsPagination helper identifies the missing top-level distinction, but is not used in production.

Concrete counterexample with 100 rows in t:

select sql_calc_found_rows *
from (select id from t order by id limit 5) d;
select found_rows();

The result set correctly contains 5 rows, so FOUND_ROWS() must be 5. Instead the inner LIMIT becomes foundRowsOwnerNode, drains all 100 input rows, and publishes 100. I added a temporary unit regression around the exact production selection logic; it failed because foundRowsOwnerNode was the nested node, while all checked-in focused/race tests passed.

This also breaks the interaction with the newly supported implicit cap:

set sql_select_limit = 1;
prepare p from 'select sql_calc_found_rows * from (select id from t order by id limit 5) d';
execute p;
select found_rows();

The expected count is still 5, but the prepared plan reserves ownership for the nested LIMIT before compileSteps creates the true top-level session LIMIT; the foundRowsOwnerNode == nil guard then prevents reassignment, and the result is again 100.

Please make top-level ownership explicit before compiling descendants: nested semantic LIMIT/OFFSET nodes must never drain/publish unless an actual outer explicit pagination node owns the count, while a dynamic prepared sql_select_limit must reserve the outer owner even when nested limits exist. Add regressions for (1) SQL_CALC_FOUND_ROWS with only a nested LIMIT and (2) the same shape under prepared execution plus sql_select_limit, including repeated EXECUTE.

@aunjgr aunjgr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at bb93d5f. The final-result owner now excludes nested pagination while preserving explicit and session-limit counting; coordinator-only evaluation and rewrite guards keep the pre-limit stream intact. Focused ownership/index regressions pass, and the LIMIT drain path passed .

@aunjgr

aunjgr commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Clarification to my approval: the coordinator LIMIT drain regression passed under the Go race detector for 100 repetitions.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed exact head bb93d5f08e49795c06123ba95f764e0737d6e428 against base ae01f96c4d5c02c973f5bac9e8c4ab82b5dac3a7. The previous nested-only LIMIT ownership blocker is closed, but one adjacent prepared/session-limit combination remains incorrect.

[P1] Let the dynamic prepared sql_select_limit drain when top-level OFFSET already owns FOUND_ROWS — pkg/sql/compile/compile.go:1388-1393,2028-2044.

For an OFFSET-only SQL_CALC_FOUND_ROWS statement, selectFoundRowsOwnerNode correctly selects the explicit top-level OFFSET. A prepared plan skips ordinary session-limit materialization, so compileSteps later appends the dynamic sql_select_limit. Because foundRowsOwnerNode is already non-nil, that appended Limit is not marked for FOUND_ROWS and returns ExecStop as soon as the session cap is reached. Its upstream OFFSET owner therefore never reaches EOF and never publishes the pre-offset count; recordLastFoundRows then falls back to the limited result-row count.

Concrete counterexample with five rows in t:

set sql_select_limit = 1;
prepare p from 'select sql_calc_found_rows id from t order by id offset 2';
execute p;          -- returns one row, id=3
select found_rows();

The correct FOUND_ROWS value is 5 (the count before final OFFSET/LIMIT), but this pipeline records no SQL_CALC count and returns 1 through the result-row fallback.

I reproduced this with a temporary regression that (1) parses the public SQL, (2) exercises the exact selectFoundRowsOwnerNode + compileSteps topology, and (3) executes the resulting normal Limit-over-counting-Offset behavior. The correct assertion FoundRowsRecorded() failed after the outer Limit returned ExecStop. The checked-in focused ownership tests and the full pkg/sql/compile package pass, but they cover nested LIMIT plus dynamic session LIMIT—not OFFSET-only plus dynamic session LIMIT.

Please ensure the final dynamic session Limit continues draining while the OFFSET owner retains the pre-offset counting semantics. Add repeated prepared execution coverage, preferably including finite/unlimited session-limit transitions so reuse cannot retain the wrong owner mode.

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep re-review of exact head 0bd3a97. I read the complete review/thread history and full diff, then checked the increment since bb93d5f. The earlier LIMIT 0, coordinator ownership, prepared reset, nested pagination, index rewrite, migration, and OFFSET-plus-dynamic-session-limit findings are closed. One independent user-visible state bug remains.

Comment thread pkg/frontend/resp_client.go Resolved

@gouhongshen gouhongshen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex automated review

Revalidated approval against head 0bd3a97 (previous approved head d357fa5). Review surface since approval: the branch was rebased onto 344d852 — patch-level comparison proves all four previously reviewed commits (a0c0921, 1f45993, 2030e66, and 673dbb6 which is content-identical to the reviewed bb93d5f) carried over with zero content delta, only hunk offsets; upstream changes to the 8 PR-owned files introduced no conflict-resolution edits to PR logic. The only new authored change is 0bd3a97, which resolves XuPeng-SH's latest P1 (dynamic prepared sql_select_limit stopping before an OFFSET owner publishes).

Disposition of prior blockers: (1) My round at 1e8529d — ordered regular-index Top-K truncation, remote-projection FOUND_ROWS evaluation, implicit sql_select_limit ownership: fixed, unchanged and still verified at this head. (2) My round at 3688730 — vector/full-text candidate truncation: fixed (skips both applyIndices anchors and drops every internal fulltext cap under the flag); pre-v22 migration state loss: fixed via fail-closed protocol negotiation gate. (3) My sole non-blocking nit at d357fa5 (dead helper statementHasSQLCalcFoundRowsPagination): resolved — 673dbb6 now uses it in selectFoundRowsOwnerNode. (4) aptend's round 1 (LIMIT 0 fast path, parallel/local ownership races, prepared Reset): fixed in earlier rounds and still intact after rebase (BeginFoundRowsStatement in Compile.Reset at pkg/sql/compile/compile.go:231; literal LIMIT-0 fast path still owner-excluded). (5) XuPeng-SH's nested-ownership findings (rounds 2 and 4): fixed by 673dbb6 — ownership now requires AST top-level pagination before the BFS runs, or the exact materialized session-limit node; nested-only pagination never becomes owner, and the dynamic prepared limit reserves ownership when no top-level owner exists. Independently re-verified, including the partition-Top-N window path (unreachable as owner: requires a WINDOW node below the root chain and skips prepared statements). (6) XuPeng-SH's round-5 P1 at bb93d5f (OFFSET-only + dynamic prepared sql_select_limit): fixed by 0bd3a97 — verified in code: compileSteps now marks the appended dynamic Limit drain-only when an owner already exists; the Limit operator splits calcFoundRows (publish) from drainInputForFoundRows (consume without publishing); the drain-only Limit pulls the child to EOF so the OFFSET owner observes EOF and publishes the pre-offset count, while Reset/dupOperatorWithContext preserve correct per-EXECUTE semantics and flags. Non-prepared OFFSET + session-limit also correct via materializeSQLSelectLimit colocating Limit on the Offset node (compileSort owner branch publishes offset count first). Explicit-LIMIT + smaller session cap also consistent: owner drains/publishes the pre-limit count, drain-only cap only trims output.

Verification at current head (built thirdparties+cgo locally, ran via the repo CGo wrapper): pkg/sql/colexec/limit, pkg/sql/colexec/offset, pkg/vm/process PASS; pkg/sql/compile FoundRows/SQLCalc/SQLSelectLimit focused tests PASS; pkg/sql/plan, pkg/frontend, pkg/proxy FoundRows filters PASS; limit+offset under -race -count=3 PASS. Full pkg/sql/compile shows 3 parquet fanout test failures that reproduce identically on base commit 344d852 (verified in a pristine base checkout) — pre-existing on main, unrelated to this PR. BVT found_rows.sql now covers repeated prepared EXECUTE across sql_select_limit 1/0/unlimited transitions exactly as XuPeng-SH requested. No blocking or non-blocking findings remain.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed exact head 045331c.

The previous blocking path is closed: a prepared dynamic sql_select_limit above the explicit OFFSET owner now drains without publishing, so the owner reaches EOF and records the full row count. The derived-statement preservation change also prevents internal SELECTs from overwriting the prior user-visible FOUND_ROWS() value.

Validation:

  • Added a temporary real operator-chain counterexample (drain-only Limit over FOUND_ROWS-owning Offset) and ran it 20 times; passed.
  • go test: limit, offset, compile, plan, process, frontend, proxy; all passed.
  • focused FOUND_ROWS race tests across limit, offset, compile, frontend, count=3; passed.
  • git diff --check passed and review worktree is clean.

No remaining blocking correctness, lifecycle, or compatibility issue found on this head.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] Fix the expected output for the zero-row prepared result\n\nThe Compose + Pessimistic BVT fails deterministically in the newly added at line 109:\n\n\n\nThe expected result omits all output, but a prepared SELECT with zero rows still emits the column metadata. The actual result is:\n\n\n\nPlease add this metadata line to and rerun CI. This failure is introduced by the PR's new regression fixture; the implementation path itself is not implicated by this specific error.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] Fix the expected output for the zero-row prepared result

The Compose + Pessimistic BVT fails deterministically in the newly added test/distributed/cases/result_count/found_rows.sql at line 109:

set sql_select_limit = 0;
execute ps_offset_session_limit;

The expected result omits all output, but a prepared SELECT with zero rows still emits the column metadata. The actual result is:

➤ id[-5,64,0]

Please add this metadata line to found_rows.result and rerun CI. This failure is introduced by the PR's new regression fixture; the implementation path itself is not implicated by this specific error.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep re-reviewed exact head 6232d23ec5424f44b48d1f9c2de98f4f79afdd03 against current PR base b284c710e1da8854d6c28b4dfe8531731b7194ab. The latest result-fixture commit correctly closes the zero-row prepared metadata blocker, and the current-head FOUND_ROWS matrix passes across frontend, proxy migration, Limit/Offset ownership and drain, compiler owner selection, planner/index guards, function evaluation, and process state. I found no additional functional, state-generation, cancellation, compatibility, or performance blocker.

One deterministic merge blocker remains: the exact-head SCA job fails gofmt on two PR-owned hunks. gofmt -d reproduces both locally:

  • pkg/frontend/mysql_cmd_executor.go: align FoundRows: ses.GetLastFoundRows() with the surrounding SessionInfo fields.
  • pkg/vm/process/types.go: reformat the fields following SqlCalcFoundRows (StorageEngine through SessionId).

Please run gofmt on those two files and push the result. This is not an ARM runner flake: CI reports exactly the same two formatting diffs and exits from static-check with code 2. The BVT metadata fix itself is correct, focused current-head tests pass, and git diff --check is clean.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep re-review completed on exact head 37e6cb3c0d871ebf6295cc445728b1322ec05fad.

The only prior blocker is closed: the new commit is a formatting-only delta in mysql_cmd_executor.go and process/types.go; all changed Go files are now gofmt-clean and git diff --check is clean. I re-audited the FOUND_ROWS state lifecycle across successful/empty result sets, response failures, failed statements, LIMIT/OFFSET and SQL_CALC_FOUND_ROWS ownership, prepared reuse, coordinator-only evaluation, and proxy migration compatibility. The previous value is published only after a successful result response; failed/status statements do not corrupt it; compile reuse resets per-statement counters; and non-zero state fails closed for pre-v22 migration targets.

Fresh local validation passed: focused FOUND_ROWS/SQL_CALC regressions across frontend, proxy, limit, offset, compile, plan, function, and process; selected-package build; and vet. No blocking correctness, unhappy-path, compatibility, or performance issue found.

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep re-review of exact head 37e6cb3c0d871ebf6295cc445728b1322ec05fad. I reread the complete review/thread history, compared the delta from aptend's previous reviewed head, and checked the full diff. The prior derived-statement overwrite blocker is closed, but two independent P1 correctness issues remain: rolling upgrades can silently lose non-zero FOUND_ROWS() state, and explicit Sirius offload returns the post-LIMIT row count for SQL_CALC_FOUND_ROWS.

Validation: focused FoundRows/SQL_CALC/SQLSelectLimit/migration tests passed; related race tests passed three times; related vet passed. I also added two temporary counterexamples: a v26 migration target was allowed past the new guard, and a SQL_CALC_FOUND_ROWS Select remained Sirius-eligible. Both failed as described below; all temporary changes were removed.

Comment thread pkg/proxy/conn_migration.go Resolved
Comment thread pkg/sql/compile/compile2.go Resolved

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review completed on exact head e4d31b4. The delta from the previously reviewed head is limited to the two requested fixes: non-zero FOUND_ROWS migration state is now gated on MORPC v29, the version that actually consumes the field, and Sirius eligibility now rejects SQL_CALC_FOUND_ROWS before offload. I also rechecked the complete diff and verified the old failure paths directly. Full pkg/proxy and pkg/sql/compile tests passed; focused FOUND_ROWS tests across frontend, plan, function, limit, offset, and process passed; both regression groups passed with race detection for 10 repetitions; go vet and diff checks passed.

@Lundomn

Lundomn commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-25 10:47 UTC · Rule: main · triggered by @Lundomn with the @mergifyio queue command
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-25 10:53 UTC · at 56df923a27c24271460519f2013ebe17f844ef23

This pull request spent 5 minutes 59 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull request #27312 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants