diff --git a/contrib/babelfishpg_tsql/sql/information_schema_tsql.sql b/contrib/babelfishpg_tsql/sql/information_schema_tsql.sql index c56bb90487..4b7c302bb6 100644 --- a/contrib/babelfishpg_tsql/sql/information_schema_tsql.sql +++ b/contrib/babelfishpg_tsql/sql/information_schema_tsql.sql @@ -538,7 +538,7 @@ BEGIN OR has_any_column_privilege(r.oid, 'SELECT, INSERT, UPDATE, REFERENCES') ); END; $$ -LANGUAGE plpgsql STABLE; +LANGUAGE plpgsql STABLE PARALLEL SAFE; /* * TABLE_CONSTRAINTS view diff --git a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.4.0--4.5.0.sql b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.4.0--4.5.0.sql index 911d1bc4ef..d80e1de0e5 100644 --- a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.4.0--4.5.0.sql +++ b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.4.0--4.5.0.sql @@ -11475,7 +11475,7 @@ BEGIN OR has_any_column_privilege(r.oid, 'SELECT, INSERT, UPDATE, REFERENCES') ); END; $$ -LANGUAGE plpgsql STABLE; +LANGUAGE plpgsql STABLE PARALLEL SAFE; CREATE OR REPLACE VIEW information_schema_tsql.table_constraints AS SELECT 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; }