Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark table_constraints_internal() function as parallel safe and set current_db_id for parallel workers #3322

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/babelfishpg_tsql/sql/information_schema_tsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9567,7 +9567,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
Expand Down
5 changes: 4 additions & 1 deletion contrib/babelfishpg_tsql/src/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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,
Expand All @@ -67,13 +68,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;
}


Expand Down