From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | "liuhuailing(at)fujitsu(dot)com" <liuhuailing(at)fujitsu(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Segment fault when excuting SPI function On PG with commit 41c6a5be |
Date: | 2021-07-30 12:38:01 |
Message-ID: | YQPyqYrMy/6JTAKa@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Jul 30, 2021 at 08:57:35AM +0000, liuhuailing(at)fujitsu(dot)com wrote:
> When I used SPI_execute_plan function on PG12 which commit 41c6a5be is used,
> Segment fault occurred.
>
> PS: If commit 41c6a5be is not used, this phenomenon will not happen.
I see nothing wrong in this commit, FWIW.
> Reproduce:
> In a background process, the following steps are executed.
> --------------------------
> StartTransactionCommand();
> SPI_connect();
> plan = SPI_prepare(query,0,NULL); ★the query is a SELECT SQL.
> SPI_keepplan(plan);
> SPI_finish();
> CommitTransactionCommand();
> StartTransactionCommand();
> SPI_connect();
> SPI_execute_plan(plan, NULL, NULL, true, 0); ★Segment fault
> --------------------------
But I see an issue with your code. It seems to me that you should
push a snapshot before doing SPI_prepare() and SPI_execute_plan(),
as of:
PushActiveSnapshot(GetTransactionSnapshot());
--
Michael
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2021-07-30 12:39:15 | Re: needless complexity in StartupXLOG |
Previous Message | Ranier Vilela | 2021-07-30 12:14:02 | Re: Segment fault when excuting SPI function On PG with commit 41c6a5be |