From 27ce17a968f3f9c2ddc3f2458716b034237c588b Mon Sep 17 00:00:00 2001 From: Sharu Goel <30777678+thephantomthief@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:45:33 +0530 Subject: [PATCH] Fix build warnings in sys_functions.sql and babelfishpg_tsql.sql (#3030) In sys_functions.sql file, we have defined the sys.is_member() function which internally calls CHARINDEX('\', ...). During build, the compiler treats \' as an escaped quote and thus complains that there is unterminated quote. To fix this, added a single quote as a comment. Task: BABEL-5359 Signed-off-by: Sharu Goel --- contrib/babelfishpg_common/Makefile | 4 ++-- .../sql/upgrades/babelfish_common_helper--4.3.0--4.4.0.sql | 2 +- contrib/babelfishpg_tsql/Makefile | 2 +- contrib/babelfishpg_tsql/sql/babelfishpg_tsql.sql | 6 +++--- contrib/babelfishpg_tsql/sql/sys_functions.sql | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/babelfishpg_common/Makefile b/contrib/babelfishpg_common/Makefile index a987ea2443..03c68f8550 100644 --- a/contrib/babelfishpg_common/Makefile +++ b/contrib/babelfishpg_common/Makefile @@ -104,7 +104,7 @@ FLAG_TO_CHECK := -DENABLE_SPATIAL_TYPES ifeq (,$(filter $(FLAG_TO_CHECK),$(PG_CPPFLAGS))) # The flag is not present then build the .in file not including the spatial type files sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).in - cpp $< | sed 's/^# /-- /g' > $@ + cpp -Werror $< | sed 's/^# /-- /g' > $@ sql/$(EXTENSION)--3.2.0--3.3.0.sql: sql/upgrades/babelfishpg_upgrades.in cpp -D PREV_VERSION=3.2.0 -D CUR_VERSION=3.3.0 $< | sed 's/^# /-- /g' > $@ @@ -129,7 +129,7 @@ ifeq (,$(filter $(FLAG_TO_CHECK),$(PG_CPPFLAGS))) else # The flag is present build the .in file including the spatial type files sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).in - cpp -D ENABLE_SPATIAL_TYPES=1 $< | sed 's/^# /-- /g' > $@ + cpp -Werror -D ENABLE_SPATIAL_TYPES=1 $< | sed 's/^# /-- /g' > $@ sql/$(EXTENSION)--3.2.0--3.3.0.sql: sql/upgrades/babelfishpg_upgrades.in cpp -D ENABLE_SPATIAL_TYPES=1 -D PREV_VERSION=3.2.0 -D CUR_VERSION=3.3.0 $< | sed 's/^# /-- /g' > $@ diff --git a/contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--4.3.0--4.4.0.sql b/contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--4.3.0--4.4.0.sql index f68f8335d3..044d5953cd 100644 --- a/contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--4.3.0--4.4.0.sql +++ b/contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--4.3.0--4.4.0.sql @@ -30,7 +30,7 @@ EXCEPTION when dependent_objects_still_exist then --if 'drop view' statement fails GET STACKED DIAGNOSTICS error_msg = MESSAGE_TEXT; raise warning '%', error_msg; - when undefined_function then --if 'Deprecated function doen't exsist' + when undefined_function then --if 'Deprecated function does not exist' GET STACKED DIAGNOSTICS error_msg = MESSAGE_TEXT; raise warning '%', error_msg; end diff --git a/contrib/babelfishpg_tsql/Makefile b/contrib/babelfishpg_tsql/Makefile index 64b1695326..c78039e504 100644 --- a/contrib/babelfishpg_tsql/Makefile +++ b/contrib/babelfishpg_tsql/Makefile @@ -149,7 +149,7 @@ $(EXTENSION).control: $(EXTENSION).control.in > $@ sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).in - cpp $< | sed 's/^# /-- /g' > $@ + cpp -Werror $< | sed 's/^# /-- /g' > $@ sql/%.sql: sql/upgrades/%.sql cp $< $@ diff --git a/contrib/babelfishpg_tsql/sql/babelfishpg_tsql.sql b/contrib/babelfishpg_tsql/sql/babelfishpg_tsql.sql index d9a7f1fd3b..10dcade293 100644 --- a/contrib/babelfishpg_tsql/sql/babelfishpg_tsql.sql +++ b/contrib/babelfishpg_tsql/sql/babelfishpg_tsql.sql @@ -500,9 +500,9 @@ BEGIN END ) as SS_DATA_TYPE from sys.sp_columns_100_view - -- TODO: Temporary fix to use '\' as escape character for now, need to remove ESCAPE clause from LIKE once we have fixed the dependencies on this procedure - where pg_catalog.lower(table_name) like pg_catalog.lower(sys.babelfish_truncate_identifier(@table_name)) COLLATE database_default ESCAPE '\' - and ((SELECT coalesce(sys.babelfish_truncate_identifier(@table_owner),'')) = '' or table_owner like sys.babelfish_truncate_identifier(@table_owner) collate database_default ESCAPE '\') + -- TODO: Temporary fix to use \ as escape character for now, need to remove ESCAPE clause from LIKE once we have fixed the dependencies on this procedure + where pg_catalog.lower(table_name) like pg_catalog.lower(sys.babelfish_truncate_identifier(@table_name)) COLLATE database_default ESCAPE '\' -- ' adding quote in comment to suppress build warning + and ((SELECT coalesce(sys.babelfish_truncate_identifier(@table_owner),'')) = '' or table_owner like sys.babelfish_truncate_identifier(@table_owner) collate database_default ESCAPE '\') -- ' adding quote in comment to suppress build warning and ((SELECT coalesce(sys.babelfish_truncate_identifier(@table_qualifier),'')) = '' or table_qualifier like sys.babelfish_truncate_identifier(@table_qualifier) collate database_default) and ((SELECT coalesce(sys.babelfish_truncate_identifier(@column_name),'')) = '' or column_name like sys.babelfish_truncate_identifier(@column_name) collate database_default) order by table_qualifier, diff --git a/contrib/babelfishpg_tsql/sql/sys_functions.sql b/contrib/babelfishpg_tsql/sql/sys_functions.sql index a0dea9426e..9e652f4682 100644 --- a/contrib/babelfishpg_tsql/sql/sys_functions.sql +++ b/contrib/babelfishpg_tsql/sql/sys_functions.sql @@ -4484,7 +4484,7 @@ CREATE OR REPLACE FUNCTION sys.is_member(IN role sys.SYSNAME) RETURNS INT AS $$ DECLARE - is_windows_grp boolean := (CHARINDEX('\', role) != 0); + is_windows_grp boolean := (CHARINDEX('\', role) != 0); -- ' adding quote in comment to suppress build warning BEGIN -- Always return 1 for 'public' IF (role = 'public' COLLATE sys.database_default )