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

short post - pspg is ready for release

https://github.com/okbob/pspg. Please, test.

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.

Monday, August 14, 2017

short update: please, test pspg

lot of done, lot of code rewritten

please, test it - https://github.com/okbob/pspg.

Friday, August 4, 2017

PostgreSQL pager pspg is ready to work

I spent lot of time on work on pspg. These points are done:
  • support for expanded mode
  • fixed resizing
  • two new styles
  • start is significantly faster
  • lot of display errors was fixed
 This code should be compiled from source code. If you want to test it - you need develop packages of ncursesw. If you don't need wide char support, you can compile pspg against ncurses library (in this case a Makefile should be modified).

Usage:
\setenv PAGER 'pspg -s 2'
\pset pager always
select * from pg_stat_activity;

Sunday, July 16, 2017

Postgres Pager (pager designed for psql)

I hope so every, who uses psql uses less pager as default pager. See important Merlin's article. less is great pager, but it is not designed for usage as pager of relational data, and miss some features. Mainly, there is not possible to freeze some rows and some columns. I didn't find any solution good enough for me, although there are some projects on github. The special pager for psql should to have some logic, to choose correctly and automatically frozen columns (in chars) and rows.

I wrote new pager pspg - Postgres pager. This pager is designed primary for usage as psql pager. Now, it is available for playing and testing. Probably there will be some unwanted artefacts - but for usual work it is good enough. It is first my ncurses applications, probably there will be some bugs.

This pager currently supports:
* possibility to set one from three themes from command line: -s 0 - black/white theme, -s 1 mc theme, -s 2 fox theme,
* possibility to set frozen columns from command line: -c N or interactively (0..4),
* first few rows with labels are frozen automatically,
* scrolling: left, rights, up, down, PgUp, PgDn, ^PgUp, ^PgDn,
* possibility to run demo from command line: -d,
* supports different psql border linestyles: ascii, unicode,
* supports different psql border levels: 0, 1, 2

Usage:
export PAGER="pspg" #default theme 1
psql dbname
\pset border 2 #best works with border 2, but others are supported too
or
export PAGER="pspg -s 0" #black white theme
psql dbname
..

  • black white theme -s 0
  • midnight commander theme -s 1
  • fox theme -s 2


I invite any cooperation with people with ncurses knowleadge. All patches are welcome.