diff options
author | vvvv <vvvv@yandex-team.ru> | 2022-02-17 21:18:45 +0300 |
---|---|---|
committer | vvvv <vvvv@yandex-team.ru> | 2022-02-17 21:18:45 +0300 |
commit | df1d39435a18570ad6722962d95e659cd4e2d736 (patch) | |
tree | 7677bb049ef5c0c98febf9019144da42af072d95 | |
parent | 3c6d2452a60e03ac4f2ab2b74b16d17d7fde4f5c (diff) | |
download | ydb-df1d39435a18570ad6722962d95e659cd4e2d736.tar.gz |
YQL-13710 more patches
ref:b9b1e6233c8bc36ea7d2603084c559a18147fea3
169 files changed, 559 insertions, 551 deletions
diff --git a/ydb/library/yql/parser/pg_query_wrapper/copy_src.py b/ydb/library/yql/parser/pg_query_wrapper/copy_src.py index 1be7d3da07..4ced17c4ba 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/copy_src.py +++ b/ydb/library/yql/parser/pg_query_wrapper/copy_src.py @@ -35,10 +35,14 @@ def fix_line(line): return line if not "=" in line: - if "(" in line or "{" in line or "}" in line: + line2=line + if "//" in line2: line2 = line2[:line2.find("//")] + if "/*" in line2: line2 = line2[:line2.find("/*")] + + if "(" in line2 or "{" in line2 or "}" in line2: return line - if ";" not in line: + if ";" not in line2: return line if line.startswith("YYSTYPE yylval;"): @@ -49,7 +53,8 @@ def fix_line(line): ret = None found_v = None for v in all_vars: - if " " + v + " " in norm or " " + v + ";" in norm: + if " " + v + " " in norm or " " + v + ";" in norm or " " + v + "[" in norm or \ + "*" + v + " " in norm or "*" + v + ";" in norm or "*" + v + "[" in norm: found_v = v if line.startswith("static"): ret = "static __thread" + line[6:] @@ -70,7 +75,7 @@ def fix_line(line): ret+="\n"; thread_funcs.append(found_v+"_init"); - if "CurrentTransactionState" in ret: + if "CurrentTransactionState" in ret or "mainrdata_last" in ret: # rewrite with address of TLS var pos=ret.find("="); init_val=ret[pos+1:]; @@ -136,6 +141,14 @@ def get_vars(): all_vars.remove("backslash_quote") all_vars.remove("sentinel") # rbtree.c + all_vars.remove("gistBufferingOptValues") + all_vars.remove("boolRelOpts") + all_vars.remove("intRelOpts") + all_vars.remove("realRelOpts") + all_vars.remove("viewCheckOptValues") + all_vars.remove("enumRelOpts") + all_vars.remove("stringRelOpts") + with open("vars.txt","w") as f: for a in sorted(all_vars): print(a, file=f) diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/common/reloptions.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/common/reloptions.c index 61b03deea1..79c052a97c 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/common/reloptions.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/common/reloptions.c @@ -526,11 +526,11 @@ static relopt_string stringRelOpts[] = {{NULL}} }; -static relopt_gen **relOpts = NULL; +static __thread relopt_gen **relOpts = NULL; static __thread bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT; static __thread int num_custom_options = 0; -static relopt_gen **custom_options = NULL; +static __thread relopt_gen **custom_options = NULL; static __thread bool need_initialization = true; static void initialize_reloptions(void); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/common/session.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/common/session.c index 0ec61d48a2..a61731dfa5 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/common/session.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/common/session.c @@ -45,7 +45,7 @@ #define SESSION_KEY_RECORD_TYPMOD_REGISTRY UINT64CONST(0xFFFFFFFFFFFF0002) /* This backend's current session. */ -Session *CurrentSession = NULL; +__thread Session *CurrentSession = NULL; /* * Set up CurrentSession to point to an empty Session object. diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/heap/syncscan.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/heap/syncscan.c index a32f6836f8..416154435e 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/heap/syncscan.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/heap/syncscan.c @@ -112,7 +112,7 @@ typedef struct ss_scan_locations_t (offsetof(ss_scan_locations_t, items) + (N) * sizeof(ss_lru_item_t)) /* Pointer to struct in shared memory */ -static ss_scan_locations_t *scan_locations; +static __thread ss_scan_locations_t *scan_locations; /* prototypes for internal functions */ static BlockNumber ss_search(RelFileNode relfilenode, diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/nbtree/nbtutils.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/nbtree/nbtutils.c index 7c33711a9f..2f9756e305 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/nbtree/nbtutils.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/nbtree/nbtutils.c @@ -1918,7 +1918,7 @@ typedef struct BTVacInfo BTOneVacInfo vacuums[FLEXIBLE_ARRAY_MEMBER]; } BTVacInfo; -static BTVacInfo *btvacinfo; +static __thread BTVacInfo *btvacinfo; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/table/tableam.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/table/tableam.c index 1a63e83ea2..62c42b9781 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/table/tableam.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/table/tableam.c @@ -31,7 +31,7 @@ /* GUC variables */ -char *default_table_access_method = DEFAULT_TABLE_ACCESS_METHOD; +__thread char *default_table_access_method = DEFAULT_TABLE_ACCESS_METHOD; __thread bool synchronize_seqscans = true; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/commit_ts.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/commit_ts.c index 490afdc9da..af4d89eec7 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/commit_ts.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/commit_ts.c @@ -96,7 +96,7 @@ typedef struct CommitTimestampShared bool commitTsActive; } CommitTimestampShared; -CommitTimestampShared *commitTsShared; +__thread CommitTimestampShared *commitTsShared; /* GUC variable */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/multixact.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/multixact.c index cb9350d3ba..bce9e87df1 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/multixact.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/multixact.c @@ -288,9 +288,9 @@ typedef struct MultiXactStateData #define MaxOldestSlot (MaxBackends + max_prepared_xacts) /* Pointers to the state data in shared memory */ -static MultiXactStateData *MultiXactState; -static MultiXactId *OldestMemberMXactId; -static MultiXactId *OldestVisibleMXactId; +static __thread MultiXactStateData *MultiXactState; +static __thread MultiXactId *OldestMemberMXactId; +static __thread MultiXactId *OldestVisibleMXactId; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/parallel.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/parallel.c index a4364a74b4..caedfc5840 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/parallel.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/parallel.c @@ -118,7 +118,7 @@ __thread volatile bool ParallelMessagePending = false; __thread bool InitializingParallelWorker = false; /* Pointer to our fixed parallel state. */ -static FixedParallelState *MyFixedParallelState; +static __thread FixedParallelState *MyFixedParallelState; /* List of active parallel contexts. */ static __thread dlist_head pcxt_list ;void pcxt_list_init(void) { dlist_init(&pcxt_list); } diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/twophase.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/twophase.c index 4222405627..b52f17aae4 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/twophase.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/twophase.c @@ -188,7 +188,7 @@ typedef struct TwoPhaseStateData GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]; } TwoPhaseStateData; -static TwoPhaseStateData *TwoPhaseState; +static __thread TwoPhaseStateData *TwoPhaseState; /* * Global transaction entry currently locked by us, if any. Note that any diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xact.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xact.c index d2550a765d..c6a8a2d2b5 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xact.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xact.c @@ -108,7 +108,7 @@ __thread int synchronous_commit = SYNCHRONOUS_COMMIT_ON; */ __thread FullTransactionId XactTopFullTransactionId = {InvalidTransactionId}; __thread int nParallelCurrentXids = 0; -TransactionId *ParallelCurrentXids; +__thread TransactionId *ParallelCurrentXids; /* * Miscellaneous flag bits to record events which occur on the top level @@ -231,7 +231,7 @@ static __thread TransactionStateData TopTransactionStateData = { * reported in an XLOG_XACT_ASSIGNMENT record. */ static __thread int nUnreportedXids; -static TransactionId unreportedXids[PGPROC_MAX_CACHED_SUBXIDS]; +static __thread TransactionId unreportedXids[PGPROC_MAX_CACHED_SUBXIDS]; static __thread TransactionState CurrentTransactionState ;void CurrentTransactionState_init(void) { CurrentTransactionState= &TopTransactionStateData; }; @@ -259,7 +259,7 @@ static __thread TimestampTz xactStopTimestamp; * GID to be used for preparing the current transaction. This is also * global to a whole transaction, so we don't keep it in the state stack. */ -static char *prepareGID; +static __thread char *prepareGID; /* * Some commands want to force synchronous commit. @@ -286,7 +286,7 @@ typedef struct XactCallbackItem void *arg; } XactCallbackItem; -static XactCallbackItem *Xact_callbacks = NULL; +static __thread XactCallbackItem *Xact_callbacks = NULL; /* * List of add-on start- and end-of-subxact callbacks @@ -298,7 +298,7 @@ typedef struct SubXactCallbackItem void *arg; } SubXactCallbackItem; -static SubXactCallbackItem *SubXact_callbacks = NULL; +static __thread SubXactCallbackItem *SubXact_callbacks = NULL; /* local function prototypes */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xlog.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xlog.c index c361c65afd..a4476cf194 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xlog.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xlog.c @@ -92,13 +92,13 @@ __thread int wal_keep_size_mb = 0; __thread int XLOGbuffers = -1; __thread int XLogArchiveTimeout = 0; __thread int XLogArchiveMode = ARCHIVE_MODE_OFF; -char *XLogArchiveCommand = NULL; +__thread char *XLogArchiveCommand = NULL; __thread bool EnableHotStandby = false; __thread bool fullPageWrites = true; __thread bool wal_log_hints = false; __thread bool wal_compression = false; -char *wal_consistency_checking_string = NULL; -bool *wal_consistency_checking = NULL; +__thread char *wal_consistency_checking_string = NULL; +__thread bool *wal_consistency_checking = NULL; __thread bool wal_init_zero = true; __thread bool wal_recycle = true; __thread bool log_checkpoints = false; @@ -281,28 +281,28 @@ static __thread bool recovery_signal_file_found = false; static __thread bool restoredFromArchive = false; /* Buffers dedicated to consistency checks of size BLCKSZ */ -static char *replay_image_masked = NULL; -static char *master_image_masked = NULL; +static __thread char *replay_image_masked = NULL; +static __thread char *master_image_masked = NULL; /* options formerly taken from recovery.conf for archive recovery */ -char *recoveryRestoreCommand = NULL; -char *recoveryEndCommand = NULL; -char *archiveCleanupCommand = NULL; +__thread char *recoveryRestoreCommand = NULL; +__thread char *recoveryEndCommand = NULL; +__thread char *archiveCleanupCommand = NULL; __thread RecoveryTargetType recoveryTarget = RECOVERY_TARGET_UNSET; __thread bool recoveryTargetInclusive = true; __thread int recoveryTargetAction = RECOVERY_TARGET_ACTION_PAUSE; __thread TransactionId recoveryTargetXid; -char *recovery_target_time_string; +__thread char *recovery_target_time_string; static __thread TimestampTz recoveryTargetTime; -const char *recoveryTargetName; +__thread const char *recoveryTargetName; __thread XLogRecPtr recoveryTargetLSN; __thread int recovery_min_apply_delay = 0; /* options formerly taken from recovery.conf for XLOG streaming */ __thread bool StandbyModeRequested = false; -char *PrimaryConnInfo = NULL; -char *PrimarySlotName = NULL; -char *PromoteTriggerFile = NULL; +__thread char *PrimaryConnInfo = NULL; +__thread char *PrimarySlotName = NULL; +__thread char *PromoteTriggerFile = NULL; __thread bool wal_receiver_create_temp_slot = false; /* are we currently in standby mode? */ @@ -318,7 +318,7 @@ static __thread bool fast_promote = false; static __thread TransactionId recoveryStopXid; static __thread TimestampTz recoveryStopTime; static __thread XLogRecPtr recoveryStopLSN; -static char recoveryStopName[MAXFNAMELEN]; +static __thread char recoveryStopName[MAXFNAMELEN]; static __thread bool recoveryStopAfter; /* @@ -350,7 +350,7 @@ static __thread bool recoveryStopAfter; __thread RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal = RECOVERY_TARGET_TIMELINE_LATEST; __thread TimeLineID recoveryTargetTLIRequested = 0; __thread TimeLineID recoveryTargetTLI = 0; -static List *expectedTLEs; +static __thread List *expectedTLEs; static __thread TimeLineID curFileTLI; /* @@ -736,15 +736,15 @@ typedef struct XLogCtlData slock_t info_lck; /* locks shared variables shown above */ } XLogCtlData; -static XLogCtlData *XLogCtl = NULL; +static __thread XLogCtlData *XLogCtl = NULL; /* a private copy of XLogCtl->Insert.WALInsertLocks, for convenience */ -static WALInsertLockPadded *WALInsertLocks = NULL; +static __thread WALInsertLockPadded *WALInsertLocks = NULL; /* * We maintain an image of pg_control in shared memory. */ -static ControlFileData *ControlFile = NULL; +static __thread ControlFileData *ControlFile = NULL; /* * Calculate the amount of space left on the page after 'endptr'. Beware diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xloginsert.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xloginsert.c index 5d8ff10ccd..ff860d85a2 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xloginsert.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xloginsert.c @@ -61,7 +61,7 @@ typedef struct char compressed_page[PGLZ_MAX_BLCKSZ]; } registered_buffer; -static registered_buffer *registered_buffers; +static __thread registered_buffer *registered_buffers; static __thread int max_registered_buffers; /* allocated size */ static __thread int max_registered_block_id = 0; /* highest block_id + 1 currently * registered */ @@ -70,8 +70,9 @@ static __thread int max_registered_block_id = 0; /* highest block_id + 1 current * A chain of XLogRecDatas to hold the "main data" of a WAL record, registered * with XLogRegisterData(...). */ -static XLogRecData *mainrdata_head; -static XLogRecData *mainrdata_last = (XLogRecData *) &mainrdata_head; +static __thread XLogRecData *mainrdata_head; +static __thread XLogRecData *mainrdata_last ;void mainrdata_last_init(void) { mainrdata_last= (XLogRecData *) &mainrdata_head; + }; static __thread uint32 mainrdata_len; /* total # of bytes in chain */ /* flags for the in-progress insertion */ @@ -86,7 +87,7 @@ static __thread uint8 curinsert_flags = 0; * WAL record. */ static __thread XLogRecData hdr_rdt; -static char *hdr_scratch = NULL; +static __thread char *hdr_scratch = NULL; #define SizeOfXlogOrigin (sizeof(RepOriginId) + sizeof(char)) @@ -98,7 +99,7 @@ static char *hdr_scratch = NULL; /* * An array of XLogRecData structs, to hold registered data. */ -static XLogRecData *rdatas; +static __thread XLogRecData *rdatas; static __thread int num_rdatas; /* entries currently used */ static __thread int max_rdatas; /* allocated size */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xlogutils.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xlogutils.c index c0251e6e69..b251a91dea 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xlogutils.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/transam/xlogutils.c @@ -57,7 +57,7 @@ typedef struct xl_invalid_page bool present; /* page existed but contained zeroes */ } xl_invalid_page; -static HTAB *invalid_page_tab = NULL; +static __thread HTAB *invalid_page_tab = NULL; /* Report a reference to an invalid page */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/bootstrap/bootscanner.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/bootstrap/bootscanner.c index 886411fe51..36e1593c2e 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/bootstrap/bootscanner.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/bootstrap/bootscanner.c @@ -530,7 +530,7 @@ static __thread int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = NULL; +static __thread char *yy_c_buf_p = NULL; static __thread int yy_init = 0; /* whether we need to initialize */ static __thread int yy_start = 0; /* start state number */ @@ -771,7 +771,7 @@ static const flex_int16_t yy_chk[192] = } ; static __thread yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; +static __thread char *yy_last_accepting_cpos; extern int yy_flex_debug; int yy_flex_debug = 0; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/bootstrap/bootstrap.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/bootstrap/bootstrap.c index 9878552475..7ce680e9e2 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/bootstrap/bootstrap.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/bootstrap/bootstrap.c @@ -73,7 +73,7 @@ __thread AuxProcType MyAuxProcType = NotAnAuxProcess; /* declared in miscadmin.h __thread Relation boot_reldesc; /* current relation descriptor */ -Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */ +__thread Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */ __thread int numattr; /* number of attributes for cur. rel */ @@ -161,11 +161,11 @@ struct typmap FormData_pg_type am_typ; }; -static struct typmap **Typ = NULL; -static struct typmap *Ap = NULL; +static __thread struct typmap **Typ = NULL; +static __thread struct typmap *Ap = NULL; static __thread Datum values[MAXATTR]; /* current row's attribute values */ -static bool Nulls[MAXATTR]; +static __thread bool Nulls[MAXATTR]; static __thread MemoryContext nogc = NULL; /* special no-gc mem context */ @@ -183,7 +183,7 @@ typedef struct _IndexList struct _IndexList *il_next; } IndexList; -static IndexList *ILHead = NULL; +static __thread IndexList *ILHead = NULL; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/heap.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/heap.c index 622d8ec791..375395c593 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/heap.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/heap.c @@ -238,7 +238,7 @@ static const FormData_pg_attribute a6 = { .attislocal = true, }; -static const FormData_pg_attribute *SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6}; +static __thread const FormData_pg_attribute *SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6}; /* * This function returns a Form_pg_attribute pointer for a system attribute. diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/index.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/index.c index 77db2d43b8..797f7b7436 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/index.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/index.c @@ -3862,7 +3862,7 @@ reindex_relation(Oid relid, int flags, int options) static __thread Oid currentlyReindexedHeap = InvalidOid; static __thread Oid currentlyReindexedIndex = InvalidOid; -static List *pendingReindexedIndexes = NIL; +static __thread List *pendingReindexedIndexes = NIL; static __thread int reindexingNestLevel = 0; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/namespace.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/namespace.c index 33c3c1ca84..f7772fac26 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/namespace.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/namespace.c @@ -135,7 +135,7 @@ /* These variables define the actually active state: */ -static List *activeSearchPath = NIL; +static __thread List *activeSearchPath = NIL; /* default place to create stuff; if InvalidOid, no default */ static __thread Oid activeCreationNamespace = InvalidOid; @@ -148,7 +148,7 @@ static __thread uint64 activePathGeneration = 1; /* These variables are the values last derived from namespace_search_path: */ -static List *baseSearchPath = NIL; +static __thread List *baseSearchPath = NIL; static __thread Oid baseCreationNamespace = InvalidOid; @@ -168,7 +168,7 @@ typedef struct int nestLevel; /* subtransaction nesting level */ } OverrideStackEntry; -static List *overrideStack = NIL; +static __thread List *overrideStack = NIL; /* * myTempNamespace is InvalidOid until and unless a TEMP namespace is set up @@ -195,7 +195,7 @@ static __thread SubTransactionId myTempNamespaceSubID = InvalidSubTransactionId; * This is the user's textual search path specification --- it's the value * of the GUC variable 'search_path'. */ -char *namespace_search_path = NULL; +__thread char *namespace_search_path = NULL; /* Local functions */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/pg_enum.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/pg_enum.c index 9b31f3ebab..55954c67f9 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/pg_enum.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/pg_enum.c @@ -44,7 +44,7 @@ __thread Oid binary_upgrade_next_pg_enum_oid = InvalidOid; * EnumValuesCreate are *not* blacklisted; we assume those are created during * CREATE TYPE, so they can't go away unless the enum type itself does. */ -static HTAB *enum_blacklist = NULL; +static __thread HTAB *enum_blacklist = NULL; static void RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems); static int sort_order_cmp(const void *p1, const void *p2); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/storage.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/storage.c index 724d388185..6b37dc5ae2 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/storage.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/storage.c @@ -72,8 +72,8 @@ typedef struct PendingRelSync bool is_truncated; /* Has the file experienced truncation? */ } PendingRelSync; -static PendingRelDelete *pendingDeletes = NULL; /* head of linked list */ -HTAB *pendingSyncHash = NULL; +static __thread PendingRelDelete *pendingDeletes = NULL; /* head of linked list */ +__thread HTAB *pendingSyncHash = NULL; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/async.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/async.c index 18872ce7cc..1eb412c06a 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/async.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/async.c @@ -294,7 +294,7 @@ typedef struct AsyncQueueControl /* backend[0] is not used; used entries are from [1] to [MaxBackends] */ } AsyncQueueControl; -static AsyncQueueControl *asyncQueueControl; +static __thread AsyncQueueControl *asyncQueueControl; #define QUEUE_HEAD (asyncQueueControl->head) #define QUEUE_TAIL (asyncQueueControl->tail) @@ -338,7 +338,7 @@ static __thread SlruCtlData NotifyCtlData; * (ie, have committed a LISTEN on). It is a simple list of channel names, * allocated in TopMemoryContext. */ -static List *listenChannels = NIL; /* list of C strings */ +static __thread List *listenChannels = NIL; /* list of C strings */ /* * State for pending LISTEN/UNLISTEN actions consists of an ordered list of @@ -370,7 +370,7 @@ typedef struct ActionList struct ActionList *upper; /* details for upper transaction levels */ } ActionList; -static ActionList *pendingActions = NULL; +static __thread ActionList *pendingActions = NULL; /* * State for outbound notifies consists of a list of all channels+payloads @@ -422,7 +422,7 @@ typedef struct NotificationHash Notification *event; /* => the actual Notification struct */ } NotificationHash; -static NotificationList *pendingNotifies = NULL; +static __thread NotificationList *pendingNotifies = NULL; /* * Inbound notifications are initially processed by HandleNotifyInterrupt(), diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/event_trigger.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/event_trigger.c index b6894cbf76..3bcd8c9a44 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/event_trigger.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/event_trigger.c @@ -70,7 +70,7 @@ typedef struct EventTriggerQueryState struct EventTriggerQueryState *previous; } EventTriggerQueryState; -static EventTriggerQueryState *currentEventTriggerState = NULL; +static __thread EventTriggerQueryState *currentEventTriggerState = NULL; /* Support for dropped objects */ typedef struct SQLDropObject diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/prepare.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/prepare.c index e54cfc8ad8..d3f63b6281 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/prepare.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/prepare.c @@ -43,7 +43,7 @@ * The keys for this hash table are the arguments to PREPARE and EXECUTE * (statement names); the entries are PreparedStatement structs. */ -static HTAB *prepared_queries = NULL; +static __thread HTAB *prepared_queries = NULL; static void InitQueryHashTable(void); static ParamListInfo EvaluateParams(ParseState *pstate, diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/seclabel.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/seclabel.c index 546275ae65..c5b97ab56d 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/seclabel.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/seclabel.c @@ -31,7 +31,7 @@ typedef struct check_object_relabel_type hook; } LabelProvider; -static List *label_provider_list = NIL; +static __thread List *label_provider_list = NIL; /* * ExecSecLabelStmt -- diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/sequence.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/sequence.c index 6aab73bfd4..a4a04c0100 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/sequence.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/sequence.c @@ -86,13 +86,13 @@ typedef struct SeqTableData typedef SeqTableData *SeqTable; -static HTAB *seqhashtab = NULL; /* hash table for SeqTable items */ +static __thread HTAB *seqhashtab = NULL; /* hash table for SeqTable items */ /* * last_used_seq is updated by nextval() to point to the last used * sequence. */ -static SeqTableData *last_used_seq = NULL; +static __thread SeqTableData *last_used_seq = NULL; static void fill_seq_with_data(Relation rel, HeapTuple tuple); static Relation lock_and_open_sequence(SeqTable seq); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/tablecmds.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/tablecmds.c index d492f27d5d..5eea242253 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/tablecmds.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/tablecmds.c @@ -119,7 +119,7 @@ typedef struct OnCommitItem SubTransactionId deleting_subid; } OnCommitItem; -static List *on_commits = NIL; +static __thread List *on_commits = NIL; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/tablespace.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/tablespace.c index 2e6cc42908..d1ac3c3d65 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/tablespace.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/tablespace.c @@ -85,8 +85,8 @@ #include "utils/varlena.h" /* GUC variables */ -char *default_tablespace = NULL; -char *temp_tablespaces = NULL; +__thread char *default_tablespace = NULL; +__thread char *temp_tablespaces = NULL; static void create_tablespace_directories(const char *location, diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/vacuum.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/vacuum.c index daa6797798..c037bf050b 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/vacuum.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/vacuum.c @@ -73,8 +73,8 @@ static __thread BufferAccessStrategy vac_strategy; * Variables for cost-based parallel vacuum. See comments atop * compute_parallel_delay to understand how it works. */ -pg_atomic_uint32 *VacuumSharedCostBalance = NULL; -pg_atomic_uint32 *VacuumActiveNWorkers = NULL; +__thread pg_atomic_uint32 *VacuumSharedCostBalance = NULL; +__thread pg_atomic_uint32 *VacuumActiveNWorkers = NULL; __thread int VacuumCostBalanceLocal = 0; /* non-export function prototypes */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/variable.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/variable.c index 7fd3ca3a42..a32ce683e0 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/variable.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/variable.c @@ -819,7 +819,7 @@ assign_session_authorization(const char *newval, void *extra) * a translation of "none" to InvalidOid. Otherwise this is much like * SET SESSION AUTHORIZATION. */ -extern char *role_string; /* in guc.c */ +extern __thread char *role_string; /* in guc.c */ bool check_role(char **newval, void **extra, GucSource source) diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/executor/execExprInterp.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/executor/execExprInterp.c index 4524034d5d..7c87c7d98b 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/executor/execExprInterp.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/executor/execExprInterp.c @@ -106,10 +106,10 @@ typedef struct ExprEvalOpLookup } ExprEvalOpLookup; /* to make dispatch_table accessible outside ExecInterpExpr() */ -static const void **dispatch_table = NULL; +static __thread const void **dispatch_table = NULL; /* jump target -> opcode lookup table */ -static ExprEvalOpLookup reverse_dispatch_table[EEOP_LAST]; +static __thread ExprEvalOpLookup reverse_dispatch_table[EEOP_LAST]; #define EEO_SWITCH() #define EEO_CASE(name) CASE_##name: diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/executor/spi.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/executor/spi.c index 6adb64b9ad..fabee42b9b 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/executor/spi.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/executor/spi.c @@ -43,11 +43,11 @@ * when entering/exiting a SPI nesting level. */ __thread uint64 SPI_processed = 0; -SPITupleTable *SPI_tuptable = NULL; +__thread SPITupleTable *SPI_tuptable = NULL; __thread int SPI_result = 0; -static _SPI_connection *_SPI_stack = NULL; -static _SPI_connection *_SPI_current = NULL; +static __thread _SPI_connection *_SPI_stack = NULL; +static __thread _SPI_connection *_SPI_current = NULL; static __thread int _SPI_stack_depth = 0; /* allocated size of _SPI_stack */ static __thread int _SPI_connected = -1; /* current stack index */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/jit/jit.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/jit/jit.c index c9d172610d..8894e106f9 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/jit/jit.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/jit/jit.c @@ -30,7 +30,7 @@ /* GUCs */ __thread bool jit_enabled = true; -char *jit_provider = NULL; +__thread char *jit_provider = NULL; __thread bool jit_debugging_support = false; __thread bool jit_dump_bitcode = false; __thread bool jit_expressions = true; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/auth.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/auth.c index e1d9f92ea5..f960f4b0c3 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/auth.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/auth.c @@ -166,7 +166,7 @@ static int CheckCertAuth(Port *port); * Kerberos and GSSAPI GUCs *---------------------------------------------------------------- */ -char *pg_krb_server_keyfile; +__thread char *pg_krb_server_keyfile; __thread bool pg_krb_caseins_users; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/be-fsstubs.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/be-fsstubs.c index e14f5ca465..2b6badb1b3 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/be-fsstubs.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/be-fsstubs.c @@ -66,7 +66,7 @@ * dynamically allocated in that context. Its current allocated size is * cookies_size entries, of which any unused entries will be NULL. */ -static LargeObjectDesc **cookies = NULL; +static __thread LargeObjectDesc **cookies = NULL; static __thread int cookies_size = 0; static __thread bool lo_cleanup_needed = false; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/be-secure-openssl.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/be-secure-openssl.c index a04f404782..892bf06f6a 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/be-secure-openssl.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/be-secure-openssl.c @@ -66,7 +66,7 @@ static const char *SSLerrmessage(unsigned long ecode); static char *X509_NAME_to_cstring(X509_NAME *name); -static SSL_CTX *SSL_context = NULL; +static __thread SSL_CTX *SSL_context = NULL; static __thread bool SSL_initialized = false; static __thread bool dummy_ssl_passwd_cb_called = false; static __thread bool ssl_is_server_start; @@ -753,7 +753,7 @@ be_tls_write(Port *port, void *ptr, size_t len, int *waitfor) #define BIO_set_data(bio, data) (bio->ptr = data) #endif -static BIO_METHOD *my_bio_methods = NULL; +static __thread BIO_METHOD *my_bio_methods = NULL; static int my_sock_read(BIO *h, char *buf, int size) diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/be-secure.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/be-secure.c index 2c9702bf4d..becc10d599 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/be-secure.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/be-secure.c @@ -37,13 +37,13 @@ #include "tcop/tcopprot.h" #include "utils/memutils.h" -char *ssl_library; -char *ssl_cert_file; -char *ssl_key_file; -char *ssl_ca_file; -char *ssl_crl_file; -char *ssl_dh_params_file; -char *ssl_passphrase_command; +__thread char *ssl_library; +__thread char *ssl_cert_file; +__thread char *ssl_key_file; +__thread char *ssl_ca_file; +__thread char *ssl_crl_file; +__thread char *ssl_dh_params_file; +__thread char *ssl_passphrase_command; __thread bool ssl_passphrase_command_supports_reload; #ifdef USE_SSL @@ -51,10 +51,10 @@ __thread bool ssl_loaded_verify_locations = false; #endif /* GUC variable controlling SSL cipher list */ -char *SSLCipherSuites = NULL; +__thread char *SSLCipherSuites = NULL; /* GUC variable for default ECHD curve. */ -char *SSLECDHCurve; +__thread char *SSLECDHCurve; /* GUC variable: if false, prefer client ciphers */ __thread bool SSLPreferServerCiphers; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/hba.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/hba.c index 25f81f190b..fbdd195353 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/hba.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/hba.c @@ -98,7 +98,7 @@ typedef struct TokenizedLine * pre-parsed content of HBA config file: list of HbaLine structs. * parsed_hba_context is the memory context where it lives. */ -static List *parsed_hba_lines = NIL; +static __thread List *parsed_hba_lines = NIL; static __thread MemoryContext parsed_hba_context = NULL; /* @@ -109,7 +109,7 @@ static __thread MemoryContext parsed_hba_context = NULL; * that live outside the memory context. Before destroying or resetting the * memory context, they need to be explicitly free'd. */ -static List *parsed_ident_lines = NIL; +static __thread List *parsed_ident_lines = NIL; static __thread MemoryContext parsed_ident_context = NULL; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/pqcomm.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/pqcomm.c index c1ff0cdaba..db0e785c86 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/pqcomm.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/pqcomm.c @@ -117,10 +117,10 @@ * Configuration options */ __thread int Unix_socket_permissions; -char *Unix_socket_group; +__thread char *Unix_socket_group; /* Where the Unix socket files are (list of palloc'd strings) */ -static List *sock_paths = NIL; +static __thread List *sock_paths = NIL; /* * Buffers for low-level I/O. @@ -132,12 +132,12 @@ static List *sock_paths = NIL; #define PQ_SEND_BUFFER_SIZE 8192 #define PQ_RECV_BUFFER_SIZE 8192 -static char *PqSendBuffer; +static __thread char *PqSendBuffer; static __thread int PqSendBufferSize; /* Size send buffer */ static __thread int PqSendPointer; /* Next index to store a byte in PqSendBuffer */ static __thread int PqSendStart; /* Next index to send a byte in PqSendBuffer */ -static char PqRecvBuffer[PQ_RECV_BUFFER_SIZE]; +static __thread char PqRecvBuffer[PQ_RECV_BUFFER_SIZE]; static __thread int PqRecvPointer; /* Next index to read a byte from PqRecvBuffer */ static __thread int PqRecvLength; /* End of data available in PqRecvBuffer */ @@ -179,9 +179,9 @@ static const PQcommMethods PqCommSocketMethods = { socket_endcopyout }; -const PQcommMethods *PqCommMethods = &PqCommSocketMethods; +__thread const PQcommMethods *PqCommMethods = &PqCommSocketMethods; -WaitEventSet *FeBeWaitSet; +__thread WaitEventSet *FeBeWaitSet; /* -------------------------------- diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/pqmq.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/pqmq.c index 628f2bde59..2780f3ed1d 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/pqmq.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/pqmq.c @@ -21,7 +21,7 @@ #include "tcop/tcopprot.h" #include "utils/builtins.h" -static shm_mq_handle *pq_mq_handle; +static __thread shm_mq_handle *pq_mq_handle; static __thread bool pq_mq_busy = false; static __thread pid_t pq_mq_parallel_master_pid = 0; static __thread pid_t pq_mq_parallel_master_backend_id = InvalidBackendId; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/nodes/extensible.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/nodes/extensible.c index ab04459c55..3c95761f34 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/nodes/extensible.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/nodes/extensible.c @@ -23,8 +23,8 @@ #include "nodes/extensible.h" #include "utils/hsearch.h" -static HTAB *extensible_node_methods = NULL; -static HTAB *custom_scan_methods = NULL; +static __thread HTAB *extensible_node_methods = NULL; +static __thread HTAB *custom_scan_methods = NULL; typedef struct { diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/nodes/nodes.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/nodes/nodes.c index e5dcda3f58..41d212b73c 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/nodes/nodes.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/nodes/nodes.c @@ -28,4 +28,4 @@ * loadable module being loaded into a GCC-built backend. */ -Node *newNodeMacroHolder; +__thread Node *newNodeMacroHolder; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/nodes/read.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/nodes/read.c index 8c1e39044c..36fd607c07 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/nodes/read.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/nodes/read.c @@ -28,7 +28,7 @@ /* Static state for pg_strtok */ -static const char *pg_strtok_ptr = NULL; +static __thread const char *pg_strtok_ptr = NULL; /* State flag that determines how readfuncs.c should treat location fields */ #ifdef WRITE_READ_PARSE_PLAN_TREES diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/optimizer/util/predtest.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/optimizer/util/predtest.c index 0edd873dca..4af20d45d0 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/optimizer/util/predtest.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/optimizer/util/predtest.c @@ -1953,7 +1953,7 @@ typedef struct OprProofCacheEntry Oid refute_test_op; /* OID of the test operator, or 0 if none */ } OprProofCacheEntry; -static HTAB *OprProofCacheHash = NULL; +static __thread HTAB *OprProofCacheHash = NULL; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/parse_oper.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/parse_oper.c index 2749974f63..ceea0ca744 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/parse_oper.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/parse_oper.c @@ -1016,7 +1016,7 @@ make_scalar_array_op(ParseState *pstate, List *opname, */ /* The operator cache hashtable */ -static HTAB *OprCacheHash = NULL; +static __thread HTAB *OprCacheHash = NULL; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/scan.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/scan.c index af10ba4c83..f89b78bd65 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/scan.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/scan.c @@ -5077,7 +5077,7 @@ static const struct yy_trans_info yy_transition[20495] = { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 257, 65 }, { 1, 0 }, }; -static const struct yy_trans_info *yy_start_state_list[25] = +static __thread const struct yy_trans_info *yy_start_state_list[25] = { &yy_transition[1], &yy_transition[3], diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/port/sysv_shmem.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/port/sysv_shmem.c index cafcfcb4a6..23b0fcb4bd 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/port/sysv_shmem.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/port/sysv_shmem.c @@ -94,10 +94,10 @@ typedef enum __thread unsigned long UsedShmemSegID = 0; -void *UsedShmemSegAddr = NULL; +__thread void *UsedShmemSegAddr = NULL; static __thread Size AnonymousShmemSize; -static void *AnonymousShmem = NULL; +static __thread void *AnonymousShmem = NULL; static void *InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size); static void IpcMemoryDetach(int status, Datum shmaddr); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/autovacuum.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/autovacuum.c index b36db2dd3f..27935c90c9 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/autovacuum.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/autovacuum.c @@ -289,7 +289,7 @@ typedef struct AutoVacuumWorkItem av_workItems[NUM_WORKITEMS]; } AutoVacuumShmemStruct; -static AutoVacuumShmemStruct *AutoVacuumShmem; +static __thread AutoVacuumShmemStruct *AutoVacuumShmem; /* * the database list (of avl_dbase elements) in the launcher, and the context diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/bgworker.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/bgworker.c index a23ad4b166..8ac10ba1b9 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/bgworker.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/bgworker.c @@ -107,7 +107,7 @@ struct BackgroundWorkerHandle uint64 generation; }; -static BackgroundWorkerArray *BackgroundWorkerData; +static __thread BackgroundWorkerArray *BackgroundWorkerData; /* * List of internal background worker entry points. We need this for diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/checkpointer.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/checkpointer.c index 4588449ccc..0656ec18c2 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/checkpointer.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/checkpointer.c @@ -135,7 +135,7 @@ typedef struct CheckpointerRequest requests[FLEXIBLE_ARRAY_MEMBER]; } CheckpointerShmemStruct; -static CheckpointerShmemStruct *CheckpointerShmem; +static __thread CheckpointerShmemStruct *CheckpointerShmem; /* interval for calling AbsorbSyncRequests in CheckpointWriteDelay */ #define WRITES_PER_ABSORB 1000 diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/pgstat.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/pgstat.c index f6fa4e73be..dddddaa9cc 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/pgstat.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/pgstat.c @@ -130,9 +130,9 @@ __thread int pgstat_track_activity_query_size = 1024; * Built from GUC parameter * ---------- */ -char *pgstat_stat_directory = NULL; -char *pgstat_stat_filename = NULL; -char *pgstat_stat_tmpname = NULL; +__thread char *pgstat_stat_directory = NULL; +__thread char *pgstat_stat_filename = NULL; +__thread char *pgstat_stat_tmpname = NULL; /* * BgWriter global statistics counters (unused in other processes). @@ -165,7 +165,7 @@ static const char *const slru_names[] = { * to copy things around. We assume this variable inits to zeroes. Entries * are one-to-one with slru_names[]. */ -static PgStat_MsgSLRU SLRUStats[SLRU_NUM_ELEMENTS]; +static __thread PgStat_MsgSLRU SLRUStats[SLRU_NUM_ELEMENTS]; /* ---------- * Local data @@ -199,7 +199,7 @@ typedef struct TabStatusArray PgStat_TableStatus tsa_entries[TABSTAT_QUANTUM]; /* per-table data */ } TabStatusArray; -static TabStatusArray *pgStatTabList = NULL; +static __thread TabStatusArray *pgStatTabList = NULL; /* * pgStatTabHash entry: map from relation OID to PgStat_TableStatus pointer @@ -213,13 +213,13 @@ typedef struct TabStatHashEntry /* * Hash table for O(1) t_id -> tsa_entry lookup */ -static HTAB *pgStatTabHash = NULL; +static __thread HTAB *pgStatTabHash = NULL; /* * Backends store per-function info that's waiting to be sent to the collector * in this hash table (indexed by function OID). */ -static HTAB *pgStatFunctions = NULL; +static __thread HTAB *pgStatFunctions = NULL; /* * Indicates if backend has some function stats that it hasn't yet @@ -241,7 +241,7 @@ typedef struct PgStat_SubXactStatus PgStat_TableXactStatus *first; /* head of list for this subxact */ } PgStat_SubXactStatus; -static PgStat_SubXactStatus *pgStatXactStack = NULL; +static __thread PgStat_SubXactStatus *pgStatXactStack = NULL; static __thread int pgStatXactCommit = 0; static __thread int pgStatXactRollback = 0; @@ -266,10 +266,10 @@ typedef struct TwoPhasePgStatRecord * Info about current "snapshot" of stats file */ static __thread MemoryContext pgStatLocalContext = NULL; -static HTAB *pgStatDBHash = NULL; +static __thread HTAB *pgStatDBHash = NULL; /* Status for backends including auxiliary */ -static LocalPgBackendStatus *localBackendStatusTable = NULL; +static __thread LocalPgBackendStatus *localBackendStatusTable = NULL; /* Total number of backends including auxiliary */ static __thread int localNumBackends = 0; @@ -281,14 +281,14 @@ static __thread int localNumBackends = 0; */ static __thread PgStat_ArchiverStats archiverStats; static __thread PgStat_GlobalStats globalStats; -static PgStat_SLRUStats slruStats[SLRU_NUM_ELEMENTS]; +static __thread PgStat_SLRUStats slruStats[SLRU_NUM_ELEMENTS]; /* * List of OIDs of databases we need to write out. If an entry is InvalidOid, * it means to write only the shared-catalog stats ("DB 0"); otherwise, we * will write both that DB's data and the shared stats. */ -static List *pending_write_requests = NIL; +static __thread List *pending_write_requests = NIL; /* * Total time charged to functions so far in the current backend. @@ -2701,14 +2701,14 @@ pgstat_fetch_slru(void) * ------------------------------------------------------------ */ -static PgBackendStatus *BackendStatusArray = NULL; -static PgBackendStatus *MyBEEntry = NULL; -static char *BackendAppnameBuffer = NULL; -static char *BackendClientHostnameBuffer = NULL; -static char *BackendActivityBuffer = NULL; +static __thread PgBackendStatus *BackendStatusArray = NULL; +static __thread PgBackendStatus *MyBEEntry = NULL; +static __thread char *BackendAppnameBuffer = NULL; +static __thread char *BackendClientHostnameBuffer = NULL; +static __thread char *BackendActivityBuffer = NULL; static __thread Size BackendActivityBufferSize = 0; #ifdef USE_SSL -static PgBackendSSLStatus *BackendSslStatusBuffer = NULL; +static __thread PgBackendSSLStatus *BackendSslStatusBuffer = NULL; #endif #ifdef ENABLE_GSS static PgBackendGSSStatus *BackendGssStatusBuffer = NULL; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/postmaster.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/postmaster.c index d1068230a4..267dabf31f 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/postmaster.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/postmaster.c @@ -188,7 +188,7 @@ static __thread dlist_head BackendList ;void BackendList_init(void) { dlist_init static Backend *ShmemBackendArray; #endif -BackgroundWorker *MyBgworkerEntry = NULL; +__thread BackgroundWorker *MyBgworkerEntry = NULL; @@ -196,10 +196,10 @@ BackgroundWorker *MyBgworkerEntry = NULL; __thread int PostPortNumber; /* The directory names for Unix socket(s) */ -char *Unix_socket_directories; +__thread char *Unix_socket_directories; /* The TCP listen address(es) */ -char *ListenAddresses; +__thread char *ListenAddresses; /* * ReservedBackends is the number of backends reserved for superuser use. @@ -214,12 +214,12 @@ __thread int ReservedBackends; /* The socket(s) we're listening to. */ #define MAXLISTEN 64 -static pgsocket ListenSocket[MAXLISTEN]; +static __thread pgsocket ListenSocket[MAXLISTEN]; /* * Set by the -o option */ -static char ExtraOptions[MAXPGPATH]; +static __thread char ExtraOptions[MAXPGPATH]; /* * These globals control the behavior of the postmaster in case some @@ -242,7 +242,7 @@ __thread bool Log_connections = false; __thread bool Db_user_namespace = false; __thread bool enable_bonjour = false; -char *bonjour_name; +__thread char *bonjour_name; __thread bool restart_after_crash = true; /* PIDs of special child processes; 0 when not running */ @@ -566,7 +566,7 @@ static void ShmemBackendArrayRemove(Backend *bn); * File descriptors for pipe used to monitor if postmaster is alive. * First is POSTMASTER_FD_WATCH, second is POSTMASTER_FD_OWN. */ -int postmaster_alive_fds[2] = {-1, -1}; +__thread int postmaster_alive_fds[2] = {-1, -1}; #else /* Process handle of postmaster used for the same purpose on Windows */ HANDLE PostmasterHandle; @@ -6166,10 +6166,10 @@ PostmasterMarkPIDForWorkerNotify(int pid) * The following need to be available to the save/restore_backend_variables * functions. They are marked NON_EXEC_STATIC in their home modules. */ -extern slock_t *ShmemLock; -extern slock_t *ProcStructLock; -extern PGPROC *AuxiliaryProcs; -extern PMSignalData *PMSignalState; +extern __thread slock_t *ShmemLock; +extern __thread slock_t *ProcStructLock; +extern __thread PGPROC *AuxiliaryProcs; +extern __thread PMSignalData *PMSignalState; extern __thread pgsocket pgStatSock; extern __thread pg_time_t first_syslogger_file_time; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/syslogger.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/syslogger.c index 7eff0cf40a..5d398be306 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/syslogger.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/postmaster/syslogger.c @@ -69,8 +69,8 @@ __thread bool Logging_collector = false; __thread int Log_RotationAge = HOURS_PER_DAY * MINS_PER_HOUR; __thread int Log_RotationSize = 10 * 1024; -char *Log_directory = NULL; -char *Log_filename = NULL; +__thread char *Log_directory = NULL; +__thread char *Log_filename = NULL; __thread bool Log_truncate_on_rotation = false; __thread int Log_file_mode = S_IRUSR | S_IWUSR; @@ -82,11 +82,11 @@ extern __thread bool redirection_done; static __thread pg_time_t next_rotation_time; static __thread bool pipe_eof_seen = false; static __thread bool rotation_disabled = false; -static FILE *syslogFile = NULL; -static FILE *csvlogFile = NULL; +static __thread FILE *syslogFile = NULL; +static __thread FILE *csvlogFile = NULL; __thread NON_EXEC_STATIC pg_time_t first_syslogger_file_time = 0; -static char *last_file_name = NULL; -static char *last_csv_file_name = NULL; +static __thread char *last_file_name = NULL; +static __thread char *last_csv_file_name = NULL; /* * Buffers for saving partial messages from different backends. @@ -106,13 +106,13 @@ typedef struct } save_buffer; #define NBUFFER_LISTS 256 -static List *buffer_lists[NBUFFER_LISTS]; +static __thread List *buffer_lists[NBUFFER_LISTS]; /* These must be exported for EXEC_BACKEND case ... annoying */ #ifndef WIN32 -int syslogPipe[2] = {-1, -1}; +__thread int syslogPipe[2] = {-1, -1}; #else -HANDLE syslogPipe[2] = {0, 0}; +__thread HANDLE syslogPipe[2] = {0, 0}; #endif #ifdef WIN32 diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/regex/regc_pg_locale.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/regex/regc_pg_locale.c index 189fa537e2..30e15b1546 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/regex/regc_pg_locale.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/regex/regc_pg_locale.c @@ -728,7 +728,7 @@ typedef struct pg_ctype_cache struct pg_ctype_cache *next; /* chain link */ } pg_ctype_cache; -static pg_ctype_cache *pg_ctype_cache_list = NULL; +static __thread pg_ctype_cache *pg_ctype_cache_list = NULL; /* * Add a chr or range to pcc->cv; return false if run out of memory diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/basebackup.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/basebackup.c index 3a1eb4870f..8d01e2981c 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/basebackup.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/basebackup.c @@ -84,7 +84,7 @@ static bool is_checksummed_file(const char *fullpath, const char *filename); static __thread bool backup_started_in_recovery = false; /* Relative path of temporary statistics directory */ -static char *statrelpath = NULL; +static __thread char *statrelpath = NULL; /* * Size of each block sent into the tar stream for larger files. diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/launcher.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/launcher.c index 531e831e69..535405b80f 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/launcher.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/launcher.c @@ -54,7 +54,7 @@ __thread int max_logical_replication_workers = 4; __thread int max_sync_workers_per_subscription = 2; -LogicalRepWorker *MyLogicalRepWorker = NULL; +__thread LogicalRepWorker *MyLogicalRepWorker = NULL; typedef struct LogicalRepCtxStruct { @@ -65,7 +65,7 @@ typedef struct LogicalRepCtxStruct LogicalRepWorker workers[FLEXIBLE_ARRAY_MEMBER]; } LogicalRepCtxStruct; -LogicalRepCtxStruct *LogicalRepCtx; +__thread LogicalRepCtxStruct *LogicalRepCtx; typedef struct LogicalRepWorkerId { @@ -85,7 +85,7 @@ typedef struct StopWorkersData * Stack of StopWorkersData elements. Each stack element contains the workers * to be stopped for that subtransaction. */ -static StopWorkersData *on_commit_stop_workers = NULL; +static __thread StopWorkersData *on_commit_stop_workers = NULL; static void ApplyLauncherWakeup(void); static void logicalrep_launcher_onexit(int code, Datum arg); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/origin.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/origin.c index 2fea672320..8467b406ba 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/origin.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/origin.c @@ -162,19 +162,19 @@ __thread TimestampTz replorigin_session_origin_timestamp = 0; * XXX: Should we use a separate variable to size this rather than * max_replication_slots? */ -static ReplicationState *replication_states; +static __thread ReplicationState *replication_states; /* * Actual shared memory block (replication_states[] is now part of this). */ -static ReplicationStateCtl *replication_states_ctl; +static __thread ReplicationStateCtl *replication_states_ctl; /* * Backend-local, cached element from ReplicationState for use in a backend * replaying remote commits, so we don't have to search ReplicationState for * the backends current RepOriginId. */ -static ReplicationState *session_replication_state = NULL; +static __thread ReplicationState *session_replication_state = NULL; /* Magic for on disk files. */ #define REPLICATION_STATE_MAGIC ((uint32) 0x1257DADE) diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/relation.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/relation.c index 0843dc31d7..3f0244a558 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/relation.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/relation.c @@ -29,7 +29,7 @@ static __thread MemoryContext LogicalRepRelMapContext = NULL; -static HTAB *LogicalRepRelMap = NULL; +static __thread HTAB *LogicalRepRelMap = NULL; /* * Partition map (LogicalRepPartMap) @@ -43,7 +43,7 @@ static HTAB *LogicalRepRelMap = NULL; * separately for each partition. */ static __thread MemoryContext LogicalRepPartMapContext = NULL; -static HTAB *LogicalRepPartMap = NULL; +static __thread HTAB *LogicalRepPartMap = NULL; typedef struct LogicalRepPartMapEntry { Oid partoid; /* LogicalRepPartMap's key */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/worker.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/worker.c index 7e48693213..caa34c89ca 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/worker.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/worker.c @@ -111,9 +111,9 @@ typedef struct ApplyExecutionData static __thread MemoryContext ApplyMessageContext = NULL; __thread MemoryContext ApplyContext = NULL; -WalReceiverConn *LogRepWorkerWalRcvConn = NULL; +__thread WalReceiverConn *LogRepWorkerWalRcvConn = NULL; -Subscription *MySubscription = NULL; +__thread Subscription *MySubscription = NULL; __thread bool MySubscriptionValid = false; __thread bool in_remote_transaction = false; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/repl_gram.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/repl_gram.c index 7c8c56dc76..c972d86637 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/repl_gram.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/repl_gram.c @@ -100,7 +100,7 @@ /* Result of the parsing is returned here */ -Node *replication_parse_result; +__thread Node *replication_parse_result; static SQLCmd *make_sqlcmd(void); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/repl_scanner.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/repl_scanner.c index 6445659b2c..6e9d35f883 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/repl_scanner.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/repl_scanner.c @@ -530,7 +530,7 @@ static __thread int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = NULL; +static __thread char *yy_c_buf_p = NULL; static __thread int yy_init = 0; /* whether we need to initialize */ static __thread int yy_start = 0; /* start state number */ @@ -927,7 +927,7 @@ static const flex_int16_t yy_chk[644] = } ; static __thread yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; +static __thread char *yy_last_accepting_cpos; extern int yy_flex_debug; int yy_flex_debug = 0; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/slot.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/slot.c index bd7a0c6e7c..47151c1fe4 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/slot.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/slot.c @@ -90,10 +90,10 @@ typedef struct ReplicationSlotOnDisk #define SLOT_VERSION 2 /* version for new files */ /* Control array for replication slot management */ -ReplicationSlotCtlData *ReplicationSlotCtl = NULL; +__thread ReplicationSlotCtlData *ReplicationSlotCtl = NULL; /* My backend's replication slot in the shared memory array */ -ReplicationSlot *MyReplicationSlot = NULL; +__thread ReplicationSlot *MyReplicationSlot = NULL; /* GUCs */ __thread int max_replication_slots = 0; /* the maximum number of replication diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/syncrep.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/syncrep.c index 032b94f088..03db753fc6 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/syncrep.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/syncrep.c @@ -87,14 +87,14 @@ #include "utils/ps_status.h" /* User-settable parameters for sync rep */ -char *SyncRepStandbyNames; +__thread char *SyncRepStandbyNames; #define SyncStandbysDefined() \ (SyncRepStandbyNames != NULL && SyncRepStandbyNames[0] != '\0') static __thread bool announce_next_takeover = true; -SyncRepConfigData *SyncRepConfig = NULL; +__thread SyncRepConfigData *SyncRepConfig = NULL; static __thread int SyncRepWaitMode = SYNC_REP_NO_WAIT; static void SyncRepQueueInsert(int mode); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/syncrep_gram.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/syncrep_gram.c index 4fc2265168..974001a94a 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/syncrep_gram.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/syncrep_gram.c @@ -94,8 +94,8 @@ #include "replication/syncrep.h" /* Result of parsing is returned in one of these two variables */ -SyncRepConfigData *syncrep_parse_result; -char *syncrep_parse_error_msg; +__thread SyncRepConfigData *syncrep_parse_result; +__thread char *syncrep_parse_error_msg; static SyncRepConfigData *create_syncrep_config(const char *num_sync, List *members, uint8 syncrep_method); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/syncrep_scanner.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/syncrep_scanner.c index e7eecd49a3..2a2b61b85e 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/syncrep_scanner.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/syncrep_scanner.c @@ -530,7 +530,7 @@ static __thread int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = NULL; +static __thread char *yy_c_buf_p = NULL; static __thread int yy_init = 0; /* whether we need to initialize */ static __thread int yy_start = 0; /* start state number */ @@ -708,7 +708,7 @@ static const flex_int16_t yy_chk[64] = } ; static __thread yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; +static __thread char *yy_last_accepting_cpos; extern int yy_flex_debug; int yy_flex_debug = 0; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/walreceiver.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/walreceiver.c index e2f7bdd5db..e2c04895df 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/walreceiver.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/walreceiver.c @@ -90,8 +90,8 @@ __thread int wal_receiver_timeout; __thread bool hot_standby_feedback; /* libpqwalreceiver connection */ -static WalReceiverConn *wrconn = NULL; -WalReceiverFunctionsType *WalReceiverFunctions = NULL; +static __thread WalReceiverConn *wrconn = NULL; +__thread WalReceiverFunctionsType *WalReceiverFunctions = NULL; #define NAPTIME_PER_CYCLE 100 /* max sleep time between cycles (100ms) */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/walreceiverfuncs.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/walreceiverfuncs.c index 3984228a11..5974b9bf34 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/walreceiverfuncs.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/walreceiverfuncs.c @@ -29,7 +29,7 @@ #include "storage/shmem.h" #include "utils/timestamp.h" -WalRcvData *WalRcv = NULL; +__thread WalRcvData *WalRcv = NULL; /* * How long to wait for walreceiver to start up after requesting diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/walsender.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/walsender.c index 7f09b67332..f23f29631f 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/walsender.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/walsender.c @@ -106,10 +106,10 @@ #define MAX_SEND_SIZE (XLOG_BLCKSZ * 16) /* Array of WalSnds in shared memory */ -WalSndCtlData *WalSndCtl = NULL; +__thread WalSndCtlData *WalSndCtl = NULL; /* My slot in the shared memory array */ -WalSnd *MyWalSnd = NULL; +__thread WalSnd *MyWalSnd = NULL; /* Global state */ __thread bool am_walsender = false; /* Am I a walsender process? */ @@ -134,7 +134,7 @@ __thread bool wake_wal_senders = false; * replication does not need xlogreader to read WAL, but it needs one to * keep a state of its work. */ -static XLogReaderState *xlogreader = NULL; +static __thread XLogReaderState *xlogreader = NULL; /* * These variables keep track of the state of the timeline we're currently @@ -194,7 +194,7 @@ static __thread volatile sig_atomic_t got_STOPPING = false; */ static __thread volatile sig_atomic_t replication_active = false; -static LogicalDecodingContext *logical_decoding_ctx = NULL; +static __thread LogicalDecodingContext *logical_decoding_ctx = NULL; /* A sample associating a WAL location with the time it was written. */ typedef struct @@ -216,7 +216,7 @@ typedef struct WalTimeSample last_read[NUM_SYNC_REP_WAIT_MODE]; } LagTracker; -static LagTracker *lag_tracker; +static __thread LagTracker *lag_tracker; /* Signal handlers */ static void WalSndLastCycleHandler(SIGNAL_ARGS); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/buf_init.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/buf_init.c index 1754fd35fa..eff1d80a8c 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/buf_init.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/buf_init.c @@ -17,11 +17,11 @@ #include "storage/buf_internals.h" #include "storage/bufmgr.h" -BufferDescPadded *BufferDescriptors; -char *BufferBlocks; -LWLockMinimallyPadded *BufferIOLWLockArray = NULL; +__thread BufferDescPadded *BufferDescriptors; +__thread char *BufferBlocks; +__thread LWLockMinimallyPadded *BufferIOLWLockArray = NULL; __thread WritebackContext BackendWritebackContext; -CkptSortItem *CkptBufferIds; +__thread CkptSortItem *CkptBufferIds; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/buf_table.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/buf_table.c index 4953ae9f82..b850ee4f4d 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/buf_table.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/buf_table.c @@ -31,7 +31,7 @@ typedef struct int id; /* Associated buffer ID */ } BufferLookupEnt; -static HTAB *SharedBufHash; +static __thread HTAB *SharedBufHash; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/bufmgr.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/bufmgr.c index 720537f2d4..5d0ccd2b62 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/bufmgr.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/bufmgr.c @@ -149,11 +149,11 @@ __thread int bgwriter_flush_after = 0; __thread int backend_flush_after = 0; /* local state for StartBufferIO and related functions */ -static BufferDesc *InProgressBuf = NULL; +static __thread BufferDesc *InProgressBuf = NULL; static __thread bool IsForInput; /* local state for LockBufferForCleanup */ -static BufferDesc *PinCountWaitBuf = NULL; +static __thread BufferDesc *PinCountWaitBuf = NULL; /* * Backend-Private refcount management: @@ -185,11 +185,11 @@ static BufferDesc *PinCountWaitBuf = NULL; * memory allocations in NewPrivateRefCountEntry() which can be important * because in some scenarios it's called with a spinlock held... */ -static struct PrivateRefCountEntry PrivateRefCountArray[REFCOUNT_ARRAY_ENTRIES]; -static HTAB *PrivateRefCountHash = NULL; +static __thread struct PrivateRefCountEntry PrivateRefCountArray[REFCOUNT_ARRAY_ENTRIES]; +static __thread HTAB *PrivateRefCountHash = NULL; static __thread int32 PrivateRefCountOverflowed = 0; static __thread uint32 PrivateRefCountClock = 0; -static PrivateRefCountEntry *ReservedRefCountEntry = NULL; +static __thread PrivateRefCountEntry *ReservedRefCountEntry = NULL; static void ReservePrivateRefCountEntry(void); static PrivateRefCountEntry *NewPrivateRefCountEntry(Buffer buffer); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/freelist.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/freelist.c index 942f8d4edd..bbc90a2400 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/freelist.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/freelist.c @@ -61,7 +61,7 @@ typedef struct } BufferStrategyControl; /* Pointers to shared state */ -static BufferStrategyControl *StrategyControl = NULL; +static __thread BufferStrategyControl *StrategyControl = NULL; /* * Private (non-shared) state for managing a ring of shared buffers to re-use. diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/localbuf.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/localbuf.c index fc560489b8..dd31b67af7 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/localbuf.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/buffer/localbuf.c @@ -40,13 +40,13 @@ typedef struct __thread int NLocBuffer = 0; /* until buffers are initialized */ -BufferDesc *LocalBufferDescriptors = NULL; -Block *LocalBufferBlockPointers = NULL; -int32 *LocalRefCount = NULL; +__thread BufferDesc *LocalBufferDescriptors = NULL; +__thread Block *LocalBufferBlockPointers = NULL; +__thread int32 *LocalRefCount = NULL; static __thread int nextFreeLocalBuf = 0; -static HTAB *LocalBufHash = NULL; +static __thread HTAB *LocalBufHash = NULL; static void InitLocalBuffers(void); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/file/fd.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/file/fd.c index e159f9e69b..c0e8ec1e9c 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/file/fd.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/file/fd.c @@ -202,7 +202,7 @@ typedef struct vfd * needed. 'File' values are indexes into this array. * Note that VfdCache[0] is not a usable VFD, just a list header. */ -static Vfd *VfdCache; +static __thread Vfd *VfdCache; static __thread Size SizeVfdCache = 0; /* @@ -250,7 +250,7 @@ typedef struct static __thread int numAllocatedDescs = 0; static __thread int maxAllocatedDescs = 0; -static AllocateDesc *allocatedDescs = NULL; +static __thread AllocateDesc *allocatedDescs = NULL; /* * Number of open "external" FDs reported to Reserve/ReleaseExternalFD. @@ -269,7 +269,7 @@ static __thread long tempFileCounter = 0; * When numTempTableSpaces is -1, this has not been set in the current * transaction. */ -static Oid *tempTableSpaces = NULL; +static __thread Oid *tempTableSpaces = NULL; static __thread int numTempTableSpaces = -1; static __thread int nextTempTableSpace = 0; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/dsm.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/dsm.c index f59871e5ee..1cb5e26d74 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/dsm.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/dsm.c @@ -126,9 +126,9 @@ static __thread dlist_head dsm_segment_list ;void dsm_segment_list_init(void) { * life cycle. For simplicity, it doesn't have a dsm_segment object either. */ static __thread dsm_handle dsm_control_handle; -static dsm_control_header *dsm_control; +static __thread dsm_control_header *dsm_control; static __thread Size dsm_control_mapped_size = 0; -static void *dsm_control_impl_private = NULL; +static __thread void *dsm_control_impl_private = NULL; /* * Start up the dynamic shared memory system. diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/ipc.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/ipc.c index e2fd3b4616..c0866b4218 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/ipc.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/ipc.c @@ -76,9 +76,9 @@ struct ONEXIT Datum arg; }; -static struct ONEXIT on_proc_exit_list[MAX_ON_EXITS]; -static struct ONEXIT on_shmem_exit_list[MAX_ON_EXITS]; -static struct ONEXIT before_shmem_exit_list[MAX_ON_EXITS]; +static __thread struct ONEXIT on_proc_exit_list[MAX_ON_EXITS]; +static __thread struct ONEXIT on_shmem_exit_list[MAX_ON_EXITS]; +static __thread struct ONEXIT before_shmem_exit_list[MAX_ON_EXITS]; static int on_proc_exit_index, on_shmem_exit_index, diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/pmsignal.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/pmsignal.c index c53b1730ff..8622480001 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/pmsignal.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/pmsignal.c @@ -73,7 +73,7 @@ struct PMSignalData sig_atomic_t PMChildFlags[FLEXIBLE_ARRAY_MEMBER]; }; -NON_EXEC_STATIC volatile PMSignalData *PMSignalState = NULL; +__thread NON_EXEC_STATIC volatile PMSignalData *PMSignalState = NULL; /* * Signal handler to be notified if postmaster dies. diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/procarray.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/procarray.c index 0c7a946e9b..1f33671b18 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/procarray.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/procarray.c @@ -99,16 +99,16 @@ typedef struct ProcArrayStruct int pgprocnos[FLEXIBLE_ARRAY_MEMBER]; } ProcArrayStruct; -static ProcArrayStruct *procArray; +static __thread ProcArrayStruct *procArray; -static PGPROC *allProcs; -static PGXACT *allPgXact; +static __thread PGPROC *allProcs; +static __thread PGXACT *allPgXact; /* * Bookkeeping for tracking emulated transactions in recovery */ -static TransactionId *KnownAssignedXids; -static bool *KnownAssignedXidsValid; +static __thread TransactionId *KnownAssignedXids; +static __thread bool *KnownAssignedXidsValid; static __thread TransactionId latestObservedXid = InvalidTransactionId; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/procsignal.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/procsignal.c index 4fa385b0ec..245f52e035 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/procsignal.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/procsignal.c @@ -87,8 +87,8 @@ typedef struct #define BARRIER_SHOULD_CHECK(flags, type) \ (((flags) & (((uint32) 1) << (uint32) (type))) != 0) -static ProcSignalHeader *ProcSignal = NULL; -static volatile ProcSignalSlot *MyProcSignalSlot = NULL; +static __thread ProcSignalHeader *ProcSignal = NULL; +static __thread volatile ProcSignalSlot *MyProcSignalSlot = NULL; static bool CheckProcSignal(ProcSignalReason reason); static void CleanupProcSignalState(int status, Datum arg); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/shmem.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/shmem.c index 97716f6aef..4c1381ea10 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/shmem.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/shmem.c @@ -79,16 +79,16 @@ static void *ShmemAllocRaw(Size size, Size *allocated_size); /* shared memory global variables */ -static PGShmemHeader *ShmemSegHdr; /* shared mem segment header */ +static __thread PGShmemHeader *ShmemSegHdr; /* shared mem segment header */ -static void *ShmemBase; /* start address of shared memory */ +static __thread void *ShmemBase; /* start address of shared memory */ -static void *ShmemEnd; /* end+1 address of shared memory */ +static __thread void *ShmemEnd; /* end+1 address of shared memory */ -slock_t *ShmemLock; /* spinlock for shared memory and LWLock +__thread slock_t *ShmemLock; /* spinlock for shared memory and LWLock * allocation */ -static HTAB *ShmemIndex = NULL; /* primary index hashtable for shmem */ +static __thread HTAB *ShmemIndex = NULL; /* primary index hashtable for shmem */ /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/sinvaladt.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/sinvaladt.c index 701270c503..197e783341 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/sinvaladt.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/sinvaladt.c @@ -188,7 +188,7 @@ typedef struct SISeg ProcState procState[FLEXIBLE_ARRAY_MEMBER]; } SISeg; -static SISeg *shmInvalBuffer; /* pointer to the shared inval buffer */ +static __thread SISeg *shmInvalBuffer; /* pointer to the shared inval buffer */ static __thread LocalTransactionId nextLocalTransactionId; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/standby.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/standby.c index 5a40aceece..9e579a5478 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/standby.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/standby.c @@ -40,7 +40,7 @@ __thread int vacuum_defer_cleanup_age; __thread int max_standby_archive_delay = 30 * 1000; __thread int max_standby_streaming_delay = 30 * 1000; -static HTAB *RecoveryLockLists; +static __thread HTAB *RecoveryLockLists; /* Flags set by timeout handlers */ static __thread volatile sig_atomic_t got_standby_deadlock_timeout = false; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/condition_variable.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/condition_variable.c index 37b6a4eecd..b7ebcf0e29 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/condition_variable.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/condition_variable.c @@ -28,10 +28,10 @@ #include "utils/memutils.h" /* Initially, we are not prepared to sleep on any condition variable. */ -static ConditionVariable *cv_sleep_target = NULL; +static __thread ConditionVariable *cv_sleep_target = NULL; /* Reusable WaitEventSet. */ -static WaitEventSet *cv_wait_event_set = NULL; +static __thread WaitEventSet *cv_wait_event_set = NULL; /* * Initialize a condition variable. diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/deadlock.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/deadlock.c index 92ba8faba7..b434bd502e 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/deadlock.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/deadlock.c @@ -99,33 +99,33 @@ static void PrintLockQueue(LOCK *lock, const char *info); */ /* Workspace for FindLockCycle */ -static PGPROC **visitedProcs; /* Array of visited procs */ +static __thread PGPROC **visitedProcs; /* Array of visited procs */ static __thread int nVisitedProcs; /* Workspace for TopoSort */ -static PGPROC **topoProcs; /* Array of not-yet-output procs */ -static int *beforeConstraints; /* Counts of remaining before-constraints */ -static int *afterConstraints; /* List head for after-constraints */ +static __thread PGPROC **topoProcs; /* Array of not-yet-output procs */ +static __thread int *beforeConstraints; /* Counts of remaining before-constraints */ +static __thread int *afterConstraints; /* List head for after-constraints */ /* Output area for ExpandConstraints */ -static WAIT_ORDER *waitOrders; /* Array of proposed queue rearrangements */ +static __thread WAIT_ORDER *waitOrders; /* Array of proposed queue rearrangements */ static __thread int nWaitOrders; static __thread PGPROC **waitOrderProcs; /* Space for waitOrders queue contents */ /* Current list of constraints being considered */ -static EDGE *curConstraints; +static __thread EDGE *curConstraints; static __thread int nCurConstraints; static __thread int maxCurConstraints; /* Storage space for results from FindLockCycle */ -static EDGE *possibleConstraints; +static __thread EDGE *possibleConstraints; static __thread int nPossibleConstraints; static __thread int maxPossibleConstraints; -static DEADLOCK_INFO *deadlockDetails; +static __thread DEADLOCK_INFO *deadlockDetails; static __thread int nDeadlockDetails; /* PGPROC pointer of any blocking autovacuum worker found */ -static PGPROC *blocking_autovacuum_proc = NULL; +static __thread PGPROC *blocking_autovacuum_proc = NULL; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/lock.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/lock.c index 95324fd990..92c112647b 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/lock.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/lock.c @@ -268,7 +268,7 @@ typedef struct uint32 count[FAST_PATH_STRONG_LOCK_HASH_PARTITIONS]; } FastPathStrongRelationLockData; -static volatile FastPathStrongRelationLockData *FastPathStrongRelationLocks; +static __thread volatile FastPathStrongRelationLockData *FastPathStrongRelationLocks; /* @@ -277,14 +277,14 @@ static volatile FastPathStrongRelationLockData *FastPathStrongRelationLocks; * The LockMethodLockHash and LockMethodProcLockHash hash tables are in * shared memory; LockMethodLocalHash is local to each backend. */ -static HTAB *LockMethodLockHash; -static HTAB *LockMethodProcLockHash; -static HTAB *LockMethodLocalHash; +static __thread HTAB *LockMethodLockHash; +static __thread HTAB *LockMethodProcLockHash; +static __thread HTAB *LockMethodLocalHash; /* private state for error cleanup */ -static LOCALLOCK *StrongLockInProgress; -static LOCALLOCK *awaitedLock; +static __thread LOCALLOCK *StrongLockInProgress; +static __thread LOCALLOCK *awaitedLock; static __thread ResourceOwner awaitedOwner; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/lwlock.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/lwlock.c index 78b9d3ee2f..ea003f13ba 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/lwlock.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/lwlock.c @@ -94,7 +94,7 @@ /* We use the ShmemLock spinlock to protect LWLockCounter */ -extern slock_t *ShmemLock; +extern __thread slock_t *ShmemLock; #define LW_FLAG_HAS_WAITERS ((uint32) 1 << 30) #define LW_FLAG_RELEASE_OK ((uint32) 1 << 29) @@ -189,7 +189,7 @@ StaticAssertDecl(lengthof(BuiltinTrancheNames) == * stores the names of all dynamically-created tranches known to the current * process. Any unused entries in the array will contain NULL. */ -static const char **LWLockTrancheNames = NULL; +static __thread const char **LWLockTrancheNames = NULL; static __thread int LWLockTrancheNamesAllocated = 0; /* @@ -197,7 +197,7 @@ static __thread int LWLockTrancheNamesAllocated = 0; * the pointer by fork from the postmaster (except in the EXEC_BACKEND case, * where we have special measures to pass it down). */ -LWLockPadded *MainLWLockArray = NULL; +__thread LWLockPadded *MainLWLockArray = NULL; /* * We use this structure to keep track of locked LWLocks for release @@ -215,7 +215,7 @@ typedef struct LWLockHandle } LWLockHandle; static __thread int num_held_lwlocks = 0; -static LWLockHandle held_lwlocks[MAX_SIMUL_LWLOCKS]; +static __thread LWLockHandle held_lwlocks[MAX_SIMUL_LWLOCKS]; /* struct representing the LWLock tranche request for named tranche */ typedef struct NamedLWLockTrancheRequest @@ -224,7 +224,7 @@ typedef struct NamedLWLockTrancheRequest int num_lwlocks; } NamedLWLockTrancheRequest; -static NamedLWLockTrancheRequest *NamedLWLockTrancheRequestArray = NULL; +static __thread NamedLWLockTrancheRequest *NamedLWLockTrancheRequestArray = NULL; static __thread int NamedLWLockTrancheRequestsAllocated = 0; /* @@ -236,7 +236,7 @@ static __thread int NamedLWLockTrancheRequestsAllocated = 0; __thread int NamedLWLockTrancheRequests = 0; /* points to data in shared memory: */ -NamedLWLockTranche *NamedLWLockTrancheArray = NULL; +__thread NamedLWLockTranche *NamedLWLockTrancheArray = NULL; static __thread bool lock_named_request_allowed = true; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/predicate.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/predicate.c index 5abc8f62ef..91de8c0905 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/predicate.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/predicate.c @@ -354,7 +354,7 @@ static __thread SerialControl serialControl; * collapsing duplicate targets. When a duplicate is found, the later * commitSeqNo is used. */ -static SERIALIZABLEXACT *OldCommittedSxact; +static __thread SERIALIZABLEXACT *OldCommittedSxact; /* @@ -388,10 +388,10 @@ static __thread RWConflictPoolHeader RWConflictPool; * The predicate locking hash tables are in shared memory. * Each backend keeps pointers to them. */ -static HTAB *SerializableXidHash; -static HTAB *PredicateLockTargetHash; -static HTAB *PredicateLockHash; -static SHM_QUEUE *FinishedSerializableTransactions; +static __thread HTAB *SerializableXidHash; +static __thread HTAB *PredicateLockTargetHash; +static __thread HTAB *PredicateLockHash; +static __thread SHM_QUEUE *FinishedSerializableTransactions; /* * Tag for a dummy entry in PredicateLockTargetHash. By temporarily removing @@ -400,20 +400,20 @@ static SHM_QUEUE *FinishedSerializableTransactions; */ static const PREDICATELOCKTARGETTAG ScratchTargetTag = {0, 0, 0, 0}; static __thread uint32 ScratchTargetTagHash; -static LWLock *ScratchPartitionLock; +static __thread LWLock *ScratchPartitionLock; /* * The local hash table used to determine when to combine multiple fine- * grained locks into a single courser-grained lock. */ -static HTAB *LocalPredicateLockHash = NULL; +static __thread HTAB *LocalPredicateLockHash = NULL; /* * Keep a pointer to the currently-running serializable transaction (if any) * for quick reference. Also, remember if we have written anything that could * cause a rw-conflict. */ -static SERIALIZABLEXACT *MySerializableXact = InvalidSerializableXact; +static __thread SERIALIZABLEXACT *MySerializableXact = InvalidSerializableXact; static __thread bool MyXactDidWrite = false; /* @@ -423,7 +423,7 @@ static __thread bool MyXactDidWrite = false; * transaction, because the workers still have a reference to it. In that * case, the leader stores it here. */ -static SERIALIZABLEXACT *SavedSerializableXact = InvalidSerializableXact; +static __thread SERIALIZABLEXACT *SavedSerializableXact = InvalidSerializableXact; /* local functions */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/proc.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/proc.c index c23fc21e8b..ee7641861a 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/proc.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/lmgr/proc.c @@ -64,8 +64,8 @@ __thread int IdleInTransactionSessionTimeout = 0; __thread bool log_lock_waits = false; /* Pointer to this process's PGPROC and PGXACT structs, if any */ -PGPROC *MyProc = NULL; -PGXACT *MyPgXact = NULL; +__thread PGPROC *MyProc = NULL; +__thread PGXACT *MyPgXact = NULL; /* * This spinlock protects the freelist of recycled PGPROC structures. @@ -74,15 +74,15 @@ PGXACT *MyPgXact = NULL; * relatively infrequently (only at backend startup or shutdown) and not for * very long, so a spinlock is okay. */ -NON_EXEC_STATIC slock_t *ProcStructLock = NULL; +__thread NON_EXEC_STATIC slock_t *ProcStructLock = NULL; /* Pointers to shared-memory structures */ -PROC_HDR *ProcGlobal = NULL; -NON_EXEC_STATIC PGPROC *AuxiliaryProcs = NULL; -PGPROC *PreparedXactProcs = NULL; +__thread PROC_HDR *ProcGlobal = NULL; +__thread NON_EXEC_STATIC PGPROC *AuxiliaryProcs = NULL; +__thread PGPROC *PreparedXactProcs = NULL; /* If we are waiting for a lock, this points to the associated LOCALLOCK */ -static LOCALLOCK *lockAwaited = NULL; +static __thread LOCALLOCK *lockAwaited = NULL; static __thread DeadLockState deadlock_state = DS_NOT_YET_CHECKED; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/smgr/smgr.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/smgr/smgr.c index 5328dfdec9..79af6da447 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/smgr/smgr.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/smgr/smgr.c @@ -90,7 +90,7 @@ static const int NSmgr = lengthof(smgrsw); * Each backend has a hashtable that stores all extant SMgrRelation objects. * In addition, "unowned" SMgrRelation objects are chained together in a list. */ -static HTAB *SMgrRelationHash = NULL; +static __thread HTAB *SMgrRelationHash = NULL; static __thread dlist_head unowned_relns; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/sync/sync.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/sync/sync.c index 70516ec0ba..457785dffb 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/sync/sync.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/sync/sync.c @@ -69,8 +69,8 @@ typedef struct bool canceled; /* true if request has been canceled */ } PendingUnlinkEntry; -static HTAB *pendingOps = NULL; -static List *pendingUnlinks = NIL; +static __thread HTAB *pendingOps = NULL; +static __thread List *pendingUnlinks = NIL; static __thread MemoryContext pendingOpsCxt; /* context for the above */ static __thread CycleCtr sync_cycle_ctr = 0; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tcop/dest.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tcop/dest.c index 96789f88ef..25c3bf6afb 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tcop/dest.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tcop/dest.c @@ -93,7 +93,7 @@ static const DestReceiver spi_printtupDR = { * It's ok to cast the constness away as any modification of the none receiver * would be a bug (which gets easier to catch this way). */ -DestReceiver *None_Receiver = (DestReceiver *) &donothingDR; +__thread DestReceiver *None_Receiver = (DestReceiver *) &donothingDR; /* ---------------- * BeginCommand - initialize the destination at start of command diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tcop/postgres.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tcop/postgres.c index 648b0ab2a1..cc9e485dda 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tcop/postgres.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tcop/postgres.c @@ -85,7 +85,7 @@ * global variables * ---------------- */ -const char *debug_query_string; /* client-supplied query string */ +__thread const char *debug_query_string; /* client-supplied query string */ /* Note: whereToSendOutput is initialized for the bootstrap/standalone case */ __thread CommandDest whereToSendOutput = DestDebug; @@ -117,7 +117,7 @@ static __thread long max_stack_depth_bytes = 100 * 1024L; * it directly. Newer versions use set_stack_base(), but we want to stay * binary-compatible for the time being. */ -char *stack_base_ptr = NULL; +__thread char *stack_base_ptr = NULL; /* * On IA64 we also have to remember the register stack base. @@ -151,10 +151,10 @@ static __thread bool ignore_till_sync = false; * We keep it separate from the hashtable kept by commands/prepare.c * in order to reduce overhead for short-lived queries. */ -static CachedPlanSource *unnamed_stmt_psrc = NULL; +static __thread CachedPlanSource *unnamed_stmt_psrc = NULL; /* assorted command-line switches */ -static const char *userDoption = NULL; /* -D switch */ +static __thread const char *userDoption = NULL; /* -D switch */ static __thread bool EchoQuery = false; /* -E switch */ static __thread bool UseSemiNewlineNewline = false; /* -j switch */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tsearch/spell.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tsearch/spell.c index 756fc859ac..4a1d9399ac 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tsearch/spell.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tsearch/spell.c @@ -190,7 +190,7 @@ lowerstr_ctx(IspellDict *Conf, const char *src) #define GETWCHAR(W,L,N,T) ( ((const uint8*)(W))[ ((T)==FF_PREFIX) ? (N) : ( (L) - 1 - (N) ) ] ) #define GETCHAR(A,N,T) GETWCHAR( (A)->repl, (A)->replen, N, T ) -static char *VoidString = ""; +static __thread char *VoidString = ""; static int cmpspell(const void *s1, const void *s2) diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/acl.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/acl.c index 95ed6da990..1c2aaa45ea 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/acl.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/acl.c @@ -73,9 +73,9 @@ typedef struct * The cache is valid if cached_member_role is not InvalidOid. */ static __thread Oid cached_privs_role = InvalidOid; -static List *cached_privs_roles = NIL; +static __thread List *cached_privs_roles = NIL; static __thread Oid cached_member_role = InvalidOid; -static List *cached_membership_roles = NIL; +static __thread List *cached_membership_roles = NIL; static const char *getid(const char *s, char *n); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/array_typanalyze.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/array_typanalyze.c index 4912cabc61..66f72e9493 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/array_typanalyze.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/array_typanalyze.c @@ -62,7 +62,7 @@ typedef struct * currently need to be re-entrant, so avoiding this is not worth the extra * notational cruft that would be needed. */ -static ArrayAnalyzeExtraData *array_extra_data; +static __thread ArrayAnalyzeExtraData *array_extra_data; /* A hash table entry for the Lossy Counting algorithm */ typedef struct diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/datetime.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/datetime.c index 0b6dfb248c..c7e18d5f4e 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/datetime.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/datetime.c @@ -234,15 +234,15 @@ static const datetkn deltatktbl[] = { static const int szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0]; -static TimeZoneAbbrevTable *zoneabbrevtbl = NULL; +static __thread TimeZoneAbbrevTable *zoneabbrevtbl = NULL; /* Caches of recent lookup results in the above tables */ -static const datetkn *datecache[MAXDATEFIELDS] = {NULL}; +static __thread const datetkn *datecache[MAXDATEFIELDS] = {NULL}; -static const datetkn *deltacache[MAXDATEFIELDS] = {NULL}; +static __thread const datetkn *deltacache[MAXDATEFIELDS] = {NULL}; -static const datetkn *abbrevcache[MAXDATEFIELDS] = {NULL}; +static __thread const datetkn *abbrevcache[MAXDATEFIELDS] = {NULL}; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/float.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/float.c index 3b9d88a18e..a806c492d5 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/float.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/float.c @@ -65,7 +65,7 @@ __thread float8 degree_c_one = 1.0; /* State for drandom() and setseed() */ static __thread bool drandom_seed_set = false; -static unsigned short drandom_seed[3] = {0, 0, 0}; +static __thread unsigned short drandom_seed[3] = {0, 0, 0}; /* Local function prototypes */ static double sind_q1(double x); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/formatting.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/formatting.c index bc307bfd38..49f43075b2 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/formatting.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/formatting.c @@ -426,12 +426,12 @@ typedef struct } NUMCacheEntry; /* global cache for date/time format pictures */ -static DCHCacheEntry *DCHCache[DCH_CACHE_ENTRIES]; +static __thread DCHCacheEntry *DCHCache[DCH_CACHE_ENTRIES]; static __thread int n_DCHCache = 0; /* current number of entries */ static __thread int DCHCounter = 0; /* aging-event counter */ /* global cache for number format pictures */ -static NUMCacheEntry *NUMCache[NUM_CACHE_ENTRIES]; +static __thread NUMCacheEntry *NUMCache[NUM_CACHE_ENTRIES]; static __thread int n_NUMCache = 0; /* current number of entries */ static __thread int NUMCounter = 0; /* aging-event counter */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/jsonpath_scan.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/jsonpath_scan.c index c436994b24..4eaddf1ace 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/jsonpath_scan.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/jsonpath_scan.c @@ -542,7 +542,7 @@ static __thread int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = NULL; +static __thread char *yy_c_buf_p = NULL; static __thread int yy_init = 0; /* whether we need to initialize */ static __thread int yy_start = 0; /* start state number */ @@ -2370,7 +2370,7 @@ static const struct yy_trans_info yy_transition[8135] = { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 257, 49 }, { 1, 0 }, }; -static const struct yy_trans_info *yy_start_state_list[11] = +static __thread const struct yy_trans_info *yy_start_state_list[11] = { &yy_transition[1], &yy_transition[3], @@ -2424,7 +2424,7 @@ static __thread JsonPathString scanstring; /* Handles to the buffer that the lexer uses internally */ static __thread YY_BUFFER_STATE scanbufhandle; -static char *scanbuf; +static __thread char *scanbuf; static __thread int scanbuflen; static void addstring(bool init, char *s, int l); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/pg_locale.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/pg_locale.c index dffa7666f2..9a4b7772e8 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/pg_locale.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/pg_locale.c @@ -91,10 +91,10 @@ /* GUC settings */ -char *locale_messages; -char *locale_monetary; -char *locale_numeric; -char *locale_time; +__thread char *locale_messages; +__thread char *locale_monetary; +__thread char *locale_numeric; +__thread char *locale_time; /* * lc_time localization cache. @@ -103,10 +103,10 @@ char *locale_time; * element is left as NULL for the convenience of outside code that wants * to sequentially scan these arrays. */ -char *localized_abbrev_days[7 + 1]; -char *localized_full_days[7 + 1]; -char *localized_abbrev_months[12 + 1]; -char *localized_full_months[12 + 1]; +__thread char *localized_abbrev_days[7 + 1]; +__thread char *localized_full_days[7 + 1]; +__thread char *localized_abbrev_months[12 + 1]; +__thread char *localized_full_months[12 + 1]; /* indicates whether locale information cache is valid */ static __thread bool CurrentLocaleConvValid = false; @@ -116,15 +116,15 @@ static __thread bool CurrentLCTimeValid = false; #define LC_ENV_BUFSIZE (NAMEDATALEN + 20) -static char lc_collate_envbuf[LC_ENV_BUFSIZE]; -static char lc_ctype_envbuf[LC_ENV_BUFSIZE]; +static __thread char lc_collate_envbuf[LC_ENV_BUFSIZE]; +static __thread char lc_ctype_envbuf[LC_ENV_BUFSIZE]; #ifdef LC_MESSAGES -static char lc_messages_envbuf[LC_ENV_BUFSIZE]; +static __thread char lc_messages_envbuf[LC_ENV_BUFSIZE]; #endif -static char lc_monetary_envbuf[LC_ENV_BUFSIZE]; -static char lc_numeric_envbuf[LC_ENV_BUFSIZE]; -static char lc_time_envbuf[LC_ENV_BUFSIZE]; +static __thread char lc_monetary_envbuf[LC_ENV_BUFSIZE]; +static __thread char lc_numeric_envbuf[LC_ENV_BUFSIZE]; +static __thread char lc_time_envbuf[LC_ENV_BUFSIZE]; /* Cache for collation-related knowledge */ @@ -137,7 +137,7 @@ typedef struct pg_locale_t locale; /* locale_t struct, or 0 if not valid */ } collation_cache_entry; -static HTAB *collation_cache = NULL; +static __thread HTAB *collation_cache = NULL; #if defined(WIN32) && defined(LC_MESSAGES) @@ -1777,7 +1777,7 @@ get_collation_actual_version(char collprovider, const char *collcollate) * in database encoding. Since the database encoding doesn't change, we only * need one of these per session. */ -static UConverter *icu_converter = NULL; +static __thread UConverter *icu_converter = NULL; static void init_icu_converter(void) diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/regexp.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/regexp.c index 1e117c357a..220dd97da2 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/regexp.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/regexp.c @@ -107,7 +107,7 @@ typedef struct cached_re_str } cached_re_str; static __thread int num_res = 0; /* # of cached re's */ -static cached_re_str re_array[MAX_CACHED_RES]; /* cached re's */ +static __thread cached_re_str re_array[MAX_CACHED_RES]; /* cached re's */ /* Local functions */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/ri_triggers.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/ri_triggers.c index a006eef8b4..806020ca30 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/ri_triggers.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/ri_triggers.c @@ -163,9 +163,9 @@ typedef struct RI_CompareHashEntry /* * Local data */ -static HTAB *ri_constraint_cache = NULL; -static HTAB *ri_query_cache = NULL; -static HTAB *ri_compare_cache = NULL; +static __thread HTAB *ri_constraint_cache = NULL; +static __thread HTAB *ri_query_cache = NULL; +static __thread HTAB *ri_compare_cache = NULL; static __thread dlist_head ri_constraint_cache_valid_list; static __thread int ri_constraint_cache_valid_count = 0; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/ruleutils.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/ruleutils.c index 62eaf40c1c..eec9a93c3f 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/ruleutils.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/ruleutils.c @@ -308,9 +308,9 @@ typedef void (*rsv_callback) (Node *node, deparse_context *context, * ---------- */ static __thread SPIPlanPtr plan_getrulebyoid = NULL; -static const char *query_getrulebyoid = "SELECT * FROM pg_catalog.pg_rewrite WHERE oid = $1"; +static __thread const char *query_getrulebyoid = "SELECT * FROM pg_catalog.pg_rewrite WHERE oid = $1"; static __thread SPIPlanPtr plan_getviewrule = NULL; -static const char *query_getviewrule = "SELECT * FROM pg_catalog.pg_rewrite WHERE ev_class = $1 AND rulename = $2"; +static __thread const char *query_getviewrule = "SELECT * FROM pg_catalog.pg_rewrite WHERE ev_class = $1 AND rulename = $2"; /* GUC parameters */ __thread bool quote_all_identifiers = false; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/attoptcache.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/attoptcache.c index 05ac366b40..8c13dcf891 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/attoptcache.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/attoptcache.c @@ -25,7 +25,7 @@ /* Hash table for information about each attribute's options */ -static HTAB *AttoptCacheHash = NULL; +static __thread HTAB *AttoptCacheHash = NULL; /* attrelid and attnum form the lookup key, and must appear first */ typedef struct diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/catcache.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/catcache.c index 3613ae5f44..dfd2061ee2 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/catcache.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/catcache.c @@ -61,7 +61,7 @@ #endif /* Cache management header --- pointer is NULL until created */ -static CatCacheHeader *CacheHdr = NULL; +static __thread CatCacheHeader *CacheHdr = NULL; static inline HeapTuple SearchCatCacheInternal(CatCache *cache, int nkeys, diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/evtcache.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/evtcache.c index 1aef8d957b..15bc489787 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/evtcache.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/evtcache.c @@ -45,7 +45,7 @@ typedef struct List *triggerlist; } EventTriggerCacheEntry; -static HTAB *EventTriggerCache; +static __thread HTAB *EventTriggerCache; static __thread MemoryContext EventTriggerCacheContext; static __thread EventTriggerCacheStateType EventTriggerCacheState = ETCS_NEEDS_REBUILD; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/inval.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/inval.c index 4b7e6f13c2..f543869a7e 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/inval.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/inval.c @@ -184,9 +184,9 @@ typedef struct TransInvalidationInfo bool RelcacheInitFileInval; } TransInvalidationInfo; -static TransInvalidationInfo *transInvalInfo = NULL; +static __thread TransInvalidationInfo *transInvalInfo = NULL; -static SharedInvalidationMessage *SharedInvalidMessagesArray; +static __thread SharedInvalidationMessage *SharedInvalidMessagesArray; static __thread int numSharedInvalidMessagesArray; static __thread int maxSharedInvalidMessagesArray; @@ -212,7 +212,7 @@ static struct SYSCACHECALLBACK Datum arg; } syscache_callback_list[MAX_SYSCACHE_CALLBACKS]; -static int16 syscache_callback_links[SysCacheSize]; +static __thread int16 syscache_callback_links[SysCacheSize]; static __thread int syscache_callback_count = 0; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/relcache.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/relcache.c index 6554cfab83..e99efce903 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/relcache.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/relcache.c @@ -128,7 +128,7 @@ typedef struct relidcacheent Relation reldesc; } RelIdCacheEnt; -static HTAB *RelationIdCache; +static __thread HTAB *RelationIdCache; /* * This flag is false until we have prepared the critical relcache entries @@ -164,7 +164,7 @@ typedef struct inprogressent bool invalidated; /* whether an invalidation arrived for it */ } InProgressEnt; -static InProgressEnt *in_progress_list; +static __thread InProgressEnt *in_progress_list; static __thread int in_progress_list_len; static __thread int in_progress_list_maxlen; @@ -179,7 +179,7 @@ static __thread int in_progress_list_maxlen; * cleanup processing must be idempotent. */ #define MAX_EOXACT_LIST 32 -static Oid eoxact_list[MAX_EOXACT_LIST]; +static __thread Oid eoxact_list[MAX_EOXACT_LIST]; static __thread int eoxact_list_len = 0; static __thread bool eoxact_list_overflowed = false; @@ -196,7 +196,7 @@ static __thread bool eoxact_list_overflowed = false; * cleanup work. The array expands as needed; there is no hashtable because * we don't need to access individual items except at EOXact. */ -static TupleDesc *EOXactTupleDescArray; +static __thread TupleDesc *EOXactTupleDescArray; static __thread int NextEOXactTupleDescNum = 0; static __thread int EOXactTupleDescArrayLen = 0; @@ -265,7 +265,7 @@ typedef struct opclasscacheent RegProcedure *supportProcs; /* OIDs of support procedures */ } OpClassCacheEnt; -static HTAB *OpClassCache = NULL; +static __thread HTAB *OpClassCache = NULL; /* non-export function prototypes */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/relfilenodemap.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/relfilenodemap.c index 68b01ca68f..2c68bf4d5c 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/relfilenodemap.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/relfilenodemap.c @@ -30,10 +30,10 @@ #include "utils/relmapper.h" /* Hash table for information about each relfilenode <-> oid pair */ -static HTAB *RelfilenodeMapHash = NULL; +static __thread HTAB *RelfilenodeMapHash = NULL; /* built first time through in InitializeRelfilenodeMap */ -static ScanKeyData relfilenode_skey[2]; +static __thread ScanKeyData relfilenode_skey[2]; typedef struct { diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/spccache.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/spccache.c index e0c3c1b1c1..e07b121cc1 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/spccache.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/spccache.c @@ -32,7 +32,7 @@ /* Hash table for information about each tablespace */ -static HTAB *TableSpaceCacheHash = NULL; +static __thread HTAB *TableSpaceCacheHash = NULL; typedef struct { diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/syscache.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/syscache.c index ca6984edda..a0a052aa45 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/syscache.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/syscache.c @@ -983,16 +983,16 @@ static const struct cachedesc cacheinfo[] = { } }; -static CatCache *SysCache[SysCacheSize]; +static __thread CatCache *SysCache[SysCacheSize]; static __thread bool CacheInitialized = false; /* Sorted array of OIDs of tables that have caches on them */ -static Oid SysCacheRelationOid[SysCacheSize]; +static __thread Oid SysCacheRelationOid[SysCacheSize]; static __thread int SysCacheRelationOidSize; /* Sorted array of OIDs of tables and indexes used by caches */ -static Oid SysCacheSupportingRelOid[SysCacheSize * 2]; +static __thread Oid SysCacheSupportingRelOid[SysCacheSize * 2]; static __thread int SysCacheSupportingRelOidSize; static int oid_compare(const void *a, const void *b); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/ts_cache.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/ts_cache.c index ce5b694d86..2fa3f9db27 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/ts_cache.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/ts_cache.c @@ -60,19 +60,19 @@ #define MAXDICTSPERTT 100 -static HTAB *TSParserCacheHash = NULL; -static TSParserCacheEntry *lastUsedParser = NULL; +static __thread HTAB *TSParserCacheHash = NULL; +static __thread TSParserCacheEntry *lastUsedParser = NULL; -static HTAB *TSDictionaryCacheHash = NULL; -static TSDictionaryCacheEntry *lastUsedDictionary = NULL; +static __thread HTAB *TSDictionaryCacheHash = NULL; +static __thread TSDictionaryCacheEntry *lastUsedDictionary = NULL; -static HTAB *TSConfigCacheHash = NULL; -static TSConfigCacheEntry *lastUsedConfig = NULL; +static __thread HTAB *TSConfigCacheHash = NULL; +static __thread TSConfigCacheEntry *lastUsedConfig = NULL; /* * GUC default_text_search_config, and a cache of the current config's OID */ -char *TSCurrentConfig = NULL; +__thread char *TSCurrentConfig = NULL; static __thread Oid TSCurrentConfigCache = InvalidOid; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/typcache.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/typcache.c index 4744edfe4b..408a714820 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/typcache.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/cache/typcache.c @@ -75,10 +75,10 @@ /* The main type cache hashtable searched by lookup_type_cache */ -static HTAB *TypeCacheHash = NULL; +static __thread HTAB *TypeCacheHash = NULL; /* List of type cache entries for domain types */ -static TypeCacheEntry *firstDomainTypeEntry = NULL; +static __thread TypeCacheEntry *firstDomainTypeEntry = NULL; /* Private flag bits in the TypeCacheEntry.flags field */ #define TCFLAGS_HAVE_PG_TYPE_DATA 0x000001 @@ -269,11 +269,11 @@ static const dshash_parameters srtr_typmod_table_params = { }; /* hashtable for recognizing registered record types */ -static HTAB *RecordCacheHash = NULL; +static __thread HTAB *RecordCacheHash = NULL; /* arrays of info about registered record types, indexed by assigned typmod */ -static TupleDesc *RecordCacheArray = NULL; -static uint64 *RecordIdentifierArray = NULL; +static __thread TupleDesc *RecordCacheArray = NULL; +static __thread uint64 *RecordIdentifierArray = NULL; static __thread int32 RecordCacheArrayLen = 0; /* allocated length of above arrays */ static __thread int32 NextRecordTypmod = 0; /* number of entries used */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/error/elog.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/error/elog.c index f5520f6558..86ffb1d6d2 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/error/elog.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/error/elog.c @@ -89,9 +89,9 @@ /* Global variables */ -ErrorContextCallback *error_context_stack = NULL; +__thread ErrorContextCallback *error_context_stack = NULL; -sigjmp_buf *PG_exception_stack = NULL; +__thread sigjmp_buf *PG_exception_stack = NULL; extern __thread bool redirection_done; @@ -106,9 +106,9 @@ __thread emit_log_hook_type emit_log_hook = NULL; /* GUC parameters */ __thread int Log_error_verbosity = PGERROR_VERBOSE; -char *Log_line_prefix = NULL; /* format for extra log line info */ +__thread char *Log_line_prefix = NULL; /* format for extra log line info */ __thread int Log_destination = LOG_DESTINATION_STDERR; -char *Log_destination_string = NULL; +__thread char *Log_destination_string = NULL; __thread bool syslog_sequence_numbers = true; __thread bool syslog_split_messages = true; @@ -126,14 +126,14 @@ __thread bool syslog_split_messages = true; #endif static __thread bool openlog_done = false; -static char *syslog_ident = NULL; +static __thread char *syslog_ident = NULL; static __thread int syslog_facility = LOG_LOCAL0; static void write_syslog(int level, const char *line); #endif #ifdef WIN32 -extern char *event_source; +extern __thread char *event_source; static void write_eventlog(int level, const char *line, int len); #endif @@ -141,7 +141,7 @@ static void write_eventlog(int level, const char *line, int len); /* We provide a small stack of ErrorData records for re-entrant cases */ #define ERRORDATA_STACK_SIZE 5 -static ErrorData errordata[ERRORDATA_STACK_SIZE]; +static __thread ErrorData errordata[ERRORDATA_STACK_SIZE]; static __thread int errordata_stack_depth = -1; /* index of topmost active frame */ @@ -155,8 +155,8 @@ static __thread struct timeval saved_timeval; static __thread bool saved_timeval_set = false; #define FORMATTED_TS_LEN 128 -static char formatted_start_time[FORMATTED_TS_LEN]; -static char formatted_log_time[FORMATTED_TS_LEN]; +static __thread char formatted_start_time[FORMATTED_TS_LEN]; +static __thread char formatted_log_time[FORMATTED_TS_LEN]; /* Macro for checking errordata_stack_depth is reasonable */ @@ -1375,7 +1375,7 @@ getinternalerrposition(void) * therefore survive until FlushErrorState() is called. */ static __thread int save_format_errnumber; -static const char *save_format_domain; +static __thread const char *save_format_domain; void pre_format_elog_string(int errnumber, const char *domain) diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/fmgr/dfmgr.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/fmgr/dfmgr.c index 9dff1f5e82..cf8e06c05d 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/fmgr/dfmgr.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/fmgr/dfmgr.c @@ -64,8 +64,8 @@ typedef struct df_files char filename[FLEXIBLE_ARRAY_MEMBER]; /* Full pathname of file */ } DynamicFileList; -static DynamicFileList *file_list = NULL; -static DynamicFileList *file_tail = NULL; +static __thread DynamicFileList *file_list = NULL; +static __thread DynamicFileList *file_tail = NULL; /* stat() call under Win32 returns an st_ino field, but it has no meaning */ #ifndef WIN32 @@ -74,7 +74,7 @@ static DynamicFileList *file_tail = NULL; #define SAME_INODE(A,B) false #endif -char *Dynamic_library_path; +__thread char *Dynamic_library_path; static void *internal_load_library(const char *libname); static void incompatible_module_error(const char *libname, diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/fmgr/fmgr.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/fmgr/fmgr.c index 7c1ced7473..bab3c846f2 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/fmgr/fmgr.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/fmgr/fmgr.c @@ -51,7 +51,7 @@ typedef struct const Pg_finfo_record *inforec; /* address of its info record */ } CFuncHashTabEntry; -static HTAB *CFuncHash = NULL; +static __thread HTAB *CFuncHash = NULL; static void fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/hash/dynahash.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/hash/dynahash.c index 9e7e156142..40b9ad3fc0 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/hash/dynahash.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/hash/dynahash.c @@ -1781,8 +1781,8 @@ next_pow2_int(long num) #define MAX_SEQ_SCANS 100 -static HTAB *seq_scan_tables[MAX_SEQ_SCANS]; /* tables being scanned */ -static int seq_scan_level[MAX_SEQ_SCANS]; /* subtransaction nest level */ +static __thread HTAB *seq_scan_tables[MAX_SEQ_SCANS]; /* tables being scanned */ +static __thread int seq_scan_level[MAX_SEQ_SCANS]; /* subtransaction nest level */ static __thread int num_seq_scans = 0; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/init/globals.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/init/globals.c index fcc4448473..b1fc67867c 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/init/globals.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/init/globals.c @@ -40,7 +40,7 @@ __thread volatile uint32 CritSectionCount = 0; __thread int MyProcPid; __thread pg_time_t MyStartTime; __thread TimestampTz MyStartTimestamp; -struct Port *MyProcPort; +__thread struct Port *MyProcPort; __thread int32 MyCancelKey; __thread int MyPMChildSlot; @@ -51,7 +51,7 @@ __thread int MyPMChildSlot; * PGPROC->procLatch if it has. Thus it can always be used in signal handlers, * without checking for its existence. */ -struct Latch *MyLatch; +__thread struct Latch *MyLatch; /* * DataDir is the absolute path to the top level of the PGDATA directory tree. @@ -59,7 +59,7 @@ struct Latch *MyLatch; * most code therefore can simply use relative paths and not reference DataDir * explicitly. */ -char *DataDir = NULL; +__thread char *DataDir = NULL; /* * Mode of the data directory. The default is 0700 but it may be changed in @@ -67,10 +67,10 @@ char *DataDir = NULL; */ __thread int data_directory_mode = PG_DIR_MODE_OWNER; -char OutputFileName[MAXPGPATH]; /* debugging output file */ +__thread char OutputFileName[MAXPGPATH]; /* debugging output file */ -char my_exec_path[MAXPGPATH]; /* full path to my executable */ -char pkglib_path[MAXPGPATH]; /* full path to lib directory */ +__thread char my_exec_path[MAXPGPATH]; /* full path to my executable */ +__thread char pkglib_path[MAXPGPATH]; /* full path to lib directory */ #ifdef EXEC_BACKEND char postgres_exec_path[MAXPGPATH]; /* full path to backend */ @@ -90,7 +90,7 @@ __thread Oid MyDatabaseTableSpace = InvalidOid; * DatabasePath is the path (relative to DataDir) of my database's * primary directory, ie, its directory in the default tablespace. */ -char *DatabasePath = NULL; +__thread char *DatabasePath = NULL; __thread pid_t PostmasterPid = 0; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/init/miscinit.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/init/miscinit.c index d3d6f923d7..dd282e3960 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/init/miscinit.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/init/miscinit.c @@ -60,7 +60,7 @@ __thread ProcessingMode Mode = InitProcessing; __thread BackendType MyBackendType; /* List of lock files to be removed at proc exit */ -static List *lock_files = NIL; +static __thread List *lock_files = NIL; static __thread Latch LocalLatchData; @@ -1560,9 +1560,9 @@ ValidatePgVersion(const char *path) * GUC variables: lists of library names to be preloaded at postmaster * start and at backend start */ -char *session_preload_libraries_string = NULL; -char *shared_preload_libraries_string = NULL; -char *local_preload_libraries_string = NULL; +__thread char *session_preload_libraries_string = NULL; +__thread char *shared_preload_libraries_string = NULL; +__thread char *local_preload_libraries_string = NULL; /* Flag telling that we are loading shared_preload_libraries */ __thread bool process_shared_preload_libraries_in_progress = false; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/mb/mbutils.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/mb/mbutils.c index b367f4540d..b91c287bb4 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/mb/mbutils.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/mb/mbutils.c @@ -58,28 +58,28 @@ typedef struct ConvProcInfo FmgrInfo to_client_info; } ConvProcInfo; -static List *ConvProcList = NIL; /* List of ConvProcInfo */ +static __thread List *ConvProcList = NIL; /* List of ConvProcInfo */ /* * These variables point to the currently active conversion functions, * or are NULL when no conversion is needed. */ -static FmgrInfo *ToServerConvProc = NULL; -static FmgrInfo *ToClientConvProc = NULL; +static __thread FmgrInfo *ToServerConvProc = NULL; +static __thread FmgrInfo *ToClientConvProc = NULL; /* * This variable stores the conversion function to convert from UTF-8 * to the server encoding. It's NULL if the server encoding *is* UTF-8, * or if we lack a conversion function for this. */ -static FmgrInfo *Utf8ToServerConvProc = NULL; +static __thread FmgrInfo *Utf8ToServerConvProc = NULL; /* * These variables track the currently-selected encodings. */ -static const pg_enc2name *ClientEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; -static const pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; -static const pg_enc2name *MessageEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; +static __thread const pg_enc2name *ClientEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; +static __thread const pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; +static __thread const pg_enc2name *MessageEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; /* * During backend startup we can't set client encoding because we (a) diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/guc-file.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/guc-file.c index efcf38da2d..701db7b8d5 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/guc-file.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/guc-file.c @@ -530,7 +530,7 @@ static __thread int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = NULL; +static __thread char *yy_c_buf_p = NULL; static __thread int yy_init = 0; /* whether we need to initialize */ static __thread int yy_start = 0; /* start state number */ @@ -732,7 +732,7 @@ static const flex_int16_t yy_chk[168] = } ; static __thread yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; +static __thread char *yy_last_accepting_cpos; extern int yy_flex_debug; int yy_flex_debug = 0; @@ -790,8 +790,8 @@ enum }; static __thread unsigned int ConfigFileLineno; -static const char *GUC_flex_fatal_errmsg; -static sigjmp_buf *GUC_flex_fatal_jmp; +static __thread const char *GUC_flex_fatal_errmsg; +static __thread sigjmp_buf *GUC_flex_fatal_jmp; static void FreeConfigVariable(ConfigVariable *item); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/guc.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/guc.c index 067da2c7ff..34c47c7923 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/guc.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/guc.c @@ -122,8 +122,8 @@ extern __thread bool Log_disconnections; extern __thread int CommitDelay; extern __thread int CommitSiblings; -extern char *default_tablespace; -extern char *temp_tablespaces; +extern __thread char *default_tablespace; +extern __thread char *temp_tablespaces; extern __thread bool ignore_checksum_failure; extern __thread bool ignore_invalid_pages; extern __thread bool synchronize_seqscans; @@ -138,9 +138,9 @@ extern bool optimize_bounded_sort; static __thread int GUC_check_errcode_value; /* global variables for check hook support */ -char *GUC_check_errmsg_string; -char *GUC_check_errdetail_string; -char *GUC_check_errhint_string; +__thread char *GUC_check_errmsg_string; +__thread char *GUC_check_errdetail_string; +__thread char *GUC_check_errhint_string; static void do_serialize(char **destptr, Size *maxbytes, const char *fmt,...) pg_attribute_printf(3, 4); @@ -490,7 +490,7 @@ const struct config_enum_entry ssl_protocol_versions_info[] = { StaticAssertDecl(lengthof(ssl_protocol_versions_info) == (PG_TLS1_3_VERSION + 2), "array length mismatch"); -static struct config_enum_entry shared_memory_options[] = { +static __thread struct config_enum_entry shared_memory_options[] = { #ifndef WIN32 {"sysv", SHMEM_TYPE_SYSV, false}, #endif @@ -527,7 +527,7 @@ __thread bool log_executor_stats = false; __thread bool log_statement_stats = false; /* this is sort of all three above * together */ __thread bool log_btree_build_stats = false; -char *event_source; +__thread char *event_source; __thread bool row_security; __thread bool check_function_bodies = true; @@ -550,22 +550,22 @@ __thread int log_temp_files = -1; __thread double log_statement_sample_rate = 1.0; __thread double log_xact_sample_rate = 0; __thread int trace_recovery_messages = LOG; -char *backtrace_functions; -char *backtrace_symbol_list; +__thread char *backtrace_functions; +__thread char *backtrace_symbol_list; __thread int temp_file_limit = -1; __thread int num_temp_buffers = 1024; -char *cluster_name = ""; -char *ConfigFileName; -char *HbaFileName; -char *IdentFileName; -char *external_pid_file; +__thread char *cluster_name = ""; +__thread char *ConfigFileName; +__thread char *HbaFileName; +__thread char *IdentFileName; +__thread char *external_pid_file; -char *pgstat_temp_directory; +__thread char *pgstat_temp_directory; -char *application_name; +__thread char *application_name; __thread int tcp_keepalives_idle; __thread int tcp_keepalives_interval; @@ -591,20 +591,20 @@ __thread int huge_pages; * cases provide the value for SHOW to display. The real state is elsewhere * and is kept in sync by assign_hooks. */ -static char *syslog_ident_str; +static __thread char *syslog_ident_str; static __thread double phony_random_seed; -static char *client_encoding_string; -static char *datestyle_string; -static char *locale_collate; -static char *locale_ctype; -static char *server_encoding_string; -static char *server_version_string; +static __thread char *client_encoding_string; +static __thread char *datestyle_string; +static __thread char *locale_collate; +static __thread char *locale_ctype; +static __thread char *server_encoding_string; +static __thread char *server_version_string; static __thread int server_version_num; -static char *timezone_string; -static char *log_timezone_string; -static char *timezone_abbreviations_string; -static char *data_directory; -static char *session_authorization_string; +static __thread char *timezone_string; +static __thread char *log_timezone_string; +static __thread char *timezone_abbreviations_string; +static __thread char *data_directory; +static __thread char *session_authorization_string; static __thread int max_function_args; static __thread int max_index_keys; static __thread int max_identifier_length; @@ -614,15 +614,15 @@ static __thread int wal_block_size; static __thread bool data_checksums; static __thread bool integer_datetimes; static __thread bool assert_enabled; -static char *recovery_target_timeline_string; -static char *recovery_target_string; -static char *recovery_target_xid_string; -static char *recovery_target_name_string; -static char *recovery_target_lsn_string; +static __thread char *recovery_target_timeline_string; +static __thread char *recovery_target_string; +static __thread char *recovery_target_xid_string; +static __thread char *recovery_target_name_string; +static __thread char *recovery_target_lsn_string; /* should be static, but commands/variable.c needs to get at this */ -char *role_string; +__thread char *role_string; /* @@ -834,7 +834,7 @@ typedef struct #error XLOG_BLCKSZ must be between 1KB and 1MB #endif -static const char *memory_units_hint = gettext_noop("Valid units for this parameter are \"B\", \"kB\", \"MB\", \"GB\", and \"TB\"."); +static __thread const char *memory_units_hint = gettext_noop("Valid units for this parameter are \"B\", \"kB\", \"MB\", \"GB\", and \"TB\"."); static const unit_conversion memory_unit_conversion_table[] = { @@ -871,7 +871,7 @@ static const unit_conversion memory_unit_conversion_table[] = {""} /* end of table marker */ }; -static const char *time_units_hint = gettext_noop("Valid units for this parameter are \"us\", \"ms\", \"s\", \"min\", \"h\", and \"d\"."); +static __thread const char *time_units_hint = gettext_noop("Valid units for this parameter are \"us\", \"ms\", \"s\", \"min\", \"h\", and \"d\"."); static const unit_conversion time_unit_conversion_table[] = { @@ -972,7 +972,7 @@ static const char *const map_old_guc_names[] = { /* * Actual lookup of variables is done through this single, sorted array. */ -static struct config_generic **guc_variables; +static __thread struct config_generic **guc_variables; /* Current number of variables contained in the vector */ static __thread int num_guc_variables; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/ps_status.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/ps_status.c index 885b94f171..9457bf1bcf 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/ps_status.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/ps_status.c @@ -95,15 +95,15 @@ __thread bool update_process_title = true; #ifndef PS_USE_CLOBBER_ARGV /* all but one option need a buffer to write their ps line in */ #define PS_BUFFER_SIZE 256 -static char ps_buffer[PS_BUFFER_SIZE]; +static __thread char ps_buffer[PS_BUFFER_SIZE]; static __thread const size_t ps_buffer_size = PS_BUFFER_SIZE; #else /* PS_USE_CLOBBER_ARGV */ -static char *ps_buffer; /* will point to argv area */ +static __thread char *ps_buffer; /* will point to argv area */ static __thread size_t ps_buffer_size; /* space determined at run time */ static __thread size_t last_status_len; /* use to minimize length of clobber */ #endif /* PS_USE_CLOBBER_ARGV */ -static size_t ps_buffer_cur_len; /* nominal strlen(ps_buffer) */ +static __thread size_t ps_buffer_cur_len; /* nominal strlen(ps_buffer) */ static __thread size_t ps_buffer_fixed_size; /* size of the constant prefix */ @@ -111,7 +111,7 @@ static __thread size_t ps_buffer_fixed_size; /* size of the constant prefix */ /* save the original argv[] location here */ static __thread int save_argc; -static char **save_argv; +static __thread char **save_argv; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/timeout.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/timeout.c index 5e38a3ef84..3e3d8a37ce 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/timeout.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/timeout.c @@ -41,7 +41,7 @@ typedef struct timeout_params /* * List of possible timeout reasons in the order of enum TimeoutId. */ -static timeout_params all_timeouts[MAX_TIMEOUTS]; +static __thread timeout_params all_timeouts[MAX_TIMEOUTS]; static __thread bool all_timeouts_initialized = false; /* @@ -49,7 +49,7 @@ static __thread bool all_timeouts_initialized = false; * This list is subject to change by the interrupt handler, so it's volatile. */ static __thread volatile int num_active_timeouts = 0; -static timeout_params *volatile active_timeouts[MAX_TIMEOUTS]; +static __thread timeout_params *volatile active_timeouts[MAX_TIMEOUTS]; /* * Flag controlling whether the signal handler is allowed to do anything. diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/mmgr/aset.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/mmgr/aset.c index 60a761caba..53659481cf 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/mmgr/aset.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/mmgr/aset.c @@ -250,7 +250,7 @@ typedef struct AllocSetFreeList } AllocSetFreeList; /* context_freelists[0] is for default params, [1] for small params */ -static AllocSetFreeList context_freelists[2] = +static __thread AllocSetFreeList context_freelists[2] = { { 0, NULL diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/mmgr/portalmem.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/mmgr/portalmem.c index f768790e61..f45101ee01 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/mmgr/portalmem.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/mmgr/portalmem.c @@ -51,7 +51,7 @@ typedef struct portalhashent Portal portal; } PortalHashEnt; -static HTAB *PortalHashTable = NULL; +static __thread HTAB *PortalHashTable = NULL; #define PortalHashTableLookup(NAME, PORTAL) \ do { \ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/resowner/resowner.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/resowner/resowner.c index 8a50fb3349..ff421cc71a 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/resowner/resowner.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/resowner/resowner.c @@ -154,7 +154,7 @@ typedef struct ResourceReleaseCallbackItem void *arg; } ResourceReleaseCallbackItem; -static ResourceReleaseCallbackItem *ResourceRelease_callbacks = NULL; +static __thread ResourceReleaseCallbackItem *ResourceRelease_callbacks = NULL; /* Internal routines */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/time/combocid.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/time/combocid.c index 287dffde41..7453c0d765 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/time/combocid.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/time/combocid.c @@ -50,7 +50,7 @@ #include "utils/memutils.h" /* Hash table to lookup combo cids by cmin and cmax */ -static HTAB *comboHash = NULL; +static __thread HTAB *comboHash = NULL; /* Key and entry structures for the hash table */ typedef struct diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/time/snapmgr.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/time/snapmgr.c index 215ce42a01..f78a38a2da 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/time/snapmgr.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/time/snapmgr.c @@ -126,7 +126,7 @@ typedef struct OldSnapshotControlData TransactionId xid_by_minute[FLEXIBLE_ARRAY_MEMBER]; } OldSnapshotControlData; -static volatile OldSnapshotControlData *oldSnapshotControl; +static __thread volatile OldSnapshotControlData *oldSnapshotControl; /* @@ -169,7 +169,7 @@ __thread TransactionId RecentGlobalXmin = InvalidTransactionId; __thread TransactionId RecentGlobalDataXmin = InvalidTransactionId; /* (table, ctid) => (cmin, cmax) mapping during timetravel */ -static HTAB *tuplecid_data = NULL; +static __thread HTAB *tuplecid_data = NULL; /* * Elements of the active snapshot stack. @@ -187,10 +187,10 @@ typedef struct ActiveSnapshotElt } ActiveSnapshotElt; /* Top of the stack of active snapshots */ -static ActiveSnapshotElt *ActiveSnapshot = NULL; +static __thread ActiveSnapshotElt *ActiveSnapshot = NULL; /* Bottom of the stack of active snapshots */ -static ActiveSnapshotElt *OldestActiveSnapshot = NULL; +static __thread ActiveSnapshotElt *OldestActiveSnapshot = NULL; /* * Currently registered Snapshots. Ordered in a heap by xmin, so that we can @@ -222,7 +222,7 @@ typedef struct ExportedSnapshot } ExportedSnapshot; /* Current xact's exported snapshots (a list of ExportedSnapshot structs) */ -static List *exportedSnapshots = NIL; +static __thread List *exportedSnapshots = NIL; /* Prototypes for local functions */ static TimestampTz AlignTimestampToMinuteBoundary(TimestampTz ts); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/pg_lzcompress.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/pg_lzcompress.c index f9c29820e3..1969b72056 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/pg_lzcompress.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/pg_lzcompress.c @@ -252,8 +252,8 @@ const PGLZ_Strategy *const PGLZ_strategy_always = &strategy_always_data; * Statically allocated work arrays for history * ---------- */ -static int16 hist_start[PGLZ_MAX_HISTORY_LISTS]; -static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE + 1]; +static __thread int16 hist_start[PGLZ_MAX_HISTORY_LISTS]; +static __thread PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE + 1]; /* * Element 0 in hist_entries is unused, and means 'invalid'. Likewise, diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/session.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/session.h index 4c1f6ffd40..84e4b81fc4 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/session.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/session.h @@ -39,6 +39,6 @@ extern void AttachSession(dsm_handle handle); extern void DetachSession(void); /* The current session, or NULL for none. */ -extern Session *CurrentSession; +extern __thread Session *CurrentSession; #endif /* SESSION_H */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/tableam.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/tableam.h index 8aa239f341..09b21aefee 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/tableam.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/tableam.h @@ -27,7 +27,7 @@ #define DEFAULT_TABLE_ACCESS_METHOD "heap" /* GUCs */ -extern char *default_table_access_method; +extern __thread char *default_table_access_method; extern __thread bool synchronize_seqscans; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/xlog.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/xlog.h index 94ddf4bdf4..521a649202 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/xlog.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/xlog.h @@ -112,33 +112,33 @@ extern __thread int max_slot_wal_keep_size_mb; extern __thread int XLOGbuffers; extern __thread int XLogArchiveTimeout; extern __thread int wal_retrieve_retry_interval; -extern char *XLogArchiveCommand; +extern __thread char *XLogArchiveCommand; extern __thread bool EnableHotStandby; extern __thread bool fullPageWrites; extern __thread bool wal_log_hints; extern __thread bool wal_compression; extern __thread bool wal_init_zero; extern __thread bool wal_recycle; -extern bool *wal_consistency_checking; -extern char *wal_consistency_checking_string; +extern __thread bool *wal_consistency_checking; +extern __thread char *wal_consistency_checking_string; extern __thread bool log_checkpoints; -extern char *recoveryRestoreCommand; -extern char *recoveryEndCommand; -extern char *archiveCleanupCommand; +extern __thread char *recoveryRestoreCommand; +extern __thread char *recoveryEndCommand; +extern __thread char *archiveCleanupCommand; extern __thread bool recoveryTargetInclusive; extern __thread int recoveryTargetAction; extern __thread int recovery_min_apply_delay; -extern char *PrimaryConnInfo; -extern char *PrimarySlotName; +extern __thread char *PrimaryConnInfo; +extern __thread char *PrimarySlotName; extern __thread bool wal_receiver_create_temp_slot; /* indirectly set via GUC system */ extern __thread TransactionId recoveryTargetXid; -extern char *recovery_target_time_string; -extern const char *recoveryTargetName; +extern __thread char *recovery_target_time_string; +extern __thread const char *recoveryTargetName; extern __thread XLogRecPtr recoveryTargetLSN; extern __thread RecoveryTargetType recoveryTarget; -extern char *PromoteTriggerFile; +extern __thread char *PromoteTriggerFile; extern __thread RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal; extern __thread TimeLineID recoveryTargetTLIRequested; extern __thread TimeLineID recoveryTargetTLI; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/xlog_internal.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/xlog_internal.h index c4c0280d9b..0e46ff2da0 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/xlog_internal.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/access/xlog_internal.h @@ -334,6 +334,6 @@ extern void GetOldestRestartPoint(XLogRecPtr *oldrecptr, TimeLineID *oldtli); extern __thread bool ArchiveRecoveryRequested; extern __thread bool InArchiveRecovery; extern __thread bool StandbyMode; -extern char *recoveryRestoreCommand; +extern __thread char *recoveryRestoreCommand; #endif /* XLOG_INTERNAL_H */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/bootstrap/bootstrap.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/bootstrap/bootstrap.h index d2f6cf325c..da2a400b01 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/bootstrap/bootstrap.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/bootstrap/bootstrap.h @@ -28,7 +28,7 @@ #define BOOTCOL_NULL_FORCE_NOT_NULL 3 extern __thread Relation boot_reldesc; -extern Form_pg_attribute attrtypes[MAXATTR]; +extern __thread Form_pg_attribute attrtypes[MAXATTR]; extern __thread int numattr; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/catalog/namespace.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/catalog/namespace.h index 2456c08bf7..739aed7d1a 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/catalog/namespace.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/catalog/namespace.h @@ -180,7 +180,7 @@ extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid); /* stuff for search_path GUC variable */ -extern char *namespace_search_path; +extern __thread char *namespace_search_path; extern List *fetch_search_path(bool includeImplicit); extern int fetch_search_path_array(Oid *sarray, int sarray_len); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/commands/vacuum.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/commands/vacuum.h index 0170d36b5d..e74bceb154 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/commands/vacuum.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/commands/vacuum.h @@ -239,8 +239,8 @@ extern __thread int vacuum_multixact_freeze_min_age; extern __thread int vacuum_multixact_freeze_table_age; /* Variables for cost-based parallel vacuum */ -extern pg_atomic_uint32 *VacuumSharedCostBalance; -extern pg_atomic_uint32 *VacuumActiveNWorkers; +extern __thread pg_atomic_uint32 *VacuumSharedCostBalance; +extern __thread pg_atomic_uint32 *VacuumActiveNWorkers; extern __thread int VacuumCostBalanceLocal; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/executor/spi.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/executor/spi.h index a7d467134d..7fa1abf97e 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/executor/spi.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/executor/spi.h @@ -78,7 +78,7 @@ typedef struct _SPI_plan *SPIPlanPtr; #define SPI_restore_connection() ((void) 0) extern __thread PGDLLIMPORT uint64 SPI_processed; -extern PGDLLIMPORT SPITupleTable *SPI_tuptable; +extern __thread PGDLLIMPORT SPITupleTable *SPI_tuptable; extern __thread PGDLLIMPORT int SPI_result; extern int SPI_connect(void); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/fmgr.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/fmgr.h index fd38c517ef..dff881ed32 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/fmgr.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/fmgr.h @@ -714,7 +714,7 @@ extern bool CheckFunctionValidatorAccess(Oid validatorOid, Oid functionOid); /* * Routines in dfmgr.c */ -extern char *Dynamic_library_path; +extern __thread char *Dynamic_library_path; extern PGFunction load_external_function(const char *filename, const char *funcname, bool signalNotFound, void **filehandle); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/jit/jit.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/jit/jit.h index b6c2605d79..ea407b70ab 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/jit/jit.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/jit/jit.h @@ -80,7 +80,7 @@ struct JitProviderCallbacks /* GUCs */ extern __thread bool jit_enabled; -extern char *jit_provider; +extern __thread char *jit_provider; extern __thread bool jit_debugging_support; extern __thread bool jit_dump_bitcode; extern __thread bool jit_expressions; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/libpq/auth.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/libpq/auth.h index 8c96879420..df33362e35 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/libpq/auth.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/libpq/auth.h @@ -16,7 +16,7 @@ #include "libpq/libpq-be.h" -extern char *pg_krb_server_keyfile; +extern __thread char *pg_krb_server_keyfile; extern __thread bool pg_krb_caseins_users; extern char *pg_krb_realm; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/libpq/libpq.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/libpq/libpq.h index 5a5e05996f..9272e21b27 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/libpq/libpq.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/libpq/libpq.h @@ -33,7 +33,7 @@ typedef struct void (*endcopyout) (bool errorAbort); } PQcommMethods; -extern const PGDLLIMPORT PQcommMethods *PqCommMethods; +extern __thread const PGDLLIMPORT PQcommMethods *PqCommMethods; #define pq_comm_reset() (PqCommMethods->comm_reset()) #define pq_flush() (PqCommMethods->flush()) @@ -53,7 +53,7 @@ extern const PGDLLIMPORT PQcommMethods *PqCommMethods; /* * prototypes for functions in pqcomm.c */ -extern WaitEventSet *FeBeWaitSet; +extern __thread WaitEventSet *FeBeWaitSet; extern int StreamServerPort(int family, const char *hostName, unsigned short portNumber, const char *unixSocketDir, @@ -78,13 +78,13 @@ extern int pq_putbytes(const char *s, size_t len); /* * prototypes for functions in be-secure.c */ -extern char *ssl_library; -extern char *ssl_cert_file; -extern char *ssl_key_file; -extern char *ssl_ca_file; -extern char *ssl_crl_file; -extern char *ssl_dh_params_file; -extern PGDLLIMPORT char *ssl_passphrase_command; +extern __thread char *ssl_library; +extern __thread char *ssl_cert_file; +extern __thread char *ssl_key_file; +extern __thread char *ssl_ca_file; +extern __thread char *ssl_crl_file; +extern __thread char *ssl_dh_params_file; +extern __thread PGDLLIMPORT char *ssl_passphrase_command; extern __thread PGDLLIMPORT bool ssl_passphrase_command_supports_reload; #ifdef USE_SSL extern __thread bool ssl_loaded_verify_locations; @@ -108,8 +108,8 @@ extern ssize_t secure_open_gssapi(Port *port); #endif /* GUCs */ -extern char *SSLCipherSuites; -extern char *SSLECDHCurve; +extern __thread char *SSLCipherSuites; +extern __thread char *SSLECDHCurve; extern __thread bool SSLPreferServerCiphers; extern __thread int ssl_min_protocol_version; extern __thread int ssl_max_protocol_version; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/miscadmin.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/miscadmin.h index beb1d46a45..b8493db63b 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/miscadmin.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/miscadmin.h @@ -165,7 +165,7 @@ extern __thread PGDLLIMPORT bool IsBinaryUpgrade; extern __thread PGDLLIMPORT bool ExitOnAnyError; -extern PGDLLIMPORT char *DataDir; +extern __thread PGDLLIMPORT char *DataDir; extern __thread PGDLLIMPORT int data_directory_mode; extern __thread PGDLLIMPORT int NBuffers; @@ -177,14 +177,14 @@ extern __thread PGDLLIMPORT int max_parallel_workers; extern __thread PGDLLIMPORT int MyProcPid; extern __thread PGDLLIMPORT pg_time_t MyStartTime; extern __thread PGDLLIMPORT TimestampTz MyStartTimestamp; -extern PGDLLIMPORT struct Port *MyProcPort; -extern PGDLLIMPORT struct Latch *MyLatch; +extern __thread PGDLLIMPORT struct Port *MyProcPort; +extern __thread PGDLLIMPORT struct Latch *MyLatch; extern __thread int32 MyCancelKey; extern __thread int MyPMChildSlot; -extern char OutputFileName[]; -extern PGDLLIMPORT char my_exec_path[]; -extern char pkglib_path[]; +extern __thread char OutputFileName[]; +extern __thread PGDLLIMPORT char my_exec_path[]; +extern __thread char pkglib_path[]; #ifdef EXEC_BACKEND extern char postgres_exec_path[]; @@ -311,7 +311,7 @@ extern int trace_recovery(int trace_level); #define SECURITY_RESTRICTED_OPERATION 0x0002 #define SECURITY_NOFORCE_RLS 0x0004 -extern char *DatabasePath; +extern __thread char *DatabasePath; /* now in utils/init/miscinit.c */ extern void InitPostmasterChild(void); @@ -462,9 +462,9 @@ extern void BaseInit(void); /* in utils/init/miscinit.c */ extern __thread bool IgnoreSystemIndexes; extern __thread PGDLLIMPORT bool process_shared_preload_libraries_in_progress; -extern char *session_preload_libraries_string; -extern char *shared_preload_libraries_string; -extern char *local_preload_libraries_string; +extern __thread char *session_preload_libraries_string; +extern __thread char *shared_preload_libraries_string; +extern __thread char *local_preload_libraries_string; extern void CreateDataDirLockFile(bool amPostmaster); extern void CreateSocketLockFile(const char *socketfile, bool amPostmaster, diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/nodes/nodes.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/nodes/nodes.h index 381d84b4e4..d356b3fc36 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/nodes/nodes.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/nodes/nodes.h @@ -562,7 +562,7 @@ typedef struct Node * Fortunately, this macro isn't recursive so we just define * a global variable for this purpose. */ -extern PGDLLIMPORT Node *newNodeMacroHolder; +extern __thread PGDLLIMPORT Node *newNodeMacroHolder; #define newNode(size, tag) \ ( \ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/pgstat.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/pgstat.h index f444165a97..a5f38db96d 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/pgstat.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/pgstat.h @@ -1250,9 +1250,9 @@ extern __thread PGDLLIMPORT bool pgstat_track_activities; extern __thread PGDLLIMPORT bool pgstat_track_counts; extern __thread PGDLLIMPORT int pgstat_track_functions; extern __thread PGDLLIMPORT int pgstat_track_activity_query_size; -extern char *pgstat_stat_directory; -extern char *pgstat_stat_tmpname; -extern char *pgstat_stat_filename; +extern __thread char *pgstat_stat_directory; +extern __thread char *pgstat_stat_tmpname; +extern __thread char *pgstat_stat_filename; /* * BgWriter statistics counters are updated directly by bgwriter and bufmgr diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/pgtime.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/pgtime.h index 0fc76d0e60..e45dab9394 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/pgtime.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/pgtime.h @@ -70,8 +70,8 @@ extern size_t pg_strftime(char *s, size_t max, const char *format, /* these functions and variables are in pgtz.c */ -extern PGDLLIMPORT pg_tz *session_timezone; -extern pg_tz *log_timezone; +extern __thread PGDLLIMPORT pg_tz *session_timezone; +extern __thread pg_tz *log_timezone; extern void pg_timezone_initialize(void); extern pg_tz *pg_tzset(const char *tzname); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/postmaster/bgworker.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/postmaster/bgworker.h index 4c6ebaa41b..3f9d2e58db 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/postmaster/bgworker.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/postmaster/bgworker.h @@ -129,7 +129,7 @@ extern const char *GetBackgroundWorkerTypeByPid(pid_t pid); extern void TerminateBackgroundWorker(BackgroundWorkerHandle *handle); /* This is valid in a running worker */ -extern PGDLLIMPORT BackgroundWorker *MyBgworkerEntry; +extern __thread PGDLLIMPORT BackgroundWorker *MyBgworkerEntry; /* * Connect to the specified database, as the specified user. Only a worker diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/postmaster/postmaster.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/postmaster/postmaster.h index ef27fcccba..5ea40c94f0 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/postmaster/postmaster.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/postmaster/postmaster.h @@ -18,22 +18,22 @@ extern __thread bool EnableSSL; extern __thread int ReservedBackends; extern __thread PGDLLIMPORT int PostPortNumber; extern __thread int Unix_socket_permissions; -extern char *Unix_socket_group; -extern char *Unix_socket_directories; -extern char *ListenAddresses; +extern __thread char *Unix_socket_group; +extern __thread char *Unix_socket_directories; +extern __thread char *ListenAddresses; extern __thread bool ClientAuthInProgress; extern __thread int PreAuthDelay; extern __thread int AuthenticationTimeout; extern __thread bool Log_connections; extern __thread bool log_hostname; extern __thread bool enable_bonjour; -extern char *bonjour_name; +extern __thread char *bonjour_name; extern __thread bool restart_after_crash; #ifdef WIN32 extern HANDLE PostmasterHandle; #else -extern int postmaster_alive_fds[2]; +extern __thread int postmaster_alive_fds[2]; /* * Constants that represent which of postmaster_alive_fds is held by diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/postmaster/syslogger.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/postmaster/syslogger.h index 3e47d7dfb0..54081b484a 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/postmaster/syslogger.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/postmaster/syslogger.h @@ -65,15 +65,15 @@ typedef union extern __thread bool Logging_collector; extern __thread int Log_RotationAge; extern __thread int Log_RotationSize; -extern PGDLLIMPORT char *Log_directory; -extern PGDLLIMPORT char *Log_filename; +extern __thread PGDLLIMPORT char *Log_directory; +extern __thread PGDLLIMPORT char *Log_filename; extern __thread bool Log_truncate_on_rotation; extern __thread int Log_file_mode; #ifndef WIN32 -extern int syslogPipe[2]; +extern __thread int syslogPipe[2]; #else -extern HANDLE syslogPipe[2]; +extern __thread HANDLE syslogPipe[2]; #endif diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/slot.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/slot.h index 7201754b58..5f2eb585a9 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/slot.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/slot.h @@ -179,8 +179,8 @@ typedef struct ReplicationSlotCtlData /* * Pointers to shared memory */ -extern PGDLLIMPORT ReplicationSlotCtlData *ReplicationSlotCtl; -extern PGDLLIMPORT ReplicationSlot *MyReplicationSlot; +extern __thread PGDLLIMPORT ReplicationSlotCtlData *ReplicationSlotCtl; +extern __thread PGDLLIMPORT ReplicationSlot *MyReplicationSlot; /* GUCs */ extern __thread PGDLLIMPORT int max_replication_slots; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/syncrep.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/syncrep.h index 9d286b66c6..c4ee89bcc3 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/syncrep.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/syncrep.h @@ -72,14 +72,14 @@ typedef struct SyncRepConfigData char member_names[FLEXIBLE_ARRAY_MEMBER]; } SyncRepConfigData; -extern SyncRepConfigData *SyncRepConfig; +extern __thread SyncRepConfigData *SyncRepConfig; /* communication variables for parsing synchronous_standby_names GUC */ -extern SyncRepConfigData *syncrep_parse_result; -extern char *syncrep_parse_error_msg; +extern __thread SyncRepConfigData *syncrep_parse_result; +extern __thread char *syncrep_parse_error_msg; /* user-settable parameters for synchronous replication */ -extern char *SyncRepStandbyNames; +extern __thread char *SyncRepStandbyNames; /* called by user backend */ extern void SyncRepWaitForLSN(XLogRecPtr lsn, bool commit); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/walreceiver.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/walreceiver.h index 4dfa25795b..81a9c630bc 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/walreceiver.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/walreceiver.h @@ -158,7 +158,7 @@ typedef struct sig_atomic_t force_reply; /* used as a bool */ } WalRcvData; -extern WalRcvData *WalRcv; +extern __thread WalRcvData *WalRcv; typedef struct { @@ -267,7 +267,7 @@ typedef struct WalReceiverFunctionsType walrcv_disconnect_fn walrcv_disconnect; } WalReceiverFunctionsType; -extern PGDLLIMPORT WalReceiverFunctionsType *WalReceiverFunctions; +extern __thread PGDLLIMPORT WalReceiverFunctionsType *WalReceiverFunctions; #define walrcv_connect(conninfo, logical, appname, err) \ WalReceiverFunctions->walrcv_connect(conninfo, logical, appname, err) diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/walsender_private.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/walsender_private.h index 509856c057..63e9bb5237 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/walsender_private.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/walsender_private.h @@ -80,7 +80,7 @@ typedef struct WalSnd TimestampTz replyTime; } WalSnd; -extern WalSnd *MyWalSnd; +extern __thread WalSnd *MyWalSnd; /* There is one WalSndCtl struct for the whole database cluster */ typedef struct @@ -107,7 +107,7 @@ typedef struct WalSnd walsnds[FLEXIBLE_ARRAY_MEMBER]; } WalSndCtlData; -extern WalSndCtlData *WalSndCtl; +extern __thread WalSndCtlData *WalSndCtl; extern void WalSndSetState(WalSndState state); @@ -122,6 +122,6 @@ extern void replication_yyerror(const char *str) pg_attribute_noreturn(); extern void replication_scanner_init(const char *query_string); extern void replication_scanner_finish(void); -extern Node *replication_parse_result; +extern __thread Node *replication_parse_result; #endif /* _WALSENDER_PRIVATE_H */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/worker_internal.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/worker_internal.h index 111d90ae83..8a953f0e2b 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/worker_internal.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/replication/worker_internal.h @@ -60,11 +60,11 @@ typedef struct LogicalRepWorker extern __thread MemoryContext ApplyContext; /* libpqreceiver connection */ -extern struct WalReceiverConn *LogRepWorkerWalRcvConn; +extern __thread struct WalReceiverConn *LogRepWorkerWalRcvConn; /* Worker and subscription objects. */ -extern Subscription *MySubscription; -extern LogicalRepWorker *MyLogicalRepWorker; +extern __thread Subscription *MySubscription; +extern __thread LogicalRepWorker *MyLogicalRepWorker; extern __thread bool in_remote_transaction; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/buf_internals.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/buf_internals.h index b2f8705958..00bc9362a0 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/buf_internals.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/buf_internals.h @@ -226,7 +226,7 @@ typedef union BufferDescPadded #define BufferDescriptorGetContentLock(bdesc) \ ((LWLock*) (&(bdesc)->content_lock)) -extern PGDLLIMPORT LWLockMinimallyPadded *BufferIOLWLockArray; +extern __thread PGDLLIMPORT LWLockMinimallyPadded *BufferIOLWLockArray; /* * The freeNext field is either the index of the next freelist entry, @@ -271,11 +271,11 @@ typedef struct WritebackContext } WritebackContext; /* in buf_init.c */ -extern PGDLLIMPORT BufferDescPadded *BufferDescriptors; +extern __thread PGDLLIMPORT BufferDescPadded *BufferDescriptors; extern __thread PGDLLIMPORT WritebackContext BackendWritebackContext; /* in localbuf.c */ -extern BufferDesc *LocalBufferDescriptors; +extern __thread BufferDesc *LocalBufferDescriptors; /* in bufmgr.c */ @@ -294,7 +294,7 @@ typedef struct CkptSortItem int buf_id; } CkptSortItem; -extern CkptSortItem *CkptBufferIds; +extern __thread CkptSortItem *CkptBufferIds; /* * Internal buffer management routines diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/bufmgr.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/bufmgr.h index c7e9b702d8..25f0f79d40 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/bufmgr.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/bufmgr.h @@ -77,12 +77,12 @@ extern __thread int backend_flush_after; extern __thread int bgwriter_flush_after; /* in buf_init.c */ -extern PGDLLIMPORT char *BufferBlocks; +extern __thread PGDLLIMPORT char *BufferBlocks; /* in localbuf.c */ extern __thread PGDLLIMPORT int NLocBuffer; -extern PGDLLIMPORT Block *LocalBufferBlockPointers; -extern PGDLLIMPORT int32 *LocalRefCount; +extern __thread PGDLLIMPORT Block *LocalBufferBlockPointers; +extern __thread PGDLLIMPORT int32 *LocalRefCount; /* upper limit for effective_io_concurrency */ #define MAX_IO_CONCURRENCY 1000 diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/lwlock.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/lwlock.h index 8f6b77dd0d..a405bf3fd8 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/lwlock.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/lwlock.h @@ -87,7 +87,7 @@ typedef union LWLockMinimallyPadded char pad[LWLOCK_MINIMAL_SIZE]; } LWLockMinimallyPadded; -extern PGDLLIMPORT LWLockPadded *MainLWLockArray; +extern __thread PGDLLIMPORT LWLockPadded *MainLWLockArray; /* struct for storing named tranche information */ typedef struct NamedLWLockTranche @@ -96,7 +96,7 @@ typedef struct NamedLWLockTranche char *trancheName; } NamedLWLockTranche; -extern PGDLLIMPORT NamedLWLockTranche *NamedLWLockTrancheArray; +extern __thread PGDLLIMPORT NamedLWLockTranche *NamedLWLockTrancheArray; extern __thread PGDLLIMPORT int NamedLWLockTrancheRequests; /* Names for fixed lwlocks */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/pg_shmem.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/pg_shmem.h index 39e607b996..aabca5d797 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/pg_shmem.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/pg_shmem.h @@ -67,7 +67,7 @@ extern __thread unsigned long UsedShmemSegID; extern __thread HANDLE UsedShmemSegID; extern void *ShmemProtectiveRegion; #endif -extern void *UsedShmemSegAddr; +extern __thread void *UsedShmemSegAddr; #if !defined(WIN32) && !defined(EXEC_BACKEND) #define DEFAULT_SHARED_MEMORY_TYPE SHMEM_TYPE_MMAP diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/proc.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/proc.h index 7ed6431e1f..df891e87ab 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/proc.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/storage/proc.h @@ -208,8 +208,8 @@ struct PGPROC /* NOTE: "typedef struct PGPROC PGPROC" appears in storage/lock.h. */ -extern PGDLLIMPORT PGPROC *MyProc; -extern PGDLLIMPORT struct PGXACT *MyPgXact; +extern __thread PGDLLIMPORT PGPROC *MyProc; +extern __thread PGDLLIMPORT struct PGXACT *MyPgXact; /* * Prior to PostgreSQL 9.2, the fields below were stored as part of the @@ -272,9 +272,9 @@ typedef struct PROC_HDR int startupBufferPinWaitBufId; } PROC_HDR; -extern PGDLLIMPORT PROC_HDR *ProcGlobal; +extern __thread PGDLLIMPORT PROC_HDR *ProcGlobal; -extern PGPROC *PreparedXactProcs; +extern __thread PGPROC *PreparedXactProcs; /* Accessor for PGPROC given a pgprocno. */ #define GetPGProcByNumber(n) (&ProcGlobal->allProcs[(n)]) diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/tcop/dest.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/tcop/dest.h index 2e07f1516d..af1b69274c 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/tcop/dest.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/tcop/dest.h @@ -130,7 +130,7 @@ struct _DestReceiver /* Private fields might appear beyond this point... */ }; -extern PGDLLIMPORT DestReceiver *None_Receiver; /* permanent receiver for +extern __thread PGDLLIMPORT DestReceiver *None_Receiver; /* permanent receiver for * DestNone */ /* The primary destination management functions */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/tcop/tcopprot.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/tcop/tcopprot.h index 7459dbb9da..7f798520dc 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/tcop/tcopprot.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/tcop/tcopprot.h @@ -26,7 +26,7 @@ #define STACK_DEPTH_SLOP (512 * 1024L) extern __thread CommandDest whereToSendOutput; -extern PGDLLIMPORT const char *debug_query_string; +extern __thread PGDLLIMPORT const char *debug_query_string; extern __thread int max_stack_depth; extern __thread int PostAuthDelay; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/tsearch/ts_cache.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/tsearch/ts_cache.h index 9149796466..9cd6baab95 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/tsearch/ts_cache.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/tsearch/ts_cache.h @@ -84,7 +84,7 @@ typedef struct /* * GUC variable for current configuration */ -extern char *TSCurrentConfig; +extern __thread char *TSCurrentConfig; extern TSParserCacheEntry *lookup_ts_parser_cache(Oid prsId); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/utils/elog.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/utils/elog.h index 4ebba7fb34..e24eb92373 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/utils/elog.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/utils/elog.h @@ -230,7 +230,7 @@ typedef struct ErrorContextCallback void *arg; } ErrorContextCallback; -extern PGDLLIMPORT ErrorContextCallback *error_context_stack; +extern __thread PGDLLIMPORT ErrorContextCallback *error_context_stack; /*---------- @@ -337,7 +337,7 @@ extern PGDLLIMPORT ErrorContextCallback *error_context_stack; (pg_re_throw(), pg_unreachable()) #endif -extern PGDLLIMPORT sigjmp_buf *PG_exception_stack; +extern __thread PGDLLIMPORT sigjmp_buf *PG_exception_stack; /* Stuff that error handlers might want to use */ @@ -408,9 +408,9 @@ typedef enum } PGErrorVerbosity; extern __thread int Log_error_verbosity; -extern char *Log_line_prefix; +extern __thread char *Log_line_prefix; extern __thread int Log_destination; -extern char *Log_destination_string; +extern __thread char *Log_destination_string; extern __thread bool syslog_sequence_numbers; extern __thread bool syslog_split_messages; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/utils/guc.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/utils/guc.h index 7365a06cc3..75d965be05 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/utils/guc.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/utils/guc.h @@ -258,20 +258,20 @@ extern __thread int log_min_duration_statement; extern __thread int log_temp_files; extern __thread double log_statement_sample_rate; extern __thread double log_xact_sample_rate; -extern char *backtrace_functions; -extern char *backtrace_symbol_list; +extern __thread char *backtrace_functions; +extern __thread char *backtrace_symbol_list; extern __thread int temp_file_limit; extern __thread int num_temp_buffers; -extern char *cluster_name; -extern PGDLLIMPORT char *ConfigFileName; -extern char *HbaFileName; -extern char *IdentFileName; -extern char *external_pid_file; +extern __thread char *cluster_name; +extern __thread PGDLLIMPORT char *ConfigFileName; +extern __thread char *HbaFileName; +extern __thread char *IdentFileName; +extern __thread char *external_pid_file; -extern PGDLLIMPORT char *application_name; +extern __thread PGDLLIMPORT char *application_name; extern __thread int tcp_keepalives_idle; extern __thread int tcp_keepalives_interval; @@ -402,9 +402,9 @@ extern void RestoreGUCState(void *gucstate); /* Support for messages reported from GUC check hooks */ -extern PGDLLIMPORT char *GUC_check_errmsg_string; -extern PGDLLIMPORT char *GUC_check_errdetail_string; -extern PGDLLIMPORT char *GUC_check_errhint_string; +extern __thread PGDLLIMPORT char *GUC_check_errmsg_string; +extern __thread PGDLLIMPORT char *GUC_check_errdetail_string; +extern __thread PGDLLIMPORT char *GUC_check_errhint_string; extern void GUC_check_errcode(int sqlerrcode); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/utils/pg_locale.h b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/utils/pg_locale.h index 9cb7d91ddf..84cd1b286a 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/utils/pg_locale.h +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/include/utils/pg_locale.h @@ -36,16 +36,16 @@ /* GUC settings */ -extern char *locale_messages; -extern char *locale_monetary; -extern char *locale_numeric; -extern char *locale_time; +extern __thread char *locale_messages; +extern __thread char *locale_monetary; +extern __thread char *locale_numeric; +extern __thread char *locale_time; /* lc_time localization cache */ -extern char *localized_abbrev_days[]; -extern char *localized_full_days[]; -extern char *localized_abbrev_months[]; -extern char *localized_full_months[]; +extern __thread char *localized_abbrev_days[]; +extern __thread char *localized_full_days[]; +extern __thread char *localized_abbrev_months[]; +extern __thread char *localized_full_months[]; extern bool check_locale_messages(char **newval, void **extra, GucSource source); diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/port/erand48.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/port/erand48.c index d67c8980f7..1ef452aeef 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/port/erand48.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/port/erand48.c @@ -46,7 +46,7 @@ #define RAND48_SEED_1 (0xabcd) #define RAND48_SEED_2 (0x1234) -static unsigned short _rand48_seed[3] = { +static __thread unsigned short _rand48_seed[3] = { RAND48_SEED_0, RAND48_SEED_1, RAND48_SEED_2 diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/timezone/pgtz.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/timezone/pgtz.c index 3f0fb51e91..a59551e746 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/timezone/pgtz.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/timezone/pgtz.c @@ -25,10 +25,10 @@ /* Current session timezone (controlled by TimeZone GUC) */ -pg_tz *session_timezone = NULL; +__thread pg_tz *session_timezone = NULL; /* Current log timezone (controlled by log_timezone GUC) */ -pg_tz *log_timezone = NULL; +__thread pg_tz *log_timezone = NULL; static bool scan_directory_ci(const char *dirname, @@ -195,7 +195,7 @@ typedef struct pg_tz tz; } pg_tz_cache; -static HTAB *timezone_cache = NULL; +static __thread HTAB *timezone_cache = NULL; static bool diff --git a/ydb/library/yql/parser/pg_query_wrapper/thread_inits.c b/ydb/library/yql/parser/pg_query_wrapper/thread_inits.c index 11d395829f..71289212af 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/thread_inits.c +++ b/ydb/library/yql/parser/pg_query_wrapper/thread_inits.c @@ -10,6 +10,7 @@ void pg_thread_init(void) { cached_expression_list_init(); dsm_segment_list_init(); lsn_mapping_init(); + mainrdata_last_init(); pcxt_list_init(); saved_plan_list_init(); } diff --git a/ydb/library/yql/parser/pg_query_wrapper/vars.txt b/ydb/library/yql/parser/pg_query_wrapper/vars.txt index 43775271aa..ea9e9e4746 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/vars.txt +++ b/ydb/library/yql/parser/pg_query_wrapper/vars.txt @@ -645,7 +645,6 @@ binary_upgrade_record_init_privs block_size blocking_autovacuum_proc bonjour_name -boolRelOpts boot_reldesc boot_yy_flex_debug boot_yychar @@ -785,7 +784,6 @@ enable_seqscan enable_sort enable_tidscan entryExecPlaceToPage.data -enumRelOpts enum_blacklist eoxact_list eoxact_list_len @@ -830,7 +828,6 @@ get_relation_info_hook get_relation_stats_hook get_stack_depth_rlimit.val gin_pending_list_limit -gistBufferingOptValues gistGetFakeLSN.counter gistGetFakeLSN.lastlsn globalStats @@ -865,7 +862,6 @@ in_progress_list_maxlen in_remote_transaction in_restore_command incoming_message -intRelOpts integer_datetimes internal_flush.last_reported_send_errno invalid_page_tab @@ -1197,7 +1193,6 @@ readOff readSegNo readSource ready_to_stop -realRelOpts receiveTLI recentMulti recentXid @@ -1379,7 +1374,6 @@ stmtStartTimestamp str_time.buf streamingDoneReceiving streamingDoneSending -stringRelOpts sync_cycle_ctr sync_method synchronize_seqscans @@ -1459,7 +1453,6 @@ vacuum_freeze_table_age vacuum_multixact_freeze_min_age vacuum_multixact_freeze_table_age values -viewCheckOptValues visitedProcs waitOrderProcs waitOrders |