Re: [PATCH] session_replication_role = replica with TRUNCATE

2017-12-29 Thread Craig Ringer
On 30 December 2017 at 03:32, Petr Jelinek wrote: > On 29/12/17 16:53, Marco Nenciarini wrote: > > Il 29/12/17 15:14, Petr Jelinek ha scritto: > >> > >> May be worth documenting that the session_replication_role also affects > >> TRUNCATE's interaction with FKs in config.sgml. > >> > > > > The cu

CONSTANT/NOT NULL/initializer properties for plpgsql record variables

2017-12-29 Thread Tom Lane
I said a couple of times in recent threads that it wouldn't be too hard to implement $SUBJECT given the other patches I've been working on. Attached is proof of the pudding. This needs to be applied on top of the patches in https://postgr.es/m/23537.1514589...@sss.pgh.pa.us and https://postgr.es/m

Re: Converting plpgsql to use DTYPE_REC for named composite types

2017-12-29 Thread Tom Lane
I wrote: > I hacked on the domain-support problem a bit and it worked out well, > so attached is a revised patch that incorporates that. This caused > me to revise some assumptions about what expandedrecord.c's internal > invariants ought to be, so it's probably better to look at this as > a new p

Re: Why standby restores some WALs many times from archive?

2017-12-29 Thread Sergey Burladyan
Jeff Janes writes: > On Thu, Dec 28, 2017 at 7:02 AM, Victor Yagofarov wrote: > > I have postgres 9.4 standby with archive-based replication (via > > restore_command). > Can you show us both your archive_command and your restore_command? We use this scripts: https://github.com/avito-tech/dba-u

Re: Fix a Oracle-compatible instr function in the documentation

2017-12-29 Thread Tatsuo Ishii
> Hi, > > Attached is a patch to fix a very trivial issue of the documentation. > > The documentation of PL/pgSQL provides sample codes of Oracle-compatible > instr functions. However, the behaviour is a little differet. > Oracle's instr raises an error when the forth argument value is less than

Re: [HACKERS] taking stdbool.h into use

2017-12-29 Thread Michael Paquier
On Fri, Dec 29, 2017 at 12:33:24PM -0500, Tom Lane wrote: > Alvaro Herrera writes: > > Michael Paquier wrote: > >> I have looked at 0002 and 0003. Those look good to ship for me. > > > Yeah, I'd vote to push those right away to see what buildfarm has to > > say. That way you can push 0001 shortl

Re: Converting plpgsql to use DTYPE_REC for named composite types

2017-12-29 Thread Tom Lane
I wrote: > I'll stick this into the January commitfest, but I'd like to get it > reviewed and committed pretty soon, because there are follow-on patches > that need to get done in time for v11 --- in particular, we need to close > out the lack of plpgsql support for domains-over-composite. I hacke

FOR EACH ROW triggers on partitioned tables

2017-12-29 Thread Alvaro Herrera
This patch enables FOR EACH ROW triggers on partitioned tables. As presented, this patch is sufficient to discuss the semantics that we want for triggers on partitioned tables, which is the most pressing question here ISTM. However, this is incomplete: it doesn't create triggers when you do ALTER

Re: pgbench - add \if support

2017-12-29 Thread Fabien COELHO
Another rebase after the pow function commit. Mostly a rebase after zipfian function commit. -- Fabien.diff --git a/doc/src/sgml/ref/pgbench.sgml b/doc/src/sgml/ref/pgbench.sgml index 1519fe7..7068063 100644 --- a/doc/src/sgml/ref/pgbench.sgml +++ b/doc/src/sgml/ref/pgbench.sgml @@ -895,6 +89

Re: [HACKERS] Proposal: Local indexes for partitioned table

2017-12-29 Thread Alvaro Herrera
I just realized there's a further problem in the area: when a partition is detached from its parent, its indexes are not made independent of the indexes on parent. So they can't be dropped on their own (booh!); and dropping the index on the former parent partitioned table drops the index on the fo

Re: [PATCH] Logical decoding of TRUNCATE

