YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/yql/pggate/util/pg_tuple.cc
Line
Count
Source
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/pggate/util/pg_tuple.h"
16
17
#include "yb/client/client.h"
18
19
#include "yb/common/ybc-internal.h"
20
21
namespace yb {
22
namespace pggate {
23
24
PgTuple::PgTuple(uint64_t *datums, bool *isnulls, PgSysColumns *syscols)
25
53.1M
    : datums_(datums), isnulls_(isnulls), syscols_(syscols) {
26
53.1M
}
27
28
63.6M
void PgTuple::WriteNull(int index, const PgWireDataHeader& header) {
29
63.6M
  isnulls_[index] = true;
30
63.6M
  datums_[index] = 0;
31
63.6M
}
32
33
534M
void PgTuple::WriteDatum(int index, uint64_t datum) {
34
534M
  isnulls_[index] = false;
35
534M
  datums_[index] = datum;
36
534M
}
37
38
void PgTuple::Write(uint8_t **pgbuf, const PgWireDataHeader& header, const uint8_t *value,
39
43.2M
                    int64_t bytes) {
40
  // TODO: return a status instead of crashing.
41
43.2M
  CHECK_LE(bytes, kYBCMaxPostgresTextSizeBytes);
42
43.2M
  CHECK_GE(bytes, 0);
43
43.2M
  *pgbuf = static_cast<uint8_t*>(YBCCStringToTextWithLen(reinterpret_cast<const char*>(value),
44
43.2M
                                                         static_cast<int>(bytes)));
45
43.2M
}
46
47
}  // namespace pggate
48
}  // namespace yb