Some time ago I wrote a site to paste SQL queries with reformatting/pretty-printing using pgFormatter library. Today, I figured out that I should update the library since it has quite some changes recently, so it would be good to incorporate its ...

July 31st, 2012 by depesz | Tags: , , , , , | 8 comments »

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 ...

February 13th, 2012 by depesz | Tags: , , , , , | Comments Off on Waiting for 9.2 – Named parameters in SQL functions

On 5th of February, Tom Lane committed patch: Allow SQL-language functions to reference parameters by name. Matthew Draper, reviewed by Hitoshi Harada

Today some guy on IRC asked question, which I didn't fully understand, but which could (probably) be summarized: how to group data into 5 minute intervals, based on some timestamp column. Well, it seems trivial (as long as you know how ...

On 25th Robert Haas committed patch which adds first of 'CREATE IF NOT EXISTS' commands: Log Message: ----------- CREATE TABLE IF NOT EXISTS. Reviewed by Bernd Helmle.

November 1st, 2009 by depesz | Tags: , , , , , | 2 comments »

On 22nd of September, Tom Lane committed a patch by Petr Jelinek: Log Message: ----------- Implement the DO statement to support execution of PL code without having to create a function for it. Procedural languages now have an additional entry point, namely a function to ...

This post has been updated with new code that uses temporary table - the code is at the end of post! There was this question on Stack Overflow. For future reference: guy asked how to do session variables - i.e. something he ...

July 22nd, 2009 by depesz | Tags: , , , , , , , , | Comments Off on Waiting for 8.5 – pgsql: DROP IF EXISTS for columns and constraints.

On 205h of July Andrew Dunstan committed patch by Andres Freund : Log Message: ----------- DROP IF EXISTS for columns and constraints. Andres Freund.

July 13th, 2009 by depesz | Tags: , , , , , , | 1 comment »

Today, on irc (#postgresql on freenode.net) Dim mentioned about writing median calculation code. It got me thinking, and consequently writing my version of median calculation code.

June 23rd, 2009 by depesz | Tags: , , , , | Comments Off on Tips N’ Tricks – Generating readable reports with plain SQL

Let's say you imported some data, but it contains duplicates. You will have to handle them in some way, but to make sensible choice on how to handle it, you need more information. So, let's start. We have table: # \d users ...