YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/bfpg/bfunc_standard.h
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
// This module defines standard C++ functions that are used to support PGSQL builtin functions.
16
// Each of these functions have one or more entries in builtin library directory. Note that C++
17
// functions don't have to be defined here as long as they are linked to this lib.
18
//
19
// Once written, this function should not be changed to avoid compatibility issues. That is,
20
// server might runs one version while client use a different version of this function.
21
//
22
// See the header of file "/util/bfpg/bfpg.h" for more general info.
23
//--------------------------------------------------------------------------------------------------
24
25
#ifndef YB_BFPG_BFUNC_STANDARD_H_
26
#define YB_BFPG_BFUNC_STANDARD_H_
27
28
#include <string>
29
30
#include "yb/util/status.h"
31
#include "yb/util/status_log.h"
32
#include "yb/util/uuid.h"
33
34
namespace yb {
35
namespace bfpg {
36
37
//--------------------------------------------------------------------------------------------------
38
// Dummy function for minimum opcode.
39
0
inline CHECKED_STATUS NoOp() {
40
0
  return Status::OK();
41
0
}
42
43
// ServerOperator that takes no argument and has no return value.
44
0
inline CHECKED_STATUS ServerOperator() {
45
0
  LOG(ERROR) << "Only tablet servers can execute this builtin call";
46
0
  return STATUS(RuntimeError, "Only tablet servers can execute this builtin call");
47
0
}
48
49
// ServerOperator that takes 1 argument and has a return value.
50
template<typename PTypePtr, typename RTypePtr>
51
0
CHECKED_STATUS ServerOperator(PTypePtr arg1, RTypePtr result) {
52
0
  LOG(ERROR) << "Only tablet servers can execute this builtin call";
53
0
  return STATUS(RuntimeError, "Only tablet servers can execute this builtin call");
54
0
}
Unexecuted instantiation: _ZN2yb4bfpg14ServerOperatorINSt3__110shared_ptrINS0_11BFTestValueEEES5_EENS_6StatusET_T0_
Unexecuted instantiation: _ZN2yb4bfpg14ServerOperatorINSt3__110shared_ptrINS_7QLValueEEES5_EENS_6StatusET_T0_
Unexecuted instantiation: _ZN2yb4bfpg14ServerOperatorIPNS_7QLValueES3_EENS_6StatusET_T0_
55
56
// This is not used but implemented as an example for future coding.
57
// ServerOperator that takes 2 arguments and has a return value.
58
template<typename PTypePtr, typename RTypePtr>
59
CHECKED_STATUS ServerOperator(PTypePtr arg1, PTypePtr arg2, RTypePtr result) {
60
  LOG(ERROR) << "Only tablet servers can execute this builtin call";
61
  return STATUS(RuntimeError, "Only tablet servers can execute this builtin call");
62
}
63
64
//--------------------------------------------------------------------------------------------------
65
// "+" and "-".
66
67
template<typename PTypePtr, typename RTypePtr>
68
3
Status AddI64I64(PTypePtr x, PTypePtr y, RTypePtr result) {
69
3
  if (x->IsNull() || y->IsNull()) {
70
0
    result->SetNull();
71
3
  } else {
72
3
    result->set_int64_value(x->int64_value() + y->int64_value());
73
3
  }
74
3
  return Status::OK();
75
3
}
_ZN2yb4bfpg9AddI64I64INSt3__110shared_ptrINS0_11BFTestValueEEES5_EENS_6StatusET_S7_T0_
Line
Count
Source
68
3
Status AddI64I64(PTypePtr x, PTypePtr y, RTypePtr result) {
69
3
  if (x->IsNull() || y->IsNull()) {
70
0
    result->SetNull();
71
3
  } else {
72
3
    result->set_int64_value(x->int64_value() + y->int64_value());
73
3
  }
74
3
  return Status::OK();
75
3
}
Unexecuted instantiation: _ZN2yb4bfpg9AddI64I64INSt3__110shared_ptrINS_7QLValueEEES5_EENS_6StatusET_S7_T0_
Unexecuted instantiation: _ZN2yb4bfpg9AddI64I64IPNS_7QLValueES3_EENS_6StatusET_S5_T0_
76
77
template<typename PTypePtr, typename RTypePtr>
78
3
Status AddDoubleDouble(PTypePtr x, PTypePtr y, RTypePtr result) {
79
3
  if (x->IsNull() || y->IsNull()) {
80
0
    result->SetNull();
81
3
  } else {
82
3
    result->set_double_value(x->double_value() + y->double_value());
83
3
  }
84
3
  return Status::OK();
85
3
}
_ZN2yb4bfpg15AddDoubleDoubleINSt3__110shared_ptrINS0_11BFTestValueEEES5_EENS_6StatusET_S7_T0_
Line
Count
Source
78
3
Status AddDoubleDouble(PTypePtr x, PTypePtr y, RTypePtr result) {
79
3
  if (x->IsNull() || y->IsNull()) {
80
0
    result->SetNull();
81
3
  } else {
82
3
    result->set_double_value(x->double_value() + y->double_value());
83
3
  }
84
3
  return Status::OK();
85
3
}
Unexecuted instantiation: _ZN2yb4bfpg15AddDoubleDoubleINSt3__110shared_ptrINS_7QLValueEEES5_EENS_6StatusET_S7_T0_
Unexecuted instantiation: _ZN2yb4bfpg15AddDoubleDoubleIPNS_7QLValueES3_EENS_6StatusET_S5_T0_
86
87
template<typename PTypePtr, typename RTypePtr>
88
1
Status AddStringString(PTypePtr x, PTypePtr y, RTypePtr result) {
89
1
  if (x->IsNull() || y->IsNull()) {
90
0
    result->SetNull();
91
1
  } else {
92
1
    result->set_string_value(x->string_value() + y->string_value());
93
1
  }
94
1
  return Status::OK();
95
1
}
_ZN2yb4bfpg15AddStringStringINSt3__110shared_ptrINS0_11BFTestValueEEES5_EENS_6StatusET_S7_T0_
Line
Count
Source
88
1
Status AddStringString(PTypePtr x, PTypePtr y, RTypePtr result) {
89
1
  if (x->IsNull() || y->IsNull()) {
90
0
    result->SetNull();
91
1
  } else {
92
1
    result->set_string_value(x->string_value() + y->string_value());
93
1
  }
94
1
  return Status::OK();
95
1
}
Unexecuted instantiation: _ZN2yb4bfpg15AddStringStringINSt3__110shared_ptrINS_7QLValueEEES5_EENS_6StatusET_S7_T0_
Unexecuted instantiation: _ZN2yb4bfpg15AddStringStringIPNS_7QLValueES3_EENS_6StatusET_S5_T0_
96
97
template<typename PTypePtr, typename RTypePtr>
98
1
Status AddStringDouble(PTypePtr x, PTypePtr y, RTypePtr result) {
99
1
  if (x->IsNull() || y->IsNull()) {
100
0
    result->SetNull();
101
1
  } else {
102
1
    result->set_string_value(x->string_value() + std::to_string(y->double_value()));
103
1
  }
104
1
  return Status::OK();
105
1
}
_ZN2yb4bfpg15AddStringDoubleINSt3__110shared_ptrINS0_11BFTestValueEEES5_EENS_6StatusET_S7_T0_
Line
Count
Source
98
1
Status AddStringDouble(PTypePtr x, PTypePtr y, RTypePtr result) {
99
1
  if (x->IsNull() || y->IsNull()) {
100
0
    result->SetNull();
101
1
  } else {
102
1
    result->set_string_value(x->string_value() + std::to_string(y->double_value()));
103
1
  }
104
1
  return Status::OK();
105
1
}
Unexecuted instantiation: _ZN2yb4bfpg15AddStringDoubleINSt3__110shared_ptrINS_7QLValueEEES5_EENS_6StatusET_S7_T0_
Unexecuted instantiation: _ZN2yb4bfpg15AddStringDoubleIPNS_7QLValueES3_EENS_6StatusET_S5_T0_
106
107
template<typename PTypePtr, typename RTypePtr>
108
1
Status AddDoubleString(PTypePtr x, PTypePtr y, RTypePtr result) {
109
1
  if (x->IsNull() || y->IsNull()) {
110
0
    result->SetNull();
111
1
  } else {
112
1
    result->set_string_value(std::to_string(x->double_value()) + y->string_value());
113
1
  }
114
1
  return Status::OK();
115
1
}
_ZN2yb4bfpg15AddDoubleStringINSt3__110shared_ptrINS0_11BFTestValueEEES5_EENS_6StatusET_S7_T0_
Line
Count
Source
108
1
Status AddDoubleString(PTypePtr x, PTypePtr y, RTypePtr result) {
109
1
  if (x->IsNull() || y->IsNull()) {
110
0
    result->SetNull();
111
1
  } else {
112
1
    result->set_string_value(std::to_string(x->double_value()) + y->string_value());
113
1
  }
114
1
  return Status::OK();
115
1
}
Unexecuted instantiation: _ZN2yb4bfpg15AddDoubleStringINSt3__110shared_ptrINS_7QLValueEEES5_EENS_6StatusET_S7_T0_
Unexecuted instantiation: _ZN2yb4bfpg15AddDoubleStringIPNS_7QLValueES3_EENS_6StatusET_S5_T0_
116
117
template<typename PTypePtr, typename RTypePtr>
118
0
Status SubI64I64(PTypePtr x, PTypePtr y, RTypePtr result) {
119
0
  if (x->IsNull() || y->IsNull()) {
120
0
    result->SetNull();
121
0
  } else {
122
0
    result->set_int64_value(x->int64_value() - y->int64_value());
123
0
  }
124
0
  return Status::OK();
125
0
}
Unexecuted instantiation: _ZN2yb4bfpg9SubI64I64INSt3__110shared_ptrINS0_11BFTestValueEEES5_EENS_6StatusET_S7_T0_
Unexecuted instantiation: _ZN2yb4bfpg9SubI64I64INSt3__110shared_ptrINS_7QLValueEEES5_EENS_6StatusET_S7_T0_
Unexecuted instantiation: _ZN2yb4bfpg9SubI64I64IPNS_7QLValueES3_EENS_6StatusET_S5_T0_
126
127
template<typename PTypePtr, typename RTypePtr>
128
0
Status SubDoubleDouble(PTypePtr x, PTypePtr y, RTypePtr result) {
129
0
  if (x->IsNull() || y->IsNull()) {
130
0
    result->SetNull();
131
0
  } else {
132
0
    result->set_double_value(x->double_value() - y->double_value());
133
0
  }
134
0
  return Status::OK();
135
0
}
Unexecuted instantiation: _ZN2yb4bfpg15SubDoubleDoubleINSt3__110shared_ptrINS0_11BFTestValueEEES5_EENS_6StatusET_S7_T0_
Unexecuted instantiation: _ZN2yb4bfpg15SubDoubleDoubleINSt3__110shared_ptrINS_7QLValueEEES5_EENS_6StatusET_S7_T0_
Unexecuted instantiation: _ZN2yb4bfpg15SubDoubleDoubleIPNS_7QLValueES3_EENS_6StatusET_S5_T0_
136
137
//--------------------------------------------------------------------------------------------------
138
// Comparison.
139
template<typename PTypePtr, typename RTypePtr>
140
0
Status Equal(PTypePtr x, PTypePtr y, RTypePtr result) {
141
0
  if (x->IsNull() || y->IsNull()) {
142
0
    result->set_bool_value(false);
143
0
  } else {
144
0
    result->set_bool_value(x->value() == y->value());
145
0
  }
146
0
  return Status::OK();
147
0
}
Unexecuted instantiation: _ZN2yb4bfpg5EqualINSt3__110shared_ptrINS0_11BFTestValueEEES5_EENS_6StatusET_S7_T0_
Unexecuted instantiation: _ZN2yb4bfpg5EqualINSt3__110shared_ptrINS_7QLValueEEES5_EENS_6StatusET_S7_T0_
Unexecuted instantiation: _ZN2yb4bfpg5EqualIPNS_7QLValueES3_EENS_6StatusET_S5_T0_
148
149
//--------------------------------------------------------------------------------------------------
150
// Now().
151
template<typename RTypePtr>
152
0
Status NowTimeUuid(RTypePtr result) {
153
0
  uuid_t linux_time_uuid;
154
0
  uuid_generate_time(linux_time_uuid);
155
0
  Uuid time_uuid(linux_time_uuid);
156
0
  CHECK_OK(time_uuid.IsTimeUuid());
157
0
  CHECK_OK(time_uuid.HashMACAddress());
158
0
  result->set_timeuuid_value(time_uuid);
159
0
  return Status::OK();
160
0
}
Unexecuted instantiation: _ZN2yb4bfpg11NowTimeUuidINSt3__110shared_ptrINS0_11BFTestValueEEEEENS_6StatusET_
Unexecuted instantiation: _ZN2yb4bfpg11NowTimeUuidINSt3__110shared_ptrINS_7QLValueEEEEENS_6StatusET_
Unexecuted instantiation: _ZN2yb4bfpg11NowTimeUuidIPNS_7QLValueEEENS_6StatusET_
161
162
//--------------------------------------------------------------------------------------------------
163
164
} // namespace bfpg
165
} // namespace yb
166
167
#endif  // YB_BFPG_BFUNC_STANDARD_H_