Re: Suggestion: Issue warning when calling SET TRANSACTION outside transaction block - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Suggestion: Issue warning when calling SET TRANSACTION outside transaction block
Date
Msg-id 20131003150222.GB6220@momjian.us
Whole thread Raw
In response to Re: Suggestion: Issue warning when calling SET TRANSACTION outside transaction block  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: Suggestion: Issue warning when calling SET TRANSACTION outside transaction block
List pgsql-hackers
On Thu, Oct  3, 2013 at 11:50:09AM +0530, Amit Kapila wrote:
> > I looked at this but could not see how to easily pass the value of
> > 'isTopLevel' down to the SELECT.  All the other checks have isTopLevel
> > passed down from the utility case statement.
> 
> Yes, we cannot pass isTopLevel, but as isTopLevel is used to decide
> whether we are in function (user defined) call, so if we can find
> during statement execution (current case set_config execution) that
> current statement is inside user function execution, then it can be
> handled.
> For example, one of the ways could be to use a mechanism similar to
> setting of user id and sec context used by fmgr_security_definer() (by
> calling function SetUserIdAndSecContext()), once userid and sec
> context are set by fmgr_security_definer(), later we can use
> InSecurityRestrictedOperation() anywhere to give error.
> 
> For current case, what we can do is after analyze
> (pg_analyze_and_rewrite), check if its not a builtin function (as we
> can have functionid after analyze, so it can be checked
> fmgr_isbuiltin(functionId)) and set variable to indicate that we are
> in function call.
> 
> Any better or simpler idea can also be used to identify isTopLevel
> during function execution.
> 
> Doing it only for detection of transaction chain in set_config path
> might seem to be more work, but I think it can be used at other places
> for detection of transaction chain as well.

I am also worried about over-engineering this.  I will wait to see if
anyone else would find top-level detection useful, and if not, I will
just apply my version of that patch that does not handle set_config.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: insert throw error when year field len > 4 for timestamptz datatype
Next
From: Bruce Momjian
Date:
Subject: Re: record identical operator - Review