The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Do you need to patch PostgreSQL to show beer o’clock?

Posted by jpluimers on 2024/02/27

One might think a PostgreSQL patch is needed for [Wayback/Archive] Devrim Gündüz on Twitter: “Just forked PostgreSQL, and fixed a problem: …”

Image

[Wayback/Archive] Andreas Scherbaum on Twitter: “@l_avrot @d_gustafsson @DevrimGunduz Folks, you are making life way too complicated. No patching required! #beer #whisky”

–jeroen

[Wayback/Archive] gist:


SET search_path TO public, pg_catalog;
SET
CREATE OR REPLACE FUNCTION now(beverage TEXT= 'beer')
RETURNS TEXT
AS $$
BEGIN
RETURN 'It's | quote literal(beverage) || o''clock! ';
END;
$$
LANGUAGE plpgsql
IMMUTABLE
COST 42
PARALLEL SAFE;
CREATE FUNCTION
SELECT NOW();
now
———————-
It's 'beer' o'clock!
(1 row)
SELECT NOW('whisky');
now
————————
It's 'whisky' o'clock!
(1 row)
now=#

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.