YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/docdb/docdb_pgapi.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/docdb/docdb_pgapi.h"
16
17
#include "yb/common/ql_expr.h"
18
#include "yb/common/schema.h"
19
20
#include "yb/gutil/singleton.h"
21
#include "yb/yql/pggate/ybc_pg_typedefs.h"
22
#include "yb/yql/pggate/pg_value.h"
23
#include "yb/yql/pggate/pg_expr.h"
24
#include "yb/yql/pggate/ybc_pggate.h"
25
26
27
#include "yb/util/result.h"
28
29
// This file comes from this directory:
30
// postgres_build/src/include/catalog
31
// added as a special include path to CMakeLists.txt
32
#include "pg_type_d.h" // NOLINT
33
34
using yb::pggate::PgValueFromPB;
35
using yb::pggate::PgValueToPB;
36
37
namespace yb {
38
namespace docdb {
39
40
#define PG_RETURN_NOT_OK(status) \
41
280k
  do { \
42
280k
    if (status.err_code != 0) { \
43
0
      std::string msg; \
44
0
      if (status.err_msg != nullptr) { \
45
0
        msg = std::string(status.err_msg); \
46
0
      } else { \
47
0
        msg = std::string("Unexpected error while evaluating expression"); \
48
0
      } \
49
0
      YbgResetMemoryContext(); \
50
0
      return STATUS(QLError, msg); \
51
0
    } \
52
280k
  } while(0);
53
54
#define SET_ELEM_LEN_BYVAL_ALIGN(elemlen, elembyval, elemalign) \
55
102
  do { \
56
102
    elmlen = elemlen; \
57
102
    elmbyval = elembyval; \
58
102
    elmalign = elemalign; \
59
102
  } while (0);
60
61
#define SET_ELEM_LEN_BYVAL_ALIGN_OPT(elemlen, elembyval, elemalign, opt) \
62
6
  do { \
63
6
    elmlen = elemlen; \
64
6
    elmbyval = elembyval; \
65
6
    elmalign = elemalign; \
66
6
    option = opt; \
67
6
  } while (0);
68
69
#define SET_RANGE_ELEM_LEN_BYVAL_ALIGN(elemlen, elembyval, elemalign, \
70
                                       range_elemlen, range_elembyval, range_elemalign) \
71
18
  do { \
72
18
    elmlen = elemlen; \
73
18
    elmbyval = elembyval; \
74
18
    elmalign = elemalign; \
75
18
    range_elmlen = range_elemlen; \
76
18
    range_elmbyval = range_elembyval; \
77
18
    range_elmalign = range_elemalign; \
78
18
  } while (0);
79
80
//-----------------------------------------------------------------------------
81
// Types
82
//-----------------------------------------------------------------------------
83
84
class DocPgTypeAnalyzer {
85
 public:
86
49.1k
  const YBCPgTypeEntity* GetTypeEntity(int32_t type_oid) {
87
49.1k
    const auto iter = type_map_.find(type_oid);
88
49.1k
    if (iter != type_map_.end()) {
89
49.1k
      return iter->second;
90
49.1k
    }
91
6
    LOG(FATAL) << "Could not find type entity for oid " << type_oid;
92
6
    return nullptr;
93
6
  }
94
95
 private:
96
428
  DocPgTypeAnalyzer() {
97
    // Setup type mapping.
98
428
    const YBCPgTypeEntity *type_table;
99
428
    int count;
100
101
428
    YbgGetTypeTable(&type_table, &count);
102
69.7k
    for (int idx = 0; idx < count; idx++) {
103
69.3k
        const YBCPgTypeEntity *type_entity = &type_table[idx];
104
69.3k
        type_map_[type_entity->type_oid] = type_entity;
105
69.3k
    }
106
428
  }
107
108
  // Mapping table of YugaByte and PostgreSQL datatypes.
109
  std::unordered_map<int, const YBCPgTypeEntity *> type_map_;
110
111
  friend class Singleton<DocPgTypeAnalyzer>;
112
  DISALLOW_COPY_AND_ASSIGN(DocPgTypeAnalyzer);
113
};
114
115
//-----------------------------------------------------------------------------
116
// Expressions/Values
117
//-----------------------------------------------------------------------------
118
119
49.1k
const YBCPgTypeEntity* DocPgGetTypeEntity(YbgTypeDesc pg_type) {
120
49.1k
    return Singleton<DocPgTypeAnalyzer>::get()->GetTypeEntity(pg_type.type_id);
121
49.1k
}
122
123
Status DocPgAddVarRef(const ColumnId& column_id,
124
                      int32_t attno,
125
                      int32_t typid,
126
                      int32_t typmod,
127
                      int32_t collid,
128
4.28k
                      std::map<int, const DocPgVarRef> *var_map) {
129
4.28k
  if (var_map->find(attno) != var_map->end()) {
130
0
    VLOG(1) << "Attribute " << attno << " is already processed";
131
0
    return Status::OK();
132
0
  }
133
4.28k
  const YBCPgTypeEntity *arg_type = DocPgGetTypeEntity({typid, typmod});
134
4.28k
  var_map->emplace(std::piecewise_construct,
135
4.28k
                   std::forward_as_tuple(attno),
136
4.28k
                   std::forward_as_tuple(column_id.rep(), arg_type, typmod));
137
7
  VLOG(1) << "Attribute " << attno << " has been processed";
138
4.28k
  return Status::OK();
139
4.28k
}
140
141
Status DocPgPrepareExpr(const std::string& expr_str,
142
                        YbgPreparedExpr *expr,
143
6.11k
                        DocPgVarRef *ret_type) {
144
6.11k
  char *expr_cstring = const_cast<char *>(expr_str.c_str());
145
4
  VLOG(1) << "Deserialize " << expr_cstring;
146
6.11k
  PG_RETURN_NOT_OK(YbgPrepareExpr(expr_cstring, expr));
147
6.11k
  if (ret_type != nullptr) {
148
5.74k
    int32_t typid;
149
5.74k
    int32_t typmod;
150
5.74k
    PG_RETURN_NOT_OK(YbgExprType(*expr, &typid));
151
5.74k
    PG_RETURN_NOT_OK(YbgExprTypmod(*expr, &typmod));
152
5.74k
    YbgTypeDesc pg_arg_type = {typid, typmod};
153
5.74k
    const YBCPgTypeEntity *arg_type = DocPgGetTypeEntity(pg_arg_type);
154
5.74k
    *ret_type = DocPgVarRef(0, arg_type, typmod);
155
0
    VLOG(1) << "Processed expression return type";
156
5.74k
  }
157
6.11k
  return Status::OK();
158
6.11k
}
159
160
Status DocPgCreateExprCtx(const std::map<int, const DocPgVarRef>& var_map,
161
4.28k
                          YbgExprContext *expr_ctx) {
162
4.28k
  if (var_map.empty()) {
163
0
    return Status::OK();
164
0
  }
165
166
4.28k
  int32_t min_attno = var_map.begin()->first;
167
4.28k
  int32_t max_attno = var_map.rbegin()->first;
168
169
4
  VLOG(2) << "Allocating expr context: (" << min_attno << ", " << max_attno << ")";
170
4.28k
  PG_RETURN_NOT_OK(YbgExprContextCreate(min_attno, max_attno, expr_ctx));
171
4.28k
  return Status::OK();
172
4.28k
}
173
174
Status DocPgPrepareExprCtx(const QLTableRow& table_row,
175
                           const std::map<int, const DocPgVarRef>& var_map,
176
58.7k
                           YbgExprContext expr_ctx) {
177
58.7k
  PG_RETURN_NOT_OK(YbgExprContextReset(expr_ctx));
178
  // Set the column values (used to resolve scan variables in the expression).
179
118k
  for (auto it = var_map.begin(); it != var_map.end(); it++) {
180
59.4k
    const int& attno = it->first;
181
59.4k
    const DocPgVarRef& arg_ref = it->second;
182
59.4k
    const QLValuePB* val = table_row.GetColumn(arg_ref.var_colid);
183
59.4k
    bool is_null = false;
184
59.4k
    uint64_t datum = 0;
185
59.4k
    RETURN_NOT_OK(PgValueFromPB(arg_ref.var_type, arg_ref.var_type_attrs, *val, &datum, &is_null));
186
783
    VLOG(1) << "Adding value for attno " << attno;
187
59.4k
    PG_RETURN_NOT_OK(YbgExprContextAddColValue(expr_ctx, attno, datum, is_null));
188
59.4k
  }
189
58.7k
  return Status::OK();
190
58.7k
}
191
192
Status DocPgEvalExpr(YbgPreparedExpr expr,
193
                     YbgExprContext expr_ctx,
194
                     uint64_t *datum,
195
62.3k
                     bool *is_null) {
196
  // Evaluate the expression and get the result.
197
62.3k
  PG_RETURN_NOT_OK(YbgEvalExpr(expr, expr_ctx, datum, is_null));
198
62.3k
  return Status::OK();
199
62.3k
}
200
201
Status SetValueFromQLBinary(const QLValuePB ql_value,
202
                            const int pg_data_type,
203
39.1k
                            DatumMessagePB* cdc_datum_message) {
204
39.1k
  PG_RETURN_NOT_OK(YbgPrepareMemoryContext());
205
206
39.1k
  RETURN_NOT_OK(SetValueFromQLBinaryHelper(
207
39.1k
    ql_value,
208
39.1k
    pg_data_type,
209
39.1k
    cdc_datum_message));
210
39.1k
  PG_RETURN_NOT_OK(YbgResetMemoryContext());
211
39.1k
  return Status::OK();
212
39.1k
}
213
214
Status ExtractTextArrayFromQLBinaryValue(const QLValuePB& ql_value,
215
0
                                         vector<QLValuePB> *const ql_value_vec) {
216
0
  PG_RETURN_NOT_OK(YbgPrepareMemoryContext());
217
218
0
  RETURN_NOT_OK(ExtractVectorFromQLBinaryValueHelper(
219
0
      ql_value,
220
0
      TEXTARRAYOID,
221
0
      TEXTOID,
222
0
      ql_value_vec));
223
0
  PG_RETURN_NOT_OK(YbgResetMemoryContext());
224
0
  return Status::OK();
225
0
}
226
227
void set_decoded_string_value(
228
    uint64_t datum,
229
    const char* func_name,
230
    DatumMessagePB* cdc_datum_message = nullptr,
231
106
    const char* timezone = nullptr) {
232
106
  char *decoded_str = nullptr;
233
234
106
  if (func_name == nullptr) {
235
0
    return;
236
0
  }
237
238
106
  if (timezone == nullptr)
239
103
    decoded_str = DecodeDatum(func_name, (uintptr_t)datum);
240
3
  else
241
3
    decoded_str = DecodeTZDatum(func_name, (uintptr_t)datum, timezone, true);
242
243
106
  cdc_datum_message->set_datum_string(decoded_str, strlen(decoded_str));
244
106
}
245
246
void set_decoded_string_range(
247
    const QLValuePB ql_value,
248
    const YBCPgTypeEntity* arg_type,
249
    const int elem_type,
250
    const char* func_name,
251
    DatumMessagePB* cdc_datum_message = nullptr,
252
15
    const char* timezone = nullptr) {
253
15
  YBCPgTypeAttrs type_attrs{-1 /* typmod */};
254
255
15
  char* decoded_str = nullptr;
256
15
  string range_val = ql_value.binary_value();
257
15
  uint64_t size = range_val.size();
258
15
  char* val = const_cast<char *>(range_val.c_str());
259
15
  uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
260
261
15
  int16 elmlen;
262
15
  bool elmbyval;
263
15
  char elmalign;
264
15
  bool from_YB = true;
265
15
  char option = '\0';
266
267
15
  switch (elem_type) {
268
3
    case INT4OID:
269
3
      SET_ELEM_LEN_BYVAL_ALIGN(sizeof(int32), true, 'i');
270
3
      break;
271
272
0
    case NUMERICOID:
273
0
      SET_ELEM_LEN_BYVAL_ALIGN(-1, false, 'i');
274
0
      break;
275
276
3
    case TIMESTAMPOID:
277
6
    case INT8OID:
278
6
      SET_ELEM_LEN_BYVAL_ALIGN(sizeof(int64), true, 'i');
279
6
      break;
280
281
3
    case TIMESTAMPTZOID:
282
3
      SET_ELEM_LEN_BYVAL_ALIGN_OPT(sizeof(int64), true, 'i', 't');
283
3
      break;
284
285
3
    case DATEOID:
286
3
      SET_ELEM_LEN_BYVAL_ALIGN(sizeof(int32), true, 'i');
287
3
      break;
288
289
0
    default:
290
0
      SET_ELEM_LEN_BYVAL_ALIGN(-1, false, 'i');
291
0
      break;
292
15
  }
293
294
15
  if (func_name != nullptr) {
295
15
    decoded_str = DecodeRangeDatum(
296
15
        "range_out", (uintptr_t)datum, elmlen, elmbyval, elmalign, option, from_YB, func_name,
297
15
        arg_type->type_oid, timezone);
298
299
15
    cdc_datum_message->set_datum_string(decoded_str, strlen(decoded_str));
300
15
  }
301
15
}
302
303
void set_decoded_string_array(const QLValuePB ql_value,
304
                              const YBCPgTypeEntity* arg_type,
305
                              const int elem_type,
306
                              const char* func_name,
307
                              DatumMessagePB* cdc_datum_message = nullptr,
308
93
                              const char* timezone = nullptr) {
309
93
  YBCPgTypeAttrs type_attrs{-1 /* typmod */};
310
311
93
  char* decoded_str = nullptr;
312
93
  string vector_val = ql_value.binary_value();
313
93
  uint64_t size = vector_val.size();
314
93
  char* val = const_cast<char *>(vector_val.c_str());
315
93
  uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
316
317
93
  int16 elmlen;
318
93
  bool elmbyval;
319
93
  char elmalign;
320
93
  char elmdelim = ',';
321
93
  bool from_YB = true;
322
93
  char option = '\0';
323
324
93
  switch (elem_type) {
325
3
    case TEXTOID:
326
3
    case XMLOID:
327
3
    case BYTEAOID:
328
3
    case INT2VECTOROID:
329
3
    case CHAROID:
330
3
    case REGPROCOID:
331
3
    case TIDOID:
332
6
    case CIDROID:
333
6
    case OIDVECTOROID:
334
9
    case BPCHAROID:
335
12
    case VARCHAROID:
336
15
    case PATHOID:
337
15
    case RELTIMEOID:
338
15
    case TINTERVALOID:
339
15
    case ACLITEMOID:
340
18
    case INETOID:
341
18
    case NUMERICOID:
342
18
    case BITOID:
343
21
    case VARBITOID:
344
21
    case REGPROCEDUREOID:
345
21
    case REGOPEROID:
346
21
    case REGOPERATOROID:
347
21
    case REGCLASSOID:
348
21
    case REGTYPEOID:
349
21
    case REGROLEOID:
350
21
    case REGNAMESPACEOID:
351
21
    case TSVECTOROID:
352
21
    case GTSVECTOROID:
353
21
    case TSQUERYOID:
354
21
    case REGCONFIGOID:
355
21
    case REGDICTIONARYOID:
356
24
    case JSONOID:
357
27
    case JSONBOID:
358
30
    case TXID_SNAPSHOTOID:
359
30
    case RECORDOID:
360
33
    case POLYGONOID:
361
33
      SET_ELEM_LEN_BYVAL_ALIGN(-1, false, 'i');
362
33
      break;
363
364
3
    case LINEOID:
365
6
    case CIRCLEOID:
366
6
      SET_ELEM_LEN_BYVAL_ALIGN(24, false, 'd');
367
6
      break;
368
369
3
    case CASHOID:
370
3
    case INT8OID:
371
6
    case TIMESTAMPOID:
372
9
    case TIMEOID:
373
9
      SET_ELEM_LEN_BYVAL_ALIGN(sizeof(int64), true, 'd');
374
9
      break;
375
376
3
    case BOOLOID:
377
3
      SET_ELEM_LEN_BYVAL_ALIGN(sizeof(bool), true, 'c');
378
3
      break;
379
380
0
    case NAMEOID:
381
0
      SET_ELEM_LEN_BYVAL_ALIGN(64, false, 'c');
382
0
      break;
383
384
3
    case INT2OID:
385
3
      SET_ELEM_LEN_BYVAL_ALIGN(2, true, 's');
386
3
      break;
387
388
3
    case INT4OID:
389
3
    case ABSTIMEOID:
390
6
    case DATEOID:
391
6
    case ANYOID:
392
6
      SET_ELEM_LEN_BYVAL_ALIGN(sizeof(int32), true, 'i');
393
6
      break;
394
395
0
    case OIDOID:
396
0
    case CIDOID:
397
3
    case FLOAT4OID:
398
3
      SET_ELEM_LEN_BYVAL_ALIGN(4, true, 'i');
399
3
      break;
400
401
0
    case XIDOID:
402
0
      SET_ELEM_LEN_BYVAL_ALIGN(16/*sizeof(TransactionId)*/, true, 'i');
403
0
      break;
404
405
3
    case POINTOID:
406
6
    case INTERVALOID:
407
6
      SET_ELEM_LEN_BYVAL_ALIGN(16, false, 'd');
408
6
      break;
409
410
3
    case LSEGOID:
411
3
      SET_ELEM_LEN_BYVAL_ALIGN(32, false, 'd');
412
3
      break;
413
414
3
    case BOXOID:
415
3
      SET_ELEM_LEN_BYVAL_ALIGN(32, false, 'd');
416
3
      elmdelim = ';';
417
3
      break;
418
419
3
    case FLOAT8OID:
420
3
      SET_ELEM_LEN_BYVAL_ALIGN(8, true, 'd');
421
3
      break;
422
423
3
    case MACADDROID:
424
3
      SET_ELEM_LEN_BYVAL_ALIGN(6, false, 'i');
425
3
      break;
426
427
3
    case MACADDR8OID:
428
3
      SET_ELEM_LEN_BYVAL_ALIGN(8, false, 'i');
429
3
      break;
430
431
0
    case CSTRINGOID:
432
0
      SET_ELEM_LEN_BYVAL_ALIGN(-1, false, 'c');
433
0
      break;
434
435
3
    case TIMESTAMPTZOID:
436
3
      SET_ELEM_LEN_BYVAL_ALIGN_OPT(sizeof(int64), true, 'd', 't');
437
3
      break;
438
439
3
    case TIMETZOID:
440
3
      SET_ELEM_LEN_BYVAL_ALIGN(12, false, 'd');
441
3
      break;
442
443
3
    case UUIDOID:
444
3
      SET_ELEM_LEN_BYVAL_ALIGN(16, false, 'c');
445
3
      break;
446
447
0
    case LSNOID:
448
0
      SET_ELEM_LEN_BYVAL_ALIGN(sizeof(uint64), true, 'i');
449
0
      break;
450
451
0
    case INT4RANGEOID:
452
0
    case NUMRANGEOID:
453
0
    case TSRANGEOID:
454
0
    case TSTZRANGEOID:
455
0
    case DATERANGEOID:
456
0
    case INT8RANGEOID:
457
0
      SET_ELEM_LEN_BYVAL_ALIGN_OPT(-1, false, 'i', 'r');
458
0
      break;
459
460
0
    default:
461
0
      SET_ELEM_LEN_BYVAL_ALIGN(-1, false, 'i');
462
0
      break;
463
93
  }
464
465
93
  if (func_name != nullptr) {
466
93
    decoded_str = DecodeArrayDatum(
467
93
        "array_out", (uintptr_t)datum, elmlen, elmbyval, elmalign, elmdelim, from_YB, func_name,
468
93
        timezone, option);
469
470
93
    cdc_datum_message->set_datum_string(decoded_str, strlen(decoded_str));
471
93
  }
472
93
}
473
474
void set_decoded_string_range_array(
475
    const QLValuePB ql_value,
476
    const YBCPgTypeEntity *arg_type,
477
    const int elem_type,
478
    const char *func_name,
479
    DatumMessagePB *cdc_datum_message = nullptr,
480
18
    const char *timezone = nullptr) {
481
18
  YBCPgTypeAttrs type_attrs{-1 /* typmod */};
482
483
18
  char* decoded_str = nullptr;
484
18
  string arr_val = ql_value.binary_value();
485
18
  uint64_t size = arr_val.size();
486
18
  char* val = const_cast<char *>(arr_val.c_str());
487
18
  uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
488
489
18
  int16 elmlen, range_elmlen;
490
18
  bool elmbyval, range_elmbyval;
491
18
  char elmalign, range_elmalign;
492
18
  char elmdelim = ',';
493
18
  bool from_YB = true;
494
18
  char option = 'r';
495
18
  char range_option = '\0';
496
497
18
  switch (elem_type) {
498
3
    case INT4RANGEOID:
499
6
    case DATERANGEOID:
500
6
      SET_RANGE_ELEM_LEN_BYVAL_ALIGN(-1, false, 'i', sizeof(int32), true, 'i');
501
6
      break;
502
503
3
    case NUMRANGEOID:
504
3
      SET_RANGE_ELEM_LEN_BYVAL_ALIGN(-1, false, 'i', -1, false, 'i');
505
3
      break;
506
507
3
    case TSRANGEOID:
508
6
    case INT8RANGEOID:
509
6
      SET_RANGE_ELEM_LEN_BYVAL_ALIGN(-1, false, 'd', sizeof(int64), true, 'i');
510
6
      break;
511
512
3
    case TSTZRANGEOID:
513
3
      SET_RANGE_ELEM_LEN_BYVAL_ALIGN(-1, false, 'd', sizeof(int64), true, 'i');
514
3
      range_option = 't';
515
3
      break;
516
517
0
    default:
518
0
      SET_RANGE_ELEM_LEN_BYVAL_ALIGN(-1, false, 'i', -1, false, 'i');
519
0
      break;
520
18
  }
521
522
18
  if (func_name != nullptr) {
523
18
    decoded_str = DecodeRangeArrayDatum(
524
18
        "array_out", (uintptr_t)datum, elmlen, range_elmlen, elmbyval, range_elmbyval, elmalign,
525
18
        range_elmalign, elmdelim, option, range_option, from_YB, "range_out", func_name, elem_type,
526
18
        timezone);
527
528
18
    cdc_datum_message->set_datum_string(decoded_str, strlen(decoded_str));
529
18
  }
530
18
}
531
532
103
void set_string_value(uint64_t datum, char const *func_name, DatumMessagePB *cdc_datum_message) {
533
103
  set_decoded_string_value(datum, func_name, cdc_datum_message);
534
103
}
535
536
void set_range_string_value(
537
    const QLValuePB ql_value,
538
    const YBCPgTypeEntity* arg_type,
539
    const int type_oid,
540
    char const* func_name,
541
12
    DatumMessagePB* cdc_datum_message) {
542
12
  set_decoded_string_range(ql_value, arg_type, type_oid, func_name, cdc_datum_message);
543
12
}
544
545
void set_array_string_value(
546
    const QLValuePB ql_value,
547
    const YBCPgTypeEntity* arg_type,
548
    const int type_oid,
549
    char const* func_name,
550
90
    DatumMessagePB* cdc_datum_message) {
551
90
  set_decoded_string_array(ql_value, arg_type, type_oid, func_name, cdc_datum_message);
552
90
}
553
554
void set_range_array_string_value(
555
    const QLValuePB ql_value,
556
    const YBCPgTypeEntity* arg_type,
557
    const int type_oid,
558
    char const* func_name,
559
15
    DatumMessagePB* cdc_datum_message) {
560
15
  set_decoded_string_range_array(ql_value, arg_type, type_oid, func_name, cdc_datum_message);
561
15
}
562
563
// This function expects that YbgPrepareMemoryContext was called
564
// by the caller of this function.
565
Status SetValueFromQLBinaryHelper(
566
39.1k
    const QLValuePB ql_value, const int pg_data_type, DatumMessagePB *cdc_datum_message) {
567
39.1k
  uint64_t size;
568
39.1k
  char* val;
569
39.1k
  const char* timezone = "GMT";
570
39.1k
  char const* func_name = nullptr;
571
572
39.1k
  YbgTypeDesc pg_arg_type{pg_data_type, -1 /* typmod */};
573
39.1k
  const YBCPgTypeEntity* arg_type = DocPgGetTypeEntity(pg_arg_type);
574
575
39.1k
  YBCPgTypeAttrs type_attrs{-1 /* typmod */};
576
577
39.1k
  cdc_datum_message->set_column_type(pg_data_type);
578
579
39.1k
  switch (arg_type->type_oid) {
580
4
    case BOOLOID: {
581
4
      func_name = "boolout";
582
4
      bool bool_val = ql_value.bool_value();
583
4
      cdc_datum_message->set_datum_bool(bool_val);
584
4
      break;
585
0
    }
586
4
    case BYTEAOID: {
587
4
      func_name = "byteaout";
588
4
      string bytea_val = ql_value.binary_value();
589
4
      size = bytea_val.size();
590
4
      val = const_cast<char *>(bytea_val.c_str());
591
4
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<void *>(val), size, &type_attrs);
592
4
      set_string_value(datum, func_name, cdc_datum_message);
593
4
      break;
594
0
    }
595
0
    case CHAROID: {
596
0
      func_name = "charout";
597
0
      int char_val = ql_value.int8_value();
598
0
      size = sizeof(int);
599
0
      uint64_t datum =
600
0
          arg_type->yb_to_datum(reinterpret_cast<char *>(&char_val), size, &type_attrs);
601
0
      set_string_value(datum, func_name, cdc_datum_message);
602
0
      break;
603
0
    }
604
0
    case NAMEOID: {
605
0
      func_name = "nameout";
606
0
      string name_val = ql_value.string_value();
607
0
      size = name_val.size();
608
0
      val = const_cast<char *>(name_val.c_str());
609
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<char *>(val), size, &type_attrs);
610
0
      set_string_value(datum, func_name, cdc_datum_message);
611
0
      break;
612
0
    }
613
0
    case INT8OID: {
614
0
      func_name = "int8out";
615
0
      int64_t int8_val = ql_value.int64_value();
616
0
      cdc_datum_message->set_datum_int64(int8_val);
617
0
      break;
618
0
    }
619
0
    case INT2OID: {
620
0
      func_name = "int2out";
621
0
      int int2_val = ql_value.int16_value();
622
0
      cdc_datum_message->set_datum_int32(int2_val);
623
0
      break;
624
0
    }
625
38.9k
    case INT4OID: {
626
38.9k
      func_name = "int4out";
627
38.9k
      int int4_val = ql_value.int32_value();
628
38.9k
      cdc_datum_message->set_datum_int32(int4_val);
629
38.9k
      break;
630
0
    }
631
0
    case REGPROCOID: {
632
0
      func_name = "regprocout";
633
0
      int regproc_val = ql_value.uint32_value();
634
0
      size = arg_type->datum_fixed_size;
635
0
      uint64_t datum =
636
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&regproc_val), size, &type_attrs);
637
0
      set_string_value(datum, func_name, cdc_datum_message);
