YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/yql/pggate/pggate_thread_local_vars.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/pggate/pggate_thread_local_vars.h"
16
17
#include <stddef.h>
18
19
namespace yb {
20
namespace pggate {
21
22
/*
23
 * This code does not need to know anything about the value internals.
24
 * TODO we could use opaque types instead of void* for additional type safety.
25
 */
26
thread_local void *thread_local_memory_context_ = NULL;
27
thread_local void *pg_strtok_ptr = NULL;
28
thread_local void *jump_buffer = NULL;
29
thread_local const void *err_msg = NULL;
30
31
//-----------------------------------------------------------------------------
32
// Memory context.
33
//-----------------------------------------------------------------------------
34
35
214M
void* PgSetThreadLocalCurrentMemoryContext(void *memctx) {
36
214M
  void *old = thread_local_memory_context_;
37
214M
  thread_local_memory_context_ = memctx;
38
214M
  return old;
39
214M
}
40
41
55.4M
void* PgGetThreadLocalCurrentMemoryContext() {
42
55.4M
  return thread_local_memory_context_;
43
55.4M
}
44
45
52.8M
void PgResetCurrentMemCtxThreadLocalVars() {
46
52.8M
  pg_strtok_ptr = NULL;
47
52.8M
  jump_buffer = NULL;
48
52.8M
  err_msg = NULL;
49
52.8M
}
50
51
//-----------------------------------------------------------------------------
52
// Error reporting.
53
//-----------------------------------------------------------------------------
54
55
269M
void* PgSetThreadLocalJumpBuffer(void* new_buffer) {
56
269M
    void *old_buffer = jump_buffer;
57
269M
    jump_buffer = new_buffer;
58
269M
    return old_buffer;
59
269M
}
60
61
0
void* PgGetThreadLocalJumpBuffer() {
62
0
    return jump_buffer;
63
0
}
64
65
0
void PgSetThreadLocalErrMsg(const void* new_msg) {
66
0
    err_msg = new_msg;
67
0
}
68
69
0
const void* PgGetThreadLocalErrMsg() {
70
0
    return err_msg;
71
0
}
72
73
//-----------------------------------------------------------------------------
74
// Expression processing.
75
//-----------------------------------------------------------------------------
76
77
1.25M
void* PgGetThreadLocalStrTokPtr() {
78
1.25M
  return pg_strtok_ptr;
79
1.25M
}
80
81
1.26M
void PgSetThreadLocalStrTokPtr(char *new_pg_strtok_ptr) {
82
1.26M
  pg_strtok_ptr = new_pg_strtok_ptr;
83
1.26M
}
84
85
}  // namespace pggate
86
}  // namespace yb