From 20e113ff6593440f737716481e2a80e06087e8ac Mon Sep 17 00:00:00 2001 From: Sumit Jaiswal Date: Fri, 27 Dec 2024 05:22:13 +0000 Subject: [PATCH] Set current db_id along with db_name for parallel workers Signed-off-by: Sumit Jaiswal --- contrib/babelfishpg_tsql/src/session.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/babelfishpg_tsql/src/session.c b/contrib/babelfishpg_tsql/src/session.c index b370392dde..d1367275e5 100644 --- a/contrib/babelfishpg_tsql/src/session.c +++ b/contrib/babelfishpg_tsql/src/session.c @@ -70,6 +70,7 @@ void set_cur_db_name_for_parallel_worker(const char* logical_db_name) { int len; + int16 db_id; if (logical_db_name == NULL) ereport(ERROR, @@ -80,13 +81,15 @@ set_cur_db_name_for_parallel_worker(const char* logical_db_name) Assert(len <= MAX_BBF_NAMEDATALEND); - if(!DbidIsValid(get_db_id(logical_db_name))) + db_id = get_db_id(logical_db_name); + if(!DbidIsValid(db_id)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("database \"%s\" does not exist", logical_db_name))); strncpy(current_db_name, logical_db_name, MAX_BBF_NAMEDATALEND); current_db_name[len] = '\0'; + current_db_id = db_id; }