638
0
      break;
639
0
    }
640
5
    case TEXTOID: {
641
5
      func_name = "textout";
642
5
      string text_val = ql_value.string_value();
643
5
      size = text_val.size();
644
5
      val = const_cast<char *>(text_val.c_str());
645
5
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<char *>(val), size, &type_attrs);
646
5
      set_string_value(datum, func_name, cdc_datum_message);
647
5
      break;
648
0
    }
649
0
    case OIDOID: {
650
0
      func_name = "oidout";
651
0
      uint32 oid_val = ql_value.uint32_value();
652
0
      cdc_datum_message->set_datum_int64(oid_val);
653
0
      break;
654
0
    }
655
0
    case TIDOID: {
656
0
      func_name = "tidout";
657
0
      string tid_val = ql_value.binary_value();
658
0
      size = arg_type->datum_fixed_size;
659
0
      val = const_cast<char *>(tid_val.c_str());
660
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
661
0
      set_string_value(datum, func_name, cdc_datum_message);
662
0
      break;
663
0
    }
664
0
    case XIDOID: {
665
0
      func_name = "xidout";
666
0
      uint32 xid_val = ql_value.uint32_value();
667
0
      size = arg_type->datum_fixed_size;
668
0
      uint64_t datum =
669
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&xid_val), size, &type_attrs);
670
0
      set_string_value(datum, func_name, cdc_datum_message);
671
0
      break;
672
0
    }
673
0
    case CIDOID: {
674
0
      func_name = "cidout";
675
0
      uint32 cid_val = ql_value.uint32_value();
676
0
      size = arg_type->datum_fixed_size;
677
0
      uint64_t datum =
678
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&cid_val), size, &type_attrs);
679
0
      set_string_value(datum, func_name, cdc_datum_message);
680
0
      break;
681
0
    }
682
5
    case JSONOID: {
683
5
      func_name = "json_out";
684
5
      string json_val = ql_value.binary_value();
685
5
      size = json_val.size();
686
5
      val = const_cast<char *>(json_val.c_str());
687
5
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
688
5
      set_string_value(datum, func_name, cdc_datum_message);
689
5
      break;
690
0
    }
691
0
    case XMLOID: {
692
0
      func_name = "xml_out";
693
0
      string xml_val = ql_value.binary_value();
694
0
      size = xml_val.size();
695
0
      val = const_cast<char *>(xml_val.c_str());
696
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
697
0
      set_string_value(datum, func_name, cdc_datum_message);
698
0
      break;
699
0
    }
700
0
    case PGNODETREEOID: {
701
0
      func_name = "pg_node_tree_out";
702
0
      string pg_node_tree_val = ql_value.binary_value();
703
0
      size = pg_node_tree_val.size();
704
0
      val = const_cast<char *>(pg_node_tree_val.c_str());
705
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<void *>(val), size, &type_attrs);
706
0
      set_string_value(datum, func_name, cdc_datum_message);
