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

fix: change default collation allowance #170

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
40 changes: 33 additions & 7 deletions mongo_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,10 @@ foreign_expr_walker(Node *node, foreign_glob_cxt *glob_cxt,
*/
collation = c->constcollid;
if (collation == InvalidOid ||
collation == DEFAULT_COLLATION_OID)
collation == DEFAULT_COLLATION_OID ||
collation == C_COLLATION_OID ||
collation == POSIX_COLLATION_OID
)
state = FDW_COLLATE_NONE;
else
state = FDW_COLLATE_UNSAFE;
Expand All @@ -1498,7 +1501,10 @@ foreign_expr_walker(Node *node, foreign_glob_cxt *glob_cxt,
*/
collation = p->paramcollid;
if (collation == InvalidOid ||
collation == DEFAULT_COLLATION_OID)
collation == DEFAULT_COLLATION_OID ||
collation == C_COLLATION_OID ||
collation == POSIX_COLLATION_OID
)
state = FDW_COLLATE_NONE;
else
state = FDW_COLLATE_UNSAFE;
Expand Down Expand Up @@ -1558,7 +1564,11 @@ foreign_expr_walker(Node *node, foreign_glob_cxt *glob_cxt,
else if (inner_cxt.state == FDW_COLLATE_SAFE &&
collation == inner_cxt.collation)
state = FDW_COLLATE_SAFE;
else if (collation == DEFAULT_COLLATION_OID)
else if (
collation == DEFAULT_COLLATION_OID ||
collation == C_COLLATION_OID ||
collation == POSIX_COLLATION_OID
)
state = FDW_COLLATE_NONE;
else
state = FDW_COLLATE_UNSAFE;
Expand All @@ -1585,7 +1595,11 @@ foreign_expr_walker(Node *node, foreign_glob_cxt *glob_cxt,
else if (inner_cxt.state == FDW_COLLATE_SAFE &&
collation == inner_cxt.collation)
state = FDW_COLLATE_SAFE;
else if (collation == DEFAULT_COLLATION_OID)
else if (
collation == DEFAULT_COLLATION_OID ||
collation == C_COLLATION_OID ||
collation == POSIX_COLLATION_OID
)
state = FDW_COLLATE_NONE;
else
state = FDW_COLLATE_UNSAFE;
Expand Down Expand Up @@ -1721,7 +1735,11 @@ foreign_expr_walker(Node *node, foreign_glob_cxt *glob_cxt,
else if (inner_cxt.state == FDW_COLLATE_SAFE &&
collation == inner_cxt.collation)
state = FDW_COLLATE_SAFE;
else if (collation == DEFAULT_COLLATION_OID)
else if (
collation == DEFAULT_COLLATION_OID ||
collation == C_COLLATION_OID ||
collation == POSIX_COLLATION_OID
)
state = FDW_COLLATE_NONE;
else
state = FDW_COLLATE_UNSAFE;
Expand Down Expand Up @@ -1760,12 +1778,20 @@ foreign_expr_walker(Node *node, foreign_glob_cxt *glob_cxt,
/*
* Non-default collation always beats default.
*/
if (outer_cxt->collation == DEFAULT_COLLATION_OID)
if (
outer_cxt->collation == DEFAULT_COLLATION_OID ||
outer_cxt->collation == C_COLLATION_OID ||
outer_cxt->collation == POSIX_COLLATION_OID
)
{
/* Override previous parent state */
outer_cxt->collation = collation;
}
else if (collation != DEFAULT_COLLATION_OID)
else if (
collation != DEFAULT_COLLATION_OID &&
collation != C_COLLATION_OID &&
collation != POSIX_COLLATION_OID
)
{
/*
* Conflict; show state as indeterminate. We don't
Expand Down