RE: [HACKERS] for row in select loop question

From: Michael Davis <michael(dot)davis(at)prevuenet(dot)com>
To: hackers(at)postgreSQL(dot)org
Subject: RE: [HACKERS] for row in select loop question
Date: 1999-03-05 15:34:11
Message-ID: 93C04F1F5173D211A27900105AA8FCFC145236@lambic.prevuenet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks. Declaring row as a record did the trick. I have a lot of tables
and I am looking to more deeply understand the PostgreSQL security module.

-----Original Message-----
From: jwieck(at)debis(dot)com [SMTP:jwieck(at)debis(dot)com]
Sent: Friday, March 05, 1999 3:00 AM
To: Michael Davis
Cc: hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] for row in select loop question

>
> The following function does not work:
>
> CREATE FUNCTION InstallPermissions(varchar, varchar) RETURNS int2
AS '
> DECLARE
> options ALIAS FOR $1;
> username ALIAS FOR $2;
> BEGIN
> FOR row IN select * from pg_tables LOOP
> REVOKE ALL ON row.tablename FROM username;
> GRANT options on row.tablename TO username;
> END LOOP;
> return 0;
> END; ' LANGUAGE 'plpgsql';
>
> "select InstallPermissions('test1', 'test2);" returns an error at
"select".
> Any suggestions on how to eliminate the error?

First you forgot to declare 'row'. Could be type record.

Second REVOKE and GRANT are utility statements not supported
for prepared SPI plans and thus PL/pgSQL currently cannot
execute them.

Jan

--


#======================================================================#
# It's easier to get forgiveness for being wrong than for being
right. #
# Let's break this rule - forgive me.
#
#======================================== jwieck(at)debis(dot)com (Jan
Wieck) #

Browse pgsql-hackers by date

  From Date Subject
Next Message Terry Mackintosh 1999-03-05 15:36:25 Regression differences on Red Hat 5.2
Previous Message Oleg Broytmann 1999-03-05 15:13:50 Re: [HACKERS] Bug on complex join