707
0
      break;
708
0
    }
709
0
    case PGNDISTINCTOID: {
710
0
      func_name = "pg_ndistinct_out";
711
0
      string pg_ndistinct_val = ql_value.binary_value();
712
0
      size = pg_ndistinct_val.size();
713
0
      val = const_cast<char *>(pg_ndistinct_val.c_str());
714
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<void *>(val), size, &type_attrs);
715
0
      set_string_value(datum, func_name, cdc_datum_message);
716
0
      break;
717
0
    }
718
0
    case PGDEPENDENCIESOID: {
719
0
      func_name = "pg_dependencies_out";
720
0
      string pg_dependencies_val = ql_value.binary_value();
721
0
      size = pg_dependencies_val.size();
722
0
      val = const_cast<char *>(pg_dependencies_val.c_str());
723
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<void *>(val), size, &type_attrs);
724
0
      set_string_value(datum, func_name, cdc_datum_message);
725
0
      break;
726
0
    }
727
0
    case PGDDLCOMMANDOID: {
728
0
      func_name = "pg_ddl_command_out";
729
0
      int64_t pg_ddl_command_val = ql_value.int64_value();
730
0
      size = arg_type->datum_fixed_size;
731
0
      uint64_t datum =
732
0
          arg_type->yb_to_datum(reinterpret_cast<int64 *>(&pg_ddl_command_val), size, &type_attrs);
733
0
      set_string_value(datum, func_name, cdc_datum_message);
734
0
      break;
735
0
    }
736
0
    case SMGROID: {
737
0
      func_name = "smgrout";
738
0
      int smgr_val = ql_value.int16_value();
739
0
      size = arg_type->datum_fixed_size;
740
0
      uint64_t datum =
741
0
          arg_type->yb_to_datum(reinterpret_cast<int16 *>(&smgr_val), size, &type_attrs);
742
0
      set_string_value(datum, func_name, cdc_datum_message);
743
0
      break;
744
0
    }
745
4
    case POINTOID: {
746
4
      func_name = "point_out";
747
4
      string point_val = ql_value.binary_value();
748
4
      size = arg_type->datum_fixed_size;
749
4
      val = const_cast<char *>(point_val.c_str());
750
4
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
751
4
      set_string_value(datum, func_name, cdc_datum_message);
752
4
      break;
753
0
    }
754
4
    case LSEGOID: {
755
4
      func_name = "lseg_out";
756
4
      string lseg_val = ql_value.binary_value();
757
4
      size = arg_type->datum_fixed_size;
758
4
      val = const_cast<char *>(lseg_val.c_str());
759
4
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<int8 *>(val), size, &type_attrs);
760
4
      set_string_value(datum, func_name, cdc_datum_message);
761
4
      break;
762
0
    }
763
4
    case PATHOID: {
764
4
      func_name = "path_out";
765
4
      string path_val = ql_value.binary_value();
766
4
      size = path_val.size();
767
4
      val = const_cast<char *>(path_val.c_str());
768
4
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
769
4
      set_string_value(datum, func_name, cdc_datum_message);
770
4
      break;
771
0
    }
772
4
    case BOXOID: {
773
4
      func_name = "box_out";
774
4
      string box_val = ql_value.binary_value();
775
4
      size = arg_type->datum_fixed_size;
776
4
      val = const_cast<char *>(box_val.c_str());
777
4
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
778
4
      set_string_value(datum, func_name, cdc_datum_message);
779
4
      break;
780
0
    }
781
4
    case LINEOID: {
782
4
      func_name = "line_out";
783
4
      string line_val = ql_value.binary_value();
784
4
      size = arg_type->datum_fixed_size;
785
4
      val = const_cast<char *>(line_val.c_str());
786
4
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
787
4
      set_string_value(datum, func_name, cdc_datum_message);
788
4
      break;
789
0
    }
790
0
    case FLOAT4OID: {
791
0
      func_name = "float4out";
792
0
      float float4_val = ql_value.float_value();
793
0
      cdc_datum_message->set_datum_float(float4_val);
794
0
      break;
795
0
    }
796
4
    case FLOAT8OID: {
797
4
      func_name = "float8out";
798
4
      double float8_val = ql_value.double_value();
799
4
      cdc_datum_message->set_datum_double(float8_val);
800
4
      break;
801
0
    }
802
4
    case CIRCLEOID: {
803
4
      func_name = "circle_out";
804
4
      string circle_val = ql_value.binary_value();
805
4
      size = arg_type->datum_fixed_size;
806
4
      val = const_cast<char *>(circle_val.c_str());
807
4
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
808
4
      set_string_value(datum, func_name, cdc_datum_message);
809
4
      break;
810
0
    }
811
5
    case CASHOID: {
812
5
      func_name = "cash_out";
813
5
      int64_t cash_val = ql_value.int64_value();
814
5
      size = arg_type->datum_fixed_size;
815
5
      val = reinterpret_cast<char *>(&cash_val);
816
5
      uint64_t datum =
817
5
          arg_type->yb_to_datum(reinterpret_cast<int64 *>(&cash_val), size, &type_attrs);
818
5
      set_string_value(datum, func_name, cdc_datum_message);
819
5
      break;
820
0
    }
821
4
    case MACADDROID: {
822
4
      func_name = "macaddr_out";
823
4
      string macaddr_val = ql_value.binary_value();
824
4
      size = arg_type->datum_fixed_size;
825
4
      val = const_cast<char *>(macaddr_val.c_str());
826
4
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
827
4
      set_string_value(datum, func_name, cdc_datum_message);
828
4
      break;
829
0
    }
830
4
    case INETOID: {
831
4
      func_name = "inet_out";
832
4
      string inet_val = ql_value.binary_value();
833
4
      size = inet_val.size();
834
4
      val = const_cast<char *>(inet_val.c_str());
835
4
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
836
4
      set_string_value(datum, func_name, cdc_datum_message);
837
4
      break;
838
0
    }
839
4
    case CIDROID: {
840
4
      func_name = "cidr_out";
841
4
      string cidr_val = ql_value.binary_value();
842
4
      size = cidr_val.size();
843
4
      val = const_cast<char *>(cidr_val.c_str());
844
4
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
845
4
      set_string_value(datum, func_name, cdc_datum_message);
846
4
      break;
847
0
    }
848
5
    case MACADDR8OID: {
849
5
      func_name = "macaddr8_out";
850
5
      string macaddr8_val = ql_value.binary_value();
851
5
      size = arg_type->datum_fixed_size;
852
5
      val = const_cast<char *>(macaddr8_val.c_str());
853
5
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
854
5
      set_string_value(datum, func_name, cdc_datum_message);
855
5
      break;
856
0
    }
857
0
    case ACLITEMOID: {
858
0
      func_name = "aclitemout";
859
0
      string aclitem_val = ql_value.binary_value();
860
0
      size = arg_type->datum_fixed_size;
861
0
      val = const_cast<char *>(aclitem_val.c_str());
862
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
863
0
      set_string_value(datum, func_name, cdc_datum_message);
864
0
      break;
865
0
    }
866
0
    case BPCHAROID: {
867
0
      func_name = "bpcharout";
868
0
      string bpchar_val = ql_value.string_value();
869
0
      size = bpchar_val.size();
870
0
      val = const_cast<char *>(bpchar_val.c_str());
871
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<char *>(val), size, &type_attrs);
872
0
      set_string_value(datum, func_name, cdc_datum_message);
873
0
      break;
874
0
    }
875
0
    case VARCHAROID: {
876
0
      func_name = "varcharout";
877
0
      string varchar_val = ql_value.string_value();
878
0
      size = varchar_val.size();
879
0
      val = const_cast<char *>(varchar_val.c_str());
880
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<char *>(val), size, &type_attrs);
881
0
      set_string_value(datum, func_name, cdc_datum_message);
882
0
      break;
883
0
    }
884
6
    case DATEOID: {
885
6
      func_name = "date_out";
886
6
      int date_val = ql_value.int32_value();
887
6
      size = arg_type->datum_fixed_size;
888
6
      uint64_t datum =
889
6
          arg_type->yb_to_datum(reinterpret_cast<int32 *>(&date_val), size, &type_attrs);
890
6
      set_string_value(datum, func_name, cdc_datum_message);
891
6
      break;
892
0
    }
893
5
    case TIMEOID: {
894
5
      func_name = "time_out";
895
5
      int64_t time_val = ql_value.int64_value();
896
5
      size = arg_type->datum_fixed_size;
897
5
      uint64_t datum =
898
5
          arg_type->yb_to_datum(reinterpret_cast<int64 *>(&time_val), size, &type_attrs);
899
5
      set_string_value(datum, func_name, cdc_datum_message);
900
5
      break;
901
0
    }
902
4
    case TIMESTAMPOID: {
903
4
      func_name = "timestamp_out";
904
4
      int64_t timestamp_val = ql_value.int64_value();
905
4
      size = arg_type->datum_fixed_size;
906
4
      uint64_t datum =
907
4
          arg_type->yb_to_datum(reinterpret_cast<int64 *>(&timestamp_val), size, &type_attrs);
908
4
      set_string_value(datum, func_name, cdc_datum_message);
909
4
      break;
910
0
    }
911
3
    case TIMESTAMPTZOID: {
912
3
      func_name = "timestamptz_out";
913
3
      int64_t timestamptz_val = ql_value.int64_value();
914
3
      size = arg_type->datum_fixed_size;
915
3
      uint64_t datum =
916
3
          arg_type->yb_to_datum(reinterpret_cast<int64 *>(&timestamptz_val), size, &type_attrs);
917
918
3
      set_decoded_string_value(datum, func_name, cdc_datum_message, timezone);
919
3
      break;
920
0
    }
921
0
    case INTERVALOID: {
922
0
      func_name = "interval_out";
923
0
      string interval_val = ql_value.binary_value();
924
0
      size = arg_type->datum_fixed_size;
925
0
      val = const_cast<char *>(interval_val.c_str());
926
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<void *>(val), size, &type_attrs);
927
0
      set_string_value(datum, func_name, cdc_datum_message);
