PROPOSAL: Support global and local disabling of indexes

2022-03-18 Thread Paul Martinez
Hey, hackers, Adding and removing indexes is a regular part of database maintenance, but in a large database, removing an index can be a very risky operation. Removing the wrong index could have disastrous consequences for performance, and it could take tens of minutes, or even hours, to rebuild

Re: [PATCH] Partial foreign key updates in referential integrity triggers

2021-12-01 Thread Paul Martinez
On Wed, Nov 24, 2021 at 10:59 AM Peter Eisentraut wrote: > > I was looking through this example to see if it could be adapted for the > documentation. > > The way the users table is defined, it appears that "id" is actually > unique and the primary key ought to be just (id). The DELETE command >

Re: [PATCH] Partial foreign key updates in referential integrity triggers

2021-11-22 Thread Paul Martinez
On Mon, Nov 22, 2021 at 10:21 PM Zhihong Yu wrote: > > Hi, > + If a foreign key with a SET NULL or SET > + DEFAULT delete action, which columns should be updated. > > which columns should be updated -> the columns that should be updated Done. > + if (fk_del_set_cols) > + { > +

Re: [PATCH] Partial foreign key updates in referential integrity triggers

2021-11-22 Thread Paul Martinez
On Thu, Nov 11, 2021 at 4:34 AM Peter Eisentraut wrote: > > I have reviewed your patch > referential-actions-on-delete-only-set-cols-v3.patch. Attached are two > patches that go on top of yours that contain my recommended changes. > > Basically, this all looks pretty good to me. My changes are

Re: [PATCH] Partial foreign key updates in referential integrity triggers

2021-10-26 Thread Paul Martinez
On Thu, Sep 2, 2021 at 1:55 PM Zhihong Yu wrote: > > Hi, > + case RI_TRIGTYPE_DELETE: > + queryno = is_set_null > + ? RI_PLAN_ONDELETE_SETNULL_DOUPDATE > + : RI_PLAN_ONDELETE_SETDEFAULT_DOUPDATE; > > Should the new symbols be renamed ? > >

Re: [PATCH] Partial foreign key updates in referential integrity triggers

2021-09-02 Thread Paul Martinez
On Wed, Sep 1, 2021 at 4:11 AM Daniel Gustafsson wrote: > This patch no longer applies, can you please submit a rebased version? It > currently fails on catversion.h, to keep that from happening repeatedly you > can > IMO skip that from the patch submission. Ah, understood. Will do that in

Re: Allow composite foreign keys to reference a superset of unique constraint columns?

2021-08-17 Thread Paul Martinez
On Tue, Aug 17, 2021 at 8:41 AM Jack Christensen wrote: > > The only way to ensure a user can only be a member of a group in the same > tenant is to user_group_memberships.tenant_id be part of the foreign key. And > that will only work with a unique key on id and tenant_id in both users and >

Allow composite foreign keys to reference a superset of unique constraint columns?

2021-08-16 Thread Paul Martinez
Hey, hackers! While working with some foreign keys, I noticed some mildly unexpected behavior. The columns referenced by a unique constraint must naturally have a unique constraint on them: CREATE TABLE foo (a integer); CREATE TABLE bar (x integer REFERENCES foo(a)); > ERROR: there is no unique

Re: [PATCH] Partial foreign key updates in referential integrity triggers

2021-08-04 Thread Paul Martinez
route. This is referential-actions-on-delete-only-set-cols-v1.patch. [1]: http://web.cecs.pdx.edu/~len/sql1999.pdf On Wed, Jul 14, 2021 at 12:36 PM Ibrar Ahmed wrote: > > > > On Wed, Jul 14, 2021 at 6:51 PM Peter Eisentraut > wrote: >> >> >> On 05.01.21 22:40, Paul M

Re: [PATCH] Note effect of max_replication_slots on subscriber side in documentation.

2021-02-26 Thread Paul Martinez
On Fri, Feb 26, 2021 at 5:22 AM Amit Kapila wrote: > > https://www.postgresql.org/docs/devel/logical-replication-config.html > Ah, yep. I added a clause to the end of the sentence to clarify why we're using max_replication_slots here: - The subscriber also requires the max_replication_slots to

Re: [PATCH] Note effect of max_replication_slots on subscriber side in documentation.

2021-02-26 Thread Paul Martinez
On Thu, Feb 25, 2021 at 5:31 AM Amit Kapila wrote: > > For docs only patch, I have few suggestions: > 1. On page [1], it is not very clear that we are suggesting to set > max_replication_slots for origins whereas your new doc patch has > clarified it, can we update the other page as well. Sorry,

Re: [PATCH] Note effect of max_replication_slots on subscriber side in documentation.

2021-02-24 Thread Paul Martinez
) is sufficient, but one of them should definitely be done to clear up the confusion. - Paul On Tue, Feb 16, 2021 at 1:03 PM Paul Martinez wrote: > Hey, all, > > The configuration parameter max_replication_slots is most notably used > to control how many replication slots ca

Re: [PATCH] pg_hba.conf error messages for logical replication connections

