Skip to content

Commit

Permalink
addressing comments
Browse files Browse the repository at this point in the history
Signed-off-by: pranav jain <[email protected]>
  • Loading branch information
pranavJ23 committed Dec 27, 2024
1 parent 96d8bc8 commit 8ba06f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
3 changes: 2 additions & 1 deletion contrib/babelfishpg_tsql/src/pltsql_coerce.c
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,8 @@ tsql_func_select_candidate_for_special_func(List *names, int nargs, Oid *input_t
continue;
/* find the best candidate based on second_arg_type(this will be valid only for the case of hasbytes)
* for hashbytes function. For other special functions we are selecting best candidate on the basis
* of return type */
* of return type
*/
if ((OidIsValid(expr_result_type) && expr_result_type == rettype)
|| (OidIsValid(expr_arg_type) && OidIsValid(second_arg_type) && expr_arg_type == second_arg_type))
{
Expand Down
35 changes: 17 additions & 18 deletions contrib/babelfishpg_tsql/src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,24 @@ static Datum return_varchar_pointer(char *buf, int size);
Datum
hashbytes(PG_FUNCTION_ARGS)
{
Oid input_type = get_fn_expr_argtype(fcinfo->flinfo,1);
const char *algorithm = text_to_cstring(PG_GETARG_TEXT_P(0));
bytea *in = PG_GETARG_BYTEA_PP(1);
size_t len = VARSIZE_ANY_EXHDR(in);
const uint8 *data = (unsigned char *) VARDATA_ANY(in);
bytea *result;
StringInfoData utf16_data;


/*
* If the input_type is nvarchar then we convert it to UTF-16 encoding
*/
Oid input_type = get_fn_expr_argtype(fcinfo->flinfo,1);
const char *algorithm = text_to_cstring(PG_GETARG_TEXT_P(0));
bytea *in = PG_GETARG_BYTEA_PP(1);
size_t len = VARSIZE_ANY_EXHDR(in);
const uint8 *data = (unsigned char *) VARDATA_ANY(in);
bytea *result;
StringInfoData utf16_data;

/*
* If the input_type is nvarchar then we convert it to UTF-16 encoding
*/
initStringInfo(&utf16_data);
if(((*common_utility_plugin_ptr->is_tsql_nvarchar_datatype)(input_type)))
{
(common_utility_plugin_ptr->TsqlUTF8toUTF16StringInfo)(&utf16_data, data, len);
len = utf16_data.len;
data = (const uint8 *)utf16_data.data;
}
if(((*common_utility_plugin_ptr->is_tsql_nvarchar_datatype)(input_type)))
{
(common_utility_plugin_ptr->TsqlUTF8toUTF16StringInfo)(&utf16_data, data, len);
len = utf16_data.len;
data = (const uint8 *)utf16_data.data;
}

if (strcasecmp(algorithm, "MD2") == 0)
{
Expand Down

0 comments on commit 8ba06f3

Please sign in to comment.