Re: pg_stat_statements: rows not updated for CREATE TABLE AS SELECTstatements - Mailing list pgsql-bugs

From Fujii Masao
Subject Re: pg_stat_statements: rows not updated for CREATE TABLE AS SELECTstatements
Date
Msg-id 54fa2fec-b133-0fc0-4227-3e308ba68812@oss.nttdata.com
Whole thread Raw
In response to Re: pg_stat_statements: rows not updated for CREATE TABLE AS SELECTstatements  (legrand legrand <legrand_legrand@hotmail.com>)
Responses Re: pg_stat_statements: rows not updated for CREATE TABLE AS SELECTstatements  (legrand legrand <legrand_legrand@hotmail.com>)
List pgsql-bugs

On 2020/03/28 2:43, legrand legrand wrote:
> Thank you for those answers !
> 
>> The utility commands that return CMDTAG_SELECT are
>> only CREATE TABLE AS SELECT and CREATE MATERIALIZED VIEW?
>> I'd just like to confirm that there is no case where "rows" must not
>> be counted when CMDTAG_SELECT is returned.
> 
> I don't have any in mind ...

I found that SELECT INTO also returns CMDTAG_SELECT.

> 
>> BTW, "rows" should be updated when FETCH or MOVE is executed
>> because each command returns or affects the rows?
> 
> Yes they should, but they aren't yet (event with CMDTAG_SELECT added)
> 
> Note that implicit cursors behave the same way ;o(

Thanks for confirming this!

Attached is the patch that makes pgss track the total number of rows
retrieved or affected by CREATE TABLE AS, SELECT INTO,
CREATE MATERIALIZED VIEW and FETCH. I think this is new feature
rather than bug fix, so am planning to add this patch into next CommitFest
for v14. Thought?

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachment

pgsql-bugs by date:

Previous
From: Bert Brezel
Date:
Subject: Re: BUG #16341: Installation with EnterpriseDB Community installer inNT AUTHORITY\SYSTEM context not possible
Next
From: John Muehlhausen
Date:
Subject: NOTIFY in multi-statement PQexec() not sent outside of transaction