2017-12-29 Thread Andres Freund
Hi, On 2017-12-29 14:15:22 +0100, Marco Nenciarini wrote: > This patch implements support for TRUNCATE statements > in logical replication. The work has mainly done by Simon Riggs then > finished by me. Tests are written by me. > > TRUNCATE is treated as a form of DELETE for the purpose of decidi

Re: Condition variable live lock

2017-12-29 Thread Andres Freund
On 2017-12-29 12:16:20 +1300, Thomas Munro wrote: > Here is one way to fix it: track the wait queue size and use that > number to limit the wakeup loop. See attached. > > That's unbackpatchable though, because it changes the size of struct > ConditionVariable, potentially breaking extensions compi

Re: Deadlock in multiple CIC.

2017-12-29 Thread Andres Freund
On 2017-12-26 13:31:03 -0300, Alvaro Herrera wrote: > It's strange that this has gone undetected for so long. I wonder if > there's an interaction with logical decoding and its historical > snapshot stuff here. I can't see how - did you have a vague theory you could share? Greetings, Andres Fre

Re: Should we nonblocking open FIFO files in COPY?

2017-12-29 Thread Andres Freund
On 2017-12-26 22:30:08 -0800, Robert Haas wrote: > On Tue, Dec 26, 2017 at 7:51 PM, Michael Paquier > wrote: > >> > Hmm. What about the case where we try to open a plain file that's on > >> > an inaccessible filesystem, e.g. due to a disk failure? Allowing > >> > cancel to work just for FIFOs wo

Re: [PATCH] session_replication_role = replica with TRUNCATE

2017-12-29 Thread Petr Jelinek
On 29/12/17 16:53, Marco Nenciarini wrote: > Il 29/12/17 15:14, Petr Jelinek ha scritto: >> >> May be worth documenting that the session_replication_role also affects >> TRUNCATE's interaction with FKs in config.sgml. >> > > The current documentation of session_replication_role GUC is: > > Co

Re: array_ndims never returns zero

2017-12-29 Thread Vladimir Svedov
Maybe if you decide not to touch the code, I should report to documentation mail group, asking to add this special exception to docs?.. Thank you On 29 December 2017 at 19:50, Pavel Stehule wrote: > > > 2017-12-29 17:52 GMT+01:00 Tom Lane : > >> Vladimir Svedov writes: >> > Reading >> > https:

Rangejoin rebased

2017-12-29 Thread Jeff Davis
New rangejoin patch attached. I had previously attempted to make this work well for multiple range join keys, but this patch implements single rangejoin keys only, and the rest of the rangejoin clauses are effectively just rechecks. I believe it can be made effective for multiple rangejoin keys, b

Re: array_ndims never returns zero

2017-12-29 Thread Pavel Stehule
2017-12-29 17:52 GMT+01:00 Tom Lane : > Vladimir Svedov writes: > > Reading > > https://stackoverflow.com/questions/48022753/why-does- > array-ndimsarray-produce-null#48022980 > > confused me much - why array_ndims never returns zero indeed?.. > > Yeah, it's not a very good choice that it returns

Re: Converting plpgsql to use DTYPE_REC for named composite types

2017-12-29 Thread Pavel Stehule
2017-12-29 18:38 GMT+01:00 Tom Lane : > Pavel Stehule writes: > > Interesting part from test: > > > alter table mutable drop column f1; > > alter table mutable add column f1 float8; > > -- currently, this fails due to cached plan for "r.f1 + 1" expression > > select sillyaddone(42); > > ERROR: t

Re: Converting plpgsql to use DTYPE_REC for named composite types

2017-12-29 Thread Tom Lane
Pavel Stehule writes: > Interesting part from test: > alter table mutable drop column f1; > alter table mutable add column f1 float8; > -- currently, this fails due to cached plan for "r.f1 + 1" expression > select sillyaddone(42); > ERROR: type of parameter 4 (double precision) does not match t

Re: [HACKERS] taking stdbool.h into use

2017-12-29 Thread Tom Lane
Alvaro Herrera writes: > Michael Paquier wrote: >> I have looked at 0002 and 0003. Those look good to ship for me. > Yeah, I'd vote to push those right away to see what buildfarm has to > say. That way you can push 0001 shortly after the dust settles (if > any), which will have an effect on the

