YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/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
83.5M
void* PgSetThreadLocalCurrentMemoryContext(void *memctx) {
36
83.5M
  void *old = thread_local_memory_context_;
37
83.5M
  thread_local_memory_context_ = memctx;
38
83.5M
  return old;
39
83.5M
}
40
41
21.7M
void* PgGetThreadLocalCurrentMemoryContext() {
42
21.7M
  return thread_local_memory_context_;
43
21.7M
}
44
45
20.5M
void PgResetCurrentMemCtxThreadLocalVars() {
46
20.5M
  pg_strtok_ptr = NULL;
47
20.5M
  jump_buffer = NULL;
48
20.5M
  err_msg = NULL;
49
20.5M
}
50
51
//-----------------------------------------------------------------------------
52
// Error reporting.
53
//-----------------------------------------------------------------------------
54
55
105M
void* PgSetThreadLocalJumpBuffer(void* new_buffer) {
56
105M
    void *old_buffer = jump_buffer;
57
105M
    jump_buffer = new_buffer;
58
105M
    return old_buffer;
59
105M
}
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
445k
void* PgGetThreadLocalStrTokPtr() {
78
445k
  return pg_strtok_ptr;
79
445k
}
80
81
452k
void PgSetThreadLocalStrTokPtr(char *new_pg_strtok_ptr) {
82
452k
  pg_strtok_ptr = new_pg_strtok_ptr;
83
452k
}
84
85
}  // namespace pggate
86
}  // namespace yb