Re: Ascii Elephant for text based protocols - Final

From: Charles Clavadetscher <clavadetscher(at)swisspug(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Ascii Elephant for text based protocols - Final
Date: 2016-05-17 04:58:14
Message-ID: 573AA4E6.5060705@swisspug.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

On 05/16/2016 10:50 PM, Michael Paquier wrote:
> On Tue, May 17, 2016 at 5:13 AM, Karsten Hilbert
> <Karsten(dot)Hilbert(at)gmx(dot)net> wrote:
>> select pg_logo();
>>
>> seems like a good idea to me :-)
>
> If you propose a patch with a function that returns a setof text, I am
> sure it would get some attention. Though I think that you should
> remove the mention of the 20th anniversary.
>

Thank you for the feedbacks.

Good idea. I will write a function. The most basic would be:

CREATE OR REPLACE FUNCTION pg_logo()
RETURNS SETOF TEXT
AS $$
BEGIN
RETURN QUERY SELECT ' ____ ______ ___ '::TEXT;
RETURN QUERY SELECT ' / )/ \/ \ '::TEXT;
RETURN QUERY SELECT '( / __ _\ )'::TEXT;
RETURN QUERY SELECT ' \ (/ o) ( o) )'::TEXT;
RETURN QUERY SELECT ' \_ (_ ) \ ) _/ '::TEXT;
RETURN QUERY SELECT ' \ /\_/ \)/ '::TEXT;
RETURN QUERY SELECT ' \/ <//| |\\> '::TEXT;
RETURN QUERY SELECT ' _| | '::TEXT;
RETURN QUERY SELECT ' \|_/ '::TEXT;
RETURN;
END;
$$ LANGUAGE plpgsql;

charles(at)charles(dot)[local]=# select pg_logo();
pg_logo
-----------------------
____ ______ ___
/ )/ \/ \
( / __ _\ )
\ (/ o) ( o) )
\_ (_ ) \ ) _/
\ /\_/ \)/
\/ <//| |\\>
_| |
\|_/
(9 rows)

But I'd like to add arguments so that it is possible to add a frame and
a text as TEXT[]. Additional arguments for the text would be the
position (bottom or right) and the alignments (top, bottom, left, right,
center). All arguments should have default values so that calling the
function without arguments delivers the logo as in the above basic function.

A question to the naming. I find pg_logo() also a good name, but is the
prefix pg_* not reserved for system functions? Of course I could use the
name I want, but was wondering if there is a policy or a best practice
in this area.

And what schema would be appropriate? I could also create the function
without defining a schema and let users decide where they want to put it.

An alternative for the name could be logo(), in analogy to version().

Bye
Charles

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message hmzha2 2016-05-17 05:03:44 Re: Fast way to delete big table?
Previous Message Viswanath 2016-05-17 04:43:24 Re: Update or Delete causes canceling of long running slave queries