Re: Converting plpgsql to use DTYPE_REC for named composite types

2017-12-29 Thread Pavel Stehule
Hi 2017-12-29 9:56 GMT+01:00 Pavel Stehule : > Hi > > I'll stick this into the January commitfest, but I'd like to get it >> reviewed and committed pretty soon, because there are follow-on patches >> that need to get done in time for v11 --- in particular, we need to close >> out the lack of plpg

Re: Possible hole in Windows directory restrictions?

2017-12-29 Thread Tom Lane
Jack Christensen writes: > On 12/29/2017 9:56 AM, Tom Lane wrote: >> In https://postgr.es/m/1514541656508-0.p...@n3.nabble.com >> it's reported that "SELECT pg_ls_dir('c:')" works to allow >> display of the root directory on drive C. If true, this >> would be a violation of the principle that the

Re: [PROPOSAL] bracketed-paste support for psql

2017-12-29 Thread Alvaro Herrera
Peter Eisentraut wrote: > On 12/15/17 11:22, Geoff Winkless wrote: > > It occurred to me the other day while people were talking about > > pasting blocks of text creating problems, especially with tabs, that > > xterm bracketed-paste support (also works in at least putty and > > probably others) th

Re: Possible hole in Windows directory restrictions?

2017-12-29 Thread Jack Christensen
On 12/29/2017 9:56 AM, Tom Lane wrote: In https://postgr.es/m/1514541656508-0.p...@n3.nabble.com it's reported that "SELECT pg_ls_dir('c:')" works to allow display of the root directory on drive C. If true, this would be a violation of the principle that the core file access functions only let

Re: array_ndims never returns zero

2017-12-29 Thread Tom Lane
Vladimir Svedov writes: > Reading > https://stackoverflow.com/questions/48022753/why-does-array-ndimsarray-produce-null#48022980 > confused me much - why array_ndims never returns zero indeed?.. Yeah, it's not a very good choice that it returns null for a zero-D array. But it's been like that fo

Re: plpgsql function startup-time improvements

2017-12-29 Thread Tom Lane
"Tels" writes: > On Thu, December 28, 2017 5:43 pm, Tom Lane wrote: >> Which field order were you checking? Are you accounting for alignment >> padding? > ... > Sounds logical, thanx for the detailed explanation. In my test the first 4 > padding bytes are probably not there, because I probably mi

Re: Basebackups reported as idle

2017-12-29 Thread Magnus Hagander
On Fri, Dec 29, 2017 at 3:11 PM, David Steele wrote: > On 12/29/17 6:49 AM, Michael Paquier wrote: > > On Thu, Dec 28, 2017 at 06:21:46PM +0100, Magnus Hagander wrote: > >> On Fri, Dec 22, 2017 at 2:31 AM, Michael Paquier < > michael.paqu...@gmail.com> > >> wrote: > >>> Could you update the patch

Possible hole in Windows directory restrictions?

2017-12-29 Thread Tom Lane
In https://postgr.es/m/1514541656508-0.p...@n3.nabble.com it's reported that "SELECT pg_ls_dir('c:')" works to allow display of the root directory on drive C. If true, this would be a violation of the principle that the core file access functions only let you get at PG-related directories. However

Re: [PATCH] session_replication_role = replica with TRUNCATE

2017-12-29 Thread Marco Nenciarini
Il 29/12/17 15:14, Petr Jelinek ha scritto: > > May be worth documenting that the session_replication_role also affects > TRUNCATE's interaction with FKs in config.sgml. > The current documentation of session_replication_role GUC is: Controls firing of replication-related triggers and rules

Re: Basebackups reported as idle

2017-12-29 Thread Alvaro Herrera
Michael Paquier wrote: > On Thu, Dec 28, 2017 at 06:21:46PM +0100, Magnus Hagander wrote: > > I thought I had, but I can see now that email was a figment of my > > imagination :) > > I'll take that as a fragment instead. Not at all ... https://www.merriam-webster.com/dictionary/figment "somethin

