Getting first and last values per group

Every so often someone needs solution to getting first (or couple of first) values for given column. Or last.

For some cases (when there is not many groups) you can use recursive queries. But it's not always the best choice.

Let's try to implement first() and last() aggregates, so these could be easily used by anybody.

Continue reading Getting first and last values per group

Generate short, random, textual IDs

Couple of people asked, on irc, about how to generate unique, short, ids for rows.

Since I wrote code for this for explain.depesz.com, I figured that instead of pointing to sources, and letting everyone to extract the functions, I will, instead, write a set of functions that what is needed in reusable way.

Continue reading Generate short, random, textual IDs

Waiting for 9.6 – Add CASCADE support for CREATE EXTENSION.

On 3rd of October, Andres Freund committed patch:

Add CASCADE support for CREATE EXTENSION.
 
Without CASCADE, if an extension has an unfullfilled dependency on
another extension, CREATE EXTENSION ERRORs out with "required extension
... is not installed". That is annoying, especially when that dependency
is an implementation detail of the extension, rather than something the
extension's user can make sense of.
 
In addition to CASCADE this also includes a small set of regression
tests around CREATE EXTENSION.
 
Author: Petr Jelinek, editorialized by Michael Paquier, Andres Freund
Reviewed-By: Michael Paquier, Andres Freund, Jeff Janes
Discussion: <a class="text" href="/gitweb/?p=postgresql.git;a=object;h=557E0520">557E0520</a>.3040800@2ndquadrant.com

Continue reading Waiting for 9.6 – Add CASCADE support for CREATE EXTENSION.