Re: Ascii Elephant for text based protocols - Final

Поиск
Список
Период
Сортировка
От Charles Clavadetscher
Тема Re: Ascii Elephant for text based protocols - Final
Дата
Msg-id 573AA4E6.5060705@swisspug.org
обсуждение исходный текст
Ответ на Re: Ascii Elephant for text based protocols - Final  (Michael Paquier <michael.paquier@gmail.com>)
Ответы Re: Ascii Elephant for text based protocols - Final  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Список 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.Hilbert@gmx.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@charles.[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


В списке pgsql-general по дате отправления:

Предыдущее
От: Lucas Possamai
Дата:
Сообщение: Re: Increased I/O / Writes
Следующее
От: hmzha2
Дата:
Сообщение: Re: Fast way to delete big table?