Re: [HACKERS] Commits don't block for synchronous replication

2017-12-29 Thread Simon Riggs
On 1 December 2017 at 02:50, Michael Paquier wrote: > On Fri, Nov 24, 2017 at 11:38 PM, Simon Riggs wrote: >> On 23 November 2017 at 11:11, Michael Paquier >> wrote: >> >>> This is older than the bug report of this thread. All those >>> indications point out that the patch has *not* been commit

Re: [HACKERS] [PATCH] Lockable views

2017-12-29 Thread Tatsuo Ishii
>> >> > 1) Leave as it is (ignore tables appearing in a subquery) >> >> > >> >> > 2) Lock all tables including in a subquery >> >> > >> >> > 3) Check subquery in the view >> > >> >> > So it seem #1 is the most reasonable way to deal with the problem >> >> > assuming that it's user's responsibil

Re: [HACKERS] why not parallel seq scan for slow functions

2017-12-29 Thread Marina Polyakova
Hello everyone in this thread! On 29-11-2017 8:01, Michael Paquier wrote: Moved to next CF for extra reviews. Amit, I would like to ask some questions about your patch (and can you please rebase it on the top of the master?): 1) + path->total_cost -= (target->cost.per_tuple - oldcost.per_

Re: [PATCH] session_replication_role = replica with TRUNCATE

2017-12-29 Thread Craig Ringer
On 29 December 2017 at 22:14, Petr Jelinek wrote: > Hi, > > On 29/12/17 13:01, Marco Nenciarini wrote: > > Hi, > > > > The current behavior of session_replication_role = replica with TRUNCATE > > is not the same of with the other commands. > > It does not check FKs for INSERT/UPDATE/DELETE but it

Re: Add hint about replication slots when nearing wraparound

2017-12-29 Thread Simon Riggs
On 27 December 2017 at 11:39, Michael Paquier wrote: > On Wed, Dec 27, 2017 at 08:47:20AM +0100, Feike Steenbergen wrote: >> Changed the block from a note to a caution, > > Thanks for the new version. > > - "You might also need to commit or roll back old prepared transactions."))); > + "You might

Re: [PATCH] session_replication_role = replica with TRUNCATE

2017-12-29 Thread Petr Jelinek
Hi, On 29/12/17 13:01, Marco Nenciarini wrote: > Hi, > > The current behavior of session_replication_role = replica with TRUNCATE > is not the same of with the other commands. > It does not check FKs for INSERT/UPDATE/DELETE but it does for TRUNCATE, > so one cannot execute TRUNCATE on a table wh

Re: Basebackups reported as idle

2017-12-29 Thread David Steele
On 12/29/17 6:49 AM, Michael Paquier wrote: > On Thu, Dec 28, 2017 at 06:21:46PM +0100, Magnus Hagander wrote: >> On Fri, Dec 22, 2017 at 2:31 AM, Michael Paquier >> wrote: >>> Could you update the patch? >> >> I thought I had, but I can see now that email was a figment of my >> imagination :) >

Re: MCV lists for highly skewed distributions

2017-12-29 Thread John Naylor
On 12/28/17, Jeff Janes wrote: > I want to revive a patch I sent couple years ago to the performance list, > as I have seen the issue pop up repeatedly since then. > If we stored just a few more values, their inclusion in the MCV would mean > they are depleted from the residual count, correctly

array_ndims never returns zero

2017-12-29 Thread Vladimir Svedov
Hi, Reading https://stackoverflow.com/questions/48022753/why-does-array-ndimsarray-produce-null#48022980 confused me much - why array_ndims never returns zero indeed?.. select char_length('') returns zero and according to https://www.postgresql.org/docs/current/static/functions-string.html it shows

Re: TAP test module - PostgresClient

2017-12-29 Thread Tels
On Thu, December 28, 2017 10:14 pm, Tom Lane wrote: > Craig Ringer writes: >> Another option might be to teach the TAP infrastructure and the >> buildfarm >> client how to fetch cpanminus and build DBD::Pg against our build-tree, >> so >> we could use Perl DBI. > > As a buildfarm owner, I'd take

[PATCH] Logical decoding of TRUNCATE

2017-12-29 Thread Marco Nenciarini
Hi, This patch implements support for TRUNCATE statements in logical replication. The work has mainly done by Simon Riggs then finished by me. Tests are written by me. TRUNCATE is treated as a form of DELETE for the purpose of deciding whether to publish, or not. The "TRUNCATE behavior when sess

Re: [HACKERS] path toward faster partition pruning

2017-12-29 Thread Alvaro Herrera
I happened to notice that Ashutosh's patch series at https://www.postgresql.org/message-id/CAFjFpReJhFSoy6DqH0ipFSHd=sLNEkSzAtz4VWCaS-w2jZL=u...@mail.gmail.com has a 0001 patch that modifies the partition_bound_cmp stuff too. Are those conflicting? Ashutosh's commit message: Modify bound c

Re: plpgsql function startup-time improvements

2017-12-29 Thread Tels
Moin, On Thu, December 28, 2017 5:43 pm, Tom Lane wrote: > "Tels" writes: >> On Wed, December 27, 2017 3:38 pm, Tom Lane wrote: >>> Also, I changed PLpgSQL_var.isconst and PLpgSQL_var.notnull from "int" >>> to "bool", which is what they should have been all along, and relocated >>> them in the PL

Re: [HACKERS] taking stdbool.h into use

2017-12-29 Thread Alvaro Herrera
Michael Paquier wrote: > On Thu, Dec 28, 2017 at 01:45:54PM -0500, Peter Eisentraut wrote: > > Here is a new patch set that picks up the best pieces of the recent > > discussions: We use stdbool.h if available, use bool8 in the system > > catalogs, define GinTernaryValue to be the same size as bo

[PATCH] session_replication_role = replica with TRUNCATE

2017-12-29 Thread Marco Nenciarini
Hi, The current behavior of session_replication_role = replica with TRUNCATE is not the same of with the other commands. It does not check FKs for INSERT/UPDATE/DELETE but it does for TRUNCATE, so one cannot execute TRUNCATE on a table when it is possible to DELETE from table without WHERE clause.

Re: Basebackups reported as idle

2017-12-29 Thread Michael Paquier
On Thu, Dec 28, 2017 at 06:21:46PM +0100, Magnus Hagander wrote: > On Fri, Dec 22, 2017 at 2:31 AM, Michael Paquier > wrote: >> Could you update the patch? > > I thought I had, but I can see now that email was a figment of my > imagination :) I'll take that as a fragment instead. The patch as pr

Re: AS OF queries

2017-12-29 Thread Konstantin Knizhnik
On 28.12.2017 20:28, Peter Eisentraut wrote: On 12/28/17 11:36, Konstantin Knizhnik wrote: Attached please find new version of AS OF patch which allows to specify time travel period. Older versions outside this period may be reclaimed by autovacuum. This behavior is controlled by "time_travel_

Fix a Oracle-compatible instr function in the documentation

2017-12-29 Thread Yugo Nagata
Hi, Attached is a patch to fix a very trivial issue of the documentation. The documentation of PL/pgSQL provides sample codes of Oracle-compatible instr functions. However, the behaviour is a little differet. Oracle's instr raises an error when the forth argument value is less than zero, but the

Re: Converting plpgsql to use DTYPE_REC for named composite types

2017-12-29 Thread Pavel Stehule
Hi I'll stick this into the January commitfest, but I'd like to get it > reviewed and committed pretty soon, because there are follow-on patches > that need to get done in time for v11 --- in particular, we need to close > out the lack of plpgsql support for domains-over-composite. > > I didn't ch

Re: [HACKERS] taking stdbool.h into use

2017-12-29 Thread Michael Paquier
On Thu, Dec 28, 2017 at 01:45:54PM -0500, Peter Eisentraut wrote: > An earlier patch I posted defines GinTernaryValue to be the same size as > bool, accounting for different possible sizes of bool. Doh. I forgot this one. Yes that approach is fine. > Here is a new patch set that picks up the best