[COMMITTERS] pgsql: Improvements to GetErrorContextStack()

2013-07-25 Thread Stephen Frost
Improvements to GetErrorContextStack() As GetErrorContextStack() borrowed setup and tear-down code from other places, it was less than clear that it must only be called as a top-level entry point into the error system and can't be called by an exception handler (unlike the rest of the error system

Re: [COMMITTERS] pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL

2013-07-25 Thread Stephen Frost
Tom, * Tom Lane ([email protected]) wrote: > I'm not following your reasoning here. This *has* to be called in an > error case, before you're outside the error processing context. > Otherwise there would be no data available to be printed. > > In short: FlushErrorState, by definition, destroys

[COMMITTERS] pgsql: pg_upgrade: adjust umask() calls

2013-07-25 Thread Bruce Momjian
pg_upgrade: adjust umask() calls Since pg_upgrade -j on Windows uses threads, calling umask() before/after opening a file via fopen_priv() is no longer possible, so set umask() as we enter the thread-creating loop, and reset it on exit. Also adjust internal fopen_priv() calls to just use fopen().

[COMMITTERS] pgsql: pg_upgrade: adjust umask() calls

2013-07-25 Thread Bruce Momjian
pg_upgrade: adjust umask() calls Since pg_upgrade -j on Windows uses threads, calling umask() before/after opening a file via fopen_priv() is no longer possible, so set umask() as we enter the thread-creating loop, and reset it on exit. Also adjust internal fopen_priv() calls to just use fopen().

[COMMITTERS] pgsql: Fix configure probe for sys/ucred.h.

2013-07-25 Thread Tom Lane
Fix configure probe for sys/ucred.h. The configure script's test for did not work on OpenBSD, because on that platform has to be included first. As a result, socket peer authentication was disabled on that platform. Problem introduced in commit be4585b1c27ac5dbdd0d61740d18f7ad9a00e268. Andres F

[COMMITTERS] pgsql: Fix configure probe for sys/ucred.h.

2013-07-25 Thread Tom Lane
Fix configure probe for sys/ucred.h. The configure script's test for did not work on OpenBSD, because on that platform has to be included first. As a result, socket peer authentication was disabled on that platform. Problem introduced in commit be4585b1c27ac5dbdd0d61740d18f7ad9a00e268. Andres F

[COMMITTERS] pgsql: Fix configure probe for sys/ucred.h.

2013-07-25 Thread Tom Lane
Fix configure probe for sys/ucred.h. The configure script's test for did not work on OpenBSD, because on that platform has to be included first. As a result, socket peer authentication was disabled on that platform. Problem introduced in commit be4585b1c27ac5dbdd0d61740d18f7ad9a00e268. Andres F

[COMMITTERS] pgsql: Fix configure probe for sys/ucred.h.

2013-07-25 Thread Tom Lane
Fix configure probe for sys/ucred.h. The configure script's test for did not work on OpenBSD, because on that platform has to be included first. As a result, socket peer authentication was disabled on that platform. Problem introduced in commit be4585b1c27ac5dbdd0d61740d18f7ad9a00e268. Andres F

Re: [COMMITTERS] pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL

2013-07-25 Thread Tom Lane
Stephen Frost writes: > I've just pushed up some much needed improvements to the comments which > hopefully clarify that this function is using error_context_stack and > calling the callbacks set up there by callers above on the PG call > stack. Now that I'm a bit more awake, I realize that my co

Re: [COMMITTERS] pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL

2013-07-25 Thread Pavel Stehule
Hello 2013/7/25 Tom Lane : > Stephen Frost writes: >> I've just pushed up some much needed improvements to the comments which >> hopefully clarify that this function is using error_context_stack and >> calling the callbacks set up there by callers above on the PG call >> stack. > > Now that I'm a

Re: [COMMITTERS] pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL

2013-07-25 Thread Stephen Frost
* Tom Lane ([email protected]) wrote: > 1. Just run the whole business in the caller's context and leave it up > to the caller to worry about whether it needs to clean up memory usage. I'd certainly be fine with that, and had considered it, but it looks like errcontext_msg() (which is called by t

Re: [COMMITTERS] pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL

2013-07-25 Thread Stephen Frost
Pavel, First, please only quote the relevant parts of the email when responding. * Pavel Stehule ([email protected]) wrote: > I used a ErrorContext because I wasn't sure so errcontext and similar > function can work in different context. Now I look there and there > should be well initializ

Re: [COMMITTERS] pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL

2013-07-25 Thread Tom Lane
Stephen Frost writes: > * Tom Lane ([email protected]) wrote: >> 1. Just run the whole business in the caller's context and leave it up >> to the caller to worry about whether it needs to clean up memory usage. > I'd certainly be fine with that, and had considered it, but it looks > like errcont

Re: [COMMITTERS] pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL

2013-07-25 Thread Pavel Stehule
2013/7/25 Stephen Frost : > Pavel, > > First, please only quote the relevant parts of the email when > responding. > > * Pavel Stehule ([email protected]) wrote: >> I used a ErrorContext because I wasn't sure so errcontext and similar >> function can work in different context. Now I look ther

Re: [COMMITTERS] pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL

2013-07-25 Thread Stephen Frost
* Tom Lane ([email protected]) wrote: > [...] a better idea is to add a memory-context-to-use field to struct > ErrorData. We'd initialize it to ErrorContext when pushing a stack > entry for normal error processing, but GetErrorContextStack could > do something different. This would eliminate mo

Re: [COMMITTERS] pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL

2013-07-25 Thread Tom Lane
Stephen Frost writes: > * Tom Lane ([email protected]) wrote: >> If you want I'll draft something up. > I'll take care of it, thanks for the idea! OK. One possibly non-obvious point is that I think the field should be defined as "context containing associated non-constant strings"; this would

[COMMITTERS] pgsql: Don't use SnapshotNow in get_actual_variable_range.

2013-07-25 Thread Robert Haas
Don't use SnapshotNow in get_actual_variable_range. Instead, use the active snapshot. Per Tom Lane, this function is most interested in knowing the range of tuples our scan will actually see. This is another step towards full removal of SnapshotNow. Branch -- master Details --- http://

[COMMITTERS] pgsql: pgstattuple: Use SnapshotDirty, not SnapshotNow.

2013-07-25 Thread Robert Haas
pgstattuple: Use SnapshotDirty, not SnapshotNow. Tuples belonging to uncommitted transactions should not be counted as dead. This is arguably a bug fix that should be back-patched, but as no one ever noticed until it came time to try to get rid of SnapshotNow, I'm only doing this in master for no

[COMMITTERS] pgsql: pgstattuple: Doc update for previous commit.

2013-07-25 Thread Robert Haas
pgstattuple: Doc update for previous commit. In my previous change to make pgstattuple use SnapshotDirty rather than SnapshotNow, I failed to notice that the documenation also needed to be updated to match. Fix. Branch -- master Details --- http://git.postgresql.org/pg/commitdiff/fd27b9

[COMMITTERS] pgsql: Change currtid functions to use an MVCC snapshot, not SnapshotNo

2013-07-25 Thread Robert Haas
Change currtid functions to use an MVCC snapshot, not SnapshotNow. This has a slight performance cost, but the only known consumers of these functions, known at the SQL level as currtid and currtid2, is pgsql-odbc; whose usage, we hope, is not sufficiently intensive to make this a problem. Per di

[COMMITTERS] pgsql: Prevent leakage of SPI tuple tables during subtransaction abort.

2013-07-25 Thread Tom Lane
Prevent leakage of SPI tuple tables during subtransaction abort. plpgsql often just remembers SPI-result tuple tables in local variables, and has no mechanism for freeing them if an ereport(ERROR) causes an escape out of the execution function whose local variable it is. In the original coding, t

[COMMITTERS] pgsql: Prevent leakage of SPI tuple tables during subtransaction abort.

2013-07-25 Thread Tom Lane
Prevent leakage of SPI tuple tables during subtransaction abort. plpgsql often just remembers SPI-result tuple tables in local variables, and has no mechanism for freeing them if an ereport(ERROR) causes an escape out of the execution function whose local variable it is. In the original coding, t