pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexander Farber <alexander.farber@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: How to return ARRAY from SQL function?
Date: Tue, 18 Jun 2019 09:10:25 -0400
Message-ID: <20726.1560863425@sss.pgh.pa.us> (raw)
In-Reply-To: <CAADeyWjshf=VGsk0CcbFgQ-196QLrgFjrsANdA8T+2+ha4HUww@mail.gmail.com>
References: <CAADeyWgc-dXvuPP+Sq-xsLiauKdTZYmuco9xePa2y0a0x1PTKw@mail.gmail.com>
	<fa667d56acfa4f4bd40556ddc1ef86e63a47a9dc.camel@cybertec.at>
	<27773.1560518732@sss.pgh.pa.us>
	<CAADeyWjshf=VGsk0CcbFgQ-196QLrgFjrsANdA8T+2+ha4HUww@mail.gmail.com>

Alexander Farber <alexander.farber@gmail.com> writes:
> And then I shuffle the letters by -

> CREATE OR REPLACE FUNCTION words_shuffle(in_array text[])
>         RETURNS text[] AS
> $func$
>         SELECT array_agg(x ORDER BY RANDOM()) FROM UNNEST(in_array) x;
> $func$ LANGUAGE sql STABLE;

Hmm ... that's not really "stable", since it depends on random()
which is volatile.

			regards, tom lane





view thread (6+ messages)  latest in thread

Message-ID: <20726.1560863425@sss.pgh.pa.us>
Permalink:  ../20726.1560863425@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20726.1560863425@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, alexander.farber@gmail.com
  Subject: Re: How to return ARRAY from SQL function?
  In-Reply-To: <20726.1560863425@sss.pgh.pa.us>
  References: <CAADeyWgc-dXvuPP+Sq-xsLiauKdTZYmuco9xePa2y0a0x1PTKw@mail.gmail.com> <fa667d56acfa4f4bd40556ddc1ef86e63a47a9dc.camel@cybertec.at> <27773.1560518732@sss.pgh.pa.us> <CAADeyWjshf=VGsk0CcbFgQ-196QLrgFjrsANdA8T+2+ha4HUww@mail.gmail.com> <20726.1560863425@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox