pgsql: Add float.h include to int8.c, for isnan().

2017-12-12 Thread Andres Freund
Add float.h include to int8.c, for isnan(). port.h redirects isnan() to _isnan() on windows, which in turn is provided by float.h rather than math.h. Therefore include the latter as well. Per buildfarm. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/8e211f5391465b

pgsql: Consistently use PG_INT(16|32|64)_(MIN|MAX).

2017-12-12 Thread Andres Freund
Consistently use PG_INT(16|32|64)_(MIN|MAX). Per buildfarm animal woodlouse. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/f512a6e1323eefa843a063e466babb96d7bfb4ce Modified Files -- contrib/btree_gist/btree_cash.c | 2 +- contrib/btree_gist/btree_int2

pgsql: PL/Python: Fix potential NULL pointer dereference

2017-12-12 Thread Peter Eisentraut
PL/Python: Fix potential NULL pointer dereference After d0aa965c0a0ac2ff7906ae1b1dad50a7952efa56, one error path in PLy_spi_execute_fetch_result() could result in the variable "result" being dereferenced after being set to NULL. Rearrange the code a bit to fix that. Also add another SPI_freetupt

pgsql: Make PGAC_C_BUILTIN_OP_OVERFLOW link instead of just compiling.

2017-12-12 Thread Andres Freund
Make PGAC_C_BUILTIN_OP_OVERFLOW link instead of just compiling. Otherwise the detection can spuriously detect symbol as available, because the compiler may just emits reference to non-existant symbol. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/85abb5b297c5b3187

pgsql: Provide overflow safe integer math inline functions.

2017-12-12 Thread Andres Freund
Provide overflow safe integer math inline functions. It's not easy to get signed integer overflow checks correct and fast. Therefore abstract the necessary infrastructure into a common header providing addition, subtraction and multiplication for 16, 32, 64 bit signed integers. The new macros are

pgsql: Use new overflow aware integer operations.

2017-12-12 Thread Andres Freund
Use new overflow aware integer operations. A previous commit added inline functions that provide fast(er) and correct overflow checks for signed integer math. Use them in a significant portion of backend code. There's more to touch in both backend and frontend code, but these were the easily iden

pgsql: Remove obsolete comment.

2017-12-12 Thread Robert Haas
Remove obsolete comment. Commit 8b304b8b72b0a60f1968d39f01cf817c8df863ec removed replacement selection, but left behind this comment text. The optimization to which the comment refers is not relevant without replacement selection, because if we had so few tuples as to require only one tape, we wo

Re: pgsql: PL/Python: Fix potential NULL pointer dereference

2017-12-12 Thread Tom Lane
Peter Eisentraut writes: > On 12/5/17 14:45, Tom Lane wrote: >> On the whole it seems like it might be better to dodge this whole business >> of changing "result" inside the TRY. You could do that if you did >> something like ... > Yeah, that looks much better. Next try attached. Looks sane to

Re: pgsql: PL/Python: Fix potential NULL pointer dereference

2017-12-12 Thread Peter Eisentraut
On 12/5/17 14:45, Tom Lane wrote: > On the whole it seems like it might be better to dodge this whole business > of changing "result" inside the TRY. You could do that if you did > something like > > result->rows = PyList_New(rows); > - if (!result->rows) > -

pgsql: Remove bug from OPTIMIZER_DEBUG code for partition-wise join.

2017-12-12 Thread Robert Haas
Remove bug from OPTIMIZER_DEBUG code for partition-wise join. Etsuro Fujita, reviewed by Ashutosh Bapat Discussion: http://postgr.es/m/5a2a60e6.6000...@lab.ntt.co.jp Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/d329dc2ea4bfac84ec60ba14b96561a7508bb37b Modified

pgsql: Make pg_trgm tests independ from standard_conforming_string. Tes

2017-12-12 Thread Teodor Sigaev
Make pg_trgm tests independ from standard_conforming_string. Tests uses regular expression which contains backslash. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/c28aa157b86f756d53f2a6b715e23ca56f219b4f Modified Files -- contrib/pg_trgm/expected/pg_tr