928
0
      break;
929
0
    }
930
4
    case TIMETZOID: {
931
4
      func_name = "timetz_out";
932
4
      string timetz_val = ql_value.binary_value();
933
4
      size = arg_type->datum_fixed_size;
934
4
      val = const_cast<char *>(timetz_val.c_str());
935
4
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
936
4
      set_string_value(datum, func_name, cdc_datum_message);
937
4
      break;
938
0
    }
939
5
    case BITOID: {
940
5
      func_name = "bit_out";
941
5
      string bit_val = ql_value.binary_value();
942
5
      size = bit_val.size();
943
5
      val = const_cast<char *>(bit_val.c_str());
944
5
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
945
5
      set_string_value(datum, func_name, cdc_datum_message);
946
5
      break;
947
0
    }
948
5
    case VARBITOID: {
949
5
      func_name = "varbit_out";
950
5
      string varbit_val = ql_value.binary_value();
951
5
      size = varbit_val.size();
952
5
      val = const_cast<char *>(varbit_val.c_str());
953
5
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
954
5
      set_string_value(datum, func_name, cdc_datum_message);
955
5
      break;
956
0
    }
957
4
    case NUMERICOID: {
958
4
      func_name = "numeric_out";
959
4
      util::Decimal decimal;
960
961
4
      Status s = decimal.DecodeFromComparable(ql_value.decimal_value());
962
4
      if (!s.ok())
963
0
        return STATUS_SUBSTITUTE(
964
4
            InternalError, "Failed to deserialize DECIMAL from $1", ql_value.decimal_value());
965
4
      string numeric_val = decimal.ToString();
966
4
      cdc_datum_message->set_datum_double(std::stod(numeric_val));
967
4
      break;
968
4
    }
969
0
    case REGPROCEDUREOID: {
970
0
      func_name = "regprocedureout";
971
0
      uint32 regprocedure_val = ql_value.uint32_value();
972
0
      size = arg_type->datum_fixed_size;
973
0
      uint64_t datum =
974
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&regprocedure_val), size, &type_attrs);
975
0
      set_string_value(datum, func_name, cdc_datum_message);
976
0
      break;
977
4
    }
978
0
    case REGOPEROID: {
979
0
      func_name = "regoperout";
980
0
      uint32 regoper_val = ql_value.uint32_value();
981
0
      size = arg_type->datum_fixed_size;
982
0
      uint64_t datum =
983
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&regoper_val), size, &type_attrs);
984
0
      set_string_value(datum, func_name, cdc_datum_message);
985
0
      break;
986
4
    }
987
0
    case REGOPERATOROID: {
988
0
      func_name = "regoperatorout";
989
0
      uint32 regoperator_val = ql_value.uint32_value();
990
0
      size = arg_type->datum_fixed_size;
991
0
      uint64_t datum =
992
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&regoperator_val), size, &type_attrs);
993
0
      set_string_value(datum, func_name, cdc_datum_message);
994
0
      break;
995
4
    }
996
0
    case REGCLASSOID: {
997
0
      func_name = "regclassout";
998
0
      uint32 regclass_val = ql_value.uint32_value();
999
0
      size = arg_type->datum_fixed_size;
1000
0
      uint64_t datum =
1001
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&regclass_val), size, &type_attrs);
1002
0
      set_string_value(datum, func_name, cdc_datum_message);
1003
0
      break;
1004
4
    }
1005
0
    case REGTYPEOID: {
1006
0
      func_name = "regtypeout";
1007
0
      uint32 regtype_val = ql_value.uint32_value();
1008
0
      size = arg_type->datum_fixed_size;
1009
0
      uint64_t datum =
1010
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&regtype_val), size, &type_attrs);
1011
0
      set_string_value(datum, func_name, cdc_datum_message);
1012
0
      break;
1013
4
    }
1014
0
    case REGROLEOID: {
1015
0
      func_name = "regroleout";
1016
0
      uint32 regrole_val = ql_value.uint32_value();
1017
0
      size = arg_type->datum_fixed_size;
1018
0
      uint64_t datum =
1019
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&regrole_val), size, &type_attrs);
1020
0
      set_string_value(datum, func_name, cdc_datum_message);
1021
0
      break;
1022
4
    }
1023
0
    case REGNAMESPACEOID: {
1024
0
      func_name = "regnamespaceout";
1025
0
      uint32 regnamespace_val = ql_value.uint32_value();
1026
0
      size = arg_type->datum_fixed_size;
1027
0
      uint64_t datum =
1028
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&regnamespace_val), size, &type_attrs);
1029
0
      set_string_value(datum, func_name, cdc_datum_message);
1030
0
      break;
1031
4
    }
1032
5
    case UUIDOID: {
1033
5
      func_name = "uuid_out";
1034
5
      string uuid_val = ql_value.binary_value();
1035
5
      size = uuid_val.size();
1036
5
      val = const_cast<char *>(uuid_val.c_str());
1037
5
      uint64_t datum =
1038
5
          arg_type->yb_to_datum(reinterpret_cast<unsigned char *>(val), size, &type_attrs);
1039
5
      set_string_value(datum, func_name, cdc_datum_message);
1040
5
      break;
1041
4
    }
1042
0
    case LSNOID: {
1043
0
      func_name = "pg_lsn_out";
1044
0
      uint64 pg_lsn_val = ql_value.uint64_value();
1045
0
      size = arg_type->datum_fixed_size;
1046
0
      uint64_t datum =
1047
0
          arg_type->yb_to_datum(reinterpret_cast<uint64 *>(&pg_lsn_val), size, &type_attrs);
1048
0
      set_string_value(datum, func_name, cdc_datum_message);
1049
0
      break;
1050
4
    }
1051
0
    case TSQUERYOID: {
1052
0
      func_name = "tsqueryout";
1053
0
      string tsquery_val = ql_value.binary_value();
1054
0
      size = tsquery_val.size();
1055
0
      val = const_cast<char *>(tsquery_val.c_str());
1056
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
1057
0
      set_string_value(datum, func_name, cdc_datum_message);
1058
0
      break;
1059
4
    }
1060
0
    case REGCONFIGOID: {
1061
0
      func_name = "regconfigout";
1062
0
      uint32 regconfig_val = ql_value.uint32_value();
1063
0
      size = arg_type->datum_fixed_size;
1064
0
      uint64_t datum =
1065
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&regconfig_val), size, &type_attrs);
1066
0
      set_string_value(datum, func_name, cdc_datum_message);
1067
0
      break;
1068
4
    }
1069
0
    case REGDICTIONARYOID: {
1070
0
      func_name = "regdictionaryout";
1071
0
      uint32 regdictionary_val = ql_value.uint32_value();
1072
0
      size = arg_type->datum_fixed_size;
1073
0
      uint64_t datum =
1074
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&regdictionary_val), size, &type_attrs);
1075
0
      set_string_value(datum, func_name, cdc_datum_message);
1076
0
      break;
1077
4
    }
1078
5
    case JSONBOID: {
1079
5
      func_name = "jsonb_out";
1080
5
      string jsonb_val = ql_value.binary_value();
1081
5
      size = jsonb_val.size();
1082
5
      val = const_cast<char *>(jsonb_val.c_str());
1083
5
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<void *>(val), size, &type_attrs);
1084
5
      set_string_value(datum, func_name, cdc_datum_message);
1085
5
      break;
1086
4
    }
1087
0
    case TXID_SNAPSHOTOID: {
1088
0
      func_name = "txid_snapshot_out";
1089
0
      string txid_val = ql_value.binary_value();
1090
0
      size = txid_val.size();
1091
0
      val = const_cast<char *>(txid_val.c_str());
1092
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<void *>(val), size, &type_attrs);
1093
0
      set_string_value(datum, func_name, cdc_datum_message);
1094
0
      break;
1095
4
    }
1096
0
    case RECORDOID: {
1097
      /*func_name = "record_out";
1098
      string record_val = ql_value.binary_value();
1099
      size = record_val.size();
1100
      val = const_cast<char *>(record_val.c_str());
1101
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
1102
1103
      if (!is_proto_record) {
1104
        set_decoded_string_value(datum, func_name, is_proto_record);
1105
      } else {
1106
1107
          set_decoded_string_value(datum, func_name,
1108
                                   cdc_datum_message);
1109
      }*/
1110
1111
0
      cdc_datum_message->set_datum_string("");
1112
0
      break;
1113
4
    }
1114
0
    case CSTRINGOID: {
1115
0
      func_name = "cstring_out";
1116
0
      string cstring_val = ql_value.string_value();
1117
0
      size = cstring_val.size();
1118
0
      val = const_cast<char *>(cstring_val.c_str());
1119
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<char *>(val), size, &type_attrs);
1120
0
      set_string_value(datum, func_name, cdc_datum_message);
1121
0
      break;
1122
4
    }
1123
0
    case ANYOID: {
1124
0
      func_name = "any_out";
1125
0
      int any_val = ql_value.int32_value();
1126
0
      size = arg_type->datum_fixed_size;
1127
0
      uint64_t datum =
1128
0
          arg_type->yb_to_datum(reinterpret_cast<int32 *>(&any_val), size, &type_attrs);
1129
0
      set_string_value(datum, func_name, cdc_datum_message);
1130
0
      break;
1131
4
    }
1132
0
    case VOIDOID: {
1133
0
      func_name = "void_out";
1134
0
      int64_t void_val = ql_value.int64_value();
1135
0
      size = arg_type->datum_fixed_size;
1136
0
      uint64_t datum =
1137
0
          arg_type->yb_to_datum(reinterpret_cast<int64 *>(&void_val), size, &type_attrs);
1138
0
      set_string_value(datum, func_name, cdc_datum_message);
1139
0
      break;
1140
4
    }
