Re: BUG: Session getting disconnected while executing a function to create materialised views in PostgreSQL 9.6 - Mailing list pgsql-bugs

From Michael Paquier
Subject Re: BUG: Session getting disconnected while executing a function to create materialised views in PostgreSQL 9.6
Date
Msg-id CAB7nPqRESWD8Ne7GNNEwt_0LmOBcCc4+4wLwPvaPQSmk2xxNZg@mail.gmail.com
Whole thread Raw
In response to BUG: Session getting disconnected while executing a function to create materialised views in PostgreSQL 9.6  ("Saxena, Shivam" <shsaxena@teamdrg.com>)
Responses Re: BUG: Session getting disconnected while executing a function to create materialised views in PostgreSQL 9.6
List pgsql-bugs
On Thu, Aug 11, 2016 at 6:30 PM, Saxena, Shivam <shsaxena@teamdrg.com> wrote:
> While creating a 9.6 database environment we have come across a situation
> where the session is getting disconnected while running a function. Below
> are the DB details and function details.

Thanks for the report!

> Few other observations:
>
> The same code snippet runs fine in PostreSQL v9.5
> When we remove the clause WITH NO DATA, then the functions runs successfully

9.5.4 and other is impacted as well by this crash, down to 9.3, and
this is an oversight of 1651b9aa that made a matview query with WITH
NO DATA not run the parser/planner when executed. spi.c has a special
handling for CTAS, and this query runs into that, so any such query
executed through the SPI is going to crash on that:
(lldb) up 1
frame #4: 0x0000000105986dde
postgres`_SPI_execute_plan(plan=0x00007f9ff383c038,
paramLI=0x0000000000000000, snapshot=0x0000000000000000,
crosscheck_snapshot=0x0000000000000000, read_only='\0',
fire_triggers='\x01', tcount=0) + 1902 at spi.c:2228
   2225                        else
   2226                        {
   2227                            /* Must be an IF NOT EXISTS that
did nothing */
-> 2228                            Assert(ctastmt->if_not_exists);
   2229                            _SPI_current->processed = 0;
   2230                        }
   2231
(lldb) p *ctastmt
(CreateTableAsStmt) $1 = {
  type = T_CreateTableAsStmt
  query = 0x00007f9ff385e4d0
  into = 0x00007f9ff3868ef0
  relkind = OBJECT_MATVIEW
  is_select_into = '\0'
  if_not_exists = '\0'
}
I'll produce a patch in the worst case by tomorrow morning my time.
--
Michael

pgsql-bugs by date:

Previous
From: "Saxena, Shivam"
Date:
Subject: BUG: Session getting disconnected while executing a function to create materialised views in PostgreSQL 9.6
Next
From: Michael Paquier
Date:
Subject: Re: BUG: Session getting disconnected while executing a function to create materialised views in PostgreSQL 9.6