Repository navigation
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
## What type of PR is this? - [x] BUG - [x] Test and CI ## Which issue(s) this PR fixes: Related to #29083 and #29082. Repairs the deterministic base BVT failure exposed by #29174 after #29143; does not claim to close every vector-index issue. ## What this PR does / why we need it: The cosine boundary golden captured float32 subnormal squared-norm error. After #29143 switched SQL scalar and batch paths to scaled float64 reductions, six assertions still expected `0.05718844756484032` rather than the correct `1 - 4/sqrt(18) = 0.05719095841793653`. The same six failures occur in the CI of #29143 and #29174; this is not a timing flake. - Correct exactly six expected values; retain all 22 SQL statements, raw scores, result shapes, and comparison rules. - Document the independent mathematical oracle rather than regenerating expectations from the implementation. - Add non-endpoint cosine scale-invariance tests for float32/float64, independently tiny operands and mixed extreme magnitudes, with negative and zero controls. - Exercise actual SQL const/column and materialized column/column execution; assert batch eligibility, DOUBLE result shape, and each path's agreement with the independent oracle at absolute tolerance 1e-14. No production code, runtime allocations, algorithm dispatch, retries, skips, or comparison tolerances changed. Reuses existing small fixtures. ### Validation - Go1.26.4 darwin/arm64 CPU, matching stamped native artifacts. - Focused new metric and SQL executor tests PASS; owning `pkg/vectorindex/metric` and `pkg/sql/plan/function` packages PASS. - Clean base service reproduces the original BVT 6/22 failures. Same ready isolated service with corrected test: 22/22 PASS twice (0.203s/0.238s); database cleanup checked between and after runs. - Targeted go vet, incremental lint, gofmt and diff checks. - Independent GPT-6-astra medium design and final overall review. Local BVT is standalone; historical failure evidence is Linux multi-CN PROXY CI. No topology/runtime change warrants another full multi-CN run locally. New PR CI remains pending; it has not been claimed green. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
812069c to
c953188
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
P1 blocker — REQUEST_CHANGES recommendation: preserve existing TEXT payloads during index rename.
The new RENAME INDEX route selects COPY at pkg/sql/plan/build_alter_table.go:1197–1198. For an upgraded table containing an ordinary TEXT value larger than 65,535 bytes, SET sql_mode='' followed by ALTER TABLE t RENAME INDEX old_idx TO new_idx copies that value through INSERT assignment conversion.
The rebased assignment rules retain casts for same-type TEXT (build_constraint_util.go:1350), impose the ordinary TEXT byte limit (func_cast.go:10094), and truncate successfully in non-strict mode (func_cast.go:9053–9058). COPY then replaces the original table, committing shortened data even though only an unrelated index name changed. Atomic rollback does not protect a successful conversion.
The conversion behavior originates in base-side #29121; this new public entry point must still satisfy the approved row-preservation invariant. Preserve unchanged column payloads, or reject lossy reconstruction atomically regardless of session SQL mode. Add an upgrade-state regression covering strict/non-strict modes and byte-for-byte preservation or atomic rejection.
Design approval, parser/planner, metadata handoff, FK/catalog, COPY lifecycle, and changed tests/results were reviewed. Exact-head required CI passes; the three changed BVTs ran successfully (61/61, 49/49, 24/24). They do not exercise this legacy-data boundary. This finding is source-proven; no upgrade reproduction was executed during this read-only review. Coverage was not used as a gate.
Independent review completed with GPT-6 Astra, medium.
fengttt
left a comment
There was a problem hiding this comment.
No, you will not copy the index just to rename it. This is not acceptable.
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed the exact head c953188 against base b2f178d. The 28 exact-head checks are complete and successful.
P1 — RENAME INDEX can silently truncate existing ordinary TEXT data.
Trigger: an upgraded/legacy table has a width-zero ordinary TEXT column containing more than 65,535 bytes; the session uses the empty/non-strict sql_mode; then it runs ALTER TABLE t RENAME INDEX old_idx TO new_idx.
Evidence:
- pkg/sql/plan/build_alter_table.go:1197-1198 routes RENAME INDEX through COPY.
- pkg/sql/plan/build_alter_table.go:628-630 copies every column with INSERT ... SELECT.
- pkg/sql/plan/build_constraint_util.go:1350-1354 and 1393-1401 force an assignment cast even when the source and target TEXT types compare equal.
- pkg/sql/plan/function/func_cast.go:10088-10103 gives width-zero TEXT the 65,535-byte limit (pkg/container/types/bytes.go:40), while 9053-9058 truncates over-limit values in non-strict mode.
The copy therefore succeeds and pkg/sql/compile/alter.go:1520-1522 publishes the replacement with shortened bytes; no rollback occurs because the conversion returned success. An unrelated index rename must preserve row bytes, or reject the reconstruction atomically. Please fix the copy path and add strict/non-strict regression coverage for legacy data.
P2 — RENAME INDEX is incompatible with legacy/partially upgraded tenant FK catalogs.
pkg/sql/compile/alter.go:1520-1522 unconditionally executes the SQL generated at pkg/sql/compile/alter_copy_index.go:61-66, which references referenced_index_name even when the table has no FK rows. However, pkg/sql/plan/build_dml_util.go:5674-5692 explicitly supports legacy/partial mo_foreign_keys layouts, and pkg/bootstrap/versions/v4_0_6/tenant_upgrade_list.go:33-35 adds this column asynchronously. If an existing session runs RENAME INDEX before that tenant upgrade has added the column, the statement reaches this SQL and fails with an unknown-column error. Make this catalog update layout-aware (or safely skip it when the column is absent) and add a legacy/partial-layout regression.
c953188 to
50ace2d
Compare
What type of PR is this?
Which issue(s) this PR addresses
Part of #23392. This PR delivers ordinary secondary-index rename. FULLTEXT, vector and other plugin indexes require their own maintenance-identity migration.
What this PR does
ALTER TABLE … RENAME INDEX old TO newandRENAME KEYuse the existing INPLACE ALTER transaction. The planner resolves clauses in order and the executor publishes final names inmo_indexesand the table constraint definition. The base table, hidden tables, index IDs and user data stay in place. Name swaps through a temporary alias publish only the final names.The INPLACE catalog rewrite now retains the original creator, owner and creation time using the existing catalog-row read. DUMP with reconstructable schema emits the live index names so its CREATE SQL agrees with the manifest.
Scope and concurrency
ALGORITHM=DEFAULT|INPLACEandLOCK=DEFAULT|EXCLUSIVE.Validation
-race. It verifies table/index/hidden-table identities, 70 KB payload digest, ownership metadata, failed clauses and transaction rollback, uniqueness, named and wildcard publication admission, a held publication row and a disjoint publisher, and FK name reuse with unrelated or reordered columns.gpt-6.2-sol/xhighproduced the design and approved50ace2d39bafter correction rounds. GitHub CI will run on the new revision.