Re: improvise callbacks in plpgsql

Lists: pgsql-performance
From: "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: improvise callbacks in plpgsql
Date: 2005-11-01 22:13:48
Message-ID: 6EE64EF3AB31D5448D0007DD34EEB3417DD767@Herge.rcsinc.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

> The body of callit() need be little more than OidFunctionCall1()
> plus whatever error checking and security checking you want to
> include.

esp=# create table test(f text);
CREATE TABLE

esp=# create function test() returns void as
$$
begin
insert into test values ('called');
end;
$$ language plpgsql;

esp=# create or replace function test2() returns void as
esp-# $$
esp$# declare
esp$# r record;
esp$# begin
esp$# select into r 'abc';
esp$# perform callit('test()'::regprocedure, r);
esp$# end;
esp$#
esp$# $$ language plpgsql;
CREATE FUNCTION

esp=# select test2();

esp=# select * from test;
f
--------
called
(1 row)

one word...
w00t

Merlin


From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: Merlin Moncure <merlin(dot)moncure(at)rcsonline(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-performance(at)postgresql(dot)org
Subject: Re: improvise callbacks in plpgsql
Date: 2005-11-01 23:04:40
Message-ID: 20051101230440.GU20349@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

Would you be willing to write up an example of this? We often get asked
about support for WITH, so I bet there's other people who would be very
interested in what you've got.

On Tue, Nov 01, 2005 at 05:13:48PM -0500, Merlin Moncure wrote:
> > The body of callit() need be little more than OidFunctionCall1()
> > plus whatever error checking and security checking you want to
> > include.
>
> esp=# create table test(f text);
> CREATE TABLE
>
> esp=# create function test() returns void as
> $$
> begin
> insert into test values ('called');
> end;
> $$ language plpgsql;
>
> esp=# create or replace function test2() returns void as
> esp-# $$
> esp$# declare
> esp$# r record;
> esp$# begin
> esp$# select into r 'abc';
> esp$# perform callit('test()'::regprocedure, r);
> esp$# end;
> esp$#
> esp$# $$ language plpgsql;
> CREATE FUNCTION
>
> esp=# select test2();
>
> esp=# select * from test;
> f
> --------
> called
> (1 row)
>
> one word...
> w00t
>
> Merlin
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>

--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461