2021-02-16 Thread Paul Martinez
On Tue, Feb 16, 2021 at 2:22 AM Amit Kapila wrote: > > I don't think we need to update the error messages, it makes the code > a bit difficult to parse without much benefit. How about just adding > errdetail? See attached and let me know what you think? > Yeah, I think that looks good. Thanks!

Re: [PATCH] pg_hba.conf error messages for logical replication connections

2021-02-01 Thread Paul Martinez
On Fri, Jan 29, 2021 at 8:41 PM Amit Kapila wrote: > > Yeah, hints or more details might improve the situation but I am not > sure we want to add more branching here. Can we write something > similar to HOSTNAME_LOOKUP_DETAIL for hints? Also, I think what you > are proposing to write is more of a

Re: [PATCH] pg_hba.conf error messages for logical replication connections

2021-01-30 Thread Paul Martinez
On Thu, Jan 28, 2021 at 8:17 PM Amit Kapila wrote: > > What exactly are you bothered about here? Is the database name not > present in the message your concern or the message uses 'replication' > but actually it doesn't relate to 'replication' specified in > pg_hba.conf your concern? I think with

[PATCH] pg_hba.conf error messages for logical replication connections

2021-01-28 Thread Paul Martinez
Hey, all, When creating a logical replication connection that isn't allowed by the current pg_hba.conf, the error message states that a "replication connection" is not allowed. This error message is confusing because although the user is trying to create a replication connection and specified

Re: Why does creating logical replication subscriptions require superuser?

2021-01-22 Thread Paul Martinez
> We successfully created exploits against Aiven and AWS RDS services gaining > superuser with their ways of subscription creation (and reported > vulnerabilities, of course). Probably, you have this (not so scary) > vulnerability too. Can you share the rough idea of how these exploits work? What

Why does creating logical replication subscriptions require superuser?

2021-01-21 Thread Paul Martinez
Hey, all, I'm working with native logical replication, and I don't fully understand why logical replication subscribers need to be superusers, nor do I fully understand the implication of some of the comments made on this page:

[PATCH] Partial foreign key updates in referential integrity triggers

2021-01-06 Thread Paul Martinez
Hey, hackers! I've created a patch to better support referential integrity constraints when using composite primary and foreign keys. This patch allows creating a foreign key using the syntax: FOREIGN KEY (tenant_id, fk_id) REFERENCES fktable ON DELETE SET NULL (fk_id) which means that only

Re: [PATCH] Simplify permission checking logic in user.c

2020-12-30 Thread Paul Martinez
On Wed, Dec 30, 2020 at 12:28 PM Andrey Borodin wrote: > I think that sharing "various small changes to permission checks" is a really > good idea. > > > 30 дек. 2020 г., в 20:39, Stephen Frost написал(а): > > In other words, I suspect people would be happier if we > > provided a way for

[PATCH] Simplify permission checking logic in user.c

2020-12-29 Thread Paul Martinez
Hey, hackers, As part of building Postgres for a managed environment in Google Cloud SQL, we've made various small changes to permission checks to carefully limit what customers have access to. We were making some changes in src/backend/commands/user.c and noticed some clunky logic related to

Proposal: Adding isbgworker column to pg_stat_activity

2020-12-02 Thread Paul Martinez
Hey, all, It is currently slightly difficult to determine how many background worker processes are currently running, which is useful when trying to manage the max_worker_processes parameter. It seems the best bet is to use the backend_type column and filter out the many types that are defined in

Proper usage of ndistinct vs. dependencies extended statistics

2019-04-10 Thread Paul Martinez
Hello, I have some questions about the different types of extended statistics that were introduced in Postgres 10. - Which types of queries are each statistic type supposed to improve? - When should one type of statistic be used over the other? Should they both always be used? We have a

Re: PATCH: Include all columns in default names for foreign key constraints.

2019-03-09 Thread Paul Martinez
Thanks for the comments! On Fri, Feb 8, 2019 at 2:11 AM Peter Eisentraut wrote: > > On 13/01/2019 01:55, Paul Martinez wrote: > > I pretty much just copied and pasted the implementation from > > ChooseIndexNameAddition and placed it in src/backend/commands/tablecmds.c. >

Re: [PROPOSAL] ON DELETE SET NULL () for Foreign Key Constraints

2019-01-19 Thread Paul Martinez
On Sat, Jan 19, 2019 at 5:12 PM Tom Lane wrote: > > Paul Martinez writes: > > I have a proposal for a feature to add to Postgres. I believe it is a > > natural > > extension to the current standard SQL ON DELETE SET NULL behavior when using > > composite foreign ke

[PROPOSAL] ON DELETE SET NULL () for Foreign Key Constraints

2019-01-19 Thread Paul Martinez
Hello! I have a proposal for a feature to add to Postgres. I believe it is a natural extension to the current standard SQL ON DELETE SET NULL behavior when using composite foreign keys. The basic idea is that you can specify which columns to set to NULL in the DELETE trigger created by a foreign

PATCH: Include all columns in default names for foreign key constraints.

2019-01-12 Thread Paul Martinez
e protocol is here to get this merged; should I add this patch to the 2019-03 Commitfest? Happy to hear any feedback! - Paul Martinez foreign-key-constraint-names-v1.patch Description: Binary data