Re: enhance SPI to support EXECUTE commands - Mailing list pgsql-hackers

From Ahsan Hadi
Subject Re: enhance SPI to support EXECUTE commands
Date
Msg-id CA+9bhCKc4dd=VEpEPCMJfwB2Ho0W5zPzQj+AVdxE8FNxawxPEQ@mail.gmail.com
Whole thread Raw
In response to enhance SPI to support EXECUTE commands  (Quan Zongliang <zongliang.quan@postgresdata.com>)
Responses Re: enhance SPI to support EXECUTE commands
List pgsql-hackers
I don't see much use for this because the documentation says that "server's execute command cannot be used directly within pl/pgsql function (and it is not needed). Within pl/pgsql you can execute update/delete commands using pl/pgsql EXECUTE command and get results like row_count using "get diagnostic". 

Why would somebody do what you have shown in your example in pl/pgsql? Or do you have a more general use-case for this enhancement?

On Thu, Sep 5, 2019 at 11:39 AM Quan Zongliang <zongliang.quan@postgresdata.com> wrote:
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.

Regards,
Quan Zongliang


--
Highgo Software (Canada/China/Pakistan)
URL : http://www.highgo.ca
ADDR: 10318 WHALLEY BLVD, Surrey, BC
EMAIL: mailto: ahsan.hadi@highgo.ca

pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: [PATCH] Speedup truncates of relation forks
Next
From: Peter Eisentraut
Date:
Subject: Re: Nondeterministic collations vs. text_pattern_ops