Re: Foreign keys and partitioned tables

2018-04-20 Thread Alvaro Herrera
Alvaro Herrera wrote: > After wasting some time trying to resolve > "minor last minute issues", I decided to reduce the scope for now: in > the current patch, it's allowed to have foreign keys in partitioned > tables, but it is not possible to have foreign keys that point to > partitioned tables.

Re: Foreign keys and partitioned tables

2018-04-04 Thread Alvaro Herrera
Robert Haas wrote: > I suspect that this leads to bugs under concurrency, something to do > with crosscheck_snapshot, but I couldn't say exactly what the problem > is off the top of my head. My hope is that partitioning might be > immune on the strength of knowing that any given tuple could only

Re: Foreign keys and partitioned tables

2018-04-04 Thread Alvaro Herrera
Tom Lane wrote: > Alvaro Herrera writes: > > Thanks, pushed. > > This has broken the selinux regression tests, evidently because it > removed ONLY from the emitted FK test queries. While we could change > the expected results, I would first like to hear a defense of why that > change is a good i

Re: Foreign keys and partitioned tables

2018-04-04 Thread Tom Lane
Alvaro Herrera writes: > Thanks, pushed. This has broken the selinux regression tests, evidently because it removed ONLY from the emitted FK test queries. While we could change the expected results, I would first like to hear a defense of why that change is a good idea. It seems highly likely t

Re: Foreign keys and partitioned tables

2018-04-04 Thread Alvaro Herrera
Peter Eisentraut wrote: > On 4/3/18 15:11, Alvaro Herrera wrote: > > 0003 is the main patch, which is a bit changed from v4, notably to cover > > your review comments: > > Looks good now. Thanks, pushed. I added a couple of test cases for ON UPDATE/DELETE and MATCH PARTIAL, after noticing that r

Re: Foreign keys and partitioned tables

2018-04-04 Thread Alvaro Herrera
Robert Haas wrote: > On Sun, Dec 31, 2017 at 2:43 PM, Alvaro Herrera > wrote: > > This patch removes all the ONLY markers from queries in ri_triggers.c. > > That makes the queries work for the new use case, but I haven't figured > > if it breaks things for other use cases. I suppose not, since re

Re: Foreign keys and partitioned tables

2018-04-04 Thread Peter Eisentraut
On 4/3/18 15:11, Alvaro Herrera wrote: > 0003 is the main patch, which is a bit changed from v4, notably to cover > your review comments: Looks good now. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Re: Foreign keys and partitioned tables

2018-04-03 Thread Alvaro Herrera
Peter Eisentraut wrote: > > 0002 is a fixup for a bug in the row triggers patch: I had a restriction > > earlier that triggers declared internal were not cloned, and I seem to > > have lost it in rebase. Reinstate it. > > Hmm, doesn't cause any test changes? Here's a test case: create table t

Re: Foreign keys and partitioned tables

2018-04-03 Thread Alvaro Herrera
Alvaro Herrera wrote: > While adding some more tests for the "action" part (i.e. updates and > deletes on the referenced table) I came across a bug that was causing > the server to crash ... but it's actually a preexisting bug in an > assert. The fix is in 0001. Yeah, it's a live bug that only ma

Re: Foreign keys and partitioned tables

2018-04-03 Thread Alvaro Herrera
While adding some more tests for the "action" part (i.e. updates and deletes on the referenced table) I came across a bug that was causing the server to crash ... but it's actually a preexisting bug in an assert. The fix is in 0001. 0002 I already posted: don't clone row triggers that are declare

Re: Foreign keys and partitioned tables