1141
0
    case TRIGGEROID: {
1142
0
      func_name = "trigger_out";
1143
0
      uint32 trigger_val = ql_value.uint32_value();
1144
0
      size = arg_type->datum_fixed_size;
1145
0
      uint64_t datum =
1146
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&trigger_val), size, &type_attrs);
1147
0
      set_string_value(datum, func_name, cdc_datum_message);
1148
0
      break;
1149
4
    }
1150
0
    case EVTTRIGGEROID: {
1151
0
      func_name = "event_trigger_out";
1152
0
      uint32 event_trigger_val = ql_value.uint32_value();
1153
0
      size = arg_type->datum_fixed_size;
1154
0
      uint64_t datum =
1155
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&event_trigger_val), size, &type_attrs);
1156
0
      set_string_value(datum, func_name, cdc_datum_message);
1157
0
      break;
1158
4
    }
1159
0
    case LANGUAGE_HANDLEROID: {
1160
0
      func_name = "language_handler_out";
1161
0
      uint32 language_handler_val = ql_value.uint32_value();
1162
0
      size = arg_type->datum_fixed_size;
1163
0
      uint64_t datum = arg_type->yb_to_datum(
1164
0
          reinterpret_cast<uint32 *>(&language_handler_val), size, &type_attrs);
1165
0
      set_string_value(datum, func_name, cdc_datum_message);
1166
0
      break;
1167
4
    }
1168
0
    case INTERNALOID: {
1169
0
      func_name = "internal_out";
1170
0
      int64_t internal_val = ql_value.int64_value();
1171
0
      size = arg_type->datum_fixed_size;
1172
0
      uint64_t datum =
1173
0
          arg_type->yb_to_datum(reinterpret_cast<int64 *>(&internal_val), size, &type_attrs);
1174
0
      set_string_value(datum, func_name, cdc_datum_message);
1175
0
      break;
1176
4
    }
1177
0
    case OPAQUEOID: {
1178
0
      func_name = "opaque_out";
1179
0
      int opaque_val = ql_value.int32_value();
1180
0
      size = arg_type->datum_fixed_size;
1181
0
      uint64_t datum =
1182
0
          arg_type->yb_to_datum(reinterpret_cast<int32 *>(&opaque_val), size, &type_attrs);
1183
0
      set_string_value(datum, func_name, cdc_datum_message);
1184
0
      break;
1185
4
    }
1186
0
    case ANYELEMENTOID: {
1187
0
      func_name = "anyelement_out";
1188
0
      int anyelement_val = ql_value.int32_value();
1189
0
      size = arg_type->datum_fixed_size;
1190
0
      uint64_t datum =
1191
0
          arg_type->yb_to_datum(reinterpret_cast<int32 *>(&anyelement_val), size, &type_attrs);
1192
0
      set_string_value(datum, func_name, cdc_datum_message);
1193
0
      break;
1194
4
    }
1195
0
    case ANYNONARRAYOID: {
1196
0
      func_name = "anynonarray_out";
1197
0
      int anynonarray_val = ql_value.int32_value();
1198
0
      size = arg_type->datum_fixed_size;
1199
0
      uint64_t datum =
1200
0
          arg_type->yb_to_datum(reinterpret_cast<int32 *>(&anynonarray_val), size, &type_attrs);
1201
0
      set_string_value(datum, func_name, cdc_datum_message);
1202
0
      break;
1203
4
    }
1204
0
    case ANYENUMOID: {
1205
0
      func_name = "anyenum_out";
1206
0
      int64_t anyenum_val = ql_value.int64_value();
1207
0
      size = arg_type->datum_fixed_size;
1208
0
      uint64_t datum =
1209
0
          arg_type->yb_to_datum(reinterpret_cast<int64 *>(&anyenum_val), size, &type_attrs);
1210
0
      set_string_value(datum, func_name, cdc_datum_message);
1211
0
      break;
1212
4
    }
1213
0
    case FDW_HANDLEROID: {
1214
0
      func_name = "fdw_handler_out";
1215
0
      uint32 fdw_handler_val = ql_value.uint32_value();
1216
0
      size = arg_type->datum_fixed_size;
1217
0
      uint64_t datum =
1218
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&fdw_handler_val), size, &type_attrs);
1219
0
      set_string_value(datum, func_name, cdc_datum_message);
1220
0
      break;
1221
4
    }
1222
0
    case INDEX_AM_HANDLEROID: {
1223
0
      func_name = "index_am_handler_out";
1224
0
      uint32 index_am_handler_val = ql_value.uint32_value();
1225
0
      size = arg_type->datum_fixed_size;
1226
0
      uint64_t datum = arg_type->yb_to_datum(
1227
0
          reinterpret_cast<uint32 *>(&index_am_handler_val), size, &type_attrs);
1228
0
      set_string_value(datum, func_name, cdc_datum_message);
1229
0
      break;
1230
4
    }
1231
0
    case TSM_HANDLEROID: {
1232
0
      func_name = "tsm_handler_out";
1233
0
      uint32 tsm_handler_val = ql_value.uint32_value();
1234
0
      size = arg_type->datum_fixed_size;
1235
0
      uint64_t datum =
1236
0
          arg_type->yb_to_datum(reinterpret_cast<uint32 *>(&tsm_handler_val), size, &type_attrs);
1237
0
      set_string_value(datum, func_name, cdc_datum_message);
1238
0
      break;
1239
4
    }
1240
0
    case ANYRANGEOID: {
1241
0
      func_name = "anyrange_out";
1242
0
      string anyrange_val = ql_value.binary_value();
1243
0
      size = anyrange_val.size();
1244
0
      val = const_cast<char *>(anyrange_val.c_str());
1245
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
1246
0
      set_string_value(datum, func_name, cdc_datum_message);
1247
0
      break;
1248
4
    }
1249
1250
0
    case INT2VECTOROID: {
1251
0
      func_name = "int2vectorout";
1252
0
      string int2vector_val = ql_value.binary_value();
1253
0
      size = int2vector_val.size();
1254
0
      val = const_cast<char *>(int2vector_val.c_str());
1255
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
1256
0
      set_string_value(datum, func_name, cdc_datum_message);
1257
0
      break;
1258
4
    }
1259
1260
0
    case OIDVECTOROID: {
1261
0
      func_name = "oidvectorout";
1262
0
      string oidvector_val = ql_value.binary_value();
1263
0
      size = oidvector_val.size();
1264
0
      val = const_cast<char *>(oidvector_val.c_str());
1265
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
1266
0
      set_string_value(datum, func_name, cdc_datum_message);
1267
0
      break;
1268
4
    }
1269
1270
0
    case TSVECTOROID: {
1271
0
      func_name = "tsvectorout";
1272
0
      string tsvector_val = ql_value.binary_value();
1273
0
      size = tsvector_val.size();
1274
0
      val = const_cast<char *>(tsvector_val.c_str());
1275
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
1276
0
      set_string_value(datum, func_name, cdc_datum_message);
1277
0
      break;
1278
4
    }
1279
1280
0
    case GTSVECTOROID: {
1281
0
      func_name = "gtsvectorout";
1282
0
      string gtsvector_val = ql_value.binary_value();
1283
0
      size = gtsvector_val.size();
1284
0
      val = const_cast<char *>(gtsvector_val.c_str());
1285
0
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
1286
0
      set_string_value(datum, func_name, cdc_datum_message);
1287
0
      break;
1288
4
    }
1289
1290
4
    case POLYGONOID: {
1291
4
      func_name = "poly_out";
1292
4
      string polygon_val = ql_value.binary_value();
1293
4
      size = polygon_val.size();
1294
4
      val = const_cast<char *>(polygon_val.c_str());
1295
4
      uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8 *>(val), size, &type_attrs);
1296
4
      set_string_value(datum, func_name, cdc_datum_message);
1297
4
      break;
1298
4
    }
1299
1300
    // Range types
1301
3
    case INT4RANGEOID: {
1302
3
      func_name = "int4out";
1303
3
      set_range_string_value(ql_value, arg_type, INT4OID, func_name, cdc_datum_message);
1304
3
      break;
1305
4
    }
1306
1307
0
    case NUMRANGEOID: {
1308
0
      func_name = "numeric_out";
1309
0
      set_range_string_value(ql_value, arg_type, NUMERICOID, func_name, cdc_datum_message);
1310
0
      break;
1311
4
    }
1312
1313
3
    case TSRANGEOID: {
1314
3
      func_name = "timestamp_out";
1315
3
      set_range_string_value(ql_value, arg_type, TIMESTAMPOID, func_name, cdc_datum_message);
1316
3
      break;
1317
4
    }
1318
1319
3
    case TSTZRANGEOID: {
1320
3
      func_name = "timestamptz_out";
1321
3
      set_decoded_string_range(
1322
3
          ql_value, arg_type, TIMESTAMPTZOID, func_name, cdc_datum_message, timezone);
1323
3
      break;
1324
4
    }
1325
1326
3
    case DATERANGEOID: {
1327
3
      func_name = "date_out";
1328
3
      set_range_string_value(ql_value, arg_type, DATEOID, func_name, cdc_datum_message);
1329
3
      break;
1330
4
    }
1331
1332
3
    case INT8RANGEOID: {
1333
3
      func_name = "int8out";
1334
3
      set_range_string_value(ql_value, arg_type, INT8OID, func_name, cdc_datum_message);
1335
3
      break;
1336
4
    }
1337
1338
    // Array types
1339
0
    case XMLARRAYOID: {
1340
0
      func_name = "xml_out";
1341
0
      set_array_string_value(ql_value, arg_type, XMLOID, func_name, cdc_datum_message);
1342
0
      break;
1343
4
    }
1344
1345
3
    case LINEARRAYOID: {
1346
3
      func_name = "line_out";
1347
3
      set_array_string_value(ql_value, arg_type, LINEOID, func_name, cdc_datum_message);
1348
3
      break;
1349
4
    }
1350
1351
3
    case CIRCLEARRAYOID: {
1352
3
      func_name = "circle_out";
1353
3
      set_array_string_value(ql_value, arg_type, CIRCLEOID, func_name, cdc_datum_message);
1354
3
      break;
1355
4
    }
1356
1357
3
    case MONEYARRAYOID: {
1358
3
      func_name = "cash_out";
1359
3
      set_array_string_value(ql_value, arg_type, CASHOID, func_name, cdc_datum_message);
1360
3
      break;
1361
4
    }
1362
1363
3
    case BOOLARRAYOID: {
1364
3
      func_name = "boolout";
1365
3
      set_array_string_value(ql_value, arg_type, BOOLOID, func_name, cdc_datum_message);
1366
3
      break;
1367
4
    }
1368
1369
0
    case BYTEAARRAYOID: {
1370
0
      func_name = "byteaout";
1371
0
      set_array_string_value(ql_value, arg_type, BYTEAOID, func_name, cdc_datum_message);
1372
0
      break;
1373
4
    }
1374
1375
0
    case CHARARRAYOID: {
1376
0
      func_name = "charout";
1377
0
      set_array_string_value(ql_value, arg_type, CHAROID, func_name, cdc_datum_message);
1378
0
      break;
1379
4
    }
1380
1381
0
    case NAMEARRAYOID: {
1382
0
      func_name = "nameout";
1383
0
      set_array_string_value(ql_value, arg_type, NAMEOID, func_name, cdc_datum_message);
1384
0
      break;
1385
4
    }
1386
1387
3
    case INT2ARRAYOID: {
1388
3
      func_name = "int2out";
1389
3
      set_array_string_value(ql_value, arg_type, INT2OID, func_name, cdc_datum_message);
1390
3
      break;
1391
4
    }
1392
1393
0
    case INT2VECTORARRAYOID: {
1394
0
      func_name = "int2vectorout";
1395
0
      set_array_string_value(ql_value, arg_type, INT2VECTOROID, func_name, cdc_datum_message);
1396
0
      break;
1397
4
    }
1398
1399
3
    case INT4ARRAYOID: {
1400
3
      func_name = "int4out";
1401
3
      set_array_string_value(ql_value, arg_type, INT4OID, func_name, cdc_datum_message);
1402
3
      break;
1403
4
    }
1404
1405
0
    case REGPROCARRAYOID: {
1406
0
      func_name = "regprocout";
1407
0
      set_array_string_value(ql_value, arg_type, REGPROCOID, func_name, cdc_datum_message);
1408
0
      break;
1409
4
    }
1410
1411
3
    case TEXTARRAYOID: {
1412
3
      func_name = "textout";
1413
3
      set_array_string_value(ql_value, arg_type, TEXTOID, func_name, cdc_datum_message);
1414
3
      break;
1415
4
    }
1416
1417
0
    case OIDARRAYOID: {
1418
0
      func_name = "oidout";
1419
0
      set_array_string_value(ql_value, arg_type, OIDOID, func_name, cdc_datum_message);
1420
0
      break;
1421
4
    }
1422
1423
3
    case CIDRARRAYOID: {
1424
3
      func_name = "cidr_out";
1425
3
      set_array_string_value(ql_value, arg_type, CIDROID, func_name, cdc_datum_message);
1426
3
      break;
1427
4
    }
1428
1429
0
    case TIDARRAYOID: {
1430
0
      func_name = "tidout";
1431
0
      set_array_string_value(ql_value, arg_type, TIDOID, func_name, cdc_datum_message);
1432
0
      break;
1433
4
    }
1434
1435
0
    case XIDARRAYOID: {
1436
0
      func_name = "xidout";
1437
0
      set_array_string_value(ql_value, arg_type, XIDOID, func_name, cdc_datum_message);
1438
0
      break;
1439
4
    }
1440
1441
0
    case CIDARRAYOID: {
1442
0
      func_name = "cidout";
1443
0
      set_array_string_value(ql_value, arg_type, CIDOID, func_name, cdc_datum_message);
1444
0
      break;
1445
4
    }
1446
1447
0
    case OIDVECTORARRAYOID: {
1448
0
      func_name = "oidvectorout";
1449
0
      set_array_string_value(ql_value, arg_type, OIDVECTOROID, func_name, cdc_datum_message);
1450
0
      break;
1451
4
    }
1452
1453
3
    case BPCHARARRAYOID: {
1454
3
      func_name = "bpcharout";
1455
3
      set_array_string_value(ql_value, arg_type, BPCHAROID, func_name, cdc_datum_message);
1456
3
      break;
1457
4
    }
1458
1459
3
    case VARCHARARRAYOID: {
1460
3
      func_name = "varcharout";
1461
3
      set_array_string_value(ql_value, arg_type, VARCHAROID, func_name, cdc_datum_message);
1462
3
      break;
1463
4
    }
1464
1465
0
    case INT8ARRAYOID: {
1466
0
      func_name = "int8out";
1467
0
      set_array_string_value(ql_value, arg_type, INT8OID, func_name, cdc_datum_message);
1468
0
      break;
1469
4
    }
1470
1471
3
    case POINTARRAYOID: {
1472
3
      func_name = "point_out";
1473
3
      set_array_string_value(ql_value, arg_type, POINTOID, func_name, cdc_datum_message);
1474
3
      break;
1475
4
    }
1476
1477
3
    case LSEGARRAYOID: {
1478
3
      func_name = "lseg_out";
1479
3
      set_array_string_value(ql_value, arg_type, LSEGOID, func_name, cdc_datum_message);
1480
3
      break;
1481
4
    }
1482
1483
3
    case PATHARRAYOID: {
1484
3
      func_name = "path_out";
1485
3
      set_array_string_value(ql_value, arg_type, PATHOID, func_name, cdc_datum_message);
1486
3
      break;
1487
4
    }
1488
1489
3
    case BOXARRAYOID: {
1490
3
      func_name = "box_out";
1491
3
      set_array_string_value(ql_value, arg_type, BOXOID, func_name, cdc_datum_message);
1492
3
      break;
1493
4
    }
1494
1495
3
    case FLOAT4ARRAYOID: {
1496
3
      func_name = "float4out";
1497
3
      set_array_string_value(ql_value, arg_type, FLOAT4OID, func_name, cdc_datum_message);
1498
3
      break;
1499
4
    }
1500
1501
3
    case FLOAT8ARRAYOID: {
1502
3
      func_name = "float8out";
1503
3
      set_array_string_value(ql_value, arg_type, FLOAT8OID, func_name, cdc_datum_message);
1504
3
      break;
1505
4
    }
1506
1507
0
    case ABSTIMEARRAYOID: {
1508
0
      func_name = "abstimeout";
1509
0
      set_array_string_value(ql_value, arg_type, ABSTIMEOID, func_name, cdc_datum_message);
1510
0
      break;
1511
4
    }
1512
1513
0
    case RELTIMEARRAYOID: {
1514
0
      func_name = "reltimeout";
1515
0
      set_array_string_value(ql_value, arg_type, RELTIMEOID, func_name, cdc_datum_message);
1516
0
      break;
1517
4
    }
1518
1519
0
    case TINTERVALARRAYOID: {
1520
0
      func_name = "tintervalout";
1521
0
      set_array_string_value(ql_value, arg_type, TINTERVALOID, func_name, cdc_datum_message);
1522
0
      break;
1523
4
    }
1524
1525
0
    case ACLITEMARRAYOID: {
1526
0
      func_name = "aclitemout";
1527
0
      set_array_string_value(ql_value, arg_type, ACLITEMOID, func_name, cdc_datum_message);
1528
0
      break;
1529
4
    }
1530
1531
3
    case MACADDRARRAYOID: {
1532
3
      func_name = "macaddr_out";
1533
3
      set_array_string_value(ql_value, arg_type, MACADDROID, func_name, cdc_datum_message);
1534
3
      break;
1535
4
    }
1536
1537
3
    case MACADDR8ARRAYOID: {
1538
3
      func_name = "macaddr8_out";
1539
3
      set_array_string_value(ql_value, arg_type, MACADDR8OID, func_name, cdc_datum_message);
1540
3
      break;
1541
4
    }
1542
1543
3
    case INETARRAYOID: {
1544
3
      func_name = "inet_out";
1545
3
      set_array_string_value(ql_value, arg_type, INETOID, func_name, cdc_datum_message);
1546
3
      break;
1547
4
    }
1548
1549
0
    case CSTRINGARRAYOID: {
1550
0
      func_name = "cstring_out";
1551
0
      set_array_string_value(ql_value, arg_type, CSTRINGOID, func_name, cdc_datum_message);
1552
0
      break;
1553
4
    }
1554
1555
3
    case TIMESTAMPARRAYOID: {
1556
3
      func_name = "timestamp_out";
1557
3
      set_array_string_value(ql_value, arg_type, TIMESTAMPOID, func_name, cdc_datum_message);
1558
3
      break;
1559
4
    }
1560
1561
3
    case DATEARRAYOID: {
1562
3
      func_name = "date_out";
1563
3
      set_array_string_value(ql_value, arg_type, DATEOID, func_name, cdc_datum_message);
1564
3
      break;
1565
4
    }
1566
1567
3
    case TIMEARRAYOID: {
1568
3
      func_name = "time_out";
1569
3
      set_array_string_value(ql_value, arg_type, TIMEOID, func_name, cdc_datum_message);
1570
3
      break;
1571
4
    }
1572
1573
3
    case TIMESTAMPTZARRAYOID: {
1574
3
      func_name = "timestamptz_out";
1575
3
      set_decoded_string_array(
1576
3
          ql_value, arg_type, TIMESTAMPTZOID, func_name, cdc_datum_message, timezone);
1577
3
      break;
1578
4
    }
1579
1580
3
    case INTERVALARRAYOID: {
1581
3
      func_name = "interval_out";
1582
3
      set_array_string_value(ql_value, arg_type, INTERVALOID, func_name, cdc_datum_message);
1583
3
      break;
1584
4
    }
1585
1586
0
    case NUMERICARRAYOID: {
1587
0
      func_name = "numeric_out";
1588
0
      set_array_string_value(ql_value, arg_type, NUMERICOID, func_name, cdc_datum_message);
1589
0
      break;
1590
4
    }
