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

BABEL-5155 #3061

Open
wants to merge 2 commits into
base: BABEL_4_X_DEV
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion contrib/babelfishpg_common/src/collation.c
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,8 @@ babelfish_define_type_default_collation(Oid typeNamespace)
const char *babelfish_dump_restore = GetConfigOption("babelfishpg_tsql.dump_restore", true, false);

/* We should only override the default collation for Babelfish data types. */
if (strcmp(get_namespace_name(typeNamespace), "sys") != 0)
if (strcmp(get_namespace_name(typeNamespace), "sys") != 0 && (!babelfish_dump_restore || (babelfish_dump_restore &&
strncmp(babelfish_dump_restore, "off", 3) == 0)))
return DEFAULT_COLLATION_OID;

/*
Expand Down
17 changes: 3 additions & 14 deletions contrib/babelfishpg_tsql/src/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static PlannedStmt *pltsql_planner_hook(Query *parse, const char *query_string,
* parser Hook
*****************************************/
static Oid set_param_collation(Param *param);
static Oid default_collation_for_builtin_type(Type typ, bool handle_text);
static Oid default_collation_for_builtin_type(Type typ);
static char* pltsql_get_object_identity_event_trigger(ObjectAddress *addr);
static const char *remove_db_name_in_schema(const char *schema_name, const char *object_type);

Expand Down Expand Up @@ -5620,15 +5620,14 @@ set_param_collation(Param *param)
* @return - default collation for the given builtin type based on dialect
*/
static Oid
default_collation_for_builtin_type(Type typ, bool handle_pg_type)
default_collation_for_builtin_type(Type typ)
{
Form_pg_type typtup;
Oid oid = InvalidOid;

typtup = (Form_pg_type) GETSTRUCT(typ);
if (OidIsValid(typtup->typcollation) &&
sql_dialect == SQL_DIALECT_TSQL &&
(typtup->typnamespace == sys_schema_oid))
sql_dialect == SQL_DIALECT_TSQL)
{
/*
* Always set CLUSTER_COLLATION_OID() for babelfish collatable types so that
Expand All @@ -5641,16 +5640,6 @@ default_collation_for_builtin_type(Type typ, bool handle_pg_type)
oid = typtup->typcollation;
}

/*
* Special handling for PG datatypes such as TEXT because Babelfish does not define sys.TEXT.
* This is required as Babelfish currently does not handle collation of String Const node correctly.
* TODO: Fix the handling of the collation for String Const node.
*/
if (handle_pg_type && oid == DEFAULT_COLLATION_OID)
{
oid = CLUSTER_COLLATION_OID();
}

return oid;
}

Expand Down
Loading