Segmentation fault with JSONB column from view passed into stored PL/PGSQL procedure that builds a new JSON return value

From: Samuel Horwitz <samuelhorwitz(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Segmentation fault with JSONB column from view passed into stored PL/PGSQL procedure that builds a new JSON return value
Date: 2017-10-26 18:26:47
Message-ID: CA+JV_JOGeA202=dTyRMtpmxOWs7yzf5HCy-8jAj+ac2x_Ju1Hw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Postgres Version: 9.6.5

I have a table that includes a JSONB column. I have a view that is based on
this table that reflects this JSONB column. I have yet another view, based
on the first view, that passes rows from the first view into a stored
PL/PGSQL procedure as anyelement. This stored procedure builds a JSON
object from it's input and returns that new JSON object. One of the values
on the new JSON object is the value of the JSONB column that has gone
through two views by this point, into the procedure.

At this point everything works. Selecting from the second view is fine.

However, if I alter the stored procedure's resulting JSON in any way, this
will cause selecting from the second view to trigger a segfault.

The solution is easy: regenerate the second view by just CREATE OR
REPLACEing it with the existing definition.

I have created a public Gist with reproduction steps and dumps, attached
here: https://gist.github.com/samuelhorwitz/0bc77a517238914512fc8cdf50d217cd

Please scroll to the bottom (or click here
https://gist.github.com/samuelhorwitz/0bc77a517238914512fc8cdf50d217cd#gistcomment-2240442)
to see my steps.

Samuel Horwitz

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message samuel.horwitz 2017-10-26 18:40:35 BUG #14876: Segmentation fault with JSONB column used in store proc that gets used by view and later altered
Previous Message Michael Paquier 2017-10-26 18:13:55 Re: [BUGS] Bug in Physical Replication Slots (at least 9.5)?