2018-04-02 Thread Peter Eisentraut
Comments on the code: @@ -7226,12 +7235,23 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, * numbers) */ if (pkrel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE) + { + /* fix recursion in ATExecValidateConstraint to enable this case */ + if (fkconstrai

Re: Foreign keys and partitioned tables

2018-04-02 Thread Peter Eisentraut
On 3/31/18 18:21, Alvaro Herrera wrote: > Yeah, I started by putting what I thought was going to be just ALTER > TABLE in that test, then moved to the other file and added what I > thought were more complete tests there and failed to move stuff to > alter_table. Honestly, I think these should most

Re: Foreign keys and partitioned tables

2018-03-31 Thread Alvaro Herrera
Peter Eisentraut wrote: > On 3/29/18 23:19, Alvaro Herrera wrote: > > 0003 is the matter of interest. This is essentially the same code I > > posted earlier, rebased to the committed row triggers patch, with a few > > minor bug fixes and some changes in the regression tests to try and make > > the

Re: Foreign keys and partitioned tables

2018-03-31 Thread Peter Eisentraut
On 3/29/18 23:19, Alvaro Herrera wrote: > 0003 is the matter of interest. This is essentially the same code I > posted earlier, rebased to the committed row triggers patch, with a few > minor bug fixes and some changes in the regression tests to try and make > them more comprehensive, including le

Re: Foreign keys and partitioned tables

2018-03-31 Thread Peter Eisentraut
On 3/29/18 23:19, Alvaro Herrera wrote: > 0001 prohibits having foreign keys pointing to partitioned tables, as > discussed above. This is already prohibited. You get an error ERROR: cannot reference partitioned table "fk_partitioned_pk" Your patch 0001 just adds the same error check a few lin

Re: Foreign keys and partitioned tables

2018-03-29 Thread Alvaro Herrera
Here's an updated version. After wasting some time trying to resolve "minor last minute issues", I decided to reduce the scope for now: in the current patch, it's allowed to have foreign keys in partitioned tables, but it is not possible to have foreign keys that point to partitioned tables. I ha

Re: Foreign keys and partitioned tables

2018-03-27 Thread Alvaro Herrera
Peter Eisentraut wrote: > Since the row triggers patch has been committed, do you plan to send an > update on this patch? Yes, I'll do that shortly. -- Álvaro Herrerahttps://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Re: Foreign keys and partitioned tables

2018-03-27 Thread Peter Eisentraut
On 3/11/18 22:40, Alvaro Herrera wrote: > [ Resending an email from yesterday. Something is going very wrong with > my outgoing mail provider :-( ] > > Rebase of the prior code, on top of the improved row triggers posted > elsewhere. I added some more tests too, and fixed a couple of small > bug

Re: Foreign keys and partitioned tables

2018-03-11 Thread Alvaro Herrera
[ Resending an email from yesterday. Something is going very wrong with my outgoing mail provider :-( ] Rebase of the prior code, on top of the improved row triggers posted elsewhere. I added some more tests too, and fixed a couple of small bugs. (This includes the patches I just posted in the

Re: Foreign keys and partitioned tables

2018-01-25 Thread Robert Haas
On Sun, Dec 31, 2017 at 2:43 PM, Alvaro Herrera wrote: > This patch removes all the ONLY markers from queries in ri_triggers.c. > That makes the queries work for the new use case, but I haven't figured > if it breaks things for other use cases. I suppose not, since regular > inheritance isn't sup

Re: Foreign keys and partitioned tables

2018-01-24 Thread Alvaro Herrera
Alvaro Herrera wrote: > This patch enables foreign key constraints to and from partitioned > tables. This version is rebased on current master. 0001: fix for a get_relation_info bug in current master. Posted in <20180124174134.ma4ui2kczmqwb4um@alvherre.pgsql> 0002: Allows local partitioned

Re: Foreign keys and partitioned tables

2017-12-31 Thread Alvaro Herrera
-- Álvaro Herrerahttps://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services 0001-Local-partitioned-indexes.patch.gz Description: application/gunzip >From b7e85e873ba77509793180e9076295fae2fd88a7 Mon Sep 17 00:00:00 2001 From: Alvaro Herre