[prev in list] [next in list] [prev in thread] [next in thread]
List: postgresql-general
Subject: Re: How to return ARRAY from SQL function?
From: Alexander Farber <alexander.farber () gmail ! com>
Date: 2019-06-26 11:30:31
Message-ID: CAADeyWiHPfZB+bJgqJ3B4qMv47ju6zPZwnzXJJoLAf_bSvjrag () mail ! gmail ! com
[Download RAW message or body]
Thank you -
On Tue, Jun 18, 2019 at 3:10 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> 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.
>
>
I was wondering that too, but assumed it is maybe STABLE because the
function does not modify any tables.
I will remove the STABLE keyword now
Regards
Alex
[Attachment #3 (text/html)]
<div dir="ltr"><div>Thank you -</div><br><div class="gmail_quote"><div \
class="gmail_attr" dir="ltr">On Tue, Jun 18, 2019 at 3:10 PM Tom Lane <<a \
href="mailto:tgl@sss.pgh.pa.us">tgl@sss.pgh.pa.us</a>> wrote:<br></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">Alexander \
Farber <<a href="mailto:alexander.farber@gmail.com" \
target="_blank">alexander.farber@gmail.com</a>> writes:<br> > And then I \
shuffle the letters by -<br> <br>
> CREATE OR REPLACE FUNCTION words_shuffle(in_array text[])<br>
> RETURNS text[] AS<br>
> $func$<br>
> SELECT array_agg(x ORDER BY RANDOM()) FROM UNNEST(in_array) x;<br>
> $func$ LANGUAGE sql STABLE;<br>
<br>
Hmm ... that's not really "stable", since it depends on random()<br>
which is volatile.<br><br></blockquote><div><br></div><div>I was wondering that too, \
but assumed it is maybe STABLE because the function does not modify any \
tables.</div><div><br></div><div>I will remove the STABLE keyword \
now</div><div><br></div><div>Regards</div><div>Alex</div><div><br></div></div></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic