Skip to content

Commit 5e1ee5a

Browse files
craig[bot]kvolirimadeodharmichae2
committed
106643: kvserver: remove redundant "too little" log line r=kvoli a=kvoli Some small improvements and fixes for allocator/store rebalancer logging. Epic: none Release note: None 106873: parser: Fix AS OF failures in TestRandomSyntaxSelect r=rimadeodhar a=rimadeodhar One of the test cases failing within the TestRandomSyntaxSelect is the usage of 'AS OF' contained within the select clause, for example - SELECT 10 AS OF FROM <table_name>. The grammar uses a single token lookahead to determine that AS OF should pick the AS OF SYSTEM TIME rule. However, this isn't accurate. This PR fixes this bug by using two token lookahead instead of one to pick the right target rule when the keywords AS OF occur adjacently within the SELECT clause. Informs cockroachdb#87361, Informs cockroachdb#99184 Epic: None Release note: none 107916: release: update predecessor map for 23.1.7 r=celiala a=michae2 Release note: None Epic: None Co-authored-by: Austen McClernon <[email protected]> Co-authored-by: rimadeodhar <[email protected]> Co-authored-by: Michael Erickson <[email protected]>
4 parents 928773b + 179a255 + da6a7c4 + a302bbd commit 5e1ee5a

File tree

7 files changed

+35
-11
lines changed

7 files changed

+35
-11
lines changed

pkg/kv/kvserver/store_rebalancer.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -865,14 +865,6 @@ func (sr *StoreRebalancer) chooseRangeToRebalance(
865865
rctx.LocalDesc.StoreID,
866866
rctx.LocalDesc.Capacity.Load(),
867867
)
868-
log.KvDistribution.Infof(
869-
ctx,
870-
"r%d's %s load is too little to matter relative to s%d's %s total load",
871-
candidateReplica.GetRangeID(),
872-
candidateReplica.RangeUsageInfo().Load(),
873-
rctx.LocalDesc.StoreID,
874-
rctx.LocalDesc.Capacity.Load(),
875-
)
876868
continue
877869
}
878870

pkg/sql/logictest/testdata/logic_test/select

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,3 +843,22 @@ RESET large_full_scan_rows;
843843
# Regression test for #58104.
844844
statement ok
845845
SELECT * FROM pg_catalog.pg_attrdef WHERE (adnum = 1 AND adrelid = 1) OR (adbin = 'foo' AND adrelid = 2)
846+
847+
# Tests with SELECT AS clause.
848+
statement ok
849+
CREATE TABLE t(a INT, b INT);
850+
851+
statement ok
852+
INSERT INTO t values(10, 20);
853+
854+
query I colnames
855+
SELECT -488 AS OF FROM t;
856+
----
857+
of
858+
-488
859+
860+
query I colnames
861+
SELECT -488 OF FROM t;
862+
----
863+
of
864+
-488

pkg/sql/parser/help_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ func TestContextualHelp(t *testing.T) {
489489

490490
{`SELECT 1 ??`, `SELECT`},
491491
{`SELECT * FROM ??`, `<SOURCE>`},
492+
{`SELECT 1 AS OF ??`, `SELECT`},
492493
{`SELECT 1 FROM foo ??`, `SELECT`},
493494
{`SELECT 1 FROM foo WHERE ??`, `SELECT`},
494495
{`SELECT 1 FROM (SELECT ??`, `SELECT`},
@@ -552,7 +553,7 @@ func TestContextualHelp(t *testing.T) {
552553

553554
{`BACKUP foo TO 'bar' ??`, `BACKUP`},
554555
{`BACKUP DATABASE ??`, `BACKUP`},
555-
{`BACKUP foo TO 'bar' AS OF ??`, `BACKUP`},
556+
{`BACKUP foo TO 'bar' AS OF SYSTEM ??`, `BACKUP`},
556557

557558
{`RESTORE foo FROM 'bar' ??`, `RESTORE`},
558559
{`RESTORE DATABASE ??`, `RESTORE`},

pkg/sql/parser/lexer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,10 @@ func (l *lexer) Lex(lval *sqlSymType) int {
224224
case AS:
225225
switch nextToken.id {
226226
case OF:
227-
lval.id = AS_LA
227+
switch secondToken.id {
228+
case SYSTEM:
229+
lval.id = AS_LA
230+
}
228231
}
229232
case NOT:
230233
switch nextToken.id {

pkg/sql/parser/lexer_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func TestLexer(t *testing.T) {
2727
{`NOT IN`, []int{NOT_LA, IN}},
2828
{`NOT SIMILAR`, []int{NOT_LA, SIMILAR}},
2929
{`AS OF SYSTEM TIME`, []int{AS_LA, OF, SYSTEM, TIME}},
30+
{`AS OF`, []int{AS, OF}},
3031
}
3132
for i, d := range testData {
3233
s := makeSQLScanner(d.sql)

pkg/sql/parser/testdata/select_clauses

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,3 +3069,11 @@ SELECT * FROM ROWS FROM (json_to_record('')) AS t (a "Nice Enum 📙", b STRING,
30693069
SELECT (*) FROM ROWS FROM ((json_to_record(('')))) AS t (a "Nice Enum 📙", b STRING, c foo) -- fully parenthesized
30703070
SELECT * FROM ROWS FROM (json_to_record('_')) AS t (a "Nice Enum 📙", b STRING, c foo) -- literals removed
30713071
SELECT * FROM ROWS FROM (json_to_record('')) AS _ (_ _, _ STRING, _ _) -- identifiers removed
3072+
3073+
parse
3074+
SELECT 123 AS OF FROM t
3075+
----
3076+
SELECT 123 AS of FROM t -- normalized!
3077+
SELECT (123) AS of FROM t -- fully parenthesized
3078+
SELECT _ AS of FROM t -- literals removed
3079+
SELECT 123 AS _ FROM _ -- identifiers removed

pkg/testutils/release/cockroach_releases.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
- 22.2.8
1515
predecessor: "22.1"
1616
"23.1":
17-
latest: 23.1.6
17+
latest: 23.1.7
1818
withdrawn:
1919
- 23.1.0
2020
predecessor: "22.2"

0 commit comments

Comments
 (0)