Profile

outlier_lynn: (Default)
outlier_lynn

January 2015

S M T W T F S
    123
45678910
11121314151617
181920 21222324
25262728293031

Most Popular Tags

Expand Cut Tags

No cut tags

July 12th, 2013

outlier_lynn: (Default)
Friday, July 12th, 2013 10:40 am
I've been working with postgresql for years now. I've written thousands of lines of sql code defining domains, types, tables, views, functions, triggers and so forth. I've read the documentation over and over and over. It's pretty damn good documentation as software manuals go, too.

Along with my friend, Greg, I've created several utility functions for dealing with time, xml and xslt, arrays, debugging, and other routine issues. Some have become obsolete as postgresql moves from major version to major version.

I feel pretty confident in my ability to design reasonable databases.

And, then, I discover something that would have made my life a bit easier a long time ago and increased the efficiency of parts of my code dramatically. There are times when I really need a function to return void even when the last statement of the function would be a select that isn't going to return void. I wrote a function that would return void that I could slip into other functions as the last statement. I did it badly. Turns out that "select null::void" is the way to do this. I won't even tell you the ridiculous function I wrote. :)

After I found this gem, I searched the postgresql documentation for any sign of the ability to cast null to void. Found nothing. I found lots of instances where one might cast null to something, but nothing that directly said I could cast null to void. It is vaguely implied with the nothing that void is a pseudotype. It's a neat trick in any event.

I wonder just how many other wonderful ways of doing things are also just out my sight.
Tags: