Skip to content

Commit

Permalink
[CBRD-24934] [Regression] extending dblink to DML: double quoted iden…
Browse files Browse the repository at this point in the history
  • Loading branch information
beyondykk9 authored Aug 17, 2023
1 parent 61c32da commit f642eeb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
36 changes: 36 additions & 0 deletions src/base/intl_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -2726,6 +2726,42 @@ intl_strcasecmp_utf8_one_cp (const ALPHABET_DATA * alphabet, unsigned char *str1
return 0;
}

/*
* intl_identifier_casecmp_for_dblinke() - compares two identifiers strings
* case insensitive excluding double quote for dblink
*
* return: 0 if dblink_col_name equals to remote_col_name
* dblink_col_name(in):
* remote_col_name(in):
*
* NOTE: this routine is the same as intl_identifier_casecmp
* the first argument dblink_col_name may start with double quote
* but the remote_col_name never
*/
int
intl_identifier_casecmp_for_dblink (const char *dblink_col_name, const char *remote_col_name)
{
int str1_size;
int str2_size;
char *str1 = (char *) dblink_col_name;
char *str2 = (char *) remote_col_name;

assert (str1 != NULL);
assert (str2 != NULL);

str1_size = strlen (str1);
str2_size = strlen (str2);

if (*str1 == '\"')
{
str1_size = str1_size - 2;
str1 = str1 + 1;
}

return intl_identifier_casecmp_w_size (lang_id (), (unsigned char *) str1, (unsigned char *) str2, str1_size,
str2_size);
}

/*
* intl_identifier_casecmp() - compares two identifiers strings
* case insensitive
Expand Down
1 change: 1 addition & 0 deletions src/base/intl_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ extern "C"
extern int intl_case_match_tok (const INTL_LANG lang_id, const INTL_CODESET codeset, unsigned char *tok,
unsigned char *src, const int size_tok, const int size_src, int *matched_size_src);
extern int intl_identifier_casecmp (const char *str1, const char *str2);
extern int intl_identifier_casecmp_for_dblink (const char *dblink_col_name, const char *remote_col_name);
extern int intl_identifier_ncasecmp (const char *str1, const char *str2, const int len);
extern int intl_identifier_cmp (const char *str1, const char *str2);
#if defined(ENABLE_UNUSED_FUNCTION)
Expand Down
6 changes: 3 additions & 3 deletions src/parser/name_resolution.c
Original file line number Diff line number Diff line change
Expand Up @@ -4930,7 +4930,7 @@ pt_mk_attr_def_node (PARSER_CONTEXT * parser, PT_NODE * name_node, S_REMOTE_TBL_
const char *col_name = name_node->info.name.original;
for (int i = 0; i < rmt_cols->get_attr_size (); i++)
{
if (intl_identifier_casecmp (col_name, rmt_cols->get_name (i)) == 0)
if (intl_identifier_casecmp_for_dblink (col_name, rmt_cols->get_name (i)) == 0)
{
if (pt_dblink_table_fill_attr_def (parser, def_node, rmt_cols->get_attr (i)))
{
Expand Down Expand Up @@ -5010,13 +5010,13 @@ pt_check_column_list (PARSER_CONTEXT * parser, const char *tbl_alias_nm, PT_DBLI
col_name = col->info.name.original;
for (i = 0; i < rmt_cols->get_attr_size (); i++)
{
if (intl_identifier_casecmp (col_name, rmt_cols->get_name (i)) == 0)
if (intl_identifier_casecmp_for_dblink (col_name, rmt_cols->get_name (i)) == 0)
{
if (col->info.name.resolved == NULL)
{
break;
}
else if (intl_identifier_casecmp (tbl_alias_nm, col->info.name.resolved) == 0)
else if (intl_identifier_casecmp_for_dblink (tbl_alias_nm, col->info.name.resolved) == 0)
{
break;
}
Expand Down

0 comments on commit f642eeb

Please sign in to comment.