Re: enhance SPI to support EXECUTE commands

From: Quan Zongliang <zongliang(dot)quan(at)postgresdata(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: enhance SPI to support EXECUTE commands
Date: 2019-09-05 08:25:15
Message-ID: 339f2a41-f55f-ae4c-7853-925470aebe0f@postgresdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2019/9/5 15:09, Pavel Stehule wrote:
>
>
> čt 5. 9. 2019 v 8:39 odesílatel Quan Zongliang
> <zongliang(dot)quan(at)postgresdata(dot)com
> <mailto:zongliang(dot)quan(at)postgresdata(dot)com>> napsal:
>
> Dear hackers,
>
> I found that such a statement would get 0 in PL/pgSQL.
>
> PREPARE smt_del(int) AS DELETE FROM t1;
> EXECUTE 'EXECUTE smt_del(100)';
> GET DIAGNOSTICS j = ROW_COUNT;
>
> In fact, this is a problem with SPI, it does not support getting result
> of the EXECUTE command. I made a little enhancement. Support for the
> number of rows processed when executing INSERT/UPDATE/DELETE statements
> dynamically.
>
>
> Is there some use case for support this feature?
>
A user deletes the data in PL/pgSQL using the above method, hoping to do
more processing according to the number of rows affected, and found that
each time will get 0.

Sample code:
PREPARE smt_del(int) AS DELETE FROM t1 WHERE c=$1;
EXECUTE 'EXECUTE smt_del(100)';
GET DIAGNOSTICS j = ROW_COUNT;

IF j=1 THEN
do something
ELSIF j=0 THEN
do something

Here j is always equal to 0.

Regards

> Regards
>
> Pavel
>
>
> Regards,
> Quan Zongliang
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2019-09-05 08:31:19 Re: enhance SPI to support EXECUTE commands
Previous Message Michael Paquier 2019-09-05 07:51:33 Re: pg_promote() can cause busy loop