Revision 8199
Added by Aaron Marcuse-Kubitza over 11 years ago
schemas/util.sql | ||
---|---|---|
817 | 817 |
|
818 | 818 |
|
819 | 819 |
-- |
820 |
-- Name: rename_if_exists(text); Type: FUNCTION; Schema: util; Owner: - |
|
821 |
-- |
|
822 |
|
|
823 |
CREATE FUNCTION rename_if_exists(sql text) RETURNS void |
|
824 |
LANGUAGE plpgsql STRICT |
|
825 |
AS $$ |
|
826 |
BEGIN |
|
827 |
EXECUTE sql; |
|
828 |
EXCEPTION |
|
829 |
WHEN undefined_column THEN NULL; |
|
830 |
WHEN duplicate_column THEN NULL; |
|
831 |
END; |
|
832 |
$$; |
|
833 |
|
|
834 |
|
|
835 |
-- |
|
836 |
-- Name: FUNCTION rename_if_exists(sql text); Type: COMMENT; Schema: util; Owner: - |
|
837 |
-- |
|
838 |
|
|
839 |
COMMENT ON FUNCTION rename_if_exists(sql text) IS 'idempotent'; |
|
840 |
|
|
841 |
|
|
842 |
-- |
|
843 | 820 |
-- Name: reset_map_table(text); Type: FUNCTION; Schema: util; Owner: - |
844 | 821 |
-- |
845 | 822 |
|
... | ... | |
981 | 958 |
|
982 | 959 |
|
983 | 960 |
-- |
961 |
-- Name: try_create(text); Type: FUNCTION; Schema: util; Owner: - |
|
962 |
-- |
|
963 |
|
|
964 |
CREATE FUNCTION try_create(sql text) RETURNS void |
|
965 |
LANGUAGE plpgsql STRICT |
|
966 |
AS $$ |
|
967 |
BEGIN |
|
968 |
EXECUTE sql; |
|
969 |
EXCEPTION |
|
970 |
WHEN undefined_column THEN NULL; |
|
971 |
WHEN duplicate_column THEN NULL; |
|
972 |
END; |
|
973 |
$$; |
|
974 |
|
|
975 |
|
|
976 |
-- |
|
977 |
-- Name: FUNCTION try_create(sql text); Type: COMMENT; Schema: util; Owner: - |
|
978 |
-- |
|
979 |
|
|
980 |
COMMENT ON FUNCTION try_create(sql text) IS 'idempotent'; |
|
981 |
|
|
982 |
|
|
983 |
-- |
|
984 | 984 |
-- Name: type_qual(anyelement); Type: FUNCTION; Schema: util; Owner: - |
985 | 985 |
-- |
986 | 986 |
|
Also available in: Unified diff
schemas/util.sql: Renamed rename_if_exists() to try_create() because it can be used to create a column in any way, not just by renaming another column