Skip to content

Commit

Permalink
Merge #42250 #42999
Browse files Browse the repository at this point in the history
42250: storage/engine: introduce a datadriven framework to run MVCC tests r=itsbilal,petermattis a=knz

Previously MVCC tests were hand-coded in Go.
This was making it hard(er) to introduce new tests or modify existing
tests.

This commit improves upon this situation by introducing a new
datadriven test, `TestMVCCHistories`, which runs MVCC
tests written using a DSL:

```
begin_txn      t=<name> [ts=<int>[,<int>]]
remove_txn     t=<name>
resolve_intent t=<name> k=<key> [status=<txnstatus>]
restart_txn    t=<name>
update_txn     t=<name> t2=<name>
step_txn       t=<name> [n=<int>]
advance_txn    t=<name> ts=<int>[,<int>]
txn_status     t=<name> status=<txnstatus>

check_intent   k=<key> [none]

put       [t=<name>] [ts=<int>[,<int>]] [resolve] k=<key> v=<string> [raw]
cput      [t=<name>] [ts=<int>[,<int>]] [resolve] k=<key> v=<string> [raw] [cond=<string>]
increment [t=<name>] [ts=<int>[,<int>]] [resolve] k=<key> [inc=<val>]
del       [t=<name>] [ts=<int>[,<int>]] [resolve] k=<key>
get       [t=<name>] [ts=<int>[,<int>]] [resolve] k=<key> [inconsistent] [tombstones]
scan      [t=<name>] [ts=<int>[,<int>]] [resolve] k=<key> [end=<key>] [inconsistent] [tombstones] [reverse]

merge     [ts=<int>[,<int>]] k=<key> v=<string> [raw]

clear_range    k=<key> end=<key>
```

Where `<key>` can be a simple string, or a string
prefixed by the following characters:

- `=foo` means exactly key `foo`
- `+foo` means `Key(foo).Next()`
- `-foo` means `Key(foo).PrefixEnd()`

Additionally, the pseudo-command `with` enables sharing
a group of arguments between multiple commands, for example:

```
with t=A
   begin_txn
   with k=a
     put v=b
     resolve_intent
```

Release note: None

42999: colexec: cfetcher errors on setup when indexed column contains unhandled type r=yuzefovich a=rohany

Fixes #42994.

Indexed columns are always decoded by the fetcher, even if they are unneeded.
This PR adds the check to cfetcher initialization to error out if an indexed
column is of an unneeded type.

Release note (bug fix): Fixed a bug where scanning an index of an unsupported
type with the vectorized engine would lead to an internal error.

Co-authored-by: Raphael 'kena' Poss <[email protected]>
Co-authored-by: Rohan Yadav <[email protected]>
  • Loading branch information
3 people committed Dec 5, 2019
3 parents 17c35af + 09b8355 + e6e9f0b commit 49fd7f0
Show file tree
Hide file tree
Showing 27 changed files with 2,144 additions and 1,223 deletions.
32 changes: 23 additions & 9 deletions pkg/sql/colexec/cfetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,6 @@ func (rf *cFetcher) Init(
}
sort.Sort(m)
colDescriptors := tableArgs.Cols
typs := make([]coltypes.T, len(colDescriptors))
for i := range typs {
typs[i] = typeconv.FromColumnType(&colDescriptors[i].Type)
if typs[i] == coltypes.Unhandled && tableArgs.ValNeededForCol.Contains(i) {
// Only return an error if the type is unhandled and needed. If not needed,
// a placeholder Vec will be created.
return errors.Errorf("unhandled type %+v", &colDescriptors[i].Type)
}
}
table := cTableInfo{
spans: tableArgs.Spans,
desc: tableArgs.Desc,
Expand All @@ -288,6 +279,29 @@ func (rf *cFetcher) Init(
extraValColOrdinals: oldTable.extraValColOrdinals[:0],
allExtraValColOrdinals: oldTable.allExtraValColOrdinals[:0],
}

// All columns that are part of the index key will be decoded when reading a key. Since some types
// are not supported by the vectorized engine, we should error out during setup if some needed columns
// or columns we decode always will be attempted to be decoded.
typs := make([]coltypes.T, len(colDescriptors))
var indexedCols util.FastIntSet
for _, colID := range tableArgs.Index.ColumnIDs {
indexedCols.Add(int(colID))
}
if cHasExtraCols(&table) {
for _, colID := range tableArgs.Index.ExtraColumnIDs {
indexedCols.Add(int(colID))
}
}
for i := range typs {
typs[i] = typeconv.FromColumnType(&colDescriptors[i].Type)
if typs[i] == coltypes.Unhandled && (tableArgs.ValNeededForCol.Contains(i) || indexedCols.Contains(int(colDescriptors[i].ID))) {
// Only return an error if the type is unhandled and needed. If not needed,
// a placeholder Vec will be created.
return errors.Errorf("unhandled type %+v", &colDescriptors[i].Type)
}
}

rf.machine.batch = allocator.NewMemBatch(typs)
rf.machine.colvecs = rf.machine.batch.ColVecs()

Expand Down
10 changes: 10 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/vectorize
Original file line number Diff line number Diff line change
Expand Up @@ -1006,3 +1006,13 @@ SELECT * FROM t_42816 ORDER BY a OFFSET 1020 LIMIT 10
1023
1024
1025

# Regression test for #42994
statement ok
CREATE TABLE t42994 (a int primary key, b bit, index i (a, b));
INSERT INTO t42994 VALUES (1, 1::BIT);

query I
SELECT a FROM t42994@i
----
1
Loading

0 comments on commit 49fd7f0

Please sign in to comment.