Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion sql/functions/check_name_length.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ CREATE FUNCTION @extschema@.check_name_length (
p_object_name text
, p_suffix text DEFAULT NULL
, p_table_partition boolean DEFAULT FALSE
, p_simple_naming boolean DEFAULT FALSE
)
RETURNS text
LANGUAGE plpgsql IMMUTABLE
Expand All @@ -22,7 +23,14 @@ IF p_table_partition IS TRUE AND (NULLIF(p_suffix, '') IS NULL) THEN
END IF;


v_suffix := format('%s%s', CASE WHEN p_table_partition THEN '_p' END, p_suffix);
v_suffix := format('%s%s',
CASE
WHEN p_table_partition AND p_simple_naming THEN '_'
WHEN p_table_partition THEN '_p'
END,
p_suffix
);

-- Use optimistic behavior: in almost all cases `v_new_name` will be less than allowed maximum.
-- Do "heavy" work only in rare cases.
v_new_name := p_object_name || v_suffix;
Expand Down