[COMMITTERS] pgsql: Use ereport(ERROR) instead of Assert() to emit syncrep_parser er

2016-04-10 Thread Fujii Masao
Use ereport(ERROR) instead of Assert() to emit syncrep_parser error. The existing code would either Assert or generate an invalid SyncRepConfig variable, neither of which is desirable. A regular error should be thrown instead. This commit silences compiler warning in non assertion-enabled builds.

[COMMITTERS] pgsql: Fix poorly thought-through code from commit 5c3c3cd0a3046339.

2016-04-10 Thread Tom Lane
Fix poorly thought-through code from commit 5c3c3cd0a3046339. It's not entirely clear to me whether PyString_AsString can return null (looks like the answer might vary between Python 2 and 3). But in any case, this code's attempt to cope with the possibility was quite broken, because pstrdup() nei

[COMMITTERS] pgsql: pg_dump: add missing "destroyPQExpBuffer(query)" in dumpForeignS

2016-04-10 Thread Tom Lane
pg_dump: add missing "destroyPQExpBuffer(query)" in dumpForeignServer(). Coverity complained about this resource leak (why now, I don't know, since it's been like that a long time). Our general policy in pg_dump is that PQExpBuffers are worth cleaning up, so do it here too. But don't bother with

[COMMITTERS] pgsql: Add comment about intentional fallthrough in switch.

2016-04-10 Thread Tom Lane
Add comment about intentional fallthrough in switch. Coverity complained about an apparent missing "break" in a switch added by bb140506df605fab. The human-readable comments are pretty clear that this is intentional, but add a standard /* FALL THRU */ comment to make it clear to tools too. Branc

[COMMITTERS] pgsql: Clean up foreign-key caching code in planner.

2016-04-10 Thread Tom Lane
Clean up foreign-key caching code in planner. Coverity complained that the code added by 015e88942aa50f0d lacked an error check for SearchSysCache1 failures, which it should have. But the code was pretty duff in other ways too, including failure to think about whether it could really cope with ar

[COMMITTERS] pgsql: Fix access-to-already-freed-memory issue in plpython's error han

2016-04-10 Thread Tom Lane
Fix access-to-already-freed-memory issue in plpython's error handling. PLy_elog() could attempt to access strings that Python had already freed, because the strings that PLy_get_spi_error_data() returns are simply pointers into storage associated with the error "val" PyObject. That's fine at the

[COMMITTERS] pgsql: Fix access-to-already-freed-memory issue in plpython's error han

2016-04-10 Thread Tom Lane
Fix access-to-already-freed-memory issue in plpython's error handling. PLy_elog() could attempt to access strings that Python had already freed, because the strings that PLy_get_spi_error_data() returns are simply pointers into storage associated with the error "val" PyObject. That's fine at the

[COMMITTERS] pgsql: Fix access-to-already-freed-memory issue in plpython's error han

2016-04-10 Thread Tom Lane
Fix access-to-already-freed-memory issue in plpython's error handling. PLy_elog() could attempt to access strings that Python had already freed, because the strings that PLy_get_spi_error_data() returns are simply pointers into storage associated with the error "val" PyObject. That's fine at the

[COMMITTERS] pgsql: Fix access-to-already-freed-memory issue in plpython's error han

2016-04-10 Thread Tom Lane
Fix access-to-already-freed-memory issue in plpython's error handling. PLy_elog() could attempt to access strings that Python had already freed, because the strings that PLy_get_spi_error_data() returns are simply pointers into storage associated with the error "val" PyObject. That's fine at the

[COMMITTERS] pgsql: Fix access-to-already-freed-memory issue in plpython's error han

2016-04-10 Thread Tom Lane
Fix access-to-already-freed-memory issue in plpython's error handling. PLy_elog() could attempt to access strings that Python had already freed, because the strings that PLy_get_spi_error_data() returns are simply pointers into storage associated with the error "val" PyObject. That's fine at the

[COMMITTERS] pgsql: Avoid the use of a separate spinlock to protect a LWLock's wait

2016-04-10 Thread Andres Freund
Avoid the use of a separate spinlock to protect a LWLock's wait queue. Previously we used a spinlock, in adition to the atomically manipulated ->state field, to protect the wait queue. But it's pretty simple to instead perform the locking using a flag in state. Due to 6150a1b0 BufferDescs, on pla

[COMMITTERS] pgsql: Allow Pin/UnpinBuffer to operate in a lockfree manner.

2016-04-10 Thread Andres Freund
Allow Pin/UnpinBuffer to operate in a lockfree manner. Pinning/Unpinning a buffer is a very frequent operation; especially in read-mostly cache resident workloads. Benchmarking shows that in various scenarios the spinlock protecting a buffer header's state becomes a significant bottleneck. The pro

[COMMITTERS] pgsql: Improve contrib/bloom regression test using code coverage info.

2016-04-10 Thread Tom Lane
Improve contrib/bloom regression test using code coverage info. Originally, this test created a 10-row test table, which made it run rather slowly compared to other contrib tests. Investigation with gcov showed that we got no further improvement in code coverage after the first 700 or so rows

Re: [COMMITTERS] pgsql: Add the "snapshot too old" feature

2016-04-10 Thread Tom Lane
Kevin Grittner writes: > Add the "snapshot too old" feature I am fairly certain that this: typedef struct OldSnapshotControlData *OldSnapshotControl; static volatile OldSnapshotControl oldSnapshotControl; does not do what you intended. That causes the pointer variable to be ma

[COMMITTERS] pgsql: Fix possible NULL dereference in ExecAlterObjectDependsStmt

2016-04-10 Thread Alvaro Herrera
Fix possible NULL dereference in ExecAlterObjectDependsStmt I used the wrong variable here. Doesn't make a difference today because the only plausible caller passes a non-NULL variable, but someday it will be wrong, and even today's correctness is subtle: the caller that does pass a NULL is never