Skip to content

Commit 5db957e

Browse files
craig[bot]DrewKimballDarrylWongrafissmsbutler
committed
144915: sql: disallow set-returning PL/pgSQL functions in mixed version state r=michae2 a=DrewKimball This commit adds a version check during routine creation for set-returning PL/pgSQL function. Fixes #144914 Release note (bug fix): Fixed a bug in alpha and beta versions of 25.2 that allowed a set-returning PL/pgSQL function to be created before the version change was finalized. 145017: opt: handle unsimplified groupby orderings r=rytaft a=DrewKimball This commit fixes a test-only assertion failure due to the GroupBy provided ordering logic relying on ordering simplification rules. The assertion errors happened because the provided ordering logic expected that a required ordering would only ever contain grouping columns. In reality, it is possible for the ordering to include `ConstAgg` and other "pass-through" columns. However, references to these columns are usually removed by rules like `SimplifyGroupByOrdering` because they are constant within a given group. Since the failure only occurs with rules disabled and only in test builds, there is no release note. Fixes #137508 Release note: None 145106: roachprod: add CLI option to download certs dir r=srosenberg a=DarrylWong This change adds a fetch-certs command that will download the pgurl certs from a cluster locally. We need a separate command for certs as opposed to just using roachprod get as lib/pq will complain about world-readable files. One benefactor of this command is testing out new roachtest operations locally. Many operations require certs and having to manually remember to make them non world readable each time is non obvious and cumbersome. Release Note: none Epic: none 145107: schemachanger: check dependents when dropping hash-sharded index r=rafiss a=rafiss fixes #145100 Release note (bug fix): Fixed a bug where DROP INDEX on a hash-sharded index did not properly detect dependencies from functions and procedures on the shard column. This bug would cause the DROP INDEX statement to fail with an internal validation error. Now, the statement returns a correct error message, and using DROP INDEX ... CASCADE works as expected by dropping the dependent function/procedure. 145332: upgrades: swallow setting override error in diagnostics migration r=rafiss a=msbutler Previously if a tenant ran the optInToDiagnosticsStatReporting migration, which sets diagnostics.reporting.enabled, after the system tenant already overrode this setting, the migration would enter a fail loop. With this patch, the migration instead noops. Epic: none Release note: none 145367: sql: reduce allocations for unsupported type checker r=mgartner a=mgartner Release note: None 145373: vecindex: bump test size under `race` r=michae2 a=rickystewart Closes #145299 Epic: none Release note: None Co-authored-by: Drew Kimball <[email protected]> Co-authored-by: DarrylWong <[email protected]> Co-authored-by: Rafi Shamim <[email protected]> Co-authored-by: Michael Butler <[email protected]> Co-authored-by: Marcus Gartner <[email protected]> Co-authored-by: Ricky Stewart <[email protected]>
8 parents bbb2b96 + 634a981 + 5e75f25 + b5145b9 + 103d69b + 2f823af + 58c3ce5 + b3de197 commit 5db957e

File tree

29 files changed

+287
-53
lines changed

29 files changed

+287
-53
lines changed

pkg/ccl/logictestccl/testdata/logic_test/plpgsql_srf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# LogicTest: !local-mixed-24.3 !local-mixed-25.1
2+
13
statement ok
24
CREATE TABLE xy (x INT, y INT);
35
INSERT INTO xy VALUES (1, 2), (3, 4), (5, 6);

pkg/ccl/logictestccl/testdata/logic_test/tenant_settings

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ SHOW CLUSTER SETTING sql.notices.enabled
109109
true
110110

111111
# Verify that we disallow setting a ApplicationLevel setting that is overridden.
112-
statement error cluster setting 'sql.notices.enabled' is currently overridden by the operator
112+
statement error cluster setting 'sql.notices.enabled' cannot be set: cluster setting is overridden by system virtual cluster
113113
SET CLUSTER SETTING sql.notices.enabled = false
114114

115-
statement error cluster setting 'sql.notices.enabled' is currently overridden by the operator
115+
statement error cluster setting 'sql.notices.enabled' cannot be set: cluster setting is overridden by system virtual cluster
116116
RESET CLUSTER SETTING sql.notices.enabled
117117

118118
user host-cluster-root

pkg/ccl/logictestccl/tests/local-mixed-24.3/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ go_test(
99
"//pkg/ccl/logictestccl:testdata", # keep
1010
],
1111
exec_properties = {"test.Pool": "large"},
12-
shard_count = 33,
12+
shard_count = 32,
1313
tags = ["cpu:1"],
1414
deps = [
1515
"//pkg/base",

pkg/ccl/logictestccl/tests/local-mixed-24.3/generated_test.go

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/ccl/logictestccl/tests/local-mixed-25.1/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ go_test(
99
"//pkg/ccl/logictestccl:testdata", # keep
1010
],
1111
exec_properties = {"test.Pool": "large"},
12-
shard_count = 33,
12+
shard_count = 32,
1313
tags = ["cpu:1"],
1414
deps = [
1515
"//pkg/base",

pkg/ccl/logictestccl/tests/local-mixed-25.1/generated_test.go

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cmd/roachprod/cli/commands.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,3 +2207,31 @@ If the time is not provided, it downloads the latest pprof file across all clust
22072207
}),
22082208
}
22092209
}
2210+
2211+
func (cr *commandRegistry) buildFetchCertsDir() *cobra.Command {
2212+
return &cobra.Command{
2213+
Use: "fetch-certs <cluster> [<dest-dir>]",
2214+
Short: "downloads the PGUrl certs directory from the cluster",
2215+
Long: fmt.Sprintf(`
2216+
Downloads the PGUrl certs directory from the cluster. In addition to downloading the
2217+
certs, it also makes sure the files are not world readable so lib/pq doesn't complain.
2218+
If a destination is not provided, the certs will be downloaded to a default %s directory.
2219+
2220+
--certs-dir: specify the directory to download the certs from
2221+
2222+
`, install.CockroachNodeCertsDir),
2223+
Args: cobra.RangeArgs(1, 2),
2224+
Run: wrap(func(cmd *cobra.Command, args []string) error {
2225+
cluster := args[0]
2226+
// If a destination is not provided, download the certs to a default directory
2227+
// for safety. FetchCertsDir will walk the entire directory and chmod each file
2228+
// so we want to avoid side effects.
2229+
dest := fmt.Sprintf("./%s", install.CockroachNodeCertsDir)
2230+
if len(args) == 2 {
2231+
dest = args[1]
2232+
}
2233+
ctx := context.Background()
2234+
return roachprod.FetchCertsDir(ctx, config.Logger, cluster, pgurlCertsDir, dest)
2235+
}),
2236+
}
2237+
}

pkg/cmd/roachprod/cli/resgistry.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,6 @@ func (cr *commandRegistry) register() {
7070
cr.buildOpentelemetryStopCmd(),
7171
cr.buildFetchLogsCmd(),
7272
cr.buildGetLatestPProfCmd(),
73+
cr.buildFetchCertsDir(),
7374
})
7475
}

pkg/cmd/roachtest/cluster.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"encoding/json"
1414
"fmt"
1515
"io"
16-
"io/fs"
1716
"log"
1817
"math/rand"
1918
"net"
@@ -2203,6 +2202,7 @@ func (c *clusterImpl) StartE(
22032202
// Do not refetch certs if that step already happened once (i.e., we
22042203
// are restarting a node).
22052204
if settings.Secure && c.localCertsDir == "" {
2205+
// Get the certs from the first node.
22062206
if err := c.RefetchCertsFromNode(ctx, 1); err != nil {
22072207
return err
22082208
}
@@ -2279,6 +2279,7 @@ func (c *clusterImpl) StartServiceForVirtualClusterE(
22792279
}
22802280

22812281
if settings.Secure {
2282+
// Get the certs from the first node.
22822283
if err := c.RefetchCertsFromNode(ctx, 1); err != nil {
22832284
return err
22842285
}
@@ -2336,20 +2337,7 @@ func (c *clusterImpl) RefetchCertsFromNode(ctx context.Context, node int) error
23362337
// certs. Bypass that distinction (which should be fixed independently, but
23372338
// that might cause fallout) by using a non-existing dir here.
23382339
c.localCertsDir = filepath.Join(c.localCertsDir, install.CockroachNodeCertsDir)
2339-
// Get the certs from the first node.
2340-
if err := c.Get(ctx, c.l, fmt.Sprintf("./%s", install.CockroachNodeCertsDir), c.localCertsDir, c.Node(node)); err != nil {
2341-
return errors.Wrap(err, "cluster.StartE")
2342-
}
2343-
// Need to prevent world readable files or lib/pq will complain.
2344-
return filepath.WalkDir(c.localCertsDir, func(path string, d fs.DirEntry, err error) error {
2345-
if err != nil {
2346-
return errors.Wrap(err, "walking localCertsDir failed")
2347-
}
2348-
if d.IsDir() {
2349-
return nil
2350-
}
2351-
return os.Chmod(path, 0600)
2352-
})
2340+
return roachprod.FetchCertsDir(ctx, c.l, c.MakeNodes(c.Node(node)), fmt.Sprintf("./%s", install.CockroachNodeCertsDir), c.localCertsDir)
23532341
}
23542342

23552343
func (c *clusterImpl) SetDefaultVirtualCluster(name string) {

pkg/crosscluster/physical/standby_read_ts_poller_job_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,19 @@ func TestStandbyReadTSPollerJob(t *testing.T) {
4343
jobutils.WaitForJobToRun(c.T, c.DestSysSQL, jobspb.JobID(ingestionJobID))
4444
t.Logf("test setup took %s", timeutil.Since(beginTS))
4545

46+
readerTenantName := fmt.Sprintf("%s-readonly", args.DestTenantName)
47+
48+
// Ensures the reader tenant can spin up even if the system tenant overrode
49+
// the diagnostics setting, set during a permanent migration.
50+
c.DestSysSQL.Exec(t, fmt.Sprintf("ALTER TENANT '%s' SET CLUSTER SETTING diagnostics.reporting.enabled = true", readerTenantName))
51+
4652
srcTime := c.SrcCluster.Server(0).Clock().Now()
4753
c.WaitUntilReplicatedTime(srcTime, jobspb.JobID(ingestionJobID))
4854

4955
stats := replicationtestutils.TestingGetStreamIngestionStatsFromReplicationJob(t, ctx, c.DestSysSQL, ingestionJobID)
5056
readerTenantID := stats.IngestionDetails.ReadTenantID
5157
require.NotNil(t, readerTenantID)
5258

53-
readerTenantName := fmt.Sprintf("%s-readonly", args.DestTenantName)
5459
c.ConnectToReaderTenant(ctx, readerTenantID, readerTenantName)
5560

5661
defaultDBQuery := `

0 commit comments

Comments
 (0)