-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit for Babelfish v4.6 (#3454)
This commit contains the following changes: - Add version info and upgrade test for 14.16, 14.17, 15.11, 15.12 and 16.7. - Add upgrade schedule files for 14.17, 15.12 and 16.7. - Bump babelfish_version from 4.5.0 to 4.6.0 - Update T-SQL extension version to 4.6.0 and add following upgrade scripts: - babelfishpg_tsql--4.5.0--4.6.0.sql. - babelfishpg_tsql--2.13.0--3.0.0.sql (Duplicate of babelfishpg_tsql--2.12.0--3.0.0.sql). - babelfishpg_tsql--3.10.0--4.0.0.sql (Duplicate of babelfishpg_tsql--3.9.0--4.0.0.sql). - Update common extension version to 4.6.0 and add following upgrade scripts: - babelfishpg_common_helper--4.5.0--4.6.0.sql. - spatial_types--4.5.0--4.6.0.sql. - babelfishpg_common--3.9.0--4.0.0.sql (Duplicate of babelfishpg_common--3.8.0--4.0.0.sql). Signed-off-by: manisha-deshpande <[email protected]> Co-authored-by: Rishabh Tanwar <[email protected]>
- Loading branch information
1 parent
e2ac7f8
commit f4b8498
Showing
16 changed files
with
2,358 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
BBFPGCMN_MAJOR_VERSION=4 | ||
BBFPGCMN_MINOR_VERSION=5 | ||
BBFPGCMN_MINOR_VERSION=6 | ||
BBFPGCMN_MICRO_VERSION=0 | ||
|
6 changes: 6 additions & 0 deletions
6
contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--4.5.0--4.6.0.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
------------------------------------------------------------------------------ | ||
---- Include changes related to other datatypes except spatial types here ---- | ||
------------------------------------------------------------------------------ | ||
|
||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION | ||
\echo Use "ALTER EXTENSION ""babelfishpg_common"" UPDATE TO "4.6.0"" to load this file. \quit |
2 changes: 2 additions & 0 deletions
2
contrib/babelfishpg_common/sql/upgrades/babelfishpg_common--3.9.0--4.0.0.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION | ||
\echo Use "ALTER EXTENSION ""babelfishpg_common"" UPDATE TO '4.0.0'" to load this file. \quit |
3 changes: 3 additions & 0 deletions
3
contrib/babelfishpg_common/sql/upgrades/spatial_types--4.5.0--4.6.0.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
------------------------------------------------------- | ||
---- Include changes related to spatial types here ---- | ||
------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--2.13.0--3.0.0.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION | ||
\echo Use "ALTER EXTENSION ""babelfishpg_tsql"" UPDATE TO '3.0.0'" to load this file. \quit | ||
|
||
-- add 'sys' to search path for the convenience | ||
SELECT set_config('search_path', 'sys, '||current_setting('search_path'), false); | ||
|
||
-- please add your SQL here | ||
|
||
CREATE OR REPLACE FUNCTION sys.babelfish_update_server_collation_name() RETURNS VOID | ||
LANGUAGE C | ||
AS 'babelfishpg_common', 'babelfish_update_server_collation_name'; | ||
|
||
SELECT sys.babelfish_update_server_collation_name(); | ||
|
||
DROP FUNCTION sys.babelfish_update_server_collation_name(); | ||
|
||
-- reset babelfishpg_tsql.restored_server_collation_name GUC | ||
do | ||
language plpgsql | ||
$$ | ||
declare | ||
query text; | ||
begin | ||
query := pg_catalog.format('alter database %s reset babelfishpg_tsql.restored_server_collation_name', CURRENT_DATABASE()); | ||
execute query; | ||
end; | ||
$$; | ||
|
||
CREATE OR REPLACE FUNCTION sys.datepart_internal(IN datepart PG_CATALOG.TEXT, IN arg anyelement,IN df_tz INTEGER DEFAULT 0) RETURNS INTEGER AS $$ | ||
DECLARE | ||
result INTEGER; | ||
first_day DATE; | ||
first_week_end INTEGER; | ||
day INTEGER; | ||
BEGIN | ||
CASE datepart | ||
WHEN 'dow' THEN | ||
result = (date_part(datepart, arg)::INTEGER - current_setting('babelfishpg_tsql.datefirst')::INTEGER + 7) % 7 + 1; | ||
WHEN 'tsql_week' THEN | ||
first_day = make_date(date_part('year', arg)::INTEGER, 1, 1); | ||
first_week_end = 8 - sys.datepart_internal('dow', first_day)::INTEGER; | ||
day = date_part('doy', arg)::INTEGER; | ||
IF day <= first_week_end THEN | ||
result = 1; | ||
ELSE | ||
result = 2 + (day - first_week_end - 1) / 7; | ||
END IF; | ||
WHEN 'second' THEN | ||
result = TRUNC(date_part(datepart, arg))::INTEGER; | ||
WHEN 'millisecond' THEN | ||
result = right(date_part(datepart, arg)::TEXT, 3)::INTEGER; | ||
WHEN 'microsecond' THEN | ||
result = right(date_part(datepart, arg)::TEXT, 6)::INTEGER; | ||
WHEN 'nanosecond' THEN | ||
-- Best we can do - Postgres does not support nanosecond precision | ||
result = right(date_part('microsecond', arg)::TEXT, 6)::INTEGER * 1000; | ||
WHEN 'tzoffset' THEN | ||
-- timezone for datetimeoffset | ||
result = df_tz; | ||
ELSE | ||
result = date_part(datepart, arg)::INTEGER; | ||
END CASE; | ||
RETURN result; | ||
EXCEPTION WHEN invalid_parameter_value or feature_not_supported THEN | ||
-- date_part() throws an exception when trying to get day/month/year etc. from | ||
-- TIME, so we just need to catch the exception in this case | ||
-- date_part() returns 0 when trying to get hour/minute/second etc. from | ||
-- DATE, which is the desirable behavior for datepart() as well. | ||
-- If the date argument data type does not have the specified datepart, | ||
-- date_part() will return the default value for that datepart. | ||
CASE datepart | ||
-- Case for datepart is year, yy and yyyy, all mappings are defined in gram.y. | ||
WHEN 'year' THEN RETURN 1900; | ||
-- Case for datepart is quater, qq and q | ||
WHEN 'quarter' THEN RETURN 1; | ||
-- Case for datepart is month, mm and m | ||
WHEN 'month' THEN RETURN 1; | ||
-- Case for datepart is day, dd and d | ||
WHEN 'day' THEN RETURN 1; | ||
-- Case for datepart is dayofyear, dy | ||
WHEN 'doy' THEN RETURN 1; | ||
-- Case for datepart is y(also refers to dayofyear) | ||
WHEN 'y' THEN RETURN 1; | ||
-- Case for datepart is week, wk and ww | ||
WHEN 'tsql_week' THEN RETURN 1; | ||
-- Case for datepart is iso_week, isowk and isoww | ||
WHEN 'week' THEN RETURN 1; | ||
-- Case for datepart is tzoffset and tz | ||
WHEN 'tzoffset' THEN RETURN 0; | ||
-- Case for datepart is weekday and dw, return dow according to datefirst | ||
WHEN 'dow' THEN | ||
RETURN (1 - current_setting('babelfishpg_tsql.datefirst')::INTEGER + 7) % 7 + 1 ; | ||
ELSE | ||
RAISE EXCEPTION '''%'' is not a recognized datepart option', datepart; | ||
RETURN -1; | ||
END CASE; | ||
END; | ||
$$ | ||
STRICT | ||
LANGUAGE plpgsql IMMUTABLE; | ||
|
||
-- Reset search_path to not affect any subsequent scripts | ||
SELECT set_config('search_path', trim(leading 'sys, ' from current_setting('search_path')), false); |
Oops, something went wrong.