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

Pick correct collation for Const Node #436

Open
wants to merge 34 commits into
base: BABEL_4_X_DEV__PG_16_X
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
113c198
Pick correct collation for Const Node
ahmed-shameem Sep 9, 2024
88ef548
Update logic for dump restore
ahmed-shameem Sep 10, 2024
e9edf7f
Rerun tests
ahmed-shameem Sep 10, 2024
ccc1b67
Fix build failure
ahmed-shameem Sep 10, 2024
f2dec32
Minor fix
ahmed-shameem Sep 10, 2024
5c5d89b
Fix failures
ahmed-shameem Sep 10, 2024
34d6e66
Merge remote-tracking branch 'upstream/BABEL_4_X_DEV__PG_16_X' into j…
ahmed-shameem Sep 11, 2024
20937d1
Remove redundant changes
ahmed-shameem Sep 11, 2024
a8d4df1
Merge remote-tracking branch 'upstream/BABEL_4_X_DEV__PG_16_X' into j…
ahmed-shameem Sep 24, 2024
592024e
Update logic
ahmed-shameem Sep 24, 2024
5fd91e6
Update logic for computed columns for babelfish objects
ahmed-shameem Sep 24, 2024
5dae2a5
Update logic for computed columns for babelfish objects 2
ahmed-shameem Sep 24, 2024
87dcb04
Update logic for computed columns for babelfish objects 3
ahmed-shameem Sep 24, 2024
b1040d0
Update logic for computed columns for babelfish objects 4
ahmed-shameem Sep 24, 2024
51b5cd1
Update logic for computed columns for babelfish objects 5
ahmed-shameem Sep 24, 2024
950fb58
Merge remote-tracking branch 'upstream/BABEL_4_X_DEV__PG_16_X' into j…
ahmed-shameem Sep 24, 2024
d0549c8
Update logic for computed columns for babelfish objects 6 (may need t…
ahmed-shameem Sep 24, 2024
90cba8e
Update logic for computed columns for babelfish objects 6 (may need t…
ahmed-shameem Sep 24, 2024
92f308b
Merge remote-tracking branch 'upstream/BABEL_4_X_DEV__PG_16_X' into j…
ahmed-shameem Sep 24, 2024
9b967ab
Remove unnecessary changes
ahmed-shameem Sep 25, 2024
1fdd4c5
Merge remote-tracking branch 'upstream/BABEL_4_X_DEV__PG_16_X' into j…
ahmed-shameem Sep 25, 2024
ab5e55c
Merge remote-tracking branch 'upstream/BABEL_4_X_DEV__PG_16_X' into j…
ahmed-shameem Oct 13, 2024
97cd842
Merge remote-tracking branch 'upstream/BABEL_4_X_DEV__PG_16_X' into j…
ahmed-shameem Nov 11, 2024
c6511ac
Merge remote-tracking branch 'upstream/BABEL_4_X_DEV__PG_16_X' into j…
ahmed-shameem Dec 2, 2024
309d65b
Check behaviour
ahmed-shameem Dec 2, 2024
be9be41
Remove unnecessary changes
ahmed-shameem Dec 2, 2024
c3a09ca
Minor change
ahmed-shameem Dec 2, 2024
9d4d56e
Merge remote-tracking branch 'upstream/BABEL_4_X_DEV__PG_16_X' into j…
ahmed-shameem Jan 9, 2025
4894138
Temporarily fix upgrade failure
ahmed-shameem Jan 9, 2025
c628c30
Test by removing maybe unnecessary change
ahmed-shameem Jan 10, 2025
854d013
Update engine logic for adding/not adding explicit COLLATE and parent…
ahmed-shameem Jan 10, 2025
25667ed
Update logic
ahmed-shameem Jan 10, 2025
5306d85
Refractor code
ahmed-shameem Jan 13, 2025
0578d11
Refractor code
ahmed-shameem Jan 13, 2025
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
37 changes: 25 additions & 12 deletions src/backend/parser/parse_collate.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "parser/parse_collate.h"
#include "parser/parser.h" /* only needed for GUC variables */
#include "utils/lsyscache.h"
#include "utils/guc.h"


/*
Expand Down Expand Up @@ -799,6 +800,7 @@ merge_collation_state(Oid collation,
int location2,
assign_collations_context *context)
{
const char *dump_restore;
/*
* If the collation strength for this node is different from what's
* already in *context, then this node either dominates or is dominated by
Expand Down Expand Up @@ -859,18 +861,29 @@ merge_collation_state(Oid collation,
case COLLATE_EXPLICIT:
if (collation != context->collation)
{
/*
* Oops, we have a conflict of explicit COLLATE clauses.
* Here we choose to throw error immediately; that is what
* the SQL standard says to do, and there's no good reason
* to be less strict.
*/
ereport(ERROR,
(errcode(ERRCODE_COLLATION_MISMATCH),
errmsg("collation mismatch between explicit collations \"%s\" and \"%s\"",
get_collation_name(context->collation),
get_collation_name(collation)),
parser_errposition(context->pstate, location)));
dump_restore = GetConfigOption("babelfishpg_tsql.dump_restore", true, false);
if (dump_restore && strcmp(dump_restore, "on") == 0)
{
context->collation = collation;
context->strength = strength;
context->location = location;
break;
}
else
{
/*
* Oops, we have a conflict of explicit COLLATE clauses.
* Here we choose to throw error immediately; that is what
* the SQL standard says to do, and there's no good reason
* to be less strict.
*/
ereport(ERROR,
(errcode(ERRCODE_COLLATION_MISMATCH),
errmsg("collation mismatch between explicit collations \"%s\" and \"%s\"",
get_collation_name(context->collation),
get_collation_name(collation)),
parser_errposition(context->pstate, location)));
}
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/backend/parser/parse_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ typeTypeCollation(Type typ)

if (handle_default_collation_hook)
{
return (*handle_default_collation_hook)(typ, false);
return (*handle_default_collation_hook)(typ);
}

return typtup->typcollation;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/utils/adt/like_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -1771,7 +1771,7 @@ string_to_const(const char *str, Oid datatype)
case TEXTOID:
case VARCHAROID:
case BPCHAROID:
collation = DEFAULT_COLLATION_OID;
collation = CLUSTER_COLLATION_OID();
constlen = -1;
break;

Expand Down
2 changes: 1 addition & 1 deletion src/backend/utils/cache/lsyscache.c
Original file line number Diff line number Diff line change
Expand Up @@ -3055,7 +3055,7 @@ get_typcollation(Oid typid)

if (handle_default_collation_hook)
{
result = (*handle_default_collation_hook)((Type) tp, true);
result = (*handle_default_collation_hook)((Type) tp);
}

ReleaseSysCache(tp);
Expand Down
2 changes: 1 addition & 1 deletion src/bin/pg_dump/pg_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -15854,7 +15854,7 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
{
if (tbinfo->attgenerated[j] == ATTRIBUTE_GENERATED_STORED)
appendPQExpBuffer(q, " GENERATED ALWAYS AS (%s) STORED",
tbinfo->attrdefs[j]->adef_expr);
tbinfo->attrdefs[j]->adef_expr);
else
appendPQExpBuffer(q, " DEFAULT %s",
tbinfo->attrdefs[j]->adef_expr);
Expand Down
2 changes: 1 addition & 1 deletion src/include/parser/parse_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extern PGDLLEXPORT check_or_set_default_typmod_hook_type check_or_set_default_ty
typedef void (*validate_var_datatype_scale_hook_type)(const TypeName *typeName, Type typ);
extern PGDLLEXPORT validate_var_datatype_scale_hook_type validate_var_datatype_scale_hook;

typedef Oid (*handle_default_collation_hook_type) (Type typ, bool handle_pg_type);
typedef Oid (*handle_default_collation_hook_type) (Type typ);
extern PGDLLEXPORT handle_default_collation_hook_type handle_default_collation_hook;

#endif /* PARSE_TYPE_H */
Loading