1591
1592
3
    case TIMETZARRAYOID: {
1593
3
      func_name = "timetz_out";
1594
3
      set_array_string_value(ql_value, arg_type, TIMETZOID, func_name, cdc_datum_message);
1595
3
      break;
1596
4
    }
1597
1598
0
    case BITARRAYOID: {
1599
0
      func_name = "bit_out";
1600
0
      set_array_string_value(ql_value, arg_type, BITOID, func_name, cdc_datum_message);
1601
0
      break;
1602
4
    }
1603
1604
3
    case VARBITARRAYOID: {
1605
3
      func_name = "varbit_out";
1606
3
      set_array_string_value(ql_value, arg_type, VARBITOID, func_name, cdc_datum_message);
1607
3
      break;
1608
4
    }
1609
1610
0
    case REGPROCEDUREARRAYOID: {
1611
0
      func_name = "regprocedureout";
1612
0
      set_array_string_value(ql_value, arg_type, REGPROCEDUREOID, func_name, cdc_datum_message);
1613
0
      break;
1614
4
    }
1615
1616
0
    case REGOPERARRAYOID: {
1617
0
      func_name = "regoperout";
1618
0
      set_array_string_value(ql_value, arg_type, REGOPEROID, func_name, cdc_datum_message);
1619
0
      break;
1620
4
    }
1621
1622
0
    case REGOPERATORARRAYOID: {
1623
0
      func_name = "regoperatorout";
1624
0
      set_array_string_value(ql_value, arg_type, REGOPERATOROID, func_name, cdc_datum_message);
1625
0
      break;
1626
4
    }
1627
1628
0
    case REGCLASSARRAYOID: {
1629
0
      func_name = "regclassout";
1630
0
      set_array_string_value(ql_value, arg_type, REGCLASSOID, func_name, cdc_datum_message);
1631
0
      break;
1632
4
    }
1633
1634
0
    case REGTYPEARRAYOID: {
1635
0
      func_name = "regtypeout";
1636
0
      set_array_string_value(ql_value, arg_type, REGTYPEOID, func_name, cdc_datum_message);
1637
0
      break;
1638
4
    }
1639
1640
0
    case REGROLEARRAYOID: {
1641
0
      func_name = "regroleout";
1642
0
      set_array_string_value(ql_value, arg_type, REGROLEOID, func_name, cdc_datum_message);
1643
0
      break;
1644
4
    }
1645
1646
0
    case REGNAMESPACEARRAYOID: {
1647
0
      func_name = "regnamespaceout";
1648
0
      set_array_string_value(ql_value, arg_type, REGNAMESPACEOID, func_name, cdc_datum_message);
1649
0
      break;
1650
4
    }
1651
1652
3
    case UUIDARRAYOID: {
1653
3
      func_name = "uuid_out";
1654
3
      set_array_string_value(ql_value, arg_type, UUIDOID, func_name, cdc_datum_message);
1655
3
      break;
1656
4
    }
1657
1658
0
    case PG_LSNARRAYOID: {
1659
0
      func_name = "pg_lsn_out";
1660
0
      set_array_string_value(ql_value, arg_type, LSNOID, func_name, cdc_datum_message);
1661
0
      break;
1662
4
    }
1663
1664
0
    case TSVECTORARRAYOID: {
1665
0
      func_name = "tsvectorout";
1666
0
      set_array_string_value(ql_value, arg_type, TSVECTOROID, func_name, cdc_datum_message);
1667
0
      break;
1668
4
    }
1669
1670
0
    case GTSVECTORARRAYOID: {
1671
0
      func_name = "gtsvectorout";
1672
0
      set_array_string_value(ql_value, arg_type, GTSVECTOROID, func_name, cdc_datum_message);
1673
0
      break;
1674
4
    }
1675
1676
0
    case TSQUERYARRAYOID: {
1677
0
      func_name = "tsqueryout";
1678
0
      set_array_string_value(ql_value, arg_type, TSQUERYOID, func_name, cdc_datum_message);
1679
0
      break;
1680
4
    }
1681
1682
0
    case REGCONFIGARRAYOID: {
1683
0
      func_name = "regconfigout";
1684
0
      set_array_string_value(ql_value, arg_type, REGCONFIGOID, func_name, cdc_datum_message);
1685
0
      break;
1686
4
    }
1687
1688
0
    case REGDICTIONARYARRAYOID: {
1689
0
      func_name = "regdictionaryout";
1690
0
      set_array_string_value(ql_value, arg_type, REGDICTIONARYOID, func_name, cdc_datum_message);
1691
0
      break;
1692
4
    }
1693
1694
3
    case JSONARRAYOID: {
1695
3
      func_name = "json_out";
1696
3
      set_array_string_value(ql_value, arg_type, JSONOID, func_name, cdc_datum_message);
1697
3
      break;
1698
4
    }
1699
1700
3
    case JSONBARRAYOID: {
1701
3
      func_name = "jsonb_out";
1702
3
      set_array_string_value(ql_value, arg_type, JSONBOID, func_name, cdc_datum_message);
1703
3
      break;
1704
4
    }
1705
1706
3
    case TXID_SNAPSHOTARRAYOID: {
1707
3
      func_name = "txid_snapshot_out";
1708
3
      set_array_string_value(ql_value, arg_type, TXID_SNAPSHOTOID, func_name, cdc_datum_message);
1709
3
      break;
1710
4
    }
1711
1712
0
    case RECORDARRAYOID: {
1713
0
      cdc_datum_message->set_datum_string("");
1714
0
      break;
1715
4
    }
1716
1717
0
    case ANYARRAYOID: {
1718
0
      func_name = "any_out";
1719
0
      set_array_string_value(ql_value, arg_type, ANYOID, func_name, cdc_datum_message);
1720
0
      break;
1721
4
    }
1722
1723
3
    case POLYGONARRAYOID: {
1724
3
      func_name = "poly_out";
1725
3
      set_array_string_value(ql_value, arg_type, POLYGONOID, func_name, cdc_datum_message);
1726
3
      break;
1727
4
    }
1728
1729
3
    case INT4RANGEARRAYOID: {
1730
3
      func_name = "int4out";
1731
3
      set_range_array_string_value(ql_value, arg_type, INT4RANGEOID, func_name, cdc_datum_message);
1732
3
      break;
1733
4
    }
1734
1735
3
    case NUMRANGEARRAYOID: {
1736
3
      func_name = "numeric_out";
1737
3
      set_range_array_string_value(ql_value, arg_type, NUMRANGEOID, func_name, cdc_datum_message);
1738
3
      break;
1739
4
    }
1740
1741
3
    case TSRANGEARRAYOID: {
1742
3
      func_name = "timestamp_out";
1743
3
      set_range_array_string_value(ql_value, arg_type, TSRANGEOID, func_name, cdc_datum_message);
1744
3
      break;
1745
4
    }
1746
1747
3
    case TSTZRANGEARRAYOID: {
1748
3
      func_name = "timestamptz_out";
1749
3
      set_decoded_string_range_array(
1750
3
          ql_value, arg_type, TSTZRANGEOID, func_name, cdc_datum_message, timezone);
1751
3
      break;
1752
4
    }
1753
1754
3
    case DATERANGEARRAYOID: {
1755
3
      func_name = "date_out";
1756
3
      set_range_array_string_value(ql_value, arg_type, DATERANGEOID, func_name, cdc_datum_message);
1757
3
      break;
1758
4
    }
1759
1760
3
    case INT8RANGEARRAYOID: {
1761
3
      func_name = "int8out";
1762
3
      set_range_array_string_value(ql_value, arg_type, INT8RANGEOID, func_name, cdc_datum_message);
1763
3
      break;
1764
4
    }
1765
1766
0
    default:
1767
0
      LOG(INFO) << "Unknown type in SetValueFromQLBinaryHelper: " << arg_type->type_oid;
1768
0
      break;
1769
39.1k
  }
1770
1771
39.1k
  return Status::OK();
1772
39.1k
}
1773
1774
// This function expects that YbgPrepareMemoryContext was called by the caller of this function.
1775
Status ExtractVectorFromQLBinaryValueHelper(const QLValuePB& ql_value,
1776
                                            const int array_type,
1777
                                            const int elem_type,
1778
0
                                            vector<QLValuePB> *const result) {
1779
0
  const uint64_t size = ql_value.binary_value().size();
1780
0
  char *val = const_cast<char *>(ql_value.binary_value().c_str());
1781
1782
0
  YbgTypeDesc pg_arg_type {array_type, -1 /* typmod */};
1783
0
  const YBCPgTypeEntity *arg_type = DocPgGetTypeEntity(pg_arg_type);
1784
0
  YBCPgTypeAttrs type_attrs {-1 /* typmod */};
1785
0
  uint64_t datum = arg_type->yb_to_datum(reinterpret_cast<uint8_t *>(val), size, &type_attrs);
1786
1787
0
  uint64_t *datum_elements;
1788
0
  int num_elems = 0;
1789
0
  PG_RETURN_NOT_OK(YbgSplitArrayDatum(datum, elem_type, &datum_elements, &num_elems));
1790
0
  YbgTypeDesc elem_pg_arg_type {elem_type, -1 /* typmod */};
1791
0
  const YBCPgTypeEntity *elem_arg_type = DocPgGetTypeEntity(elem_pg_arg_type);
1792
0
  VLOG(4) << "Number of parsed elements: " << num_elems;
1793
0
  for (int i = 0; i < num_elems; ++i) {
1794
0
    QLValuePB ql_val;
1795
0
    pggate::PgConstant value(elem_arg_type,
1796
0
                             false /* collate_is_valid_non_c */,
1797
0
                             nullptr /* collation_sortkey */,
1798
0
                             datum_elements[i], false /* isNull */);
1799
0
    RETURN_NOT_OK(value.Eval(&ql_val));
1800
0
    VLOG(4) << "Parsed value: " << ql_val.string_value();
1801
0
    result->emplace_back(std::move(ql_val));
1802
0
  }
1803
0
  return Status::OK();
1804
0
}
1805
1806
}  // namespace docdb
1807
}  // namespace yb