-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
77063: sql: don't panic when PREPARING a PREPARE r=jordanlewis a=jordanlewis Depends on #77059 Closes #77061 Previously, trying to run a PREPARE statement via the extended protocol would panic the server. This is no longer the case. Release note (bug fix): the database no longer crashes when running a SQL PREPARE via the Postgres extended protocol. Release justification: Bug fixes and low-risk updates to new functionality 77113: dev: add build targets to `dev build --help` r=rickystewart a=ajwerner It was painful to figure out what you could build before this. ``` Build the specified binaries: bazel-remote buildifier buildozer cockroach cockroach-oss cockroach-short cockroach-sql crlfmt dev docgen execgen gofmt goimports label-merged-pr langgen optfmt optgen oss roachprod roachprod-stress roachtest short staticcheck stress workload ``` Release justification: non-production code change Release note: None 77131: vendor: bump Pebble to 40d39da505a5 r=jbowens a=jbowens ``` 40d39da5 db: produce the FlushEnd event after installing readState cef3f146 compaction: add support for concurrent manual compactions cb848478 manifest: add methods for extending table bounds 7e5c8ee1 sstable: move block property collector calls to the Writer client goroutine 0e0d279a internal/keyspan: move MergingIter from internal/rangekey 09203fd9 *: Expose range key iterators through table cache 894b57aa db: correctly set point key bounds in `TestIngest_UpdateSequenceNumber` 6c7f6ed4 base: update IsExclusiveSentinel to account for multiple range key kinds e0589417 db: add external sstable merging iterator 85162b61 sstable: unify sstable size estimation by using a single abstraction bac6da8f internal/rangekey: adjust MergingIter interface, return fragment sets 7eb64ae7 Revert "db: add experimental DB.RegisterFlushCompletedCallback" 2c522458 db: remove unnecessary key clones during ingest load 998400e7 db: fix skipped key during Prev at synthetic range key marker 13f8f7ce *: separately track smallest/largest point/range keys in FileMetadata 7449c652 sstable: change index block size estimation to use inflight size 31899eb1 sstable: flush index blocks only from the Writer client goroutine 129bc0d4 internal/rangekey: fix invariant violation during SeekGE(upper-bound) 87ab6c71 db: write range keys to memtables ``` Release note: None Release justification: commits merged in Pebble before stability period Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com> Co-authored-by: Andrew Werner <awerner32@gmail.com> Co-authored-by: Jackson Owens <jackson@cockroachlabs.com>
- Loading branch information
Showing
16 changed files
with
146 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package sql | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/base" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/cockroachdb/cockroach/pkg/util/log" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// Make sure that running a wire-protocol-level PREPARE of a SQL-level PREPARE | ||
// and SQL-level EXECUTE doesn't cause any problems. | ||
func TestPreparePrepareExecute(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
defer log.Scope(t).Close(t) | ||
|
||
srv, db, _ := serverutils.StartServer(t, base.TestServerArgs{Insecure: true}) | ||
defer srv.Stopper().Stop(context.Background()) | ||
defer db.Close() | ||
|
||
// Test that preparing an invalid EXECUTE fails at prepare-time. | ||
_, err := db.Prepare("EXECUTE x(3)") | ||
require.Contains(t, err.Error(), "no such prepared statement") | ||
|
||
// Test that we can prepare and execute a PREPARE. | ||
s, err := db.Prepare("PREPARE x AS SELECT $1::int") | ||
require.NoError(t, err) | ||
|
||
_, err = s.Exec() | ||
require.NoError(t, err) | ||
|
||
// Make sure we can't send arguments to the PREPARE even though it has a | ||
// placeholder inside (that placeholder is for the "inner" PREPARE). | ||
_, err = s.Exec(3) | ||
require.Contains(t, err.Error(), "expected 0 arguments, got 1") | ||
|
||
// Test that we can prepare and execute the corresponding EXECUTE. | ||
s, err = db.Prepare("EXECUTE x(3)") | ||
require.NoError(t, err) | ||
|
||
var output int | ||
err = s.QueryRow().Scan(&output) | ||
require.NoError(t, err) | ||
require.Equal(t, 3, output) | ||
|
||
// Make sure we can't send arguments to the prepared EXECUTE. | ||
_, err = s.Exec(3) | ||
require.Contains(t, err.Error(), "expected 0 arguments, got 1") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule vendor
updated
29 files