YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/common/row_mark.cc
Line
Count
Source (jump to first uncovered line)
1
//
2
// Copyright (c) YugaByte, Inc.
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
// in compliance with the License.  You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software distributed under the License
10
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
// or implied.  See the License for the specific language governing permissions and limitations
12
// under the License.
13
//
14
15
#include "yb/common/row_mark.h"
16
17
#include <glog/logging.h>
18
19
#include "yb/common/common.pb.h"
20
#include "yb/gutil/macros.h"
21
22
namespace yb {
23
24
7.78k
RowMarkType GetStrongestRowMarkType(std::initializer_list<RowMarkType> row_mark_types) {
25
7.78k
  RowMarkType strongest_row_mark_type = RowMarkType::ROW_MARK_ABSENT;
26
15.5k
  for (RowMarkType row_mark_type : row_mark_types) {
27
15.5k
    strongest_row_mark_type = std::min(row_mark_type, strongest_row_mark_type);
28
15.5k
  }
29
7.78k
  return strongest_row_mark_type;
30
7.78k
}
31
32
42.0M
bool IsValidRowMarkType(RowMarkType row_mark_type) {
33
42.0M
  switch (row_mark_type) {
34
101k
    case RowMarkType::ROW_MARK_EXCLUSIVE: FALLTHROUGH_INTENDED;
35
101k
    case RowMarkType::ROW_MARK_NOKEYEXCLUSIVE: FALLTHROUGH_INTENDED;
36
119k
    case RowMarkType::ROW_MARK_SHARE: FALLTHROUGH_INTENDED;
37
357k
    case RowMarkType::ROW_MARK_KEYSHARE:
38
357k
      return true;
39
41.7M
    default:
40
41.7M
      return false;
41
42.0M
  }
42
42.0M
}
43
44
1.89M
bool RowMarkNeedsHigherPriority(RowMarkType row_mark_type) {
45
  /*
46
   * Currently, using higher priority for all supported row marks except the key share lock.
47
   * This is because key share locks are used for foreign keys and we don't want higher priority
48
   * there.
49
   */
50
1.89M
  return IsValidRowMarkType(row_mark_type) &&
51
7.77k
      row_mark_type != RowMarkType::ROW_MARK_KEYSHARE;
52
1.89M
}
53
54
} // namespace yb