Skip to content

Commit

Permalink
core: Turning procedures to functions
Browse files Browse the repository at this point in the history
According to Postgres documentation a PROCEDURE executes SQL commands
and does not return any data.
In oVirt we are always returning a value (even VOID is considered as a
returned value), So we should use the term FUNCTION instead of PROCEDURE

This patch changes all relevant PROCEDURE declarations to a FUNCTION.
The patch is just a semantic change, was tested and can be safely
merged.

See also  https://bugzilla.redhat.com/2077794

Signed-off-by: Eli Mesika<[email protected]>
  • Loading branch information
emesika authored Aug 9, 2022
1 parent a605e98 commit fc271ec
Show file tree
Hide file tree
Showing 83 changed files with 2,649 additions and 2,649 deletions.
32 changes: 16 additions & 16 deletions packaging/dbscripts/ad_groups_sp.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CREATE OR REPLACE FUNCTION InsertGroup (
v_external_id TEXT,
v_namespace VARCHAR(2048)
)
RETURNS VOID AS $PROCEDURE$
RETURNS VOID AS $FUNCTION$
BEGIN
INSERT INTO ad_groups (
id,
Expand All @@ -29,7 +29,7 @@ BEGIN
v_external_id,
v_namespace
);
END;$PROCEDURE$
END;$FUNCTION$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION UpdateGroup (
Expand All @@ -42,7 +42,7 @@ CREATE OR REPLACE FUNCTION UpdateGroup (
)
RETURNS VOID
--The [ad_groups] table doesn't have a timestamp column. Optimistic concurrency logic cannot be generated
AS $PROCEDURE$
AS $FUNCTION$
BEGIN
UPDATE ad_groups
SET name = v_name,
Expand All @@ -51,11 +51,11 @@ BEGIN
external_id = v_external_id,
namespace = v_namespace
WHERE id = v_id;
END;$PROCEDURE$
END;$FUNCTION$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION DeleteGroup (v_id UUID)
RETURNS VOID AS $PROCEDURE$
RETURNS VOID AS $FUNCTION$
BEGIN
DELETE
FROM tags_user_group_map
Expand All @@ -64,66 +64,66 @@ BEGIN
DELETE
FROM ad_groups
WHERE id = v_id;
END;$PROCEDURE$
END;$FUNCTION$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION GetAllGroups ()
RETURNS SETOF ad_groups STABLE AS $PROCEDURE$
RETURNS SETOF ad_groups STABLE AS $FUNCTION$
BEGIN
RETURN QUERY

SELECT *
FROM ad_groups;
END;$PROCEDURE$
END;$FUNCTION$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION GetGroupById (v_id UUID)
RETURNS SETOF ad_groups STABLE AS $PROCEDURE$
RETURNS SETOF ad_groups STABLE AS $FUNCTION$
BEGIN
RETURN QUERY

SELECT *
FROM ad_groups
WHERE id = v_id;
END;$PROCEDURE$
END;$FUNCTION$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION GetGroupByExternalId (
v_domain VARCHAR(100),
v_external_id TEXT
)
RETURNS SETOF ad_groups STABLE AS $PROCEDURE$
RETURNS SETOF ad_groups STABLE AS $FUNCTION$
BEGIN
RETURN QUERY

SELECT *
FROM ad_groups
WHERE domain = v_domain
AND external_id = v_external_id;
END;$PROCEDURE$
END;$FUNCTION$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION GetGroupByName (v_name VARCHAR(256))
RETURNS SETOF ad_groups STABLE AS $PROCEDURE$
RETURNS SETOF ad_groups STABLE AS $FUNCTION$
BEGIN
RETURN QUERY

SELECT *
FROM ad_groups
WHERE name = v_name;
END;$PROCEDURE$
END;$FUNCTION$
LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION GetGroupByNameAndDomain (v_name VARCHAR(256), v_domain VARCHAR(256))
RETURNS SETOF ad_groups STABLE AS $PROCEDURE$
RETURNS SETOF ad_groups STABLE AS $FUNCTION$
BEGIN
RETURN QUERY

SELECT *
FROM ad_groups
WHERE name = v_name
AND domain = v_domain;
END;$PROCEDURE$
END;$FUNCTION$
LANGUAGE plpgsql;


Loading

0 comments on commit fc271ec

Please sign in to comment.