Skip to content

Commit

Permalink
Fix build warnings in sys_functions.sql and babelfishpg_tsql.sql (#3030)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
thephantomthief authored Oct 28, 2024
1 parent 0e99bab commit 27ce17a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions contrib/babelfishpg_common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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' > $@
Expand All @@ -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' > $@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contrib/babelfishpg_tsql/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $< $@
Expand Down
6 changes: 3 additions & 3 deletions contrib/babelfishpg_tsql/sql/babelfishpg_tsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion contrib/babelfishpg_tsql/sql/sys_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down

0 comments on commit 27ce17a

Please sign in to comment.