Skip to content

Commit

Permalink
Reimplement datepart function to improve the performance (#2195)
Browse files Browse the repository at this point in the history
1/ sys. datepart_internal function takes longer time in Babelfish than expected
2/ The function is reimplemented in C for faster execution.
3/ Different wrapper functions are created according to the data type of the second argument in sys.datepart_internal.
Additional tests are added covering all cases since previously incorrect query outputs were written in tests and logical errors were present in code

Task: BABEL-4302, BABEL-979, BABEL-4366
Signed-off-by: Parikshit Sarode [email protected]
  • Loading branch information
ParikshitSarode authored Jan 3, 2024
1 parent 05b7fbb commit 5d80c2a
Show file tree
Hide file tree
Showing 10 changed files with 9,561 additions and 76 deletions.
1 change: 1 addition & 0 deletions contrib/babelfishpg_common/src/babelfishpg_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ get_common_utility_plugin(void)
common_utility_plugin_var.datetime_in_str = &datetime_in_str;
common_utility_plugin_var.datetime2sqlvariant = &datetime2sqlvariant;
common_utility_plugin_var.timestamp_datetimeoffset = &timestamp_datetimeoffset;
common_utility_plugin_var.datetimeoffset_timestamp = &datetimeoffset_timestamp;
common_utility_plugin_var.tinyint2sqlvariant = &tinyint2sqlvariant;
common_utility_plugin_var.translate_pg_type_to_tsql = &translate_pg_type_to_tsql;
common_utility_plugin_var.TdsGetPGbaseType = &TdsGetPGbaseType;
Expand Down
1 change: 1 addition & 0 deletions contrib/babelfishpg_common/src/babelfishpg_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ typedef struct common_utility_plugin
Datum (*datetime_in_str) (char *str);
Datum (*datetime2sqlvariant) (PG_FUNCTION_ARGS);
Datum (*timestamp_datetimeoffset) (PG_FUNCTION_ARGS);
Datum (*datetimeoffset_timestamp) (PG_FUNCTION_ARGS);
Datum (*tinyint2sqlvariant) (PG_FUNCTION_ARGS);
Datum (*translate_pg_type_to_tsql) (PG_FUNCTION_ARGS);
void (*TdsGetPGbaseType) (uint8 variantBaseType, int *pgBaseType, int tempLen,
Expand Down
1 change: 1 addition & 0 deletions contrib/babelfishpg_common/src/datetimeoffset.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern void CheckSmalldatetimeRange(const Timestamp time);
extern void CheckDatetimeRange(const Timestamp time);
extern void CheckDatetime2Range(const Timestamp time);
extern Datum timestamp_datetimeoffset(PG_FUNCTION_ARGS);
extern Datum datetimeoffset_timestamp(PG_FUNCTION_ARGS);
typedef struct tsql_datetimeoffset
{
int64 tsql_ts;
Expand Down
Loading

0 comments on commit 5d80c2a

Please sign in to comment.