Pg::SQL::Parser

Some time ago I was looking (warning: post in polish) for someone to teach me proper parsing.

One of really great polish Perl programmers – Dozzie – reached out, and helped me. By the way – thanks a lot, Dozzie.

Based on what he taught me, I started writing module for parsing SQL queries. By that I mean proper parsing, with grammar (using Parse::Eyapp), and not set of regular expressions.

My parser is not ready. To say it lightly. Very lightly.

For now, it just knows how to parse the simplest queries like:

  • select 1;
  • select ‘a' as b;

I am working very slowly on it, so don't expect any usable version in any defined future. I will get there, eventually, but it is a project that I work on in my free time, after I finish everything else that I could work on in given moment.

This post is intended to announce that I'm working on it (so I will have kind of obligation to do it). And, if anyone is interested – I more than welcome all contributors/reviewers, and perhaps even critics 🙂

Final note – if you'll review the code, and want to comment on ugly list of regexps in Lexer – I know. It will be eventually replaced by one regular expression, but since it will be regular expression built by Regexp::Optimizer – it will not really be readable (though it will be faster than current approach).

Changes on explain.depesz.com

One of the features that is actually disliked is anonymization. But, regardless of the dislike – it has some users. And one of the user mailed me with information about a bug – namely – foreign table file names were not anonymized.

So, I wrote a patch, tests, released new version of underlying parsing library.

Continue reading Changes on explain.depesz.com

OmniPITR 0.3.0

Just released version 0.3.0 of our tool for handling WAL based replication in PostgreSQL – OmniPITR.

Version jump is related to addition of another tool – omnipitr-synch. This tool is used to copy PostgreSQL data dir (including all tablespaces of course) to remote location(s).

While this process is usually simple (call pg_start_backup(), transfer data, call pg_stop_backup()), thanks to the tool it can be wrapped as single call, with standardized logging, and tested logic. It also makes it trivial, and cheap, to setup more than one new slave at a time, without need to read data off master more than once.

explain.depesz.com version 2.0

Thanks to enormous work done by Łukasz ‘metys' Lewandowski, explain.depesz.com page is no longer “desiged by depesz" (which is a code for “ugly as hell"), but is nice, and good looking.

If you like it, please do send some thank you note to Łukasz – he blogs in Polish, but he reads and understands English too.

Change is not only skin deep. The whole site has been rewritten, and uses now Mojolicious web framework instead of Catalyst.

This change should be a welcome surprise to anyone willing to setup their own copy of the site for top-secret plans from their company – mostly because number of dependencies dropped significantly.

All in all – have fun, and thanks for using the site.

Waiting for 9.1 – Arrays in PL/Perl

On 18th of February, Alvaro Herrera committed patch:

Convert Postgres arrays to Perl arrays on PL/perl input arguments
 
More generally, arrays are turned in Perl array references, and row and
composite types are turned into Perl hash references.  This is done
recursively, in a way that's natural to every Perl programmer.
 
To avoid a backwards compatibility hit, the string representation of
each structure is also available if the function requests it.
 
Authors: Alexey Klyukin and Alex Hunsaker.
Some code cleanups by me.

Continue reading Waiting for 9.1 – Arrays in PL/Perl

Two years of explain.depesz.com

First of all – just today I committed patch for Pg::Explain – which is the workhorse behind explain.depesz.com.

This patch fixes calculation of exclusive time for explain nodes, and the best thing about it is – I didn't write it. It's full patch provided by someone else – Filip Rembiałkowski – my former colleague, friend, and PostgreSQL DBA (not olny PG!).

This is (as far as I recall) first patch that was provided to me for this library, and I'm really grateful for the contribution.

New version of Pg::Explain will hit CPAN mirrors shortly (it's already uploaded, now we're waiting for CPAN mirrors to get it).

When I was updating it, I checked state of database. And I learned that explain.depesz.com is over 2 years now! Some stats follow.

Continue reading Two years of explain.depesz.com

OmniPITR – update

OmniPITR project that I wrote about some time ago is going on.

Just today I finished tests for omnipitr-backup-slave – part of OmniPITR which lets you make hot-backups of WAL-slave machine – without any additional load on master.

As previously – please download (svn co) and test. In case you have problems – please mail me or contact me on irc.freenode.net – I'm usually on #postgresql.