YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/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
10.9k
RowMarkType GetStrongestRowMarkType(std::initializer_list<RowMarkType> row_mark_types) {
25
10.9k
  RowMarkType strongest_row_mark_type = RowMarkType::ROW_MARK_ABSENT;
26
21.6k
  for (RowMarkType row_mark_type : row_mark_types) {
27
21.6k
    strongest_row_mark_type = std::min(row_mark_type, strongest_row_mark_type);
28
21.6k
  }
29
10.9k
  return strongest_row_mark_type;
30
10.9k
}
31
32
113M
bool IsValidRowMarkType(RowMarkType row_mark_type) {
33
113M
  switch (row_mark_type) {
34
126k
    case RowMarkType::ROW_MARK_EXCLUSIVE: FALLTHROUGH_INTENDED;
35
130k
    case RowMarkType::ROW_MARK_NOKEYEXCLUSIVE: FALLTHROUGH_INTENDED;
36
156k
    case RowMarkType::ROW_MARK_SHARE: FALLTHROUGH_INTENDED;
37
428k
    case RowMarkType::ROW_MARK_KEYSHARE:
38
428k
      return true;
39
112M
    default:
40
112M
      return false;
41
113M
  }
42
113M
}
43
44
3.60M
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
3.60M
  return IsValidRowMarkType(row_mark_type) &&
51
3.60M
      
row_mark_type != RowMarkType::ROW_MARK_KEYSHARE8.20k
;
52
3.60M
}
53
54
} // namespace yb