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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
GPT-6 medium deep review at current head 9f22d4de345e5b5c523f3c9ab085d1ea64061cd7: no verified blocking finding.
The validator covers all supported geometry shapes and members, rejects non-finite/out-of-range longitude and latitude, permits inclusive WGS 84 bounds, skips empty points, and bounds nested collections. Both ST_Distance operands are validated before distance/containment shortcuts; ST_Length and ST_Area validate before their numeric kernels. Effective-SRID dispatch keeps SRID 0 Cartesian behavior unchanged, and both geometry precisions use the guarded path.
Racing-UT review: the new work is a linear coordinate scan confined to SRID 4326 geodetic measurements; it adds no shared state, lock, goroutine, or allocation on the common path. Tests reuse lightweight evaluator fixtures and add no cluster, sleeps, retries, or large workloads. Exact-head CI run 34768265065 passed, including Ubuntu UT with the function package in the race-enabled stage and the extended geodetic BVT. No material racing-UT time increase is indicated; no base/head full-suite duration delta was measured.
## What type of PR is this? - [x] BUG - [ ] API-change - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#28191 ## What this PR does / why we need it: SRID-4326 `ST_Distance`, `ST_Length`, and `ST_Area` previously passed finite out-of-range longitude/latitude values to S2, which normalizes them and can return plausible but incorrect measurements. Add one allocation-free coordinate validator and invoke it at the geodetic measurement boundary. Distance validates both operands before containment/zero-distance shortcuts, so an invalid later vertex cannot be hidden by an earlier match. The effective SRID determines validation: typed or explicit SRID 4326 enforces finite longitude `[-180,180]` and latitude `[-90,90]`; SRID 0 remains Cartesian, including explicit SRID-0 overrides on values typed as 4326. Constructors/storage and the separate `ST_DISTANCE_SPHERE` contract are unchanged. `GEOGRAPHY` and `GEOGRAPHY32` use the same guard. ### Risks and performance - Each effective SRID-4326 measurement adds one O(n) coordinate scan (O(n+m) for distance); kernel complexity is unchanged. On Apple M4, a temporary microbenchmark measured approximately +1% for point distance, +5.3% for a 4096-coordinate line, and +2% for a 4096-vertex polygon, with zero additional allocations. These measurements are local directional evidence, not a production workload benchmark. - The numeric-only `geo.LengthMeters`, `geo.AreaSquareMeters`, and `geo.DistanceMeters` APIs retain their signatures and cannot return validation errors. Their precondition is now documented; all in-repository production call sites either validate here or use `ST_DISTANCE_SPHERE`'s separate Point/MultiPoint validator. - Out-of-range geometry can still be constructed/stored and used under SRID 0; it is rejected when measured using effective SRID 4326. This preserves explicit-SRID override behavior. ### Validation - Verified the four issue reproducers fail on the unchanged base (`67a9a4b130388956971888a67fc626784deade48`) because each previously returned success; the same evaluator regressions pass with the fix. - `GOWORK=off go test -mod=readonly -count=1 -timeout=180s ./pkg/geo` — PASS. - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=10m ./pkg/sql/plan/function` — PASS. - `GOWORK=off go vet -mod=readonly ./pkg/geo ./pkg/sql/plan/function` — PASS. - `golangci-lint run --config .golangci.yml --new-from-rev=67a9a4b130388956971888a67fc626784deade48 ./pkg/geo ./pkg/sql/plan/function` — PASS, 0 issues. - `test/distributed/cases/geo/geo_geodetic.sql/.result` now covers invalid constants, explicit/default SRID controls, `GEOGRAPHY`/`GEOGRAPHY32` columns, inclusive boundaries, and prepared-query valid → invalid → valid reuse. The BVT was not run against a local service; its result is pending the PR's BVT CI. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [x] BUG - [ ] API-change - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#28191 ## What this PR does / why we need it: SRID-4326 `ST_Distance`, `ST_Length`, and `ST_Area` previously passed finite out-of-range longitude/latitude values to S2, which normalizes them and can return plausible but incorrect measurements. Add one allocation-free coordinate validator and invoke it at the geodetic measurement boundary. Distance validates both operands before containment/zero-distance shortcuts, so an invalid later vertex cannot be hidden by an earlier match. The effective SRID determines validation: typed or explicit SRID 4326 enforces finite longitude `[-180,180]` and latitude `[-90,90]`; SRID 0 remains Cartesian, including explicit SRID-0 overrides on values typed as 4326. Constructors/storage and the separate `ST_DISTANCE_SPHERE` contract are unchanged. `GEOGRAPHY` and `GEOGRAPHY32` use the same guard. ### Risks and performance - Each effective SRID-4326 measurement adds one O(n) coordinate scan (O(n+m) for distance); kernel complexity is unchanged. On Apple M4, a temporary microbenchmark measured approximately +1% for point distance, +5.3% for a 4096-coordinate line, and +2% for a 4096-vertex polygon, with zero additional allocations. These measurements are local directional evidence, not a production workload benchmark. - The numeric-only `geo.LengthMeters`, `geo.AreaSquareMeters`, and `geo.DistanceMeters` APIs retain their signatures and cannot return validation errors. Their precondition is now documented; all in-repository production call sites either validate here or use `ST_DISTANCE_SPHERE`'s separate Point/MultiPoint validator. - Out-of-range geometry can still be constructed/stored and used under SRID 0; it is rejected when measured using effective SRID 4326. This preserves explicit-SRID override behavior. ### Validation - Verified the four issue reproducers fail on the unchanged base (`67a9a4b130388956971888a67fc626784deade48`) because each previously returned success; the same evaluator regressions pass with the fix. - `GOWORK=off go test -mod=readonly -count=1 -timeout=180s ./pkg/geo` — PASS. - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=10m ./pkg/sql/plan/function` — PASS. - `GOWORK=off go vet -mod=readonly ./pkg/geo ./pkg/sql/plan/function` — PASS. - `golangci-lint run --config .golangci.yml --new-from-rev=67a9a4b130388956971888a67fc626784deade48 ./pkg/geo ./pkg/sql/plan/function` — PASS, 0 issues. - `test/distributed/cases/geo/geo_geodetic.sql/.result` now covers invalid constants, explicit/default SRID controls, `GEOGRAPHY`/`GEOGRAPHY32` columns, inclusive boundaries, and prepared-query valid → invalid → valid reuse. The BVT was not run against a local service; its result is pending the PR's BVT CI. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [x] BUG - [ ] API-change - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#28191 ## What this PR does / why we need it: SRID-4326 `ST_Distance`, `ST_Length`, and `ST_Area` previously passed finite out-of-range longitude/latitude values to S2, which normalizes them and can return plausible but incorrect measurements. Add one allocation-free coordinate validator and invoke it at the geodetic measurement boundary. Distance validates both operands before containment/zero-distance shortcuts, so an invalid later vertex cannot be hidden by an earlier match. The effective SRID determines validation: typed or explicit SRID 4326 enforces finite longitude `[-180,180]` and latitude `[-90,90]`; SRID 0 remains Cartesian, including explicit SRID-0 overrides on values typed as 4326. Constructors/storage and the separate `ST_DISTANCE_SPHERE` contract are unchanged. `GEOGRAPHY` and `GEOGRAPHY32` use the same guard. ### Risks and performance - Each effective SRID-4326 measurement adds one O(n) coordinate scan (O(n+m) for distance); kernel complexity is unchanged. On Apple M4, a temporary microbenchmark measured approximately +1% for point distance, +5.3% for a 4096-coordinate line, and +2% for a 4096-vertex polygon, with zero additional allocations. These measurements are local directional evidence, not a production workload benchmark. - The numeric-only `geo.LengthMeters`, `geo.AreaSquareMeters`, and `geo.DistanceMeters` APIs retain their signatures and cannot return validation errors. Their precondition is now documented; all in-repository production call sites either validate here or use `ST_DISTANCE_SPHERE`'s separate Point/MultiPoint validator. - Out-of-range geometry can still be constructed/stored and used under SRID 0; it is rejected when measured using effective SRID 4326. This preserves explicit-SRID override behavior. ### Validation - Verified the four issue reproducers fail on the unchanged base (`67a9a4b130388956971888a67fc626784deade48`) because each previously returned success; the same evaluator regressions pass with the fix. - `GOWORK=off go test -mod=readonly -count=1 -timeout=180s ./pkg/geo` — PASS. - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=10m ./pkg/sql/plan/function` — PASS. - `GOWORK=off go vet -mod=readonly ./pkg/geo ./pkg/sql/plan/function` — PASS. - `golangci-lint run --config .golangci.yml --new-from-rev=67a9a4b130388956971888a67fc626784deade48 ./pkg/geo ./pkg/sql/plan/function` — PASS, 0 issues. - `test/distributed/cases/geo/geo_geodetic.sql/.result` now covers invalid constants, explicit/default SRID controls, `GEOGRAPHY`/`GEOGRAPHY32` columns, inclusive boundaries, and prepared-query valid → invalid → valid reuse. The BVT was not run against a local service; its result is pending the PR's BVT CI. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #28191
What this PR does / why we need it:
SRID-4326
ST_Distance,ST_Length, andST_Areapreviously passed finite out-of-range longitude/latitude values to S2, which normalizes them and can return plausible but incorrect measurements. Add one allocation-free coordinate validator and invoke it at the geodetic measurement boundary. Distance validates both operands before containment/zero-distance shortcuts, so an invalid later vertex cannot be hidden by an earlier match.The effective SRID determines validation: typed or explicit SRID 4326 enforces finite longitude
[-180,180]and latitude[-90,90]; SRID 0 remains Cartesian, including explicit SRID-0 overrides on values typed as 4326. Constructors/storage and the separateST_DISTANCE_SPHEREcontract are unchanged.GEOGRAPHYandGEOGRAPHY32use the same guard.Risks and performance
geo.LengthMeters,geo.AreaSquareMeters, andgeo.DistanceMetersAPIs retain their signatures and cannot return validation errors. Their precondition is now documented; all in-repository production call sites either validate here or useST_DISTANCE_SPHERE's separate Point/MultiPoint validator.Validation
67a9a4b130388956971888a67fc626784deade48) because each previously returned success; the same evaluator regressions pass with the fix.GOWORK=off go test -mod=readonly -count=1 -timeout=180s ./pkg/geo— PASS..agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=10m ./pkg/sql/plan/function— PASS.GOWORK=off go vet -mod=readonly ./pkg/geo ./pkg/sql/plan/function— PASS.golangci-lint run --config .golangci.yml --new-from-rev=67a9a4b130388956971888a67fc626784deade48 ./pkg/geo ./pkg/sql/plan/function— PASS, 0 issues.test/distributed/cases/geo/geo_geodetic.sql/.resultnow covers invalid constants, explicit/default SRID controls,GEOGRAPHY/GEOGRAPHY32columns, inclusive boundaries, and prepared-query valid → invalid → valid reuse. The BVT was not run against a local service; its result is pending the PR's BVT CI.