diff options
author | vvvv <vvvv@yandex-team.ru> | 2022-02-21 18:46:41 +0300 |
---|---|---|
committer | vvvv <vvvv@yandex-team.ru> | 2022-02-21 18:46:41 +0300 |
commit | 57f5cc235bb3c759ffac3f5acc34dfe5c45273ae (patch) | |
tree | 5da14ac58d292f7edea9e883f3ce08fe6a560003 | |
parent | 506dcc5f3b89218631ec9fb9e6370e45bd2b0259 (diff) | |
download | ydb-57f5cc235bb3c759ffac3f5acc34dfe5c45273ae.tar.gz |
YQL-13710 more patches, verify script
ref:3e820e2b73aad000b45a219791ece63594e4fc7a
64 files changed, 214 insertions, 157 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 0dafe34f36..a5eeaac789 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/copy_src.py +++ b/ydb/library/yql/parser/pg_query_wrapper/copy_src.py @@ -4,8 +4,10 @@ import os from shutil import Error, copy2, rmtree import subprocess +from collections import defaultdict all_vars = set() +all_funcs_with_statics = defaultdict(list) thread_funcs = [] define_for_yylval = None skip_func = False @@ -13,11 +15,13 @@ split_def = False def_type = None def_var = None ignore_func = False +inside_func = None to_add_const = set([ "nullSemAction", "sentinel", "backslash_quote", + "Dummy_trace", "escape_string_warning", "standard_conforming_strings", "gistBufferingOptValues", @@ -29,10 +33,15 @@ to_add_const = set([ "stringRelOpts"]) def fix_line(line, all_lines, pos): + global inside_func global define_for_yylval if line.startswith("#define yylval"): define_for_yylval=line[14:].strip() + if "static YYSTYPE yyval_default" in line or \ + "static YYLTYPE yyloc_default" in line: + return line.replace("static","static __thread") + global skip_func if line.startswith("build_guc_variables(void)"): skip_func = True @@ -43,6 +52,29 @@ def fix_line(line, all_lines, pos): ignore_func = True return line + if inside_func is not None: + for v in all_funcs_with_statics[inside_func]: + if v in line and "static" in line: + return line.replace("static","static __thread") + + if inside_func: + if line.startswith("}"): + inside_func=None + + if skip_func: + if line.startswith("{"): + return line + if not line.startswith("}"): + return None + skip_func=False + + if ignore_func: + if line.startswith("{"): + return line + if not line.startswith("}"): + return line + ignore_func=False + global split_def global def_type global def_var @@ -52,6 +84,18 @@ def fix_line(line, all_lines, pos): def_var = "records"; return "typedef struct xllist\n"; + if line.startswith("static struct RELCACHECALLBACK"): + split_def = True + def_type = "RELCACHECALLBACK" + def_var = "relcache_callback_list[MAX_RELCACHE_CALLBACKS]"; + return "typedef struct RELCACHECALLBACK\n"; + + if line.startswith("static struct SYSCACHECALLBACK"): + split_def = True + def_type = "SYSCACHECALLBACK" + def_var = "syscache_callback_list[MAX_SYSCACHE_CALLBACKS]"; + return "typedef struct SYSCACHECALLBACK\n"; + if split_def and line.startswith("}"): split_def = False; return "} " + def_type + "; static __thread " + def_type + " " + def_var + ";\n" @@ -71,23 +115,14 @@ def fix_line(line, all_lines, pos): skip_func = True return line - if skip_func: - if line.startswith("{"): - return line - if not line.startswith("}"): - return None - skip_func=False - - if ignore_func: - if line.startswith("{"): - return line - if not line.startswith("}"): - return line - ignore_func=False - if line.startswith("#") or line.startswith(" ") or line.startswith("\t"): return line + for f in all_funcs_with_statics: + if f in line and ";" not in line: + inside_func = f + return line + if not "=" in line: line2=line if "//" in line2: line2 = line2[:line2.find("//")] @@ -212,11 +247,16 @@ def get_vars(): if sym is not None: all_vars.add(sym.replace("yql_","")) - all_vars.remove("Dummy_trace") - for x in to_add_const: all_vars.remove(x) + all_vars.remove("BlockSig") + all_vars.remove("StartupBlockSig") + all_vars.remove("UnBlockSig") + all_vars.remove("on_proc_exit_index") + all_vars.remove("on_shmem_exit_index") + all_vars.remove("before_shmem_exit_index") + all_vars.add("yychar") all_vars.add("yyin") all_vars.add("yyout") @@ -230,6 +270,11 @@ def get_vars(): for a in sorted(all_vars): print(a, file=f) + for a in all_vars: + l=a.split(".") + if len(l)==2: + all_funcs_with_statics[l[0]].append(l[1]) + def write_thread_inits(): with open("thread_inits.c","w") as f: print("#include \"thread_inits.h\"", 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 2a531e1093..e42878d845 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 @@ -675,7 +675,7 @@ add_reloption_kind(void) static void add_reloption(relopt_gen *newoption) { - static int max_custom_options = 0; + static __thread int max_custom_options = 0; if (num_custom_options >= max_custom_options) { diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/gin/gindatapage.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/gin/gindatapage.c index 7a2690e97f..9cc346840d 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/gin/gindatapage.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/gin/gindatapage.c @@ -1162,7 +1162,7 @@ dataExecPlaceToPageInternal(GinBtree btree, Buffer buf, GinBtreeStack *stack, * and we can't palloc here. Ugly, but the XLogInsert infrastructure * isn't reentrant anyway. */ - static ginxlogInsertDataInternal data; + static __thread ginxlogInsertDataInternal data; data.offset = off; data.newitem = *pitem; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/gin/ginentrypage.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/gin/ginentrypage.c index af14baf93c..675ff93d11 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/gin/ginentrypage.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/gin/ginentrypage.c @@ -578,7 +578,7 @@ entryExecPlaceToPage(GinBtree btree, Buffer buf, GinBtreeStack *stack, * and we can't palloc here. Ugly, but the XLogInsert infrastructure * isn't reentrant anyway. */ - static ginxlogInsertEntry data; + static __thread ginxlogInsertEntry data; data.isDelete = insertData->isDelete; data.offset = off; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/gist/gistutil.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/gist/gistutil.c index 765329bbcd..60652bbb04 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/gist/gistutil.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/access/gist/gistutil.c @@ -1017,7 +1017,7 @@ gistGetFakeLSN(Relation rel) * Temporary relations are only accessible in our session, so a simple * backend-local counter will do. */ - static XLogRecPtr counter = FirstNormalUnloggedLSN; + static __thread XLogRecPtr counter = FirstNormalUnloggedLSN; return counter++; } @@ -1029,7 +1029,7 @@ gistGetFakeLSN(Relation rel) * Emit a dummy WAL record if insert-LSN hasn't advanced after the * last call. */ - static XLogRecPtr lastlsn = InvalidXLogRecPtr; + static __thread XLogRecPtr lastlsn = InvalidXLogRecPtr; XLogRecPtr currlsn = GetXLogInsertRecPtr(); /* Shouldn't be called for WAL-logging relations */ 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 bce9e87df1..25168b2189 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 @@ -1635,7 +1635,7 @@ mxstatus_to_string(MultiXactStatus status) char * mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members) { - static char *str = NULL; + static __thread char *str = NULL; StringInfoData buf; int i; 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 caedfc5840..aaa5448551 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 @@ -1015,7 +1015,7 @@ HandleParallelMessages(void) dlist_iter iter; MemoryContext oldcontext; - static MemoryContext hpm_context = NULL; + static __thread MemoryContext hpm_context = NULL; /* * This is invoked from ProcessInterrupts(), and since some of the 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 6622764d9b..2dc273bf4b 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 @@ -821,8 +821,8 @@ TwoPhaseGetGXact(TransactionId xid, bool lock_held) GlobalTransaction result = NULL; int i; - static TransactionId cached_xid = InvalidTransactionId; - static GlobalTransaction cached_gxact = NULL; + static __thread TransactionId cached_xid = InvalidTransactionId; + static __thread GlobalTransaction cached_gxact = NULL; Assert(!lock_held || LWLockHeldByMe(TwoPhaseStateLock)); 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 c6a8a2d2b5..ab0d867b04 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 @@ -527,8 +527,8 @@ MarkCurrentTransactionIdLoggedIfAny(void) TransactionId GetStableLatestTransactionId(void) { - static LocalTransactionId lxid = InvalidLocalTransactionId; - static TransactionId stablexid = InvalidTransactionId; + static __thread LocalTransactionId lxid = InvalidLocalTransactionId; + static __thread TransactionId stablexid = InvalidTransactionId; if (lxid != MyProc->lxid) { 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 a4476cf194..dc381c6896 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 @@ -1676,7 +1676,7 @@ WALInsertLockAcquire(void) * (semi-)randomly. This allows the locks to be used evenly if you have a * lot of very short connections. */ - static int lockToTry = -1; + static __thread int lockToTry = -1; if (lockToTry == -1) lockToTry = MyProc->pgprocno % NUM_XLOGINSERT_LOCKS; @@ -1897,8 +1897,8 @@ GetXLogBuffer(XLogRecPtr ptr) { int idx; XLogRecPtr endptr; - static uint64 cachedPage = 0; - static char *cachedPos = NULL; + static __thread uint64 cachedPage = 0; + static __thread char *cachedPos = NULL; XLogRecPtr expectedEndPtr; /* @@ -3058,7 +3058,7 @@ XLogBackgroundFlush(void) { XLogwrtRqst WriteRqst; bool flexible = true; - static TimestampTz lastflush; + static __thread TimestampTz lastflush; TimestampTz now; int flushbytes; @@ -4739,7 +4739,7 @@ ReadControlFile(void) { pg_crc32c crc; int fd; - static char wal_segsz_str[20]; + static __thread char wal_segsz_str[20]; int r; /* @@ -5395,7 +5395,7 @@ BootStrapXLOG(void) static char * str_time(pg_time_t tnow) { - static char buf[128]; + static __thread char buf[128]; pg_strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", @@ -11630,7 +11630,7 @@ do_pg_abort_backup(int code, Datum arg) void register_persistent_abort_backup_handler(void) { - static bool already_done = false; + static __thread bool already_done = false; if (already_done) return; @@ -12240,7 +12240,7 @@ static bool WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, bool fetching_ckpt, XLogRecPtr tliRecPtr) { - static TimestampTz last_fail_time = 0; + static __thread TimestampTz last_fail_time = 0; TimestampTz now; bool streaming_reply_sent = false; @@ -12711,7 +12711,7 @@ StartupRequestWalReceiverRestart(void) static int emode_for_corrupt_record(int emode, XLogRecPtr RecPtr) { - static XLogRecPtr lastComplaint = 0; + static __thread XLogRecPtr lastComplaint = 0; if (readSource == XLOG_FROM_PG_WAL && emode == LOG) { 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 375395c593..b33be51529 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 @@ -2180,7 +2180,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, Relation adrel; HeapTuple tuple; Datum values[4]; - static bool nulls[4] = {false, false, false, false}; + static __thread bool nulls[4] = {false, false, false, false}; Relation attrrel; HeapTuple atttup; Form_pg_attribute attStruct; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/objectaddress.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/objectaddress.c index 91c722adf6..b8895cb6a0 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/objectaddress.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/catalog/objectaddress.c @@ -2671,7 +2671,7 @@ is_objectclass_supported(Oid class_id) static const ObjectPropertyType * get_object_property_data(Oid class_id) { - static const ObjectPropertyType *prop_last = NULL; + static __thread const ObjectPropertyType *prop_last = NULL; int index; /* diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/createas.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/createas.c index d53ec952d0..42a9cd5120 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/createas.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/commands/createas.c @@ -88,7 +88,7 @@ create_ctas_internal(List *attrList, IntoClause *into) bool is_matview; char relkind; Datum toast_options; - static char *validnsps[] = HEAP_RELOPT_NAMESPACES; + static __thread char *validnsps[] = HEAP_RELOPT_NAMESPACES; ObjectAddress intoRelationAddr; /* This code supports both CREATE TABLE AS and CREATE MATERIALIZED VIEW */ 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 5eea242253..14a0c3f367 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 @@ -600,7 +600,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, ListCell *listptr; AttrNumber attnum; bool partitioned; - static char *validnsps[] = HEAP_RELOPT_NAMESPACES; + static __thread char *validnsps[] = HEAP_RELOPT_NAMESPACES; Oid ofTypeId; ObjectAddress address; LOCKMODE parentLockmode; @@ -2127,7 +2127,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence, List *constraints = NIL; bool have_bogus_defaults = false; int child_attno; - static Node bogus_marker = {0}; /* marks conflicting defaults */ + static __thread Node bogus_marker = {0}; /* marks conflicting defaults */ List *saved_schema = NIL; ListCell *entry; @@ -13140,7 +13140,7 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation, Datum repl_val[Natts_pg_class]; bool repl_null[Natts_pg_class]; bool repl_repl[Natts_pg_class]; - static char *validnsps[] = HEAP_RELOPT_NAMESPACES; + static __thread char *validnsps[] = HEAP_RELOPT_NAMESPACES; if (defList == NIL && operation != AT_ReplaceRelOptions) return; /* nothing to do */ 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 c037bf050b..03b9129313 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 @@ -272,7 +272,7 @@ void vacuum(List *relations, VacuumParams *params, BufferAccessStrategy bstrategy, bool isTopLevel) { - static bool in_vacuum = false; + static __thread bool in_vacuum = false; const char *stmttype; volatile bool in_outer_xact, 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 fabee42b9b..18d690f9ba 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 @@ -1697,7 +1697,7 @@ SPI_plan_is_valid(SPIPlanPtr plan) const char * SPI_result_code_string(int code) { - static char buf[64]; + static __thread char buf[64]; switch (code) { diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/auth-scram.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/auth-scram.c index 5214d32865..d4b1741688 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/auth-scram.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/libpq/auth-scram.c @@ -748,7 +748,7 @@ is_scram_printable(char *p) static char * sanitize_char(char c) { - static char buf[5]; + static __thread char buf[5]; if (c >= 0x21 && c <= 0x7E) snprintf(buf, sizeof(buf), "'%c'", c); @@ -768,7 +768,7 @@ sanitize_char(char c) static char * sanitize_str(const char *s) { - static char buf[30 + 1]; + static __thread char buf[30 + 1]; int i; for (i = 0; i < sizeof(buf) - 1; i++) @@ -1394,7 +1394,7 @@ static char * scram_mock_salt(const char *username) { pg_sha256_ctx ctx; - static uint8 sha_digest[PG_SHA256_DIGEST_LENGTH]; + static __thread uint8 sha_digest[PG_SHA256_DIGEST_LENGTH]; char *mock_auth_nonce = GetMockAuthenticationNonce(); /* 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 892bf06f6a..3cd6b9b923 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 @@ -1152,7 +1152,7 @@ static const char * SSLerrmessage(unsigned long ecode) { const char *errreason; - static char errbuf[36]; + static __thread char errbuf[36]; if (ecode == 0) return _("no SSL error reported"); 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 db0e785c86..0cb6dd8709 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 @@ -1417,7 +1417,7 @@ socket_flush(void) static int internal_flush(void) { - static int last_reported_send_errno = 0; + static __thread int last_reported_send_errno = 0; char *bufptr = PqSendBuffer + PqSendStart; char *bufend = PqSendBuffer + PqSendPointer; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/gram.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/gram.c index 2b2f75904e..766eae14d9 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/gram.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/parser/gram.c @@ -25601,11 +25601,11 @@ int yychar; /* The semantic value of the lookahead symbol. */ /* Default value used for initialization, for pacifying older GCCs or non-GCC compilers. */ -YY_INITIAL_VALUE (static YYSTYPE yyval_default;) +YY_INITIAL_VALUE (static __thread YYSTYPE yyval_default;) YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); /* Location data for the lookahead symbol. */ -static YYLTYPE yyloc_default +static __thread YYLTYPE yyloc_default # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL = { 1, 1, 1, 1 } # endif 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 27935c90c9..b9177b52d3 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 @@ -3380,7 +3380,7 @@ autovac_refresh_stats(void) { if (IsAutoVacuumLauncherProcess()) { - static TimestampTz last_read = 0; + static __thread TimestampTz last_read = 0; TimestampTz current_time; current_time = GetCurrentTimestamp(); 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 8ac10ba1b9..9d827d0c8c 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 @@ -904,7 +904,7 @@ void RegisterBackgroundWorker(BackgroundWorker *worker) { RegisteredBgWorker *rw; - static int numworkers = 0; + static __thread int numworkers = 0; if (!IsUnderPostmaster) ereport(DEBUG1, @@ -1315,7 +1315,7 @@ GetBackgroundWorkerTypeByPid(pid_t pid) { int slotno; bool found = false; - static char result[BGW_MAXLEN]; + static __thread char result[BGW_MAXLEN]; LWLockAcquire(BackgroundWorkerLock, LW_SHARED); 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 0656ec18c2..aae41e1c55 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 @@ -669,7 +669,7 @@ ImmediateCheckpointRequested(void) void CheckpointWriteDelay(int flags, double progress) { - static int absorb_counter = WRITES_PER_ABSORB; + static __thread int absorb_counter = WRITES_PER_ABSORB; /* Do nothing if checkpoint is being executed by non-checkpointer process */ if (!AmCheckpointerProcess()) @@ -1308,7 +1308,7 @@ UpdateSharedMemoryConfig(void) bool FirstCallSinceLastCheckpoint(void) { - static int ckpt_done = 0; + static __thread int ckpt_done = 0; int new_done; bool FirstCall = false; 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 dddddaa9cc..94a887d0ce 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 @@ -840,7 +840,7 @@ pgstat_report_stat(bool force) { /* we assume this inits to all zeroes: */ static const PgStat_TableCounts all_zeroes; - static TimestampTz last_report = 0; + static __thread TimestampTz last_report = 0; TimestampTz now; PgStat_MsgTabstat regular_msg; 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 8467b406ba..851efb13c7 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 @@ -1055,7 +1055,7 @@ ReplicationOriginExitCleanup(int code, Datum arg) void replorigin_session_setup(RepOriginId node) { - static bool registered_cleanup; + static __thread bool registered_cleanup; int i; int free_slot = -1; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/tablesync.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/tablesync.c index 47156f65e4..35ded05127 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/tablesync.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/replication/logical/tablesync.c @@ -324,8 +324,8 @@ process_syncing_tables_for_apply(XLogRecPtr current_lsn) Oid relid; TimestampTz last_start_time; }; - static List *table_states = NIL; - static HTAB *last_start_times = NULL; + static __thread List *table_states = NIL; + static __thread HTAB *last_start_times = NULL; ListCell *lc; bool started_tx = false; 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 caa34c89ca..0b3fc7c770 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 @@ -1756,12 +1756,12 @@ LogicalRepApplyLoop(XLogRecPtr last_received) static void send_feedback(XLogRecPtr recvpos, bool force, bool requestReply) { - static StringInfo reply_message = NULL; - static TimestampTz send_time = 0; + static __thread StringInfo reply_message = NULL; + static __thread TimestampTz send_time = 0; - static XLogRecPtr last_recvpos = InvalidXLogRecPtr; - static XLogRecPtr last_writepos = InvalidXLogRecPtr; - static XLogRecPtr last_flushpos = InvalidXLogRecPtr; + static __thread XLogRecPtr last_recvpos = InvalidXLogRecPtr; + static __thread XLogRecPtr last_writepos = InvalidXLogRecPtr; + static __thread XLogRecPtr last_flushpos = InvalidXLogRecPtr; XLogRecPtr writepos; XLogRecPtr flushpos; 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 98536a7c05..2deae306d2 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 @@ -1093,10 +1093,10 @@ XLogWalRcvClose(XLogRecPtr recptr) static void XLogWalRcvSendReply(bool force, bool requestReply) { - static XLogRecPtr writePtr = 0; - static XLogRecPtr flushPtr = 0; + static __thread XLogRecPtr writePtr = 0; + static __thread XLogRecPtr flushPtr = 0; XLogRecPtr applyPtr; - static TimestampTz sendTime = 0; + static __thread TimestampTz sendTime = 0; TimestampTz now; /* @@ -1169,10 +1169,10 @@ XLogWalRcvSendHSFeedback(bool immed) catalog_xmin_epoch; TransactionId xmin, catalog_xmin; - static TimestampTz sendTime = 0; + static __thread TimestampTz sendTime = 0; /* initially true so we always send at least one feedback message */ - static bool master_has_standby_xmin = true; + static __thread bool master_has_standby_xmin = true; /* * If the user doesn't want status to be reported to the master, be sure 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 f23f29631f..adb665f2c1 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 @@ -1352,7 +1352,7 @@ WalSndWriteData(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid, static void WalSndUpdateProgress(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid) { - static TimestampTz sendTime = 0; + static __thread TimestampTz sendTime = 0; TimestampTz now = GetCurrentTimestamp(); /* @@ -1379,7 +1379,7 @@ static XLogRecPtr WalSndWaitForWal(XLogRecPtr loc) { int wakeEvents; - static XLogRecPtr RecentFlushPtr = InvalidXLogRecPtr; + static __thread XLogRecPtr RecentFlushPtr = InvalidXLogRecPtr; /* * Fast path to avoid acquiring the spinlock in case we already know we @@ -1877,7 +1877,7 @@ ProcessStandbyReplyMessage(void) TimestampTz now; TimestampTz replyTime; - static bool fullyAppliedLastTime = false; + static __thread bool fullyAppliedLastTime = false; /* the caller already consumed the msgtype byte */ writePtr = pq_getmsgint64(&reply_message); @@ -2839,7 +2839,7 @@ XLogSendLogical(void) * helpful because GetFlushRecPtr() needs to acquire a heavily-contended * spinlock. */ - static XLogRecPtr flushPtr = InvalidXLogRecPtr; + static __thread XLogRecPtr flushPtr = InvalidXLogRecPtr; /* * Don't know whether we've caught up yet. We'll set WalSndCaughtUp to 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 5d0ccd2b62..d032751726 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 @@ -2092,15 +2092,15 @@ BgBufferSync(WritebackContext *wb_context) * Information saved between calls so we can determine the strategy * point's advance rate and avoid scanning already-cleaned buffers. */ - static bool saved_info_valid = false; - static int prev_strategy_buf_id; - static uint32 prev_strategy_passes; - static int next_to_clean; - static uint32 next_passes; + static __thread bool saved_info_valid = false; + static __thread int prev_strategy_buf_id; + static __thread uint32 prev_strategy_passes; + static __thread int next_to_clean; + static __thread uint32 next_passes; /* Moving averages of allocation rate and clean-buffer density */ - static float smoothed_alloc = 0; - static float smoothed_density = 10.0; + static __thread float smoothed_alloc = 0; + static __thread float smoothed_density = 10.0; /* Potentially these could be tunables, but for now, not */ float smoothing_samples = 16; 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 dd31b67af7..94296f8825 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 @@ -493,11 +493,11 @@ InitLocalBuffers(void) static Block GetLocalBufferStorage(void) { - static char *cur_block = NULL; - static int next_buf_in_block = 0; - static int num_bufs_in_block = 0; - static int total_bufs_allocated = 0; - static MemoryContext LocalBufferContext = NULL; + static __thread char *cur_block = NULL; + static __thread int next_buf_in_block = 0; + static __thread int num_bufs_in_block = 0; + static __thread int total_bufs_allocated = 0; + static __thread MemoryContext LocalBufferContext = NULL; char *this_buf; 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 c0e8ec1e9c..fe60e040cf 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 @@ -470,7 +470,7 @@ pg_flush_data(int fd, off_t offset, off_t nbytes) #if defined(HAVE_SYNC_FILE_RANGE) { int rc; - static bool not_implemented_by_kernel = false; + static __thread bool not_implemented_by_kernel = false; if (not_implemented_by_kernel) return; @@ -514,7 +514,7 @@ pg_flush_data(int fd, off_t offset, off_t nbytes) #if !defined(WIN32) && defined(MS_ASYNC) { void *p; - static int pagesize = 0; + static __thread int pagesize = 0; /* * On several OSs msync(MS_ASYNC) on a mmap'ed file triggers diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/file/sharedfileset.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/file/sharedfileset.c index 16b7594756..855a4ad4c8 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/file/sharedfileset.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/file/sharedfileset.c @@ -48,7 +48,7 @@ static Oid ChooseTablespace(const SharedFileSet *fileset, const char *name); void SharedFileSetInit(SharedFileSet *fileset, dsm_segment *seg) { - static uint32 counter = 0; + static __thread uint32 counter = 0; SpinLockInit(&fileset->mutex); fileset->refcnt = 1; 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 1f33671b18..722843be76 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 @@ -985,7 +985,7 @@ ProcArrayApplyXidAssignment(TransactionId topxid, bool TransactionIdIsInProgress(TransactionId xid) { - static TransactionId *xids = NULL; + static __thread TransactionId *xids = NULL; int nxids = 0; ProcArrayStruct *arrayP = procArray; TransactionId topxid; @@ -1936,7 +1936,7 @@ RunningTransactions GetRunningTransactionData(void) { /* result workspace */ - static RunningTransactionsData CurrentRunningXactsData; + static __thread RunningTransactionsData CurrentRunningXactsData; ProcArrayStruct *arrayP = procArray; RunningTransactions CurrentRunningXacts = &CurrentRunningXactsData; @@ -2577,7 +2577,7 @@ GetCurrentVirtualXIDs(TransactionId limitXmin, bool excludeXmin0, VirtualTransactionId * GetConflictingVirtualXIDs(TransactionId limitXmin, Oid dbOid) { - static VirtualTransactionId *vxids; + static __thread VirtualTransactionId *vxids; ProcArrayStruct *arrayP = procArray; int count = 0; int index; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/sinval.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/sinval.c index f060efdc3f..278386c143 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/sinval.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/ipc/sinval.c @@ -72,14 +72,14 @@ ReceiveSharedInvalidMessages(void (*invalFunction) (SharedInvalidationMessage *m void (*resetFunction) (void)) { #define MAXINVALMSGS 32 - static SharedInvalidationMessage messages[MAXINVALMSGS]; + static __thread SharedInvalidationMessage messages[MAXINVALMSGS]; /* * We use volatile here to prevent bugs if a compiler doesn't realize that * recursion is a possibility ... */ - static volatile int nextmsg = 0; - static volatile int nummsgs = 0; + static __thread volatile int nextmsg = 0; + static __thread volatile int nummsgs = 0; /* Deal with any messages still pending from an outer recursion */ while (nextmsg < nummsgs) 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 92c112647b..9a55f73714 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 @@ -119,7 +119,7 @@ static const char *const lock_mode_names[] = }; #ifndef LOCK_DEBUG -static bool Dummy_trace = false; +static const bool Dummy_trace = false; #endif static const LockMethodData default_lockmethod = { @@ -2913,7 +2913,7 @@ FastPathGetRelationLockEntry(LOCALLOCK *locallock) VirtualTransactionId * GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *countp) { - static VirtualTransactionId *vxids; + static __thread VirtualTransactionId *vxids; LOCKMETHODID lockmethodid = locktag->locktag_lockmethodid; LockMethod lockMethodTable; LOCK *lock; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/page/bufpage.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/page/bufpage.c index c33df1ee6c..072c28001d 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/page/bufpage.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/storage/page/bufpage.c @@ -1184,7 +1184,7 @@ PageIndexTupleOverwrite(Page page, OffsetNumber offnum, char * PageSetChecksumCopy(Page page, BlockNumber blkno) { - static char *pageCopy = NULL; + static __thread char *pageCopy = NULL; /* If we don't need a checksum, just return the passed-in data */ if (PageIsNew(page) || !DataChecksumsEnabled()) 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 457785dffb..a3325ddee4 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 @@ -259,7 +259,7 @@ SyncPostCheckpoint(void) void ProcessSyncRequests(void) { - static bool sync_in_progress = false; + static __thread bool sync_in_progress = false; HASH_SEQ_STATUS hstat; PendingFsyncEntry *entry; 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 cc9e485dda..8986a819d4 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 @@ -4597,7 +4597,7 @@ long get_stack_depth_rlimit(void) { #if defined(HAVE_GETRLIMIT) && defined(RLIMIT_STACK) - static long val = 0; + static __thread long val = 0; /* This won't change after process launch, so check just once */ if (val == 0) diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tcop/utility.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tcop/utility.c index eec6af4263..0e2864e201 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tcop/utility.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tcop/utility.c @@ -1174,7 +1174,7 @@ ProcessUtilitySlow(ParseState *pstate, { CreateStmt *cstmt = (CreateStmt *) stmt; Datum toast_options; - static char *validnsps[] = HEAP_RELOPT_NAMESPACES; + static __thread char *validnsps[] = HEAP_RELOPT_NAMESPACES; /* Remember transformed RangeVar for LIKE */ table_rv = cstmt->relation; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tsearch/dict_thesaurus.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tsearch/dict_thesaurus.c index cb0835982d..8d86d65257 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tsearch/dict_thesaurus.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/tsearch/dict_thesaurus.c @@ -105,8 +105,8 @@ newLexeme(DictThesaurus *d, char *b, char *e, uint32 idsubst, uint16 posinsubst) static void addWrd(DictThesaurus *d, char *b, char *e, uint32 idsubst, uint16 nwrd, uint16 posinsubst, bool useasis) { - static int nres = 0; - static int ntres = 0; + static __thread int nres = 0; + static __thread int ntres = 0; TheSubstitute *ptr; if (nwrd == 0) diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/cash.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/cash.c index 6515fc8ec6..0720314632 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/cash.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/cash.c @@ -38,7 +38,7 @@ static const char * num_word(Cash value) { - static char buf[128]; + static __thread char buf[128]; static const char *const small[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/jsonpath_exec.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/jsonpath_exec.c index 8c8422e1e4..ba74b0509c 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/jsonpath_exec.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/jsonpath_exec.c @@ -1841,7 +1841,7 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, * We also support ISO 8601 for timestamps, because to_json[b]() * functions use this format. */ - static const char *fmt_str[] = + static __thread const char *fmt_str[] = { "yyyy-mm-dd", "HH24:MI:SSTZH:TZM", @@ -1856,7 +1856,7 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, }; /* cache for format texts */ - static text *fmt_txt[lengthof(fmt_str)] = {0}; + static __thread text *fmt_txt[lengthof(fmt_str)] = {0}; int i; /* loop until datetime format fits */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/jsonpath_gram.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/jsonpath_gram.c index 5e85c8864e..0470eddfc8 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/jsonpath_gram.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/jsonpath_gram.c @@ -1219,7 +1219,7 @@ int yychar; /* The semantic value of the lookahead symbol. */ /* Default value used for initialization, for pacifying older GCCs or non-GCC compilers. */ -YY_INITIAL_VALUE (static YYSTYPE yyval_default;) +YY_INITIAL_VALUE (static __thread YYSTYPE yyval_default;) YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); /* Number of syntax errors so far. */ diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/like_support.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/like_support.c index b9144e0abb..0a9a41a9e0 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/like_support.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/like_support.c @@ -1581,8 +1581,8 @@ make_greater_string(const Const *str_const, FmgrInfo *ltproc, Oid collation) else { /* If first time through, determine the suffix to use */ - static char suffixchar = 0; - static Oid suffixcollation = 0; + static __thread char suffixchar = 0; + static __thread Oid suffixcollation = 0; if (!suffixchar || suffixcollation != collation) { 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 9a4b7772e8..d6e881d5b2 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 @@ -203,7 +203,7 @@ pg_perm_setlocale(int category, const char *locale) */ if (category == LC_CTYPE) { - static char save_lc_ctype[LC_ENV_BUFSIZE]; + static __thread char save_lc_ctype[LC_ENV_BUFSIZE]; /* copy setlocale() return value before callee invokes it again */ strlcpy(save_lc_ctype, result, sizeof(save_lc_ctype)); @@ -498,8 +498,8 @@ db_encoding_convert(int encoding, char **str) struct lconv * PGLC_localeconv(void) { - static struct lconv CurrentLocaleConv; - static bool CurrentLocaleConvAllocated = false; + static __thread struct lconv CurrentLocaleConv; + static __thread bool CurrentLocaleConvAllocated = false; struct lconv *extlconv; struct lconv worklconv; char *save_lc_monetary; @@ -1368,7 +1368,7 @@ lc_collate_is_c(Oid collation) */ if (collation == DEFAULT_COLLATION_OID) { - static int result = -1; + static __thread int result = -1; char *localeptr; if (result >= 0) @@ -1418,7 +1418,7 @@ lc_ctype_is_c(Oid collation) */ if (collation == DEFAULT_COLLATION_OID) { - static int result = -1; + static __thread int result = -1; char *localeptr; if (result >= 0) diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/timestamp.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/timestamp.c index 2f80a9e091..b87857b1ed 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/timestamp.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/timestamp.c @@ -1767,7 +1767,7 @@ timestamptz_to_time_t(TimestampTz t) const char * timestamptz_to_str(TimestampTz t) { - static char buf[MAXDATELEN + 1]; + static __thread char buf[MAXDATELEN + 1]; int tz; struct pg_tm tt, *tm = &tt; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/tsrank.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/tsrank.c index c88ebfc7d4..c858181cdb 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/tsrank.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/tsrank.c @@ -399,7 +399,7 @@ calc_rank(const float *w, TSVector t, TSQuery q, int32 method) static const float * getWeights(ArrayType *win) { - static float ws[lengthof(weights)]; + static __thread float ws[lengthof(weights)]; int i; float4 *arrdata; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/xml.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/xml.c index 680e914f8f..8ae8ec7336 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/xml.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/adt/xml.c @@ -946,7 +946,7 @@ xml_is_document(xmltype *arg) void pg_xml_init_library(void) { - static bool first_time = true; + static __thread bool first_time = true; if (first_time) { 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 f543869a7e..2d9cdacc09 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 @@ -204,23 +204,23 @@ static __thread int maxSharedInvalidMessagesArray; #define MAX_SYSCACHE_CALLBACKS 64 #define MAX_RELCACHE_CALLBACKS 10 -static struct SYSCACHECALLBACK +typedef struct SYSCACHECALLBACK { int16 id; /* cache number */ int16 link; /* next callback index+1 for same cache */ SyscacheCallbackFunction function; Datum arg; -} syscache_callback_list[MAX_SYSCACHE_CALLBACKS]; +} SYSCACHECALLBACK; static __thread SYSCACHECALLBACK syscache_callback_list[MAX_SYSCACHE_CALLBACKS]; static __thread int16 syscache_callback_links[SysCacheSize]; static __thread int syscache_callback_count = 0; -static struct RELCACHECALLBACK +typedef struct RELCACHECALLBACK { RelcacheCallbackFunction function; Datum arg; -} relcache_callback_list[MAX_RELCACHE_CALLBACKS]; +} RELCACHECALLBACK; static __thread RELCACHECALLBACK relcache_callback_list[MAX_RELCACHE_CALLBACKS]; static __thread int relcache_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 e99efce903..1b905270f4 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 @@ -4336,7 +4336,7 @@ BuildHardcodedDescriptor(int natts, const FormData_pg_attribute *attrs) static TupleDesc GetPgClassDescriptor(void) { - static TupleDesc pgclassdesc = NULL; + static __thread TupleDesc pgclassdesc = NULL; /* Already done? */ if (pgclassdesc == NULL) @@ -4349,7 +4349,7 @@ GetPgClassDescriptor(void) static TupleDesc GetPgIndexDescriptor(void) { - static TupleDesc pgindexdesc = NULL; + static __thread TupleDesc pgindexdesc = NULL; /* Already done? */ if (pgindexdesc == NULL) 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 86ffb1d6d2..d22a775845 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 @@ -1925,7 +1925,7 @@ set_syslog_parameters(const char *ident, int facility) static void write_syslog(int level, const char *line) { - static unsigned long seq = 0; + static __thread unsigned long seq = 0; int len; const char *nlpos; @@ -2297,10 +2297,10 @@ static void log_line_prefix(StringInfo buf, ErrorData *edata) { /* static counter for line numbers */ - static long log_line_number = 0; + static __thread long log_line_number = 0; /* has counter been reset in current process? */ - static int log_my_pid = 0; + static __thread int log_my_pid = 0; int padding; const char *p; @@ -2651,10 +2651,10 @@ write_csvlog(ErrorData *edata) bool print_stmt = false; /* static counter for line numbers */ - static long log_line_number = 0; + static __thread long log_line_number = 0; /* has counter been reset in current process? */ - static int log_my_pid = 0; + static __thread int log_my_pid = 0; /* * This is one of the few places where we'd rather not inherit a static @@ -2854,7 +2854,7 @@ write_csvlog(ErrorData *edata) char * unpack_sql_state(int sql_state) { - static char buf[12]; + static __thread char buf[12]; int i; for (i = 0; i < 5; i++) 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 cf8e06c05d..08132034b2 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 @@ -670,7 +670,7 @@ find_in_dynamic_libpath(const char *basename) void ** find_rendezvous_variable(const char *varName) { - static HTAB *rendezvousHash = NULL; + static __thread HTAB *rendezvousHash = NULL; rendezvousHashEntry *hentry; bool found; 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 1275c08f1b..569ac06f77 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 @@ -2532,7 +2532,7 @@ get_config_unit_name(int flags) return "MB"; case GUC_UNIT_BLOCKS: { - static char bbuf[8]; + static __thread char bbuf[8]; /* initialize if first time through */ if (bbuf[0] == '\0') @@ -2541,7 +2541,7 @@ get_config_unit_name(int flags) } case GUC_UNIT_XBLOCKS: { - static char xbuf[8]; + static __thread char xbuf[8]; /* initialize if first time through */ if (xbuf[0] == '\0') @@ -3851,7 +3851,7 @@ const char * GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged) { struct config_generic *record; - static char buffer[256]; + static __thread char buffer[256]; record = find_option(name, false, ERROR); if (record == NULL) @@ -3907,7 +3907,7 @@ const char * GetConfigOptionResetString(const char *name) { struct config_generic *record; - static char buffer[256]; + static __thread char buffer[256]; record = find_option(name, false, ERROR); if (record == NULL) @@ -7589,7 +7589,7 @@ static const char * show_tcp_keepalives_idle(void) { /* See comments in assign_tcp_keepalives_idle */ - static char nbuf[16]; + static __thread char nbuf[16]; snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesidle(MyProcPort)); return nbuf; @@ -7606,7 +7606,7 @@ static const char * show_tcp_keepalives_interval(void) { /* See comments in assign_tcp_keepalives_idle */ - static char nbuf[16]; + static __thread char nbuf[16]; snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesinterval(MyProcPort)); return nbuf; @@ -7623,7 +7623,7 @@ static const char * show_tcp_keepalives_count(void) { /* See comments in assign_tcp_keepalives_idle */ - static char nbuf[16]; + static __thread char nbuf[16]; snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivescount(MyProcPort)); return nbuf; @@ -7640,7 +7640,7 @@ static const char * show_tcp_user_timeout(void) { /* See comments in assign_tcp_keepalives_idle */ - static char nbuf[16]; + static __thread char nbuf[16]; snprintf(nbuf, sizeof(nbuf), "%d", pq_gettcpusertimeout(MyProcPort)); return nbuf; @@ -7788,7 +7788,7 @@ check_cluster_name(char **newval, void **extra, GucSource source) static const char * show_unix_socket_permissions(void) { - static char buf[12]; + static __thread char buf[12]; snprintf(buf, sizeof(buf), "%04o", Unix_socket_permissions); return buf; @@ -7797,7 +7797,7 @@ show_unix_socket_permissions(void) static const char * show_log_file_mode(void) { - static char buf[12]; + static __thread char buf[12]; snprintf(buf, sizeof(buf), "%04o", Log_file_mode); return buf; @@ -7806,7 +7806,7 @@ show_log_file_mode(void) static const char * show_data_directory_mode(void) { - static char buf[12]; + static __thread char buf[12]; snprintf(buf, sizeof(buf), "%04o", data_directory_mode); return buf; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/pg_rusage.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/pg_rusage.c index 64a6af3152..eab87b4526 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/pg_rusage.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/backend/utils/misc/pg_rusage.c @@ -39,7 +39,7 @@ pg_rusage_init(PGRUsage *ru0) const char * pg_rusage_show(const PGRUsage *ru0) { - static char result[100]; + static __thread char result[100]; PGRUsage ru1; pg_rusage_init(&ru1); 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 f45101ee01..3df62c7a79 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 @@ -234,7 +234,7 @@ CreatePortal(const char *name, bool allowDup, bool dupSilent) Portal CreateNewPortal(void) { - static unsigned int unnamed_portal_count = 0; + static __thread unsigned int unnamed_portal_count = 0; char portalname[MAX_PORTALNAME_LEN]; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/md5.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/md5.c index 5f790c6800..a150d8a9b6 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/md5.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/md5.c @@ -247,7 +247,7 @@ calculateDigestFromBuffer(const uint8 *b, uint32 len, uint8 sum[16]) static void bytesToHex(uint8 b[16], char *s) { - static const char *hex = "0123456789abcdef"; + static __thread const char *hex = "0123456789abcdef"; int q, w; diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/unicode_norm.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/unicode_norm.c index ab5ce59345..a00d983b5a 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/unicode_norm.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/common/unicode_norm.c @@ -78,7 +78,7 @@ get_code_entry(pg_wchar code) static const pg_wchar * get_code_decomposition(pg_unicode_decomposition *entry, int *dec_size) { - static pg_wchar x; + static __thread pg_wchar x; if (DECOMPOSITION_IS_INLINE(entry)) { diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/port/strerror.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/port/strerror.c index 375edb0f5a..4d95162782 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/port/strerror.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/port/strerror.c @@ -34,7 +34,7 @@ static char *win32_socket_strerror(int errnum, char *buf, size_t buflen); char * pg_strerror(int errnum) { - static char errorstr_buf[PG_STRERROR_R_BUFLEN]; + static __thread char errorstr_buf[PG_STRERROR_R_BUFLEN]; return pg_strerror_r(errnum, errorstr_buf, sizeof(errorstr_buf)); } diff --git a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/timezone/localtime.c b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/timezone/localtime.c index 964085840e..69d451e551 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/timezone/localtime.c +++ b/ydb/library/yql/parser/pg_query_wrapper/postgresql/src/timezone/localtime.c @@ -1358,7 +1358,7 @@ gmtsub(pg_time_t const *timep, int32 offset, struct pg_tm *result; /* GMT timezone state data is kept here */ - static struct state *gmtptr = NULL; + static __thread struct state *gmtptr = NULL; if (gmtptr == NULL) { 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 a59551e746..99526bb296 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 @@ -44,8 +44,8 @@ pg_TZDIR(void) { #ifndef SYSTEMTZDIR /* normal case: timezone stuff is under our share dir */ - static bool done_tzdir = false; - static char tzdir[MAXPGPATH]; + static __thread bool done_tzdir = false; + static __thread char tzdir[MAXPGPATH]; if (done_tzdir) return tzdir; diff --git a/ydb/library/yql/parser/pg_query_wrapper/readme.md b/ydb/library/yql/parser/pg_query_wrapper/readme.md new file mode 100644 index 0000000000..b75f7fb588 --- /dev/null +++ b/ydb/library/yql/parser/pg_query_wrapper/readme.md @@ -0,0 +1,7 @@ +To sync PostrgeSQL sources from contrib, run command: + +``` +./copy_src.sh && ./verify.sh +``` + +Expected output: ```***PASSED***``` diff --git a/ydb/library/yql/parser/pg_query_wrapper/vars.txt b/ydb/library/yql/parser/pg_query_wrapper/vars.txt index 6d79349aa4..d0f235fd91 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/vars.txt +++ b/ydb/library/yql/parser/pg_query_wrapper/vars.txt @@ -39,7 +39,6 @@ BgBufferSync.smoothed_density BgWriterDelay BgWriterPID BgWriterStats -BlockSig BufferBlocks BufferDescriptors BufferIOLWLockArray @@ -445,7 +444,6 @@ SnapshotSelfData StandbyMode StandbyModeRequested StartWorkerNeeded -StartupBlockSig StartupPID StartupStatus StatementTimeout @@ -488,7 +486,6 @@ TwoPhaseGetGXact.cached_xid TwoPhaseState Typ TypeCacheHash -UnBlockSig Unix_socket_directories Unix_socket_group Unix_socket_permissions @@ -626,7 +623,6 @@ baseTempCreationPending base_yyparse.yyloc_default base_yyparse.yyval_default beforeConstraints -before_shmem_exit_index before_shmem_exit_list begininsert_called bgwriterLaunched @@ -791,7 +787,6 @@ eoxact_list_overflowed error_context_stack errordata errordata_stack_depth -escape_string_warning event_source executeDateTimeMethod.fmt_str executeDateTimeMethod.fmt_txt @@ -1067,9 +1062,7 @@ oldrs on_commit_launcher_wakeup on_commit_stop_workers on_commits -on_proc_exit_index on_proc_exit_list -on_shmem_exit_index on_shmem_exit_list one_minus_cos_60 opCtx @@ -1361,7 +1354,6 @@ ssl_passphrase_command ssl_passphrase_command_supports_reload ssl_renegotiation_limit stack_base_ptr -standard_conforming_strings standbySnapshotPendingXmin standbyState standbyWait_us diff --git a/ydb/library/yql/parser/pg_query_wrapper/verify.sh b/ydb/library/yql/parser/pg_query_wrapper/verify.sh new file mode 100755 index 0000000000..511aae5fbc --- /dev/null +++ b/ydb/library/yql/parser/pg_query_wrapper/verify.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -eu +ya make +err=0 +objdump libyql-parser-pg_query_wrapper.a -t | grep -E "\.data\.|\.bss\." | \ +grep -v -E "progname|pg_popcount32|pg_popcount64|pg_comp_crc32c|_ZN4NYqlL10GlobalInitE|BlockSig|StartupBlockSig|UnBlockSig" | \ +grep -v -E "on_proc_exit_index|on_shmem_exit_index|before_shmem_exit_index" || err=$? +if [ $err -eq 1 ]; then + echo "***PASSED***" +fi +if [ $err -ne 1 ]; then + echo "***UNEXPECTED SYMBOLS***" +fi |