[ovirt-devel] anonymous upgrade script instead of tmp function ceremony
Roy Golan
rgolan at redhat.com
Mon Jul 25 08:31:40 UTC 2016
We all use the pattern of temporary creating a function for upgrade script,
declaring it (copy pasting from last script) and then calling it, then
deleting it.
This very verbose can be replaced with DO instruction which does
essentially the same.
# existing declaration
```sql
CREATE OR REPLACE FUNCTION __tmp_count() RETURNS VOID AS
$procedure$
DECLARE
i int;
BEGIN
i:= (select count(*) from vms) -- useless count just for the demo
END;
$procedure$
LANGUAGE plpgsql;
SELECT __tmp_count();
DROP FUNCTION __tmp_acount();
```
Can be replaced with
```sql
DO $$
DECLARE
i int;
BEGIN
i := (select count(*) from vms) -- useless count for demo
END
$$;
```
Not tested but tons of less lines to code. Exist in version 9.0.23 and above
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/devel/attachments/20160725/2ef1fbd7/attachment-0001.html>
More information about the Devel
mailing list