-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
53975: vendor: bump Pebble to b66f9d0155ab r=jbowens a=jbowens ``` b66f9d01 db: fix nil pointer dereference in compaction c29cc161 internal/record: write an EOF trailer on LogWriter Close ``` Release justification: These Pebble commits fix high-severity bugs. Release note: none 53999: builtins: implement ST_RemoveRepeatedPoints r=otan a=erikgrinaker Release justification: low risk, high benefit changes to existing functionality Release note (sql change): Implement the geometry builtin `ST_RemoveRepeatedPoints`. Closes #49017. 54013: builtins: add ST_LineFromMultiPoint and ST_LineMerge r=otan a=erikgrinaker One test case for `ST_LineFromMultiPoint` is commented out until #53997 is resolved - this may fail and need code changes. Release justification: low risk, high benefit changes to existing functionality Release note (sql change): Implement the geometry builtins `ST_LineFromMultiPoint` and `ST_LineMerge`. Closes #48970. Closes #48974. 54023: sqlliveness/slstorage: fix erroneous use of RLock r=ajwerner a=ajwerner We cannot RLock the cache as a successful retrieval mutates the underlying LRU. This commit also adds a test that pushes on the concurrency in the package. It's perhaps too complex but it instantly reproduces this error and is a general sanity check. Fixes #53972 Release justification: bug fixes and low-risk updates to new functionality Release note: None 54024: opt: fix issue with FastIntSet copy in statisticsBuilder r=rytaft a=rytaft Release justification: low risk, high benefit changes to existing functionality This commit fixes a bug that could happen in rare cases when there were many columns in a query (due to a single table with many columns or many tables), causing any `ColSets` maintained by the optimizer to use the `Sparse` format. When the `Sparse` format is used, it is not safe to perform a shallow copy of the `ColSet`, because modifying the copy can corrupt the original version. This commit fixes two instances in the `statisticsBuilder` where we were performing a shallow copy of the relational property `NotNullCols` and modifying it, causing the relational property to be corrupted. Fixes #54011 Release note (bug fix): Fixed a rare bug where the optimizer incorrectly classified some columns as not-null, possibly leading to invalid query plans and incorrect results. Co-authored-by: Jackson Owens <jackson@cockroachlabs.com> Co-authored-by: Erik Grinaker <erik@grinaker.org> Co-authored-by: Andrew Werner <ajwerner@cockroachlabs.com> Co-authored-by: Rebecca Taft <becca@cockroachlabs.com>
- Loading branch information
Showing
17 changed files
with
713 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// Copyright 2020 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package geomfn | ||
|
||
import ( | ||
"github.com/cockroachdb/cockroach/pkg/geo" | ||
"github.com/cockroachdb/errors" | ||
"github.com/twpayne/go-geom" | ||
) | ||
|
||
// RemoveRepeatedPoints returns the geometry with repeated points removed. | ||
func RemoveRepeatedPoints(g geo.Geometry, tolerance float64) (geo.Geometry, error) { | ||
t, err := g.AsGeomT() | ||
if err != nil { | ||
return geo.Geometry{}, err | ||
} | ||
// Use the square of the tolerance to avoid taking the square root of distance results. | ||
t, err = removeRepeatedPointsFromGeomT(t, tolerance*tolerance) | ||
if err != nil { | ||
return geo.Geometry{}, err | ||
} | ||
return geo.MakeGeometryFromGeomT(t) | ||
} | ||
|
||
func removeRepeatedPointsFromGeomT(t geom.T, tolerance2 float64) (geom.T, error) { | ||
switch t := t.(type) { | ||
case *geom.Point: | ||
case *geom.LineString: | ||
if coords, modified := removeRepeatedCoords(t.Layout(), t.Coords(), tolerance2, 2); modified { | ||
return t.SetCoords(coords) | ||
} | ||
case *geom.Polygon: | ||
if coords, modified := removeRepeatedCoords2(t.Layout(), t.Coords(), tolerance2, 4); modified { | ||
return t.SetCoords(coords) | ||
} | ||
case *geom.MultiPoint: | ||
if coords, modified := removeRepeatedCoords(t.Layout(), t.Coords(), tolerance2, 0); modified { | ||
return t.SetCoords(coords) | ||
} | ||
case *geom.MultiLineString: | ||
if coords, modified := removeRepeatedCoords2(t.Layout(), t.Coords(), tolerance2, 2); modified { | ||
return t.SetCoords(coords) | ||
} | ||
case *geom.MultiPolygon: | ||
if coords, modified := removeRepeatedCoords3(t.Layout(), t.Coords(), tolerance2, 4); modified { | ||
return t.SetCoords(coords) | ||
} | ||
case *geom.GeometryCollection: | ||
for _, g := range t.Geoms() { | ||
if _, err := removeRepeatedPointsFromGeomT(g, tolerance2); err != nil { | ||
return nil, err | ||
} | ||
} | ||
default: | ||
return nil, errors.AssertionFailedf("unknown geometry type: %T", t) | ||
} | ||
return t, nil | ||
} | ||
|
||
func removeRepeatedCoords( | ||
layout geom.Layout, coords []geom.Coord, tolerance2 float64, minCoords int, | ||
) ([]geom.Coord, bool) { | ||
modified := false | ||
switch tolerance2 { | ||
case 0: | ||
for i := 1; i < len(coords) && len(coords) > minCoords; i++ { | ||
if coords[i].Equal(layout, coords[i-1]) { | ||
coords = append(coords[:i], coords[i+1:]...) | ||
modified = true | ||
i-- | ||
} | ||
} | ||
default: | ||
for i := 1; i < len(coords) && len(coords) > minCoords; i++ { | ||
if coordMag2(coordSub(coords[i], coords[i-1])) <= tolerance2 { | ||
coords = append(coords[:i], coords[i+1:]...) | ||
modified = true | ||
i-- | ||
} | ||
} | ||
} | ||
return coords, modified | ||
} | ||
|
||
func removeRepeatedCoords2( | ||
layout geom.Layout, coords2 [][]geom.Coord, tolerance2 float64, minCoords int, | ||
) ([][]geom.Coord, bool) { | ||
modified := false | ||
for i, coords := range coords2 { | ||
if c, m := removeRepeatedCoords(layout, coords, tolerance2, minCoords); m { | ||
coords2[i] = c | ||
modified = true | ||
} | ||
} | ||
return coords2, modified | ||
} | ||
|
||
func removeRepeatedCoords3( | ||
layout geom.Layout, coords3 [][][]geom.Coord, tolerance2 float64, minCoords int, | ||
) ([][][]geom.Coord, bool) { | ||
modified := false | ||
for i, coords2 := range coords3 { | ||
for j, coords := range coords2 { | ||
if c, m := removeRepeatedCoords(layout, coords, tolerance2, minCoords); m { | ||
coords3[i][j] = c | ||
modified = true | ||
} | ||
} | ||
} | ||
return coords3, modified | ||
} |
Oops, something went wrong.