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

Yesterday on my favorite IRC channel fooqux asked interesting question. I took some more questions, and here is problem description: We have a system which, every 5 minutes, takes a number of tasks to be done. Tasks are uniform. Within 5 ...

On 29th of September (I know, there is a backlog - I'll work on it, I promise), Tom Lane committed another patch from Pavel Stehule: Allow MOVE FORWARD n, MOVE BACKWARD n, MOVE FORWARD ALL, MOVE BACKWARD ALL in plpgsql. Clean ...

One of my clients hit a strange limitation - apparently you cannot inherit CREATE ROLE privilege. First, let's test if it's really true:

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

Every so often you need to get list of unique elements in some column. The standard way to do it is: select distinct column from table; or select column from table group by column; The only problem is that it's slow - as it ...

So, you have a table which looks like this: # \d test Table "public.test" ...

Today, on #postgresql on IRC, guy (can't contact him now to get his permission to name him), said: I have a table called problematic_hostnames. It contains a list of banned hostnames in column "hostname" (varchar). I would like to display the ...

On 28th of October Tom Lane committed his patch that changes some internals of functions, but it also adds interesting capability.