pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers@lists.postgresql.org, Andres Freund <andres@anarazel.de>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Bruce Momjian <bruce@momjian.us>
Cc: Michael Paquier <michael@paquier.xyz>
Subject: Re: transction_timestamp() inside of procedures
Date: Mon, 08 Oct 2018 15:53:48 -0400
Message-ID: <32763.1539028428@sss.pgh.pa.us> (raw)
In-Reply-To: <E28DF5C1-E2EB-49D6-AC94-AC5FB99E58CF@anarazel.de>
References: <20180926155443.u4zh7jactzflys3z@alvherre.pgsql>
	<ec816bd0-0357-23a9-bea2-3ef1619eb340@2ndquadrant.com>
	<e2ad8aaf-e1d8-499e-4de0-e3616f8d908d@2ndquadrant.com>
	<20181002145853.wvhcb7pbrzgjyxns@alap3.anarazel.de>
	<38e36919-8bee-c717-be99-91137ad28aaf@2ndquadrant.com>
	<27414.1539018874@sss.pgh.pa.us>
	<E28DF5C1-E2EB-49D6-AC94-AC5FB99E58CF@anarazel.de>

Andres Freund <andres@anarazel.de> writes:
> On October 8, 2018 10:14:34 AM PDT, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Surely there is some way that we can directly test whether we're inside
>> a procedure or not?  I think the logic should be basically
>> ...

> Seems more reasonable from here.

We are rapidly running out of time to get this fixed before RC1.
In the interests of getting across the finish line, I took a look
around, and found that indeed there does not seem to be any exported
way to detect whether we're inside a procedure or not.  Which seems
pretty darn dumb from here.

The best way to determine that seems to be to check that that the SPI
stack is (a) nonempty and (b) has a "nonatomic" topmost entry.

Barring objections, I'm going to make a quick hack that adds a SPI
entry point along the lines of "bool SPI_inside_nonatomic_context(void)"
to do that test, adapt the xact.c code as I said upthread, and commit
with Peter's regression test case.

			regards, tom lane




view thread (32+ messages)

Message-ID: <32763.1539028428@sss.pgh.pa.us>
Permalink:  ../32763.1539028428@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/32763.1539028428@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, peter.eisentraut@2ndquadrant.com, andres@anarazel.de, alvherre@2ndquadrant.com, bruce@momjian.us, michael@paquier.xyz
  Subject: Re: transction_timestamp() inside of procedures
  In-Reply-To: <32763.1539028428@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox