YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/yql/cql/ql/util/statement_params.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/yql/cql/ql/util/statement_params.h"
16
17
#include "yb/common/read_hybrid_time.h"
18
#include "yb/util/result.h"
19
#include "yb/util/status.h"
20
21
namespace yb {
22
namespace ql {
23
24
using std::string;
25
26
StatementParameters::StatementParameters()
27
    : page_size_(INT64_MAX),
28
4.93M
      yb_consistency_level_(YBConsistencyLevel::STRONG) {
29
4.93M
}
30
31
StatementParameters::StatementParameters(const StatementParameters& other)
32
    : page_size_(other.page_size_),
33
      paging_state_(
34
        other.paging_state_ != nullptr ? new QLPagingStatePB(*other.paging_state_) : nullptr),
35
0
      yb_consistency_level_(YBConsistencyLevel::STRONG) {
36
0
}
37
38
4.92M
StatementParameters::~StatementParameters() {
39
4.92M
}
40
41
4.81M
ReadHybridTime StatementParameters::read_time() const {
42
4.81M
  if (!paging_state_) {
43
4.81M
    return ReadHybridTime();
44
4.81M
  }
45
46
2.67k
  return ReadHybridTime::FromReadTimePB(*paging_state_);
47
2.67k
}
48
49
279
Status StatementParameters::SetPagingState(const std::string& paging_state) {
50
  // For performance, create QLPagingStatePB on demand only when setting paging state because
51
  // only SELECT statements continuing from a previous page carry a paging state.
52
279
  if (paging_state_ == nullptr) {
53
279
    paging_state_.reset(new QLPagingStatePB());
54
279
  }
55
279
  if (!paging_state_->ParseFromString(paging_state)) {
56
0
    return STATUS(Corruption, "Invalid paging state");
57
0
  }
58
59
279
  if (paging_state_->has_original_request_id()) {
60
279
    request_id_ = paging_state_->original_request_id();
61
279
  }
62
63
279
  return Status::OK();
64
279
}
65
66
Result<bool> StatementParameters::IsBindVariableUnset(const std::string& name,
67
0
                                         int64_t pos) const {
68
0
  return STATUS(RuntimeError, "no bind variable available");
69
0
}
70
71
// Retrieve a bind variable for the execution of the statement. To be overridden by subclasses
72
// to return actual bind variables.
73
Status StatementParameters::GetBindVariable(const std::string& name,
74
                                            int64_t pos,
75
                                            const std::shared_ptr<QLType>& type,
76
0
                                            QLValue* value) const {
77
0
  return STATUS(RuntimeError, "no bind variable available");
78
0
}
79
80
} // namespace ql
81
} // namespace yb