From 9a2ac8b7c498b055b8e9429c420f22af4d697d7c Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Mon, 31 Aug 2020 18:20:55 +0200 Subject: [PATCH 01/13] roachtest: deflake some tests Release justification: non-production code changes Release note: None --- pkg/cmd/roachtest/cli.go | 7 +------ pkg/cmd/roachtest/decommission.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pkg/cmd/roachtest/cli.go b/pkg/cmd/roachtest/cli.go index 4f05a95898c7..e569a3b0bbaa 100644 --- a/pkg/cmd/roachtest/cli.go +++ b/pkg/cmd/roachtest/cli.go @@ -28,13 +28,8 @@ func runCLINodeStatus(ctx context.Context, t *test, c *cluster) { lastWords := func(s string) []string { var result []string + s = elideInsecureDeprecationNotice(s) lines := strings.Split(s, "\n") - // v20.1 introduces a deprecation notice for --insecure. Skip over it. - // TODO(knz): Remove this when --insecure is dropped. - // See: https://github.com/cockroachdb/cockroach/issues/53404 - if len(lines) > 0 && strings.HasPrefix(lines[0], "Flag --insecure has been deprecated") { - lines = lines[2:] - } for _, line := range lines { words := strings.Fields(line) if n := len(words); n > 0 { diff --git a/pkg/cmd/roachtest/decommission.go b/pkg/cmd/roachtest/decommission.go index dd2485836e80..3617d0a4669c 100644 --- a/pkg/cmd/roachtest/decommission.go +++ b/pkg/cmd/roachtest/decommission.go @@ -902,8 +902,20 @@ func (h *decommTestHelper) recommission( return execCLI(ctx, h.t, h.c, runNode, args...) } +func elideInsecureDeprecationNotice(csvStr string) string { + // v20.1 introduces a deprecation notice for --insecure. Skip over it. + // TODO(knz): Remove this when --insecure is dropped. + // See: https://github.com/cockroachdb/cockroach/issues/53404 + lines := strings.SplitN(csvStr, "\n", 3) + if len(lines) > 0 && strings.HasPrefix(lines[0], "Flag --insecure has been deprecated") { + csvStr = lines[2] + } + return csvStr +} + // getCsvNumCols returns the number of columns in the given csv string. func (h *decommTestHelper) getCsvNumCols(csvStr string) (cols int) { + csvStr = elideInsecureDeprecationNotice(csvStr) reader := csv.NewReader(strings.NewReader(csvStr)) records, err := reader.Read() if err != nil { @@ -922,6 +934,7 @@ func (h *decommTestHelper) matchCSV(csvStr string, matchColRow [][]string) (err } }() + csvStr = elideInsecureDeprecationNotice(csvStr) reader := csv.NewReader(strings.NewReader(csvStr)) reader.FieldsPerRecord = -1 records, err := reader.ReadAll() From d777d88e42fdd4b98bfbb8874e716e378b396106 Mon Sep 17 00:00:00 2001 From: Solon Gordon Date: Thu, 27 Aug 2020 17:08:09 -0400 Subject: [PATCH 02/13] sql: fix race in execStmtInOpenState Fixes #53573 Release justification: low-risk update to new functionality Release note: None --- pkg/sql/conn_executor_exec.go | 3 +++ pkg/sql/run_control_test.go | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/sql/conn_executor_exec.go b/pkg/sql/conn_executor_exec.go index 9ced7c785ae6..2c441bd9c6da 100644 --- a/pkg/sql/conn_executor_exec.go +++ b/pkg/sql/conn_executor_exec.go @@ -244,7 +244,10 @@ func (ex *connExecutor) execStmtInOpenState( ex.incrementExecutedStmtCounter(stmt) } }() + + ex.state.mu.Lock() ex.state.mu.stmtCount++ + ex.state.mu.Unlock() os := ex.machine.CurState().(stateOpen) diff --git a/pkg/sql/run_control_test.go b/pkg/sql/run_control_test.go index 99fc8293c6ce..b2e92d1a008a 100644 --- a/pkg/sql/run_control_test.go +++ b/pkg/sql/run_control_test.go @@ -27,7 +27,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" - "github.com/cockroachdb/cockroach/pkg/testutils/skip" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" "github.com/cockroachdb/cockroach/pkg/util/leaktest" "github.com/cockroachdb/cockroach/pkg/util/log" @@ -300,7 +299,6 @@ GRANT admin TO has_admin2; func TestCancelQueryPermissions(t *testing.T) { defer leaktest.AfterTest(t)() - skip.WithIssue(t, 53584, "flaky test") defer log.Scope(t).Close(t) // getQueryIDs retrieves the IDs of any currently running queries for the From 688d9350f070d07bcf9650841611ae9118da5fca Mon Sep 17 00:00:00 2001 From: Bilal Akhtar Date: Mon, 31 Aug 2020 10:56:19 -0400 Subject: [PATCH 03/13] vendor: Bump pebble to e6a9f9a3c936adb8ee8642e4afb2c1ff8dee4562 Changes pulled in: - e6a9f9a3c936adb8ee8642e4afb2c1ff8dee4562 compaction: Don't set grandparent limit "behind" keys in fragmenter - 04c6a8caf99b691124110f869ef288832cb89356 cmd/pebble: fix rocksdb build errors - 4c3a7a171486d287c872cd9bfb38fd811fb0199b internal/manifest: add clone method to iterator - 778e980e984175bcb1adb1d09c88a5e04b7762e1 internal/manifest: update FileMetadata refcounts within B-Tree - 841f44b62f4bba532d646486928a75c24b66d380 internal/manifest: prohibit overwritten keys in B-Tree - 341164583f87cb754452e7c085d22e0119f25c24 *: Add diskHealthChecking{FS,File}, use it to wrap disk writes Only changes that affect Cockroach are the first and last list items above. Release justification: Bugfix change in Pebble, plus a low-risk change for better visibility into slow disks. Release note: None. --- go.mod | 2 +- go.sum | 4 ++-- vendor | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 670bdd0e551b..3b5cde065bab 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/cockroachdb/go-test-teamcity v0.0.0-20191211140407-cff980ad0a55 github.com/cockroachdb/gostdlib v1.13.0 github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f - github.com/cockroachdb/pebble v0.0.0-20200824180455-875ca32696b6 + github.com/cockroachdb/pebble v0.0.0-20200831143935-e6a9f9a3c936 github.com/cockroachdb/redact v1.0.2 github.com/cockroachdb/returncheck v0.0.0-20200612231554-92cdbca611dd github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 diff --git a/go.sum b/go.sum index a4f816d45cb5..63cce6d9483b 100644 --- a/go.sum +++ b/go.sum @@ -162,8 +162,8 @@ github.com/cockroachdb/grpc-gateway v1.14.6-0.20200519165156-52697fc4a249 h1:pZu github.com/cockroachdb/grpc-gateway v1.14.6-0.20200519165156-52697fc4a249/go.mod h1:UJ0EZAp832vCd54Wev9N1BMKEyvcZ5+IM0AwDrnlkEc= github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY= github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= -github.com/cockroachdb/pebble v0.0.0-20200824180455-875ca32696b6 h1:erL/39EP/sn3v5oEwYHCPcewADqwQhgzXGRbaRilAjc= -github.com/cockroachdb/pebble v0.0.0-20200824180455-875ca32696b6/go.mod h1:hU7vhtrqonEphNF+xt8/lHdaBprxmV1h8BOGrd9XwmQ= +github.com/cockroachdb/pebble v0.0.0-20200831143935-e6a9f9a3c936 h1:MaPvrDBbbWMzmI3uuBMKvcpDfZDY/QHx22T1pb9J6YI= +github.com/cockroachdb/pebble v0.0.0-20200831143935-e6a9f9a3c936/go.mod h1:hU7vhtrqonEphNF+xt8/lHdaBprxmV1h8BOGrd9XwmQ= github.com/cockroachdb/redact v0.0.0-20200622112456-cd282804bbd3 h1:2+dpIJzYMSbLi0587YXpi8tOJT52qCOI/1I0UNThc/I= github.com/cockroachdb/redact v0.0.0-20200622112456-cd282804bbd3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/redact v1.0.2 h1:bRktqHBXPqI+9bkOx0ikn9RS09G9k83oAdLx6rXRVTQ= diff --git a/vendor b/vendor index 42efe9fa6bfa..e45b0079e30c 160000 --- a/vendor +++ b/vendor @@ -1 +1 @@ -Subproject commit 42efe9fa6bfa3354f9c62bdea44c25b34549ea4e +Subproject commit e45b0079e30c9a7fc384525896c9d5d4b288f793 From f27dc9a4079e5fe762c5f81b68d6dfe2bc041dca Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Mon, 31 Aug 2020 20:21:55 +0200 Subject: [PATCH 04/13] roachtest: re-enable acceptance/bank/zerosum-restart This test had been flaking earlier in 2019 due to unclean graceful shutdowns. Since we've heavily reworked that logic since, let's give the test a second chance. Release justification: non-production code changes Release note: None --- pkg/cmd/roachtest/acceptance.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cmd/roachtest/acceptance.go b/pkg/cmd/roachtest/acceptance.go index 0a9ef885ee99..a89dd1036f07 100644 --- a/pkg/cmd/roachtest/acceptance.go +++ b/pkg/cmd/roachtest/acceptance.go @@ -31,7 +31,7 @@ func registerAcceptance(r *testRegistry) { skip: "https://github.com/cockroachdb/cockroach/issues/33683 (runs into " + " various errors during its rebalances, see IsExpectedRelocateError)", }, - // {"bank/zerosum-restart", runBankZeroSumRestart}, + {name: "bank/zerosum-restart", fn: runBankZeroSumRestart}, {name: "build-info", fn: runBuildInfo}, {name: "build-analyze", fn: runBuildAnalyze}, {name: "cli/node-status", fn: runCLINodeStatus}, From 9bd14db5f459e3f9bf11ce0c5ba6ead3e0d221ee Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Mon, 31 Aug 2020 20:25:02 +0200 Subject: [PATCH 05/13] roachtest: re-enable acceptance/bank/zerosum-splits PR #34080 which intended to skip `bank/zerosum-restarts`, mistakenly skipped `bank/zerosum-splits` instead. (As `zerosum-restarts` had been skipped already prior) There was no reason to skip `zerosum-splits`, so this commit re-enables it. Release justification: non-production code changes Release note: None --- pkg/cmd/roachtest/acceptance.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/cmd/roachtest/acceptance.go b/pkg/cmd/roachtest/acceptance.go index a89dd1036f07..61f919347622 100644 --- a/pkg/cmd/roachtest/acceptance.go +++ b/pkg/cmd/roachtest/acceptance.go @@ -26,11 +26,7 @@ func registerAcceptance(r *testRegistry) { // Sorted. Please keep it that way. {name: "bank/cluster-recovery", fn: runBankClusterRecovery}, {name: "bank/node-restart", fn: runBankNodeRestart}, - { - name: "bank/zerosum-splits", fn: runBankNodeZeroSum, - skip: "https://github.com/cockroachdb/cockroach/issues/33683 (runs into " + - " various errors during its rebalances, see IsExpectedRelocateError)", - }, + {name: "bank/zerosum-splits", fn: runBankNodeZeroSum}, {name: "bank/zerosum-restart", fn: runBankZeroSumRestart}, {name: "build-info", fn: runBuildInfo}, {name: "build-analyze", fn: runBuildAnalyze}, From efd0beaed89169c935bd5b41236750de6fb679c6 Mon Sep 17 00:00:00 2001 From: Cyrus Javan Date: Mon, 31 Aug 2020 11:27:20 -0700 Subject: [PATCH 06/13] geo/geomfn: implement ST_SymmetricDifference Added ST_SymmetricDifference builtin. ST_SymmetricDifference is simply an alias for ST_SymDifference. Release justification: low-risk update to new functionality Release note (sql change): Implemented the geometry based builtin . Resolves: #49052 --- docs/generated/sql/functions.md | 3 + .../logictest/testdata/logic_test/geospatial | 446 ++++++++++++------ pkg/sql/sem/builtins/geo_builtins.go | 1 + 3 files changed, 303 insertions(+), 147 deletions(-) diff --git a/docs/generated/sql/functions.md b/docs/generated/sql/functions.md index 24653216c7d4..1bb8a7cd38c1 100644 --- a/docs/generated/sql/functions.md +++ b/docs/generated/sql/functions.md @@ -1641,6 +1641,9 @@ The paths themselves are given in the direction of the first geometry.

st_symdifference(geometry_a: geometry, geometry_b: geometry) → geometry

Returns the symmetric difference of both geometries.

This function utilizes the GEOS module.

+st_symmetricdifference(geometry_a: geometry, geometry_b: geometry) → geometry

Returns the symmetric difference of both geometries.

+

This function utilizes the GEOS module.

+
st_touches(geometry_a: geometry, geometry_b: geometry) → bool

Returns true if the only points in common between geometry_a and geometry_b are on the boundary. Note points do not touch other points.

This function utilizes the GEOS module.

This function variant will attempt to utilize any available geospatial index.

diff --git a/pkg/sql/logictest/testdata/logic_test/geospatial b/pkg/sql/logictest/testdata/logic_test/geospatial index 4c5c8e53fe57..77102b034841 100644 --- a/pkg/sql/logictest/testdata/logic_test/geospatial +++ b/pkg/sql/logictest/testdata/logic_test/geospatial @@ -1013,161 +1013,160 @@ SELECT ST_IsRing('POINT(0 0)') # Topology operators -query TTTBT +query TTTB SELECT a.dsc, b.dsc, ST_AsEWKT(ST_Intersection(a.geom, b.geom)), - ST_Intersection(a.geom, b.geom) = ST_Intersection(a.geom::string, b.geom::string), - ST_AsEWKT(ST_SymDifference(a.geom, b.geom)) + ST_Intersection(a.geom, b.geom) = ST_Intersection(a.geom::string, b.geom::string) FROM geom_operators_test a JOIN geom_operators_test b ON (1=1) ORDER BY a.dsc, b.dsc ---- -Empty GeometryCollection Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true GEOMETRYCOLLECTION EMPTY -Empty GeometryCollection Empty LineString GEOMETRYCOLLECTION EMPTY true LINESTRING EMPTY -Empty GeometryCollection Empty Point GEOMETRYCOLLECTION EMPTY true POINT EMPTY -Empty GeometryCollection Faraway point GEOMETRYCOLLECTION EMPTY true POINT (5 5) -Empty GeometryCollection Line going through left and right square GEOMETRYCOLLECTION EMPTY true LINESTRING (-0.5 0.5, 0.5 0.5) -Empty GeometryCollection NULL NULL NULL NULL -Empty GeometryCollection Nested Geometry Collection GEOMETRYCOLLECTION EMPTY true GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) -Empty GeometryCollection Point middle of Left Square GEOMETRYCOLLECTION EMPTY true POINT (-0.5 0.5) -Empty GeometryCollection Point middle of Right Square GEOMETRYCOLLECTION EMPTY true POINT (0.5 0.5) -Empty GeometryCollection Square (left) GEOMETRYCOLLECTION EMPTY true POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) -Empty GeometryCollection Square (right) GEOMETRYCOLLECTION EMPTY true POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) -Empty GeometryCollection Square overlapping left and right square GEOMETRYCOLLECTION EMPTY true POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) -Empty LineString Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true GEOMETRYCOLLECTION EMPTY -Empty LineString Empty LineString GEOMETRYCOLLECTION EMPTY true LINESTRING EMPTY -Empty LineString Empty Point GEOMETRYCOLLECTION EMPTY true POINT EMPTY -Empty LineString Faraway point GEOMETRYCOLLECTION EMPTY true POINT (5 5) -Empty LineString Line going through left and right square GEOMETRYCOLLECTION EMPTY true LINESTRING (-0.5 0.5, 0.5 0.5) -Empty LineString NULL NULL NULL NULL -Empty LineString Nested Geometry Collection GEOMETRYCOLLECTION EMPTY true GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) -Empty LineString Point middle of Left Square GEOMETRYCOLLECTION EMPTY true POINT (-0.5 0.5) -Empty LineString Point middle of Right Square GEOMETRYCOLLECTION EMPTY true POINT (0.5 0.5) -Empty LineString Square (left) GEOMETRYCOLLECTION EMPTY true POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) -Empty LineString Square (right) GEOMETRYCOLLECTION EMPTY true POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) -Empty LineString Square overlapping left and right square GEOMETRYCOLLECTION EMPTY true POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) -Empty Point Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true GEOMETRYCOLLECTION EMPTY -Empty Point Empty LineString GEOMETRYCOLLECTION EMPTY true LINESTRING EMPTY -Empty Point Empty Point GEOMETRYCOLLECTION EMPTY true POINT EMPTY -Empty Point Faraway point GEOMETRYCOLLECTION EMPTY true POINT (5 5) -Empty Point Line going through left and right square GEOMETRYCOLLECTION EMPTY true LINESTRING (-0.5 0.5, 0.5 0.5) -Empty Point NULL NULL NULL NULL -Empty Point Nested Geometry Collection GEOMETRYCOLLECTION EMPTY true GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) -Empty Point Point middle of Left Square GEOMETRYCOLLECTION EMPTY true POINT (-0.5 0.5) -Empty Point Point middle of Right Square GEOMETRYCOLLECTION EMPTY true POINT (0.5 0.5) -Empty Point Square (left) GEOMETRYCOLLECTION EMPTY true POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) -Empty Point Square (right) GEOMETRYCOLLECTION EMPTY true POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) -Empty Point Square overlapping left and right square GEOMETRYCOLLECTION EMPTY true POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) -Faraway point Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true POINT (5 5) -Faraway point Empty LineString GEOMETRYCOLLECTION EMPTY true POINT (5 5) -Faraway point Empty Point GEOMETRYCOLLECTION EMPTY true POINT (5 5) -Faraway point Faraway point POINT (5 5) true POINT EMPTY -Faraway point Line going through left and right square POINT EMPTY true GEOMETRYCOLLECTION (POINT (5 5), LINESTRING (-0.5 0.5, 0.5 0.5)) -Faraway point NULL NULL NULL NULL -Faraway point Nested Geometry Collection POINT EMPTY true GEOMETRYCOLLECTION (POINT (5 5), GEOMETRYCOLLECTION (POINT (0 0))) -Faraway point Point middle of Left Square POINT EMPTY true MULTIPOINT (5 5, -0.5 0.5) -Faraway point Point middle of Right Square POINT EMPTY true MULTIPOINT (5 5, 0.5 0.5) -Faraway point Square (left) POINT EMPTY true GEOMETRYCOLLECTION (POINT (5 5), POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0))) -Faraway point Square (right) POINT EMPTY true GEOMETRYCOLLECTION (POINT (5 5), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))) -Faraway point Square overlapping left and right square POINT EMPTY true GEOMETRYCOLLECTION (POINT (5 5), POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0))) -Line going through left and right square Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true LINESTRING (-0.5 0.5, 0.5 0.5) -Line going through left and right square Empty LineString GEOMETRYCOLLECTION EMPTY true LINESTRING (-0.5 0.5, 0.5 0.5) -Line going through left and right square Empty Point GEOMETRYCOLLECTION EMPTY true LINESTRING (-0.5 0.5, 0.5 0.5) -Line going through left and right square Faraway point POINT EMPTY true GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, 0.5 0.5), POINT (5 5)) -Line going through left and right square Line going through left and right square LINESTRING (-0.5 0.5, 0.5 0.5) true LINESTRING EMPTY -Line going through left and right square NULL NULL NULL NULL -Line going through left and right square Nested Geometry Collection POINT EMPTY true GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, 0.5 0.5), GEOMETRYCOLLECTION (POINT (0 0))) -Line going through left and right square Point middle of Left Square POINT (-0.5 0.5) true LINESTRING (-0.5 0.5, 0.5 0.5) -Line going through left and right square Point middle of Right Square POINT (0.5 0.5) true LINESTRING (-0.5 0.5, 0.5 0.5) -Line going through left and right square Square (left) LINESTRING (-0.5 0.5, 0 0.5) true GEOMETRYCOLLECTION (LINESTRING (0 0.5, 0.5 0.5), POLYGON ((0 0.5, 0 0, -1 0, -1 1, 0 1, 0 0.5))) -Line going through left and right square Square (right) LINESTRING (0 0.5, 0.5 0.5) true GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, 0 0.5), POLYGON ((0 0.5, 0 1, 1 1, 1 0, 0 0, 0 0.5))) -Line going through left and right square Square overlapping left and right square LINESTRING (-0.1 0.5, 0.5 0.5) true GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, -0.1 0.5), POLYGON ((-0.1 0.5, -0.1 1, 1 1, 1 0, -0.1 0, -0.1 0.5))) -NULL Empty GeometryCollection NULL NULL NULL -NULL Empty LineString NULL NULL NULL -NULL Empty Point NULL NULL NULL -NULL Faraway point NULL NULL NULL -NULL Line going through left and right square NULL NULL NULL -NULL NULL NULL NULL NULL -NULL Nested Geometry Collection NULL NULL NULL -NULL Point middle of Left Square NULL NULL NULL -NULL Point middle of Right Square NULL NULL NULL -NULL Square (left) NULL NULL NULL -NULL Square (right) NULL NULL NULL -NULL Square overlapping left and right square NULL NULL NULL -Nested Geometry Collection Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) -Nested Geometry Collection Empty LineString GEOMETRYCOLLECTION EMPTY true GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) -Nested Geometry Collection Empty Point GEOMETRYCOLLECTION EMPTY true GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) -Nested Geometry Collection Faraway point POINT EMPTY true GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0)), POINT (5 5)) -Nested Geometry Collection Line going through left and right square POINT EMPTY true GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0)), LINESTRING (-0.5 0.5, 0.5 0.5)) -Nested Geometry Collection NULL NULL NULL NULL -Nested Geometry Collection Nested Geometry Collection POINT (0 0) true POINT EMPTY -Nested Geometry Collection Point middle of Left Square POINT EMPTY true GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0)), POINT (-0.5 0.5)) -Nested Geometry Collection Point middle of Right Square POINT EMPTY true GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0)), POINT (0.5 0.5)) -Nested Geometry Collection Square (left) POINT (0 0) true POLYGON ((-1 0, -1 1, 0 1, 0 0, -1 0)) -Nested Geometry Collection Square (right) POINT (0 0) true POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) -Nested Geometry Collection Square overlapping left and right square POINT (0 0) true POLYGON ((-0.1 0, -0.1 1, 1 1, 1 0, -0.1 0)) -Point middle of Left Square Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true POINT (-0.5 0.5) -Point middle of Left Square Empty LineString GEOMETRYCOLLECTION EMPTY true POINT (-0.5 0.5) -Point middle of Left Square Empty Point GEOMETRYCOLLECTION EMPTY true POINT (-0.5 0.5) -Point middle of Left Square Faraway point POINT EMPTY true MULTIPOINT (-0.5 0.5, 5 5) -Point middle of Left Square Line going through left and right square POINT (-0.5 0.5) true LINESTRING (-0.5 0.5, 0.5 0.5) -Point middle of Left Square NULL NULL NULL NULL -Point middle of Left Square Nested Geometry Collection POINT EMPTY true GEOMETRYCOLLECTION (POINT (-0.5 0.5), GEOMETRYCOLLECTION (POINT (0 0))) -Point middle of Left Square Point middle of Left Square POINT (-0.5 0.5) true POINT EMPTY -Point middle of Left Square Point middle of Right Square POINT EMPTY true MULTIPOINT (-0.5 0.5, 0.5 0.5) -Point middle of Left Square Square (left) POINT (-0.5 0.5) true POLYGON ((-1 0, -1 1, 0 1, 0 0, -1 0)) -Point middle of Left Square Square (right) POINT EMPTY true GEOMETRYCOLLECTION (POINT (-0.5 0.5), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))) -Point middle of Left Square Square overlapping left and right square POINT EMPTY true GEOMETRYCOLLECTION (POINT (-0.5 0.5), POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0))) -Point middle of Right Square Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true POINT (0.5 0.5) -Point middle of Right Square Empty LineString GEOMETRYCOLLECTION EMPTY true POINT (0.5 0.5) -Point middle of Right Square Empty Point GEOMETRYCOLLECTION EMPTY true POINT (0.5 0.5) -Point middle of Right Square Faraway point POINT EMPTY true MULTIPOINT (0.5 0.5, 5 5) -Point middle of Right Square Line going through left and right square POINT (0.5 0.5) true LINESTRING (-0.5 0.5, 0.5 0.5) -Point middle of Right Square NULL NULL NULL NULL -Point middle of Right Square Nested Geometry Collection POINT EMPTY true GEOMETRYCOLLECTION (POINT (0.5 0.5), GEOMETRYCOLLECTION (POINT (0 0))) -Point middle of Right Square Point middle of Left Square POINT EMPTY true MULTIPOINT (0.5 0.5, -0.5 0.5) -Point middle of Right Square Point middle of Right Square POINT (0.5 0.5) true POINT EMPTY -Point middle of Right Square Square (left) POINT EMPTY true GEOMETRYCOLLECTION (POINT (0.5 0.5), POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0))) -Point middle of Right Square Square (right) POINT (0.5 0.5) true POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) -Point middle of Right Square Square overlapping left and right square POINT (0.5 0.5) true POLYGON ((-0.1 0, -0.1 1, 1 1, 1 0, -0.1 0)) -Square (left) Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) -Square (left) Empty LineString GEOMETRYCOLLECTION EMPTY true POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) -Square (left) Empty Point GEOMETRYCOLLECTION EMPTY true POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) -Square (left) Faraway point POINT EMPTY true GEOMETRYCOLLECTION (POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)), POINT (5 5)) -Square (left) Line going through left and right square LINESTRING (-0.5 0.5, 0 0.5) true GEOMETRYCOLLECTION (LINESTRING (0 0.5, 0.5 0.5), POLYGON ((0 0.5, 0 0, -1 0, -1 1, 0 1, 0 0.5))) -Square (left) NULL NULL NULL NULL -Square (left) Nested Geometry Collection POINT (0 0) true POLYGON ((-1 0, -1 1, 0 1, 0 0, -1 0)) -Square (left) Point middle of Left Square POINT (-0.5 0.5) true POLYGON ((-1 0, -1 1, 0 1, 0 0, -1 0)) -Square (left) Point middle of Right Square POINT EMPTY true GEOMETRYCOLLECTION (POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)), POINT (0.5 0.5)) -Square (left) Square (left) POLYGON ((0 0, -1 0, -1 1, 0 1, 0 0)) true POLYGON EMPTY -Square (left) Square (right) LINESTRING (0 0, 0 1) true POLYGON ((0 0, -1 0, -1 1, 0 1, 1 1, 1 0, 0 0)) -Square (left) Square overlapping left and right square POLYGON ((0 0, -0.1 0, -0.1 1, 0 1, 0 0)) true MULTIPOLYGON (((-0.1 0, -1 0, -1 1, -0.1 1, -0.1 0)), ((0 0, 0 1, 1 1, 1 0, 0 0))) -Square (right) Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) -Square (right) Empty LineString GEOMETRYCOLLECTION EMPTY true POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) -Square (right) Empty Point GEOMETRYCOLLECTION EMPTY true POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) -Square (right) Faraway point POINT EMPTY true GEOMETRYCOLLECTION (POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)), POINT (5 5)) -Square (right) Line going through left and right square LINESTRING (0 0.5, 0.5 0.5) true GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, 0 0.5), POLYGON ((0 0.5, 0 1, 1 1, 1 0, 0 0, 0 0.5))) -Square (right) NULL NULL NULL NULL -Square (right) Nested Geometry Collection POINT (0 0) true POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) -Square (right) Point middle of Left Square POINT EMPTY true GEOMETRYCOLLECTION (POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)), POINT (-0.5 0.5)) -Square (right) Point middle of Right Square POINT (0.5 0.5) true POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) -Square (right) Square (left) LINESTRING (0 1, 0 0) true POLYGON ((0 1, 1 1, 1 0, 0 0, -1 0, -1 1, 0 1)) -Square (right) Square (right) POLYGON ((1 0, 0 0, 0 1, 1 1, 1 0)) true POLYGON EMPTY -Square (right) Square overlapping left and right square POLYGON ((1 0, 0 0, 0 1, 1 1, 1 0)) true POLYGON ((0 1, 0 0, -0.1 0, -0.1 1, 0 1)) -Square overlapping left and right square Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) -Square overlapping left and right square Empty LineString GEOMETRYCOLLECTION EMPTY true POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) -Square overlapping left and right square Empty Point GEOMETRYCOLLECTION EMPTY true POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) -Square overlapping left and right square Faraway point POINT EMPTY true GEOMETRYCOLLECTION (POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)), POINT (5 5)) -Square overlapping left and right square Line going through left and right square LINESTRING (-0.1 0.5, 0.5 0.5) true GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, -0.1 0.5), POLYGON ((-0.1 0.5, -0.1 1, 1 1, 1 0, -0.1 0, -0.1 0.5))) -Square overlapping left and right square NULL NULL NULL NULL -Square overlapping left and right square Nested Geometry Collection POINT (0 0) true POLYGON ((-0.1 0, -0.1 1, 1 1, 1 0, -0.1 0)) -Square overlapping left and right square Point middle of Left Square POINT EMPTY true GEOMETRYCOLLECTION (POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)), POINT (-0.5 0.5)) -Square overlapping left and right square Point middle of Right Square POINT (0.5 0.5) true POLYGON ((-0.1 0, -0.1 1, 1 1, 1 0, -0.1 0)) -Square overlapping left and right square Square (left) POLYGON ((0 0, -0.1 0, -0.1 1, 0 1, 0 0)) true MULTIPOLYGON (((0 1, 1 1, 1 0, 0 0, 0 1)), ((-0.1 1, -0.1 0, -1 0, -1 1, -0.1 1))) -Square overlapping left and right square Square (right) POLYGON ((1 0, 0 0, 0 1, 1 1, 1 0)) true POLYGON ((0 0, -0.1 0, -0.1 1, 0 1, 0 0)) -Square overlapping left and right square Square overlapping left and right square POLYGON ((1 0, -0.1 0, -0.1 1, 1 1, 1 0)) true POLYGON EMPTY +Empty GeometryCollection Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true +Empty GeometryCollection Empty LineString GEOMETRYCOLLECTION EMPTY true +Empty GeometryCollection Empty Point GEOMETRYCOLLECTION EMPTY true +Empty GeometryCollection Faraway point GEOMETRYCOLLECTION EMPTY true +Empty GeometryCollection Line going through left and right square GEOMETRYCOLLECTION EMPTY true +Empty GeometryCollection NULL NULL NULL +Empty GeometryCollection Nested Geometry Collection GEOMETRYCOLLECTION EMPTY true +Empty GeometryCollection Point middle of Left Square GEOMETRYCOLLECTION EMPTY true +Empty GeometryCollection Point middle of Right Square GEOMETRYCOLLECTION EMPTY true +Empty GeometryCollection Square (left) GEOMETRYCOLLECTION EMPTY true +Empty GeometryCollection Square (right) GEOMETRYCOLLECTION EMPTY true +Empty GeometryCollection Square overlapping left and right square GEOMETRYCOLLECTION EMPTY true +Empty LineString Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true +Empty LineString Empty LineString GEOMETRYCOLLECTION EMPTY true +Empty LineString Empty Point GEOMETRYCOLLECTION EMPTY true +Empty LineString Faraway point GEOMETRYCOLLECTION EMPTY true +Empty LineString Line going through left and right square GEOMETRYCOLLECTION EMPTY true +Empty LineString NULL NULL NULL +Empty LineString Nested Geometry Collection GEOMETRYCOLLECTION EMPTY true +Empty LineString Point middle of Left Square GEOMETRYCOLLECTION EMPTY true +Empty LineString Point middle of Right Square GEOMETRYCOLLECTION EMPTY true +Empty LineString Square (left) GEOMETRYCOLLECTION EMPTY true +Empty LineString Square (right) GEOMETRYCOLLECTION EMPTY true +Empty LineString Square overlapping left and right square GEOMETRYCOLLECTION EMPTY true +Empty Point Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true +Empty Point Empty LineString GEOMETRYCOLLECTION EMPTY true +Empty Point Empty Point GEOMETRYCOLLECTION EMPTY true +Empty Point Faraway point GEOMETRYCOLLECTION EMPTY true +Empty Point Line going through left and right square GEOMETRYCOLLECTION EMPTY true +Empty Point NULL NULL NULL +Empty Point Nested Geometry Collection GEOMETRYCOLLECTION EMPTY true +Empty Point Point middle of Left Square GEOMETRYCOLLECTION EMPTY true +Empty Point Point middle of Right Square GEOMETRYCOLLECTION EMPTY true +Empty Point Square (left) GEOMETRYCOLLECTION EMPTY true +Empty Point Square (right) GEOMETRYCOLLECTION EMPTY true +Empty Point Square overlapping left and right square GEOMETRYCOLLECTION EMPTY true +Faraway point Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true +Faraway point Empty LineString GEOMETRYCOLLECTION EMPTY true +Faraway point Empty Point GEOMETRYCOLLECTION EMPTY true +Faraway point Faraway point POINT (5 5) true +Faraway point Line going through left and right square POINT EMPTY true +Faraway point NULL NULL NULL +Faraway point Nested Geometry Collection POINT EMPTY true +Faraway point Point middle of Left Square POINT EMPTY true +Faraway point Point middle of Right Square POINT EMPTY true +Faraway point Square (left) POINT EMPTY true +Faraway point Square (right) POINT EMPTY true +Faraway point Square overlapping left and right square POINT EMPTY true +Line going through left and right square Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true +Line going through left and right square Empty LineString GEOMETRYCOLLECTION EMPTY true +Line going through left and right square Empty Point GEOMETRYCOLLECTION EMPTY true +Line going through left and right square Faraway point POINT EMPTY true +Line going through left and right square Line going through left and right square LINESTRING (-0.5 0.5, 0.5 0.5) true +Line going through left and right square NULL NULL NULL +Line going through left and right square Nested Geometry Collection POINT EMPTY true +Line going through left and right square Point middle of Left Square POINT (-0.5 0.5) true +Line going through left and right square Point middle of Right Square POINT (0.5 0.5) true +Line going through left and right square Square (left) LINESTRING (-0.5 0.5, 0 0.5) true +Line going through left and right square Square (right) LINESTRING (0 0.5, 0.5 0.5) true +Line going through left and right square Square overlapping left and right square LINESTRING (-0.1 0.5, 0.5 0.5) true +NULL Empty GeometryCollection NULL NULL +NULL Empty LineString NULL NULL +NULL Empty Point NULL NULL +NULL Faraway point NULL NULL +NULL Line going through left and right square NULL NULL +NULL NULL NULL NULL +NULL Nested Geometry Collection NULL NULL +NULL Point middle of Left Square NULL NULL +NULL Point middle of Right Square NULL NULL +NULL Square (left) NULL NULL +NULL Square (right) NULL NULL +NULL Square overlapping left and right square NULL NULL +Nested Geometry Collection Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true +Nested Geometry Collection Empty LineString GEOMETRYCOLLECTION EMPTY true +Nested Geometry Collection Empty Point GEOMETRYCOLLECTION EMPTY true +Nested Geometry Collection Faraway point POINT EMPTY true +Nested Geometry Collection Line going through left and right square POINT EMPTY true +Nested Geometry Collection NULL NULL NULL +Nested Geometry Collection Nested Geometry Collection POINT (0 0) true +Nested Geometry Collection Point middle of Left Square POINT EMPTY true +Nested Geometry Collection Point middle of Right Square POINT EMPTY true +Nested Geometry Collection Square (left) POINT (0 0) true +Nested Geometry Collection Square (right) POINT (0 0) true +Nested Geometry Collection Square overlapping left and right square POINT (0 0) true +Point middle of Left Square Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true +Point middle of Left Square Empty LineString GEOMETRYCOLLECTION EMPTY true +Point middle of Left Square Empty Point GEOMETRYCOLLECTION EMPTY true +Point middle of Left Square Faraway point POINT EMPTY true +Point middle of Left Square Line going through left and right square POINT (-0.5 0.5) true +Point middle of Left Square NULL NULL NULL +Point middle of Left Square Nested Geometry Collection POINT EMPTY true +Point middle of Left Square Point middle of Left Square POINT (-0.5 0.5) true +Point middle of Left Square Point middle of Right Square POINT EMPTY true +Point middle of Left Square Square (left) POINT (-0.5 0.5) true +Point middle of Left Square Square (right) POINT EMPTY true +Point middle of Left Square Square overlapping left and right square POINT EMPTY true +Point middle of Right Square Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true +Point middle of Right Square Empty LineString GEOMETRYCOLLECTION EMPTY true +Point middle of Right Square Empty Point GEOMETRYCOLLECTION EMPTY true +Point middle of Right Square Faraway point POINT EMPTY true +Point middle of Right Square Line going through left and right square POINT (0.5 0.5) true +Point middle of Right Square NULL NULL NULL +Point middle of Right Square Nested Geometry Collection POINT EMPTY true +Point middle of Right Square Point middle of Left Square POINT EMPTY true +Point middle of Right Square Point middle of Right Square POINT (0.5 0.5) true +Point middle of Right Square Square (left) POINT EMPTY true +Point middle of Right Square Square (right) POINT (0.5 0.5) true +Point middle of Right Square Square overlapping left and right square POINT (0.5 0.5) true +Square (left) Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true +Square (left) Empty LineString GEOMETRYCOLLECTION EMPTY true +Square (left) Empty Point GEOMETRYCOLLECTION EMPTY true +Square (left) Faraway point POINT EMPTY true +Square (left) Line going through left and right square LINESTRING (-0.5 0.5, 0 0.5) true +Square (left) NULL NULL NULL +Square (left) Nested Geometry Collection POINT (0 0) true +Square (left) Point middle of Left Square POINT (-0.5 0.5) true +Square (left) Point middle of Right Square POINT EMPTY true +Square (left) Square (left) POLYGON ((0 0, -1 0, -1 1, 0 1, 0 0)) true +Square (left) Square (right) LINESTRING (0 0, 0 1) true +Square (left) Square overlapping left and right square POLYGON ((0 0, -0.1 0, -0.1 1, 0 1, 0 0)) true +Square (right) Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true +Square (right) Empty LineString GEOMETRYCOLLECTION EMPTY true +Square (right) Empty Point GEOMETRYCOLLECTION EMPTY true +Square (right) Faraway point POINT EMPTY true +Square (right) Line going through left and right square LINESTRING (0 0.5, 0.5 0.5) true +Square (right) NULL NULL NULL +Square (right) Nested Geometry Collection POINT (0 0) true +Square (right) Point middle of Left Square POINT EMPTY true +Square (right) Point middle of Right Square POINT (0.5 0.5) true +Square (right) Square (left) LINESTRING (0 1, 0 0) true +Square (right) Square (right) POLYGON ((1 0, 0 0, 0 1, 1 1, 1 0)) true +Square (right) Square overlapping left and right square POLYGON ((1 0, 0 0, 0 1, 1 1, 1 0)) true +Square overlapping left and right square Empty GeometryCollection GEOMETRYCOLLECTION EMPTY true +Square overlapping left and right square Empty LineString GEOMETRYCOLLECTION EMPTY true +Square overlapping left and right square Empty Point GEOMETRYCOLLECTION EMPTY true +Square overlapping left and right square Faraway point POINT EMPTY true +Square overlapping left and right square Line going through left and right square LINESTRING (-0.1 0.5, 0.5 0.5) true +Square overlapping left and right square NULL NULL NULL +Square overlapping left and right square Nested Geometry Collection POINT (0 0) true +Square overlapping left and right square Point middle of Left Square POINT EMPTY true +Square overlapping left and right square Point middle of Right Square POINT (0.5 0.5) true +Square overlapping left and right square Square (left) POLYGON ((0 0, -0.1 0, -0.1 1, 0 1, 0 0)) true +Square overlapping left and right square Square (right) POLYGON ((1 0, 0 0, 0 1, 1 1, 1 0)) true +Square overlapping left and right square Square overlapping left and right square POLYGON ((1 0, -0.1 0, -0.1 1, 1 1, 1 0)) true query TTTT SELECT @@ -1211,6 +1210,159 @@ Square (left) GEOMETRYCOLLECTION EMPTY Square (right) POLYGON ((0 0, 0 0.5, 0.5 0.5, 0.5 0, 0 0)) Square overlapping left and right square POLYGON ((0 0, 0 0.5, 0.5 0.5, 0.5 0, 0 0)) +query TT +SELECT + ST_AsEWKT(ST_SymDifference(a.geom, b.geom)), + ST_AsEWKT(ST_SymmetricDifference(a.geom, b.geom)) +FROM geom_operators_test a +JOIN geom_operators_test b ON (1=1) +ORDER BY a.dsc, b.dsc +---- +GEOMETRYCOLLECTION EMPTY GEOMETRYCOLLECTION EMPTY +LINESTRING EMPTY LINESTRING EMPTY +POINT EMPTY POINT EMPTY +POINT (5 5) POINT (5 5) +LINESTRING (-0.5 0.5, 0.5 0.5) LINESTRING (-0.5 0.5, 0.5 0.5) +NULL NULL +GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) +POINT (-0.5 0.5) POINT (-0.5 0.5) +POINT (0.5 0.5) POINT (0.5 0.5) +POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) +POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) +POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) +GEOMETRYCOLLECTION EMPTY GEOMETRYCOLLECTION EMPTY +LINESTRING EMPTY LINESTRING EMPTY +POINT EMPTY POINT EMPTY +POINT (5 5) POINT (5 5) +LINESTRING (-0.5 0.5, 0.5 0.5) LINESTRING (-0.5 0.5, 0.5 0.5) +NULL NULL +GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) +POINT (-0.5 0.5) POINT (-0.5 0.5) +POINT (0.5 0.5) POINT (0.5 0.5) +POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) +POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) +POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) +GEOMETRYCOLLECTION EMPTY GEOMETRYCOLLECTION EMPTY +LINESTRING EMPTY LINESTRING EMPTY +POINT EMPTY POINT EMPTY +POINT (5 5) POINT (5 5) +LINESTRING (-0.5 0.5, 0.5 0.5) LINESTRING (-0.5 0.5, 0.5 0.5) +NULL NULL +GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) +POINT (-0.5 0.5) POINT (-0.5 0.5) +POINT (0.5 0.5) POINT (0.5 0.5) +POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) +POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) +POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) +POINT (5 5) POINT (5 5) +POINT (5 5) POINT (5 5) +POINT (5 5) POINT (5 5) +POINT EMPTY POINT EMPTY +GEOMETRYCOLLECTION (POINT (5 5), LINESTRING (-0.5 0.5, 0.5 0.5)) GEOMETRYCOLLECTION (POINT (5 5), LINESTRING (-0.5 0.5, 0.5 0.5)) +NULL NULL +GEOMETRYCOLLECTION (POINT (5 5), GEOMETRYCOLLECTION (POINT (0 0))) GEOMETRYCOLLECTION (POINT (5 5), GEOMETRYCOLLECTION (POINT (0 0))) +MULTIPOINT (5 5, -0.5 0.5) MULTIPOINT (5 5, -0.5 0.5) +MULTIPOINT (5 5, 0.5 0.5) MULTIPOINT (5 5, 0.5 0.5) +GEOMETRYCOLLECTION (POINT (5 5), POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0))) GEOMETRYCOLLECTION (POINT (5 5), POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0))) +GEOMETRYCOLLECTION (POINT (5 5), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))) GEOMETRYCOLLECTION (POINT (5 5), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))) +GEOMETRYCOLLECTION (POINT (5 5), POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0))) GEOMETRYCOLLECTION (POINT (5 5), POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0))) +LINESTRING (-0.5 0.5, 0.5 0.5) LINESTRING (-0.5 0.5, 0.5 0.5) +LINESTRING (-0.5 0.5, 0.5 0.5) LINESTRING (-0.5 0.5, 0.5 0.5) +LINESTRING (-0.5 0.5, 0.5 0.5) LINESTRING (-0.5 0.5, 0.5 0.5) +GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, 0.5 0.5), POINT (5 5)) GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, 0.5 0.5), POINT (5 5)) +LINESTRING EMPTY LINESTRING EMPTY +NULL NULL +GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, 0.5 0.5), GEOMETRYCOLLECTION (POINT (0 0))) GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, 0.5 0.5), GEOMETRYCOLLECTION (POINT (0 0))) +LINESTRING (-0.5 0.5, 0.5 0.5) LINESTRING (-0.5 0.5, 0.5 0.5) +LINESTRING (-0.5 0.5, 0.5 0.5) LINESTRING (-0.5 0.5, 0.5 0.5) +GEOMETRYCOLLECTION (LINESTRING (0 0.5, 0.5 0.5), POLYGON ((0 0.5, 0 0, -1 0, -1 1, 0 1, 0 0.5))) GEOMETRYCOLLECTION (LINESTRING (0 0.5, 0.5 0.5), POLYGON ((0 0.5, 0 0, -1 0, -1 1, 0 1, 0 0.5))) +GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, 0 0.5), POLYGON ((0 0.5, 0 1, 1 1, 1 0, 0 0, 0 0.5))) GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, 0 0.5), POLYGON ((0 0.5, 0 1, 1 1, 1 0, 0 0, 0 0.5))) +GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, -0.1 0.5), POLYGON ((-0.1 0.5, -0.1 1, 1 1, 1 0, -0.1 0, -0.1 0.5))) GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, -0.1 0.5), POLYGON ((-0.1 0.5, -0.1 1, 1 1, 1 0, -0.1 0, -0.1 0.5))) +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) +GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) +GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0))) +GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0)), POINT (5 5)) GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0)), POINT (5 5)) +GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0)), LINESTRING (-0.5 0.5, 0.5 0.5)) GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0)), LINESTRING (-0.5 0.5, 0.5 0.5)) +NULL NULL +POINT EMPTY POINT EMPTY +GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0)), POINT (-0.5 0.5)) GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0)), POINT (-0.5 0.5)) +GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0)), POINT (0.5 0.5)) GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (0 0)), POINT (0.5 0.5)) +POLYGON ((-1 0, -1 1, 0 1, 0 0, -1 0)) POLYGON ((-1 0, -1 1, 0 1, 0 0, -1 0)) +POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) +POLYGON ((-0.1 0, -0.1 1, 1 1, 1 0, -0.1 0)) POLYGON ((-0.1 0, -0.1 1, 1 1, 1 0, -0.1 0)) +POINT (-0.5 0.5) POINT (-0.5 0.5) +POINT (-0.5 0.5) POINT (-0.5 0.5) +POINT (-0.5 0.5) POINT (-0.5 0.5) +MULTIPOINT (-0.5 0.5, 5 5) MULTIPOINT (-0.5 0.5, 5 5) +LINESTRING (-0.5 0.5, 0.5 0.5) LINESTRING (-0.5 0.5, 0.5 0.5) +NULL NULL +GEOMETRYCOLLECTION (POINT (-0.5 0.5), GEOMETRYCOLLECTION (POINT (0 0))) GEOMETRYCOLLECTION (POINT (-0.5 0.5), GEOMETRYCOLLECTION (POINT (0 0))) +POINT EMPTY POINT EMPTY +MULTIPOINT (-0.5 0.5, 0.5 0.5) MULTIPOINT (-0.5 0.5, 0.5 0.5) +POLYGON ((-1 0, -1 1, 0 1, 0 0, -1 0)) POLYGON ((-1 0, -1 1, 0 1, 0 0, -1 0)) +GEOMETRYCOLLECTION (POINT (-0.5 0.5), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))) GEOMETRYCOLLECTION (POINT (-0.5 0.5), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))) +GEOMETRYCOLLECTION (POINT (-0.5 0.5), POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0))) GEOMETRYCOLLECTION (POINT (-0.5 0.5), POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0))) +POINT (0.5 0.5) POINT (0.5 0.5) +POINT (0.5 0.5) POINT (0.5 0.5) +POINT (0.5 0.5) POINT (0.5 0.5) +MULTIPOINT (0.5 0.5, 5 5) MULTIPOINT (0.5 0.5, 5 5) +LINESTRING (-0.5 0.5, 0.5 0.5) LINESTRING (-0.5 0.5, 0.5 0.5) +NULL NULL +GEOMETRYCOLLECTION (POINT (0.5 0.5), GEOMETRYCOLLECTION (POINT (0 0))) GEOMETRYCOLLECTION (POINT (0.5 0.5), GEOMETRYCOLLECTION (POINT (0 0))) +MULTIPOINT (0.5 0.5, -0.5 0.5) MULTIPOINT (0.5 0.5, -0.5 0.5) +POINT EMPTY POINT EMPTY +GEOMETRYCOLLECTION (POINT (0.5 0.5), POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0))) GEOMETRYCOLLECTION (POINT (0.5 0.5), POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0))) +POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) +POLYGON ((-0.1 0, -0.1 1, 1 1, 1 0, -0.1 0)) POLYGON ((-0.1 0, -0.1 1, 1 1, 1 0, -0.1 0)) +POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) +POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) +POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)) +GEOMETRYCOLLECTION (POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)), POINT (5 5)) GEOMETRYCOLLECTION (POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)), POINT (5 5)) +GEOMETRYCOLLECTION (LINESTRING (0 0.5, 0.5 0.5), POLYGON ((0 0.5, 0 0, -1 0, -1 1, 0 1, 0 0.5))) GEOMETRYCOLLECTION (LINESTRING (0 0.5, 0.5 0.5), POLYGON ((0 0.5, 0 0, -1 0, -1 1, 0 1, 0 0.5))) +NULL NULL +POLYGON ((-1 0, -1 1, 0 1, 0 0, -1 0)) POLYGON ((-1 0, -1 1, 0 1, 0 0, -1 0)) +POLYGON ((-1 0, -1 1, 0 1, 0 0, -1 0)) POLYGON ((-1 0, -1 1, 0 1, 0 0, -1 0)) +GEOMETRYCOLLECTION (POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)), POINT (0.5 0.5)) GEOMETRYCOLLECTION (POLYGON ((-1 0, 0 0, 0 1, -1 1, -1 0)), POINT (0.5 0.5)) +POLYGON EMPTY POLYGON EMPTY +POLYGON ((0 0, -1 0, -1 1, 0 1, 1 1, 1 0, 0 0)) POLYGON ((0 0, -1 0, -1 1, 0 1, 1 1, 1 0, 0 0)) +MULTIPOLYGON (((-0.1 0, -1 0, -1 1, -0.1 1, -0.1 0)), ((0 0, 0 1, 1 1, 1 0, 0 0))) MULTIPOLYGON (((-0.1 0, -1 0, -1 1, -0.1 1, -0.1 0)), ((0 0, 0 1, 1 1, 1 0, 0 0))) +POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) +POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) +POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) +GEOMETRYCOLLECTION (POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)), POINT (5 5)) GEOMETRYCOLLECTION (POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)), POINT (5 5)) +GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, 0 0.5), POLYGON ((0 0.5, 0 1, 1 1, 1 0, 0 0, 0 0.5))) GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, 0 0.5), POLYGON ((0 0.5, 0 1, 1 1, 1 0, 0 0, 0 0.5))) +NULL NULL +POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) +GEOMETRYCOLLECTION (POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)), POINT (-0.5 0.5)) GEOMETRYCOLLECTION (POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)), POINT (-0.5 0.5)) +POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) +POLYGON ((0 1, 1 1, 1 0, 0 0, -1 0, -1 1, 0 1)) POLYGON ((0 1, 1 1, 1 0, 0 0, -1 0, -1 1, 0 1)) +POLYGON EMPTY POLYGON EMPTY +POLYGON ((0 1, 0 0, -0.1 0, -0.1 1, 0 1)) POLYGON ((0 1, 0 0, -0.1 0, -0.1 1, 0 1)) +POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) +POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) +POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)) +GEOMETRYCOLLECTION (POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)), POINT (5 5)) GEOMETRYCOLLECTION (POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)), POINT (5 5)) +GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, -0.1 0.5), POLYGON ((-0.1 0.5, -0.1 1, 1 1, 1 0, -0.1 0, -0.1 0.5))) GEOMETRYCOLLECTION (LINESTRING (-0.5 0.5, -0.1 0.5), POLYGON ((-0.1 0.5, -0.1 1, 1 1, 1 0, -0.1 0, -0.1 0.5))) +NULL NULL +POLYGON ((-0.1 0, -0.1 1, 1 1, 1 0, -0.1 0)) POLYGON ((-0.1 0, -0.1 1, 1 1, 1 0, -0.1 0)) +GEOMETRYCOLLECTION (POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)), POINT (-0.5 0.5)) GEOMETRYCOLLECTION (POLYGON ((-0.1 0, 1 0, 1 1, -0.1 1, -0.1 0)), POINT (-0.5 0.5)) +POLYGON ((-0.1 0, -0.1 1, 1 1, 1 0, -0.1 0)) POLYGON ((-0.1 0, -0.1 1, 1 1, 1 0, -0.1 0)) +MULTIPOLYGON (((0 1, 1 1, 1 0, 0 0, 0 1)), ((-0.1 1, -0.1 0, -1 0, -1 1, -0.1 1))) MULTIPOLYGON (((0 1, 1 1, 1 0, 0 0, 0 1)), ((-0.1 1, -0.1 0, -1 0, -1 1, -0.1 1))) +POLYGON ((0 0, -0.1 0, -0.1 1, 0 1, 0 0)) POLYGON ((0 0, -0.1 0, -0.1 1, 0 1, 0 0)) +POLYGON EMPTY POLYGON EMPTY + # CW/CCW predicates. query TBBTT SELECT diff --git a/pkg/sql/sem/builtins/geo_builtins.go b/pkg/sql/sem/builtins/geo_builtins.go index d7563fffd2d3..d27c98e1686d 100644 --- a/pkg/sql/sem/builtins/geo_builtins.go +++ b/pkg/sql/sem/builtins/geo_builtins.go @@ -4622,6 +4622,7 @@ func initGeoBuiltins() { {"st_geomfromtext", "st_geometryfromtext"}, {"st_numinteriorring", "st_numinteriorrings"}, {"st_makepoint", "st_point"}, + {"st_symmetricdifference", "st_symdifference"}, } { if _, ok := geoBuiltins[alias.builtinName]; !ok { panic("expected builtin definition for alias: " + alias.builtinName) From 9c12267553c662e9b2dbe30bed472a9c56c909b4 Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Mon, 31 Aug 2020 19:03:47 +0200 Subject: [PATCH 07/13] roachtests: re-enable election-after-restart and kv/gracefuldraining/nodes=3 Release justification: non-production code changes Release note: None --- pkg/cmd/roachtest/election.go | 4 +++- pkg/cmd/roachtest/kv.go | 4 +++- pkg/cmd/roachtest/test.go | 24 +++++++++++++++++++----- pkg/testutils/skip/skip.go | 20 +++++++++++++------- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/pkg/cmd/roachtest/election.go b/pkg/cmd/roachtest/election.go index e243e89d1383..1d649371f96d 100644 --- a/pkg/cmd/roachtest/election.go +++ b/pkg/cmd/roachtest/election.go @@ -14,6 +14,7 @@ import ( "context" "time" + "github.com/cockroachdb/cockroach/pkg/testutils/skip" "github.com/cockroachdb/cockroach/pkg/util/timeutil" ) @@ -21,9 +22,10 @@ func registerElectionAfterRestart(r *testRegistry) { r.Add(testSpec{ Name: "election-after-restart", Owner: OwnerKV, - Skip: "https://github.com/cockroachdb/cockroach/issues/35047", Cluster: makeClusterSpec(3), Run: func(ctx context.Context, t *test, c *cluster) { + skip.UnderRace(t, "race builds make this test exceed its timeout") + t.Status("starting up") c.Put(ctx, cockroach, "./cockroach") c.Start(ctx, t) diff --git a/pkg/cmd/roachtest/kv.go b/pkg/cmd/roachtest/kv.go index 3a50bd3a078b..3d756c9748e2 100644 --- a/pkg/cmd/roachtest/kv.go +++ b/pkg/cmd/roachtest/kv.go @@ -23,6 +23,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/kv" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" + "github.com/cockroachdb/cockroach/pkg/testutils/skip" "github.com/cockroachdb/cockroach/pkg/ts/tspb" "github.com/cockroachdb/cockroach/pkg/util/httputil" "github.com/cockroachdb/cockroach/pkg/util/timeutil" @@ -349,11 +350,12 @@ func registerKVQuiescenceDead(r *testRegistry) { func registerKVGracefulDraining(r *testRegistry) { r.Add(testSpec{ - Skip: "https://github.com/cockroachdb/cockroach/issues/33501", Name: "kv/gracefuldraining/nodes=3", Owner: OwnerKV, Cluster: makeClusterSpec(4), Run: func(ctx context.Context, t *test, c *cluster) { + skip.UnderRace(t, "race builds make this test exceed its timeout") + nodes := c.spec.NodeCount - 1 c.Put(ctx, cockroach, "./cockroach", c.Range(1, nodes)) c.Put(ctx, workload, "./workload", c.Node(nodes+1)) diff --git a/pkg/cmd/roachtest/test.go b/pkg/cmd/roachtest/test.go index 98e317b5bfe0..8e6992176172 100644 --- a/pkg/cmd/roachtest/test.go +++ b/pkg/cmd/roachtest/test.go @@ -21,6 +21,7 @@ import ( "strings" "time" + "github.com/cockroachdb/cockroach/pkg/testutils/skip" "github.com/cockroachdb/cockroach/pkg/util/syncutil" "github.com/cockroachdb/cockroach/pkg/util/timeutil" "github.com/cockroachdb/cockroach/pkg/util/version" @@ -232,11 +233,24 @@ func (t *test) WorkerProgress(frac float64) { t.progress(goid.Get(), frac) } -// Skip records msg into t.spec.Skip and calls panic(errTestFatal) - thus -// interrupting the running of the test. -func (t *test) Skip(msg string, details string) { - t.spec.Skip = msg - t.spec.SkipDetails = details +var _ skip.SkippableTest = (*test)(nil) + +// Skip skips the test. The first argument if any is the main message. +// The remaining argument, if any, form the details. +// This implements the skip.SkippableTest interface. +func (t *test) Skip(args ...interface{}) { + if len(args) > 0 { + t.spec.Skip = fmt.Sprint(args[0]) + args = args[1:] + } + t.spec.SkipDetails = fmt.Sprint(args...) + panic(errTestFatal) +} + +// Skipf skips the test. The formatted message becomes the skip reason. +// This implements the skip.SkippableTest interface. +func (t *test) Skipf(format string, args ...interface{}) { + t.spec.Skip = fmt.Sprintf(format, args...) panic(errTestFatal) } diff --git a/pkg/testutils/skip/skip.go b/pkg/testutils/skip/skip.go index 2d50520a5733..9f1648f4a1ac 100644 --- a/pkg/testutils/skip/skip.go +++ b/pkg/testutils/skip/skip.go @@ -17,8 +17,14 @@ import ( "github.com/cockroachdb/cockroach/pkg/util" ) +// SkippableTest is a testing.TB with Skip methods. +type SkippableTest interface { + Skip(...interface{}) + Skipf(string, ...interface{}) +} + // WithIssue skips this test, logging the given issue ID as the reason. -func WithIssue(t testing.TB, githubIssueID int, args ...interface{}) { +func WithIssue(t SkippableTest, githubIssueID int, args ...interface{}) { t.Skip(append([]interface{}{ fmt.Sprintf("https://github.com/cockroachdb/cockroach/issue/%d", githubIssueID)}, args...)) @@ -27,31 +33,31 @@ func WithIssue(t testing.TB, githubIssueID int, args ...interface{}) { // IgnoreLint skips this test, explicitly marking it as not a test that // should be tracked as a "skipped test" by external tools. You should use this // if, for example, your test should only be run in Race mode. -func IgnoreLint(t testing.TB, args ...interface{}) { +func IgnoreLint(t SkippableTest, args ...interface{}) { t.Skip(args...) } // IgnoreLintf is like IgnoreLint, and it also takes a format string. -func IgnoreLintf(t testing.TB, format string, args ...interface{}) { +func IgnoreLintf(t SkippableTest, format string, args ...interface{}) { t.Skipf(format, args...) } // UnderRace skips this test if the race detector is enabled. -func UnderRace(t testing.TB, args ...interface{}) { +func UnderRace(t SkippableTest, args ...interface{}) { if util.RaceEnabled { t.Skip(append([]interface{}{"disabled under race"}, args...)) } } // UnderShort skips this test if the -short flag is specified. -func UnderShort(t testing.TB, args ...interface{}) { +func UnderShort(t SkippableTest, args ...interface{}) { if testing.Short() { t.Skip(append([]interface{}{"disabled under -short"}, args...)) } } // UnderStress skips this test when running under stress. -func UnderStress(t testing.TB, args ...interface{}) { +func UnderStress(t SkippableTest, args ...interface{}) { if NightlyStress() { t.Skip(append([]interface{}{"disabled under stress"}, args...)) } @@ -59,7 +65,7 @@ func UnderStress(t testing.TB, args ...interface{}) { // UnderStressRace skips this test during stressrace runs, which are tests // run under stress with the -race flag. -func UnderStressRace(t testing.TB, args ...interface{}) { +func UnderStressRace(t SkippableTest, args ...interface{}) { if NightlyStress() && util.RaceEnabled { t.Skip(append([]interface{}{"disabled under stressrace"}, args...)) } From 66f3a96de5939493324fc5f778457465d39862ad Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Mon, 31 Aug 2020 18:39:56 +0200 Subject: [PATCH 08/13] security: add telemetry for OCSP server checks This commit adds two telemetry counters: - `server.ocsp.conn-verifications` counts the number of connections for which the OCSP feature is enabled - `server.ocsp.cert-verifications` counts the number of times a certificate actually underwent OCSP verification. Release justification: low risk, high benefit changes to existing functionality Release note: None --- pkg/security/ocsp.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/security/ocsp.go b/pkg/security/ocsp.go index afd7173b7ddc..334116f150a1 100644 --- a/pkg/security/ocsp.go +++ b/pkg/security/ocsp.go @@ -18,6 +18,7 @@ import ( "io/ioutil" "net/http" + "github.com/cockroachdb/cockroach/pkg/server/telemetry" "github.com/cockroachdb/cockroach/pkg/util/contextutil" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/errors" @@ -39,6 +40,9 @@ func makeOCSPVerifier(settings TLSSettings) func([][]byte, [][]*x509.Certificate return contextutil.RunWithTimeout(context.Background(), "OCSP verification", settings.ocspTimeout(), func(ctx context.Context) error { + // Per-conn telemetry counter. + telemetry.Inc(ocspChecksCounter) + errG, gCtx := errgroup.WithContext(ctx) for _, chain := range verifiedChains { // Ignore the last cert in the chain; it's the root and if it @@ -60,10 +64,26 @@ func makeOCSPVerifier(settings TLSSettings) func([][]byte, [][]*x509.Certificate } } +// ocspChecksCounter counts the number of connections that are +// undergoing OCSP validations. This counter exists so that the value +// of ocspCheckWithOCSPServerInCertCounter can be interpreted as a +// percentage. +var ocspChecksCounter = telemetry.GetCounterOnce("server.ocsp.conn-verifications") + +// ocspCheckWithOCSPServerInCert counts the number of certificate +// verifications performed with a populated OCSPServer field in one of +// the certs in the validation chain. +var ocspCheckWithOCSPServerInCertCounter = telemetry.GetCounterOnce("server.ocsp.cert-verifications") + func verifyOCSP(ctx context.Context, settings TLSSettings, cert, issuer *x509.Certificate) error { if len(cert.OCSPServer) == 0 { return nil } + + // Per-cert telemetry counter. We only count requests when there is + // an OCSP server to check in the first place. + telemetry.Inc(ocspCheckWithOCSPServerInCertCounter) + var errs []error for _, url := range cert.OCSPServer { ok, err := queryOCSP(ctx, url, cert, issuer) From 155b79d3f322bb035082e9ccda6866c14e91b47d Mon Sep 17 00:00:00 2001 From: Rohan Yadav Date: Thu, 27 Aug 2020 15:31:25 -0400 Subject: [PATCH 09/13] sql: implement `CREATE SCHEMA ... AUTHORIZATION` Fixes #53559. This commit adds the `CREATE SCHEMA ... AUTHORIZATION` command. When authorization is provided, the target user is given ownership of the schema. If the schema name is not provided, then the schema is named the same name as the target role. Release justification: low risk updates to new functionality Release note (sql change): Support the `CREATE SCHEMA ... AUTHORIZATION` command. --- docs/generated/sql/bnf/stmt_block.bnf | 9 +++-- pkg/sql/create_schema.go | 29 ++++++++++++---- pkg/sql/logictest/testdata/logic_test/schema | 35 ++++++++++++++++++++ pkg/sql/parser/parse_test.go | 4 +++ pkg/sql/parser/sql.y | 25 +++++++++++--- pkg/sql/sem/tree/create.go | 15 +++++++-- 6 files changed, 102 insertions(+), 15 deletions(-) diff --git a/docs/generated/sql/bnf/stmt_block.bnf b/docs/generated/sql/bnf/stmt_block.bnf index 5332184aa5bc..8d8c9efeb4bc 100644 --- a/docs/generated/sql/bnf/stmt_block.bnf +++ b/docs/generated/sql/bnf/stmt_block.bnf @@ -739,7 +739,6 @@ unreserved_keyword ::= | 'AT' | 'ATTRIBUTE' | 'AUTOMATIC' - | 'AUTHORIZATION' | 'BACKUP' | 'BACKUPS' | 'BEFORE' @@ -1215,6 +1214,8 @@ create_index_stmt ::= create_schema_stmt ::= 'CREATE' 'SCHEMA' schema_name | 'CREATE' 'SCHEMA' 'IF' 'NOT' 'EXISTS' schema_name + | 'CREATE' 'SCHEMA' opt_schema_name 'AUTHORIZATION' role_spec + | 'CREATE' 'SCHEMA' 'IF' 'NOT' 'EXISTS' opt_schema_name 'AUTHORIZATION' role_spec create_table_stmt ::= 'CREATE' opt_persistence_temp_table 'TABLE' table_name '(' opt_table_elem_list ')' opt_interleave opt_partition_by @@ -1690,6 +1691,9 @@ opt_partition_by ::= partition_by | +opt_schema_name ::= + opt_name + opt_persistence_temp_table ::= opt_temp | 'LOCAL' 'TEMPORARY' @@ -2217,7 +2221,8 @@ row_source_extension_stmt ::= | upsert_stmt type_func_name_no_crdb_extra_keyword ::= - 'COLLATION' + 'AUTHORIZATION' + | 'COLLATION' | 'CROSS' | 'FULL' | 'INNER' diff --git a/pkg/sql/create_schema.go b/pkg/sql/create_schema.go index 8d048cf19619..83b5232a7dc3 100644 --- a/pkg/sql/create_schema.go +++ b/pkg/sql/create_schema.go @@ -50,8 +50,13 @@ func (p *planner) createUserDefinedSchema(params runParams, n *tree.CreateSchema return pgerror.New(pgcode.InvalidObjectDefinition, "cannot create schemas in the system database") } + schemaName := n.Schema + if n.Schema == "" { + schemaName = n.AuthRole + } + // Ensure there aren't any name collisions. - exists, err := p.schemaExists(params.ctx, db.ID, n.Schema) + exists, err := p.schemaExists(params.ctx, db.ID, schemaName) if err != nil { return err } @@ -60,11 +65,11 @@ func (p *planner) createUserDefinedSchema(params runParams, n *tree.CreateSchema if n.IfNotExists { return nil } - return pgerror.Newf(pgcode.DuplicateSchema, "schema %q already exists", n.Schema) + return pgerror.Newf(pgcode.DuplicateSchema, "schema %q already exists", schemaName) } // Check validity of the schema name. - if err := schemadesc.IsSchemaNameValid(n.Schema); err != nil { + if err := schemadesc.IsSchemaNameValid(schemaName); err != nil { return err } @@ -89,12 +94,24 @@ func (p *planner) createUserDefinedSchema(params runParams, n *tree.CreateSchema // Inherit the parent privileges. privs := db.GetPrivileges() - privs.SetOwner(params.SessionData().User) + + if n.AuthRole != "" { + exists, err := p.RoleExists(params.ctx, n.AuthRole) + if err != nil { + return err + } + if !exists { + return pgerror.Newf(pgcode.UndefinedObject, "role/user %q does not exist", n.AuthRole) + } + privs.SetOwner(n.AuthRole) + } else { + privs.SetOwner(params.SessionData().User) + } // Create the SchemaDescriptor. desc := schemadesc.NewCreatedMutable(descpb.SchemaDescriptor{ ParentID: db.ID, - Name: n.Schema, + Name: schemaName, ID: id, Privileges: privs, Version: 1, @@ -119,7 +136,7 @@ func (p *planner) createUserDefinedSchema(params runParams, n *tree.CreateSchema // Finally create the schema on disk. return p.createDescriptorWithID( params.ctx, - catalogkeys.NewSchemaKey(db.ID, n.Schema).Key(p.ExecCfg().Codec), + catalogkeys.NewSchemaKey(db.ID, schemaName).Key(p.ExecCfg().Codec), id, desc, params.ExecCfg().Settings, diff --git a/pkg/sql/logictest/testdata/logic_test/schema b/pkg/sql/logictest/testdata/logic_test/schema index 9e4f2c2d2c15..db9265c3b091 100644 --- a/pkg/sql/logictest/testdata/logic_test/schema +++ b/pkg/sql/logictest/testdata/logic_test/schema @@ -348,3 +348,38 @@ COMMENT ON COLUMN privs.usage_tbl.x IS 'foo' statement error pq: user testuser does not have USAGE privilege on schema privs ALTER TYPE privs.usage_typ ADD VALUE 'denied' + +subtest authorization + +user root +# Test the AUTHORIZATION argument to CREATE SCHEMA. + +# Create a user to create a schema for. +statement ok +CREATE USER user1; + +# Creates a schema for named with user1 as the owner. +statement ok +CREATE SCHEMA AUTHORIZATION user1 + +statement error pq: schema "user1" already exists +CREATE SCHEMA AUTHORIZATION user1 + +statement ok +CREATE SCHEMA IF NOT EXISTS AUTHORIZATION user1 + +statement ok +CREATE SCHEMA user1_schema AUTHORIZATION user1 + +# The created schemas should both be owned by user1. +query TT +SELECT + nspname, usename +FROM + pg_catalog.pg_namespace + LEFT JOIN pg_catalog.pg_user ON pg_namespace.nspowner = pg_user.usesysid +WHERE + nspname LIKE 'user1%'; +---- +user1 user1 +user1_schema user1 diff --git a/pkg/sql/parser/parse_test.go b/pkg/sql/parser/parse_test.go index 929f8f353f78..f1c78b1c3b49 100644 --- a/pkg/sql/parser/parse_test.go +++ b/pkg/sql/parser/parse_test.go @@ -81,6 +81,10 @@ func TestParse(t *testing.T) { {`CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'template0' ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'INVALID'`}, {`CREATE SCHEMA IF NOT EXISTS foo`}, {`CREATE SCHEMA foo`}, + {`CREATE SCHEMA IF NOT EXISTS foo AUTHORIZATION foobar`}, + {`CREATE SCHEMA foo AUTHORIZATION foobar`}, + {`CREATE SCHEMA IF NOT EXISTS AUTHORIZATION foobar`}, + {`CREATE SCHEMA AUTHORIZATION foobar`}, {`CREATE INDEX a ON b (c)`}, {`CREATE INDEX CONCURRENTLY a ON b (c)`}, diff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y index 68396b09b463..36f55ba049b6 100644 --- a/pkg/sql/parser/sql.y +++ b/pkg/sql/parser/sql.y @@ -934,7 +934,7 @@ func (u *sqlSymUnion) refreshDataOption() tree.RefreshDataOption { %type db_object_name_component %type <*tree.UnresolvedObjectName> table_name standalone_index_name sequence_name type_name view_name db_object_name simple_db_object_name complex_db_object_name %type <[]*tree.UnresolvedObjectName> type_name_list -%type schema_name +%type schema_name opt_schema_name %type <[]string> schema_name_list %type <*tree.UnresolvedName> table_pattern complex_table_pattern %type <*tree.UnresolvedName> column_path prefixed_column_path column_path_with_star @@ -5294,7 +5294,7 @@ pause_schedules_stmt: // %Help: CREATE SCHEMA - create a new schema // %Category: DDL // %Text: -// CREATE SCHEMA [IF NOT EXISTS] +// CREATE SCHEMA [IF NOT EXISTS] { | [] AUTHORIZATION } create_schema_stmt: CREATE SCHEMA schema_name { @@ -5309,6 +5309,21 @@ create_schema_stmt: IfNotExists: true, } } +| CREATE SCHEMA opt_schema_name AUTHORIZATION role_spec + { + $$.val = &tree.CreateSchema{ + Schema: $3, + AuthRole: $5, + } + } +| CREATE SCHEMA IF NOT EXISTS opt_schema_name AUTHORIZATION role_spec + { + $$.val = &tree.CreateSchema{ + Schema: $6, + IfNotExists: true, + AuthRole: $8, + } + } | CREATE SCHEMA error // SHOW HELP: CREATE SCHEMA // %Help: ALTER SCHEMA - alter an existing schema @@ -11104,6 +11119,8 @@ sequence_name: db_object_name schema_name: name +opt_schema_name: opt_name + table_name: db_object_name standalone_index_name: db_object_name @@ -11317,7 +11334,6 @@ unreserved_keyword: | AT | ATTRIBUTE | AUTOMATIC -| AUTHORIZATION | BACKUP | BACKUPS | BEFORE @@ -11688,7 +11704,8 @@ type_func_name_keyword: // // See type_func_name_crdb_extra_keyword below. type_func_name_no_crdb_extra_keyword: - COLLATION + AUTHORIZATION +| COLLATION | CROSS | FULL | INNER diff --git a/pkg/sql/sem/tree/create.go b/pkg/sql/sem/tree/create.go index fd6e2b0e047c..04cab0831ce3 100644 --- a/pkg/sql/sem/tree/create.go +++ b/pkg/sql/sem/tree/create.go @@ -1216,17 +1216,26 @@ func (node *CreateTable) HoistConstraints() { type CreateSchema struct { IfNotExists bool Schema string + AuthRole string } // Format implements the NodeFormatter interface. func (node *CreateSchema) Format(ctx *FmtCtx) { - ctx.WriteString("CREATE SCHEMA ") + ctx.WriteString("CREATE SCHEMA") if node.IfNotExists { - ctx.WriteString("IF NOT EXISTS ") + ctx.WriteString(" IF NOT EXISTS") } - ctx.WriteString(node.Schema) + if node.Schema != "" { + ctx.WriteString(" ") + ctx.WriteString(node.Schema) + } + + if node.AuthRole != "" { + ctx.WriteString(" AUTHORIZATION ") + ctx.WriteString(node.AuthRole) + } } // CreateSequence represents a CREATE SEQUENCE statement. From 9e84b4563fa526831b03668d8a2a15b73a11b5c4 Mon Sep 17 00:00:00 2001 From: Oliver Tan Date: Mon, 31 Aug 2020 12:40:25 -0700 Subject: [PATCH 10/13] geos: fix compile error with -Wsign-conversion Not sure why this wasn't caught in #53647. Release justification: bug fixes and low-risk updates to new functionality Release note: None --- c-deps/geos | 2 +- c-deps/geos-rebuild | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/c-deps/geos b/c-deps/geos index 6c5e20a1e597..385ac9b562c2 160000 --- a/c-deps/geos +++ b/c-deps/geos @@ -1 +1 @@ -Subproject commit 6c5e20a1e59714a719b1bba2463feb5888ca42fa +Subproject commit 385ac9b562c2847dc059109e0435a80e68a0c8b6 diff --git a/c-deps/geos-rebuild b/c-deps/geos-rebuild index cb267a9afe3b..e682bb627eae 100644 --- a/c-deps/geos-rebuild +++ b/c-deps/geos-rebuild @@ -1,4 +1,4 @@ Bump the version below when changing geos configure flags. Search for "BUILD ARTIFACT CACHING" in build/common.mk for rationale. -3 +4 From b591af7ddaeccc9a12f2d7a3a961f895a767f0a5 Mon Sep 17 00:00:00 2001 From: arulajmani Date: Mon, 31 Aug 2020 15:58:59 -0400 Subject: [PATCH 11/13] cloud: update orchestrator configs to point to v20.1.5 Release justification: changes as part of v20.1.5 release. Release note: None --- cloud/kubernetes/bring-your-own-certs/client.yaml | 2 +- .../bring-your-own-certs/cockroachdb-statefulset.yaml | 2 +- cloud/kubernetes/client-secure.yaml | 2 +- cloud/kubernetes/cluster-init-secure.yaml | 2 +- cloud/kubernetes/cluster-init.yaml | 2 +- cloud/kubernetes/cockroachdb-statefulset-secure.yaml | 2 +- cloud/kubernetes/cockroachdb-statefulset.yaml | 2 +- cloud/kubernetes/multiregion/client-secure.yaml | 2 +- cloud/kubernetes/multiregion/cluster-init-secure.yaml | 2 +- .../kubernetes/multiregion/cockroachdb-statefulset-secure.yaml | 2 +- cloud/kubernetes/multiregion/eks/dns-lb-eks.yaml | 2 +- .../kubernetes/performance/cockroachdb-daemonset-insecure.yaml | 2 +- cloud/kubernetes/performance/cockroachdb-daemonset-secure.yaml | 2 +- .../performance/cockroachdb-statefulset-insecure.yaml | 2 +- .../kubernetes/performance/cockroachdb-statefulset-secure.yaml | 2 +- cloud/kubernetes/v1.6/client-secure.yaml | 2 +- cloud/kubernetes/v1.6/cluster-init-secure.yaml | 2 +- cloud/kubernetes/v1.6/cluster-init.yaml | 2 +- cloud/kubernetes/v1.6/cockroachdb-statefulset-secure.yaml | 2 +- cloud/kubernetes/v1.6/cockroachdb-statefulset.yaml | 2 +- cloud/kubernetes/v1.7/client-secure.yaml | 2 +- cloud/kubernetes/v1.7/cluster-init-secure.yaml | 2 +- cloud/kubernetes/v1.7/cluster-init.yaml | 2 +- cloud/kubernetes/v1.7/cockroachdb-statefulset-secure.yaml | 2 +- cloud/kubernetes/v1.7/cockroachdb-statefulset.yaml | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/cloud/kubernetes/bring-your-own-certs/client.yaml b/cloud/kubernetes/bring-your-own-certs/client.yaml index c3b94576b4e5..9fb69a45aad4 100644 --- a/cloud/kubernetes/bring-your-own-certs/client.yaml +++ b/cloud/kubernetes/bring-your-own-certs/client.yaml @@ -19,7 +19,7 @@ spec: serviceAccountName: cockroachdb containers: - name: cockroachdb-client - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 # Keep a pod open indefinitely so kubectl exec can be used to get a shell to it # and run cockroach client commands, such as cockroach sql, cockroach node status, etc. command: diff --git a/cloud/kubernetes/bring-your-own-certs/cockroachdb-statefulset.yaml b/cloud/kubernetes/bring-your-own-certs/cockroachdb-statefulset.yaml index 8196360116fd..eddeb1c84a88 100644 --- a/cloud/kubernetes/bring-your-own-certs/cockroachdb-statefulset.yaml +++ b/cloud/kubernetes/bring-your-own-certs/cockroachdb-statefulset.yaml @@ -152,7 +152,7 @@ spec: topologyKey: kubernetes.io/hostname containers: - name: cockroachdb - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent ports: - containerPort: 26257 diff --git a/cloud/kubernetes/client-secure.yaml b/cloud/kubernetes/client-secure.yaml index f4a910a7277a..1c70986fa9c6 100644 --- a/cloud/kubernetes/client-secure.yaml +++ b/cloud/kubernetes/client-secure.yaml @@ -31,7 +31,7 @@ spec: mountPath: /cockroach-certs containers: - name: cockroachdb-client - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent volumeMounts: - name: client-certs diff --git a/cloud/kubernetes/cluster-init-secure.yaml b/cloud/kubernetes/cluster-init-secure.yaml index 6885a47b0a00..6ca7e10f49ca 100644 --- a/cloud/kubernetes/cluster-init-secure.yaml +++ b/cloud/kubernetes/cluster-init-secure.yaml @@ -33,7 +33,7 @@ spec: mountPath: /cockroach-certs containers: - name: cluster-init - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent volumeMounts: - name: client-certs diff --git a/cloud/kubernetes/cluster-init.yaml b/cloud/kubernetes/cluster-init.yaml index b2aba7a57bf5..00da483a65a6 100644 --- a/cloud/kubernetes/cluster-init.yaml +++ b/cloud/kubernetes/cluster-init.yaml @@ -9,7 +9,7 @@ spec: spec: containers: - name: cluster-init - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent command: - "/cockroach/cockroach" diff --git a/cloud/kubernetes/cockroachdb-statefulset-secure.yaml b/cloud/kubernetes/cockroachdb-statefulset-secure.yaml index 56deed0813da..841e7c6cec1b 100644 --- a/cloud/kubernetes/cockroachdb-statefulset-secure.yaml +++ b/cloud/kubernetes/cockroachdb-statefulset-secure.yaml @@ -194,7 +194,7 @@ spec: topologyKey: kubernetes.io/hostname containers: - name: cockroachdb - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent # TODO: Change these to appropriate values for the hardware that you're running. You can see # the amount of allocatable resources on each of your Kubernetes nodes by running: diff --git a/cloud/kubernetes/cockroachdb-statefulset.yaml b/cloud/kubernetes/cockroachdb-statefulset.yaml index 43d4d03100e8..aa50d24f3d5b 100644 --- a/cloud/kubernetes/cockroachdb-statefulset.yaml +++ b/cloud/kubernetes/cockroachdb-statefulset.yaml @@ -97,7 +97,7 @@ spec: topologyKey: kubernetes.io/hostname containers: - name: cockroachdb - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent # TODO: Change these to appropriate values for the hardware that you're running. You can see # the amount of allocatable resources on each of your Kubernetes nodes by running: diff --git a/cloud/kubernetes/multiregion/client-secure.yaml b/cloud/kubernetes/multiregion/client-secure.yaml index de356e60bb75..6eee2172c70e 100644 --- a/cloud/kubernetes/multiregion/client-secure.yaml +++ b/cloud/kubernetes/multiregion/client-secure.yaml @@ -8,7 +8,7 @@ spec: serviceAccountName: cockroachdb containers: - name: cockroachdb-client - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent volumeMounts: - name: client-certs diff --git a/cloud/kubernetes/multiregion/cluster-init-secure.yaml b/cloud/kubernetes/multiregion/cluster-init-secure.yaml index b21d6e3e22f3..767acd36a047 100644 --- a/cloud/kubernetes/multiregion/cluster-init-secure.yaml +++ b/cloud/kubernetes/multiregion/cluster-init-secure.yaml @@ -10,7 +10,7 @@ spec: serviceAccountName: cockroachdb containers: - name: cluster-init - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent volumeMounts: - name: client-certs diff --git a/cloud/kubernetes/multiregion/cockroachdb-statefulset-secure.yaml b/cloud/kubernetes/multiregion/cockroachdb-statefulset-secure.yaml index a0fcb470c1d5..d08df3d49cc3 100644 --- a/cloud/kubernetes/multiregion/cockroachdb-statefulset-secure.yaml +++ b/cloud/kubernetes/multiregion/cockroachdb-statefulset-secure.yaml @@ -166,7 +166,7 @@ spec: topologyKey: kubernetes.io/hostname containers: - name: cockroachdb - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent ports: - containerPort: 26257 diff --git a/cloud/kubernetes/multiregion/eks/dns-lb-eks.yaml b/cloud/kubernetes/multiregion/eks/dns-lb-eks.yaml index 773460299d49..e80c63f29d39 100644 --- a/cloud/kubernetes/multiregion/eks/dns-lb-eks.yaml +++ b/cloud/kubernetes/multiregion/eks/dns-lb-eks.yaml @@ -16,4 +16,4 @@ spec: selector: k8s-app: kube-dns type: LoadBalancer - loadBalancerSourceRanges: ["0.0.0.0/0"] \ No newline at end of file + loadBalancerSourceRanges: ["0.0.0.0/0"] diff --git a/cloud/kubernetes/performance/cockroachdb-daemonset-insecure.yaml b/cloud/kubernetes/performance/cockroachdb-daemonset-insecure.yaml index d19df8822a43..7a775e4f8113 100644 --- a/cloud/kubernetes/performance/cockroachdb-daemonset-insecure.yaml +++ b/cloud/kubernetes/performance/cockroachdb-daemonset-insecure.yaml @@ -81,7 +81,7 @@ spec: hostNetwork: true containers: - name: cockroachdb - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent # TODO: If you configured taints to give CockroachDB exclusive access to nodes, feel free # to remove the requests and limits sections. If you didn't, you'll need to change these to diff --git a/cloud/kubernetes/performance/cockroachdb-daemonset-secure.yaml b/cloud/kubernetes/performance/cockroachdb-daemonset-secure.yaml index 9820a426ef5b..1d0fddb2611f 100644 --- a/cloud/kubernetes/performance/cockroachdb-daemonset-secure.yaml +++ b/cloud/kubernetes/performance/cockroachdb-daemonset-secure.yaml @@ -197,7 +197,7 @@ spec: topologyKey: kubernetes.io/hostname containers: - name: cockroachdb - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent # TODO: If you configured taints to give CockroachDB exclusive access to nodes, feel free # to remove the requests and limits sections. If you didn't, you'll need to change these to diff --git a/cloud/kubernetes/performance/cockroachdb-statefulset-insecure.yaml b/cloud/kubernetes/performance/cockroachdb-statefulset-insecure.yaml index 5e06a399d8ba..72d6d12d5e2a 100644 --- a/cloud/kubernetes/performance/cockroachdb-statefulset-insecure.yaml +++ b/cloud/kubernetes/performance/cockroachdb-statefulset-insecure.yaml @@ -140,7 +140,7 @@ spec: - name: cockroachdb # NOTE: Always use the most recent version of CockroachDB for the best # performance and reliability. - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent # TODO: Change these to appropriate values for the hardware that you're running. You can see # the amount of allocatable resources on each of your Kubernetes nodes by running: diff --git a/cloud/kubernetes/performance/cockroachdb-statefulset-secure.yaml b/cloud/kubernetes/performance/cockroachdb-statefulset-secure.yaml index 9a8483763ffa..1a6570364eb2 100644 --- a/cloud/kubernetes/performance/cockroachdb-statefulset-secure.yaml +++ b/cloud/kubernetes/performance/cockroachdb-statefulset-secure.yaml @@ -231,7 +231,7 @@ spec: - name: cockroachdb # NOTE: Always use the most recent version of CockroachDB for the best # performance and reliability. - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent # TODO: Change these to appropriate values for the hardware that you're running. You can see # the amount of allocatable resources on each of your Kubernetes nodes by running: diff --git a/cloud/kubernetes/v1.6/client-secure.yaml b/cloud/kubernetes/v1.6/client-secure.yaml index f4a910a7277a..1c70986fa9c6 100644 --- a/cloud/kubernetes/v1.6/client-secure.yaml +++ b/cloud/kubernetes/v1.6/client-secure.yaml @@ -31,7 +31,7 @@ spec: mountPath: /cockroach-certs containers: - name: cockroachdb-client - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent volumeMounts: - name: client-certs diff --git a/cloud/kubernetes/v1.6/cluster-init-secure.yaml b/cloud/kubernetes/v1.6/cluster-init-secure.yaml index 6885a47b0a00..6ca7e10f49ca 100644 --- a/cloud/kubernetes/v1.6/cluster-init-secure.yaml +++ b/cloud/kubernetes/v1.6/cluster-init-secure.yaml @@ -33,7 +33,7 @@ spec: mountPath: /cockroach-certs containers: - name: cluster-init - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent volumeMounts: - name: client-certs diff --git a/cloud/kubernetes/v1.6/cluster-init.yaml b/cloud/kubernetes/v1.6/cluster-init.yaml index b2aba7a57bf5..00da483a65a6 100644 --- a/cloud/kubernetes/v1.6/cluster-init.yaml +++ b/cloud/kubernetes/v1.6/cluster-init.yaml @@ -9,7 +9,7 @@ spec: spec: containers: - name: cluster-init - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent command: - "/cockroach/cockroach" diff --git a/cloud/kubernetes/v1.6/cockroachdb-statefulset-secure.yaml b/cloud/kubernetes/v1.6/cockroachdb-statefulset-secure.yaml index 44930c0c59fa..8a2f6ccbaa10 100644 --- a/cloud/kubernetes/v1.6/cockroachdb-statefulset-secure.yaml +++ b/cloud/kubernetes/v1.6/cockroachdb-statefulset-secure.yaml @@ -177,7 +177,7 @@ spec: topologyKey: kubernetes.io/hostname containers: - name: cockroachdb - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent ports: - containerPort: 26257 diff --git a/cloud/kubernetes/v1.6/cockroachdb-statefulset.yaml b/cloud/kubernetes/v1.6/cockroachdb-statefulset.yaml index 0f5ae58567f0..a9b069d2f20c 100644 --- a/cloud/kubernetes/v1.6/cockroachdb-statefulset.yaml +++ b/cloud/kubernetes/v1.6/cockroachdb-statefulset.yaml @@ -80,7 +80,7 @@ spec: topologyKey: kubernetes.io/hostname containers: - name: cockroachdb - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent ports: - containerPort: 26257 diff --git a/cloud/kubernetes/v1.7/client-secure.yaml b/cloud/kubernetes/v1.7/client-secure.yaml index f4a910a7277a..1c70986fa9c6 100644 --- a/cloud/kubernetes/v1.7/client-secure.yaml +++ b/cloud/kubernetes/v1.7/client-secure.yaml @@ -31,7 +31,7 @@ spec: mountPath: /cockroach-certs containers: - name: cockroachdb-client - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent volumeMounts: - name: client-certs diff --git a/cloud/kubernetes/v1.7/cluster-init-secure.yaml b/cloud/kubernetes/v1.7/cluster-init-secure.yaml index 6885a47b0a00..6ca7e10f49ca 100644 --- a/cloud/kubernetes/v1.7/cluster-init-secure.yaml +++ b/cloud/kubernetes/v1.7/cluster-init-secure.yaml @@ -33,7 +33,7 @@ spec: mountPath: /cockroach-certs containers: - name: cluster-init - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent volumeMounts: - name: client-certs diff --git a/cloud/kubernetes/v1.7/cluster-init.yaml b/cloud/kubernetes/v1.7/cluster-init.yaml index b2aba7a57bf5..00da483a65a6 100644 --- a/cloud/kubernetes/v1.7/cluster-init.yaml +++ b/cloud/kubernetes/v1.7/cluster-init.yaml @@ -9,7 +9,7 @@ spec: spec: containers: - name: cluster-init - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent command: - "/cockroach/cockroach" diff --git a/cloud/kubernetes/v1.7/cockroachdb-statefulset-secure.yaml b/cloud/kubernetes/v1.7/cockroachdb-statefulset-secure.yaml index ab3c2fb8a6fc..f93edc0053d1 100644 --- a/cloud/kubernetes/v1.7/cockroachdb-statefulset-secure.yaml +++ b/cloud/kubernetes/v1.7/cockroachdb-statefulset-secure.yaml @@ -189,7 +189,7 @@ spec: topologyKey: kubernetes.io/hostname containers: - name: cockroachdb - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent ports: - containerPort: 26257 diff --git a/cloud/kubernetes/v1.7/cockroachdb-statefulset.yaml b/cloud/kubernetes/v1.7/cockroachdb-statefulset.yaml index b2bdeb316314..249c40a7a8bd 100644 --- a/cloud/kubernetes/v1.7/cockroachdb-statefulset.yaml +++ b/cloud/kubernetes/v1.7/cockroachdb-statefulset.yaml @@ -92,7 +92,7 @@ spec: topologyKey: kubernetes.io/hostname containers: - name: cockroachdb - image: cockroachdb/cockroach:v20.1.4 + image: cockroachdb/cockroach:v20.1.5 imagePullPolicy: IfNotPresent ports: - containerPort: 26257 From 666d47dc71da626d0a1be0a62427561503978205 Mon Sep 17 00:00:00 2001 From: Rohan Yadav Date: Mon, 31 Aug 2020 16:11:12 -0400 Subject: [PATCH 12/13] sql: update `format_type` to handle user defined types Fixes #53684. Update the `format_type` builtin to handle user defined types. Release justification: bug fix Release note: None --- pkg/sql/faketreeeval/evalctx.go | 13 +++++++++++ .../logictest/testdata/logic_test/pg_builtins | 15 ++++++++++++ pkg/sql/sem/builtins/pg_builtins.go | 23 ++++++++++++++++--- pkg/sql/sem/tree/eval.go | 1 + 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/pkg/sql/faketreeeval/evalctx.go b/pkg/sql/faketreeeval/evalctx.go index 5b7eebdb800d..58db1900119f 100644 --- a/pkg/sql/faketreeeval/evalctx.go +++ b/pkg/sql/faketreeeval/evalctx.go @@ -22,6 +22,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/util/errorutil/unimplemented" "github.com/cockroachdb/errors" + "github.com/lib/pq/oid" ) // DummySequenceOperators implements the tree.SequenceOperators interface by @@ -119,6 +120,18 @@ func (ep *DummyEvalPlanner) EvalSubquery(expr *tree.Subquery) (tree.Datum, error return nil, errors.WithStack(errEvalPlanner) } +// ResolveTypeByOID implements the tree.TypeReferenceResolver interface. +func (ep *DummyEvalPlanner) ResolveTypeByOID(_ context.Context, _ oid.Oid) (*types.T, error) { + return nil, errors.WithStack(errEvalPlanner) +} + +// ResolveType implements the tree.TypeReferenceResolver interface. +func (ep *DummyEvalPlanner) ResolveType( + _ context.Context, _ *tree.UnresolvedObjectName, +) (*types.T, error) { + return nil, errors.WithStack(errEvalPlanner) +} + // DummyPrivilegedAccessor implements the tree.PrivilegedAccessor interface by returning errors. type DummyPrivilegedAccessor struct{} diff --git a/pkg/sql/logictest/testdata/logic_test/pg_builtins b/pkg/sql/logictest/testdata/logic_test/pg_builtins index e2f4b966e1f0..f441ff9cdfe7 100644 --- a/pkg/sql/logictest/testdata/logic_test/pg_builtins +++ b/pkg/sql/logictest/testdata/logic_test/pg_builtins @@ -18,3 +18,18 @@ SELECT pg_my_temp_schema() # Regression test for #49072. statement ok SELECT has_table_privilege('root'::NAME, 0, 'select') + +# Regression test for #53684. +statement ok +CREATE TYPE typ AS ENUM ('hello') + +query T +SELECT format_type(oid, 0) FROM pg_catalog.pg_type WHERE typname = 'typ' +---- +typ + +# Nothing breaks if we put a non-existing oid into format_type. +query T +SELECT format_type(152100, 0) +---- +unknown (OID=152100) diff --git a/pkg/sql/sem/builtins/pg_builtins.go b/pkg/sql/sem/builtins/pg_builtins.go index 5b45d38ef68c..7d00d9e31a57 100644 --- a/pkg/sql/sem/builtins/pg_builtins.go +++ b/pkg/sql/sem/builtins/pg_builtins.go @@ -16,6 +16,7 @@ import ( "time" "github.com/cockroachdb/cockroach/pkg/keys" + "github.com/cockroachdb/cockroach/pkg/sql/catalog" "github.com/cockroachdb/cockroach/pkg/sql/catalog/catconstants" "github.com/cockroachdb/cockroach/pkg/sql/parser" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" @@ -827,7 +828,7 @@ var pgBuiltins = map[string]builtinDefinition{ }, ), - "format_type": makeBuiltin(tree.FunctionProperties{NullableArgs: true}, + "format_type": makeBuiltin(tree.FunctionProperties{NullableArgs: true, DistsqlBlocklist: true}, tree.Overload{ Types: tree.ArgTypes{{"type_oid", types.Oid}, {"typemod", types.Int}}, ReturnType: tree.FixedReturnType(types.String), @@ -838,9 +839,25 @@ var pgBuiltins = map[string]builtinDefinition{ return tree.DNull, nil } maybeTypmod := args[1] - typ, ok := types.OidToType[oid.Oid(int(oidArg.(*tree.DOid).DInt))] + oid := oid.Oid(int(oidArg.(*tree.DOid).DInt)) + typ, ok := types.OidToType[oid] if !ok { - return tree.NewDString(fmt.Sprintf("unknown (OID=%s)", oidArg)), nil + // If the type wasn't statically known, try looking it up as a user + // defined type. + var err error + typ, err = ctx.Planner.ResolveTypeByOID(ctx.Context, oid) + if err != nil { + // If the error is a descriptor does not exist error, then swallow it. + unknown := tree.NewDString(fmt.Sprintf("unknown (OID=%s)", oidArg)) + switch { + case errors.Is(err, catalog.ErrDescriptorNotFound): + return unknown, nil + case pgerror.GetPGCode(err) == pgcode.UndefinedObject: + return unknown, nil + default: + return nil, err + } + } } var hasTypmod bool var typmod int diff --git a/pkg/sql/sem/tree/eval.go b/pkg/sql/sem/tree/eval.go index 479ba7d14234..7d1531d210f8 100644 --- a/pkg/sql/sem/tree/eval.go +++ b/pkg/sql/sem/tree/eval.go @@ -2993,6 +2993,7 @@ type EvalDatabase interface { // EvalPlanner is a limited planner that can be used from EvalContext. type EvalPlanner interface { EvalDatabase + TypeReferenceResolver // ParseType parses a column type. ParseType(sql string) (*types.T, error) From a8bd0df2b3a23a30a6e6124dc95c85a562842a91 Mon Sep 17 00:00:00 2001 From: Bilal Akhtar Date: Mon, 31 Aug 2020 16:20:16 -0400 Subject: [PATCH 13/13] roachprod: Build Charybdefs against thrift 0.13 As we use Ubuntu 18.04 on Roachprod clusters, which has a newer version of bundler and ruby, we have to use a newer version of Thrift. Using newer Thrift also necessitates some changes in Charybdefs' build files, so I've forked it, used the fork here, and submitted the changes upstream: https://github.com/scylladb/charybdefs/pull/21 Fixes #52533. Release justification: Roachtest/roachprod only fix. Release note: None. --- pkg/cmd/roachprod/install/install.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/roachprod/install/install.go b/pkg/cmd/roachprod/install/install.go index afa8964ba293..6699189511bf 100644 --- a/pkg/cmd/roachprod/install/install.go +++ b/pkg/cmd/roachprod/install/install.go @@ -39,7 +39,7 @@ sudo service cassandra stop; sudo mkdir -p "${thrift_dir}" sudo chmod 777 "${thrift_dir}" cd "${thrift_dir}" - curl "https://downloads.apache.org/thrift/0.10.0/thrift-0.10.0.tar.gz" | sudo tar xvz --strip-components 1 + curl "https://downloads.apache.org/thrift/0.13.0/thrift-0.13.0.tar.gz" | sudo tar xvz --strip-components 1 sudo ./configure --prefix=/usr sudo make -j$(nproc) sudo make install @@ -54,7 +54,8 @@ sudo service cassandra stop; sudo rm -rf "${charybde_dir}" "${nemesis_path}" /usr/local/bin/charybdefs{,-nemesis} sudo mkdir -p "${charybde_dir}" sudo chmod 777 "${charybde_dir}" - git clone --depth 1 "https://github.com/scylladb/charybdefs.git" "${charybde_dir}" + # TODO(bilal): Change URL back to scylladb/charybdefs once https://github.com/scylladb/charybdefs/pull/21 is merged. + git clone --depth 1 "https://github.com/itsbilal/charybdefs.git" "${charybde_dir}" cd "${charybde_dir}" thrift -r --gen cpp server.thrift