Skip to content

Commit

Permalink
changes reverted
Browse files Browse the repository at this point in the history
  • Loading branch information
Parikshit Sarode committed Dec 29, 2023
1 parent 9c24cef commit f90c043
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 111 deletions.
103 changes: 3 additions & 100 deletions contrib/babelfishpg_tsql/runtime/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
#define TSQL_STAT_GET_ACTIVITY_COLS 26
#define SP_DATATYPE_INFO_HELPER_COLS 23
#define SYSVARCHAR_MAX_LENGTH 4000
#define DAYS_BETWEEN_YEARS_1900_TO_2000 36524 /* number of days present in between 1/1/1900 and 1/1/2000 */
#define DATEPART_MAX_VALUE 2958463 /* maximum value for datepart general_integer_datatype */
#define DATEPART_MIN_VALUE -53690 /* minimun value for datepart general_integer_datatype */
#define DAYS_BETWEEN_YEARS_1900_TO_2000 36524 /* number of days present in between 1/1/1900 and 1/1/2000 */
#define DATEPART_MAX_VALUE 2958463 /* maximum value for datepart general_integer_datatype */
#define DATEPART_MIN_VALUE -53690 /* minimun value for datepart general_integer_datatype */
#define DATEPART_SMALLMONEY_MAX_VALUE 214748.3647 /* maximum value for datepart smallmoney */
#define DATEPART_SMALLMONEY_MIN_VALUE -53690 /* minimum value for datepart smallmoney */

Expand Down Expand Up @@ -182,7 +182,6 @@ PG_FUNCTION_INFO_V1(datepart_internal_date);
PG_FUNCTION_INFO_V1(datepart_internal_datetime);
PG_FUNCTION_INFO_V1(datepart_internal_datetimeoffset);
PG_FUNCTION_INFO_V1(datepart_internal_time);
// PG_FUNCTION_INFO_V1(datepart_internal_interval);
PG_FUNCTION_INFO_V1(datepart_internal_decimal);
PG_FUNCTION_INFO_V1(datepart_internal_float);
PG_FUNCTION_INFO_V1(datepart_internal_real);
Expand Down Expand Up @@ -809,102 +808,6 @@ datepart_internal_time(PG_FUNCTION_ARGS)
return datepart_internal(field, timestamp, (float8)df_tz, false);
}

/*
* datepart_internal_interval takes interval and extracts the required field
* Since it is interval, there is no need to call datepart_internal
*/

// Datum
// datepart_internal_interval(PG_FUNCTION_ARGS)
// {
// char *field = text_to_cstring(PG_GETARG_TEXT_PP(0));
// int df_tz = PG_GETARG_INT32(2);
// int result;

// Interval* interval = PG_GETARG_INTERVAL_P(1);

// Timestamp interval_time = interval->time + (Timestamp) df_tz * SECS_PER_MINUTE * USECS_PER_SEC;

// int32 interval_days,interval_month;
// int year,month,days,hours,minutes,sec,millisec,microsec,nanosec;
// interval_days = interval->day;
// interval_month = interval->month;

// /* Extracting year, months, days, etc from the interval period. */

// year = interval_month / MONTHS_PER_YEAR;
// month = (interval_month % MONTHS_PER_YEAR) == 0 ? MONTHS_PER_YEAR : (interval_month % MONTHS_PER_YEAR);
// days = interval_days;

// hours = (interval_time / USECS_PER_HOUR) % HOURS_PER_DAY;
// minutes = (interval_time / USECS_PER_MINUTE) % MINS_PER_HOUR;
// sec = (interval_time / USECS_PER_SEC) % SECS_PER_MINUTE;

// millisec = ((1L * interval_time) / 1000);
// microsec = interval_time;
// nanosec = (interval_time * 1L) * 1000;

// if(strcasecmp(field , "year") == 0)
// {
// result = year;
// }
// else if(strcasecmp(field , "quarter") == 0)
// {
// result = (int)ceil((float)month / 3.0);
// }
// else if(strcasecmp(field , "month") == 0)
// {
// result = month;
// }
// else if(strcasecmp(field , "day") == 0)
// {
// result = days;
// }
// else if(strcasecmp(field , "y") == 0)
// {
// result = year;
// }
// else if(strcasecmp(field , "tzoffset") == 0)
// {
// result = 0;
// }
// else if(strcasecmp(field , "minute") == 0)
// {
// result = minutes;
// }
// else if(strcasecmp(field , "nanosecond") == 0)
// {
// result = nanosec;
// }
// else if(strcasecmp(field , "second") == 0)
// {
// result = sec;
// }
// else if(strcasecmp(field , "millisecond") == 0)
// {
// result = millisec;
// }
// else if(strcasecmp(field , "microsecond") == 0)
// {
// result = microsec;
// }
// else if(strcasecmp(field , "hour") == 0)
// {
// result = hours;
// }
// else
// {
// ereport(ERROR,
// (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
// errmsg("\'%s\' is not a recognized datepart option", field)));

// result = -1;
// }

// PG_RETURN_INT32(result);

// }


Datum
trancount(PG_FUNCTION_ARGS)
Expand Down
5 changes: 0 additions & 5 deletions contrib/babelfishpg_tsql/sql/sys_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,6 @@ RETURNS INTEGER
AS 'babelfishpg_tsql', 'datepart_internal_time'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;

-- CREATE OR REPLACE FUNCTION sys.datepart_internal(field text, datapart_date INTERVAL ,df_tz INTEGER DEFAULT 0)
-- RETURNS INTEGER
-- AS 'babelfishpg_tsql', 'datepart_internal_interval'
-- LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;

CREATE OR REPLACE FUNCTION sys.datepart_internal(field text, datapart_date sys.DECIMAL ,df_tz INTEGER DEFAULT 0)
RETURNS INTEGER
AS 'babelfishpg_tsql', 'datepart_internal_decimal'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ BEGIN
AS 'babelfishpg_tsql', 'datepart_internal_time'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;

CREATE OR REPLACE FUNCTION sys.datepart_internal(field text, datapart_date INTERVAL ,df_tz INTEGER DEFAULT 0)
RETURNS INTEGER
AS 'babelfishpg_tsql', 'datepart_internal_interval'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;

CREATE OR REPLACE FUNCTION sys.datepart_internal(field text, datapart_date sys.DECIMAL ,df_tz INTEGER DEFAULT 0)
RETURNS INTEGER
AS 'babelfishpg_tsql', 'datepart_internal_decimal'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ Function sys.datepart_internal(text,bigint,integer)
Function sys.datepart_internal(text,date,integer)
Function sys.datepart_internal(text,double precision,integer)
Function sys.datepart_internal(text,integer,integer)
Function sys.datepart_internal(text,interval,integer)
Function sys.datepart_internal(text,numeric,integer)
Function sys.datepart_internal(text,real,integer)
Function sys.datepart_internal(text,smallint,integer)
Expand Down

0 comments on commit f90c043

Please sign in to comment.