Search Postgresql Archives

array UNNESTed to rows stable with respect to order?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all

I have created following statement to get the ordered parameter list of functions. I use UNNEST to get rows from array. This works fine but I am not sure whether the ordering remains in the later use. Background is PL/pgSQL to revoke grants to get a pristine start for granting. As the order of the parameter is important, I should use a statement that returns the properly ordered list of parameters. Maybe I did take a wrong turn and one can achieve this simpler.

Suggestions are very welcome.

Kind regards Thiemo

with PRO_UNNESTED_TYPES as(
  select
    oid as PROOID,
    PRONAME,
    unnest(PROARGTYPES) as PROARGTYPE,
    PRONAMESPACE,
    PROOWNER
  from
    PG_CATALOG.PG_PROC
) select
  P.PRONAME,
  string_agg(
    T.TYPNAME,
    ', '
  ) as PARAMETER_LIST_STRING,
  G.GRANTEE
from
  PRO_UNNESTED_TYPES P
inner join PG_CATALOG.PG_TYPE T on
  P.PROARGTYPE = T.OID
inner join PG_CATALOG.PG_NAMESPACE N on
  P.PRONAMESPACE = N.OID
inner join INFORMATION_SCHEMA.ROUTINE_PRIVILEGES G on
  -- copied from INFORMATION_SCHEMA.ROUTINE_PRIVILEGES source
 -- as seen in DBeaver 4.3.2
(
    (
      P.PRONAME::text || '_'::text
    )|| P.PROOID::text
  )::INFORMATION_SCHEMA.SQL_IDENTIFIER = G.SPECIFIC_NAME
where
  N.NSPNAME = current_user
  and G.GRANTEE != current_user
group by
  P.PROOID,
  P.PRONAME,
  G.GRANTEE
order by
  P.PRONAME asc,
  G.GRANTEE asc,
  PARAMETER_LIST_STRING asc;



--
Öffentlicher PGP-Schlüssel:
http://pgp.mit.edu/pks/lookup?op=get&search=0xCA167FB0E717AFFC
begin:vcard
fn:Thiemo Kellner
n:Kellner;Thiemo
adr:;;Landstr. 34;Weilheim-Bannholz;BW;79809;Deutschland
email;internet:thiemo@xxxxxxxxxxxxxxxxxxxx
tel;work:+49 1578 772 37 37
tel;cell:+41 78 947 36 21
note;quoted-printable:Auf Gelassene Pferde kann man bauen!=0D=0A=
	+49 (0)1578-772 37 37 (Mo, Di)=0D=0A=
	+41 (0)78 947 36 21 (Mi - Fr)=0D=0A=
	sip: thiemo.kellner@xxxxxxxxx=0D=0A=
	Skype: thiemo.kellner=0D=0A=
	http://www.gelassene-pferde.biz=0D=0A=
	Mitglied bei http://www.keep-it-natural.org=0D=0A=
	=C3=96ffentlicher PGP-Schl=C3=BCssel: http://pgp.mit.edu/pks/lookup?op=3D=
	get&search=3D0x8F70EFD2D972CBEF
x-mozilla-html:FALSE
url:http://www.gelassene-pferde.biz
version:2.1
end:vcard


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux