Pavel Stehule's blog
Some notes about PostgreSQL
Saturday, September 30, 2017
Thursday, September 14, 2017
New release of plpgsql_check
plpgsql_check 1.2.1 is available. Now there some analyse of dead code and detection of missing RETURN command is included.
create or replace function fx(x int) returns int as $$ begin begin if (x > 0) then raise exception 'xxx' using errcode = 'XX888'; else raise exception 'yyy' using errcode = 'YY888'; end if; return -1; -- dead code; end; return -1; end; $$ language plpgsql; select * from plpgsql_check_function_tb('fx(int)'); functionid | lineno | statement | sqlstate | message | detail | hint | level | position | query | context. ------------+--------+-----------+----------+------------------+--------+------+---------------+----------+-------+--------- fx | 9 | RETURN | 00000 | unreachable code | | | warning extra | | |. fx | 11 | RETURN | 00000 | unreachable code | | | warning extra | | |. (2 rows) create or replace function fx(x int) returns int as $$ begin begin if (x > 0) then raise exception 'xxx' using errcode = 'XX888'; else raise exception 'yyy' using errcode = 'YY888'; end if; exception when sqlstate 'XX888' then null; when sqlstate 'YY888' then null; end; end; -- missing return; $$ language plpgsql; select * from plpgsql_check_function_tb('fx(int)'); functionid | lineno | statement | sqlstate | message | detail | hint | level | position | query | context. ------------+--------+-----------+----------+------------------------------------------------+--------+------+-------+----------+-------+--------- fx | | | 2F005 | control reached end of function without RETURN | | | error | | |. (1 row)
Source code: https://github.com/okbob/plpgsql_check/releases
Tuesday, September 12, 2017
Wednesday, September 6, 2017
Article about migration from Oracle to PostgreSQL with Ora2pg
I wrote a article about migration large set of PL/SQL procedures to Postgres. This article is in Czech language, but Google translator works.
Friday, September 1, 2017
New Ora2pg is available
I am a happy user of Ora2pg - mainly because it really helps with my work. Year ago Ora2pg has minimal support for PL/SQL to PL/pgSQL conversion. Now, this conversion is very well supported. Sure, PL/SQL and Oracle are very large/rich language (environment), so is not possible to support all patterns, but some basic and often used patterns are supported already. What I have to say - a cooperation with Gilles Darold is perfect - see: Ora2Pg v18.2 has been released.