Re: NOT ENFORCED constraint feature

2025-04-02 Thread Amul Sul
On Wed, Apr 2, 2025 at 6:02 PM Peter Eisentraut wrote: > > On 28.03.25 14:27, Amul Sul wrote: > > On Fri, Mar 28, 2025 at 3:34 PM Ashutosh Bapat > > wrote: > >> > >> On Thu, Mar 27, 2025 at 6:25 PM Amul Sul wrote: > >> > >>> > >>> I am not sure how to make such tests stable enough since the trig

Re: NOT ENFORCED constraint feature

2025-04-02 Thread Peter Eisentraut
On 28.03.25 14:27, Amul Sul wrote: On Fri, Mar 28, 2025 at 3:34 PM Ashutosh Bapat wrote: On Thu, Mar 27, 2025 at 6:25 PM Amul Sul wrote: I am not sure how to make such tests stable enough since the trigger name involves OIDs. In count check, I tried adjusting the join condition to ensure t

Re: NOT ENFORCED constraint feature

2025-03-28 Thread Ashutosh Bapat
On Thu, Mar 27, 2025 at 6:25 PM Amul Sul wrote: > > I am not sure how to make such tests stable enough since the trigger > name involves OIDs. In count check, I tried adjusting the join > condition to ensure that I get the exact same type of constraint > w.r.t. trigger relation and the constraint

Re: NOT ENFORCED constraint feature

2025-03-27 Thread Álvaro Herrera
On 2025-Mar-27, Amul Sul wrote: > On Thu, Mar 27, 2025 at 6:28 PM Peter Eisentraut wrote: > > That said, is there a simpler way? Patch 0003 appears to add a lot of > > complexity. Could we make this simpler by saying, if you have otherwise > > matching constraints with different enforceability

Re: NOT ENFORCED constraint feature

2025-03-27 Thread Amul Sul
On Thu, Mar 27, 2025 at 6:28 PM Peter Eisentraut wrote: > > On 25.03.25 17:48, Peter Eisentraut wrote: > > I have committed patches 0001 through 0003. I made some small changes: > > > I will work through the remaining patches. It looks good to me so far. > > For the time being, here are the rema

Re: NOT ENFORCED constraint feature

2025-03-26 Thread Ashutosh Bapat
On Wed, Mar 26, 2025 at 9:33 AM Amul Sul wrote: > On Tue, Mar 25, 2025 at 10:18 PM Peter Eisentraut > wrote: > > > > On 21.03.25 06:58, Amul Sul wrote: > > > > > > [] > > > Attached is the updated version, where the commit messages for patch > > > 0005 and 0006 have been slightly corrected.

Re: NOT ENFORCED constraint feature

2025-03-26 Thread Amul Sul
On Wed, Mar 26, 2025 at 12:29 PM Álvaro Herrera wrote: > > On 2025-Mar-26, Amul Sul wrote: > > > The reason for the change is to revert to the behavior before commit > > #80d7f990496b1c, where recursion occurred regardless of the > > changed flags. This is also described in the header comment for

Re: NOT ENFORCED constraint feature

2025-03-25 Thread Álvaro Herrera
On 2025-Mar-26, Amul Sul wrote: > The reason for the change is to revert to the behavior before commit > #80d7f990496b1c, where recursion occurred regardless of the > changed flags. This is also described in the header comment for > ATExecAlterConstrDeferrability() (earlier it was for > ATExecAlte

Re: NOT ENFORCED constraint feature

2025-03-25 Thread Amul Sul
On Tue, Mar 25, 2025 at 10:18 PM Peter Eisentraut wrote: > > On 21.03.25 06:58, Amul Sul wrote: > > > > [] > > Attached is the updated version, where the commit messages for patch > > 0005 and 0006 have been slightly corrected. Additionally, a few code > > comments have been updated to consist

Re: NOT ENFORCED constraint feature

2025-03-25 Thread Peter Eisentraut
On 21.03.25 06:58, Amul Sul wrote: I think the next step here is that you work to fix Álvaro's concerns about the recursion structure. Yes, I worked on that in the attached version. I refactored ATExecAlterConstraintInternal() and moved the code that updates the pg_constraint entry into a separ

Re: NOT ENFORCED constraint feature

2025-03-18 Thread Álvaro Herrera
On 2025-Mar-12, Amul Sul wrote: > On Tue, Mar 11, 2025 at 11:13 PM Peter Eisentraut > wrote: > > I think the next step here is that you work to fix Álvaro's concerns > > about the recursion structure. > > Yes, I worked on that in the attached version. I refactored > ATExecAlterConstraintIntern

Re: NOT ENFORCED constraint feature

2025-03-15 Thread Alexandra Wang
Hi Amul, On Thu, Feb 27, 2025 at 12:57 AM Amul Sul wrote: > Attached is the rebased patch set against the latest master head, > which also includes a *new* refactoring patch (0001). In this patch, > I’ve re-added ATExecAlterChildConstr(), which is required for the main > feature patch (0008) to

Re: NOT ENFORCED constraint feature

2025-03-11 Thread Peter Eisentraut
I have committed the first three refactoring patches (v16-0001, v16-0002, v16-0003). (I guess Álvaro didn't like the first one, so I suppose I'll revert that one, but it's a simple one, so you can proceed either way.) I think the next step here is that you work to fix Álvaro's concerns about

Re: NOT ENFORCED constraint feature

2025-03-11 Thread Álvaro Herrera
On 2025-Feb-28, Amul Sul wrote: > Yeah, that was intentional. I wanted to avoid recursion again by > hitting ATExecAlterChildConstr() at the end of > ATExecAlterConstraintInternal(). Also, I realized the value doesn’t > matter since recurse = false is explicitly set inside the > cmdcon->alterEnfor

Re: NOT ENFORCED constraint feature

2025-02-27 Thread Amul Sul
On Thu, Feb 27, 2025 at 4:48 PM Álvaro Herrera wrote: > > On 2025-Feb-27, Amul Sul wrote: > > > Attached is the rebased patch set against the latest master head, > > which also includes a *new* refactoring patch (0001). In this patch, > > I’ve re-added ATExecAlterChildConstr(), which is required f

Re: NOT ENFORCED constraint feature

2025-02-27 Thread Álvaro Herrera
On 2025-Feb-27, Amul Sul wrote: > Attached is the rebased patch set against the latest master head, > which also includes a *new* refactoring patch (0001). In this patch, > I’ve re-added ATExecAlterChildConstr(), which is required for the main > feature patch (0008) to handle recursion from differ

Re: NOT ENFORCED constraint feature

2025-02-18 Thread Álvaro Herrera
On 2025-Feb-18, Amul Sul wrote: > The patch looks quite reasonable, but I’m concerned that renaming > ATExecAlterConstrRecurse() and ATExecAlterChildConstr() exclusively > for deferrability might require the enforceability patch to duplicate > these functions, even though some operations (e.g., pg

Re: NOT ENFORCED constraint feature

2025-02-17 Thread Amul Sul
On Tue, Feb 18, 2025 at 12:47 AM Álvaro Herrera wrote: > > Hello, > > On 2025-Feb-17, Amul Sul wrote: > > > I have renamed AlterConstraintStmt to ATAlterConstraint as per your > > suggestion in the attached version. Apart from this, there are no > > other changes, as the final behavior is still un

Re: NOT ENFORCED constraint feature

2025-02-17 Thread Álvaro Herrera
Hello, On 2025-Feb-17, Amul Sul wrote: > I have renamed AlterConstraintStmt to ATAlterConstraint as per your > suggestion in the attached version. Apart from this, there are no > other changes, as the final behavior is still unclear based on the > discussions so far. Okay, thanks. I've taken yo

Re: NOT ENFORCED constraint feature

2025-02-16 Thread Amul Sul
On Fri, Feb 14, 2025 at 8:41 PM Ashutosh Bapat wrote: > > On Thu, Feb 13, 2025 at 5:27 PM Álvaro Herrera > wrote: > > > > On 2025-Feb-13, Ashutosh Bapat wrote: > > > > > > So considering that, I think a three-state system makes more sense. > > > > Something like: > > > > > > > > 1) NOT ENFORCED

Re: NOT ENFORCED constraint feature

2025-02-14 Thread Isaac Morland
On Fri, 14 Feb 2025 at 10:11, Ashutosh Bapat wrote: > > > I think, what you intend to say is clearer with 4 state system {NE, E} > > > * {NV, V} = {(NE, NV), (NE, V), (E, NV), (E, V)} where (NE, V) is > > > unreachable. Let's name them S1, S2, S3, S4 respectively. > > [...] > > > Notice that the

Re: NOT ENFORCED constraint feature

2025-02-14 Thread Ashutosh Bapat
On Thu, Feb 13, 2025 at 5:27 PM Álvaro Herrera wrote: > > On 2025-Feb-13, Ashutosh Bapat wrote: > > > > So considering that, I think a three-state system makes more sense. > > > Something like: > > > > > > 1) NOT ENFORCED -- no data is checked > > > 2) NOT VALID -- existing data is unchecked, new

Re: NOT ENFORCED constraint feature

2025-02-13 Thread Álvaro Herrera
On 2025-Feb-13, Ashutosh Bapat wrote: > > So considering that, I think a three-state system makes more sense. > > Something like: > > > > 1) NOT ENFORCED -- no data is checked > > 2) NOT VALID -- existing data is unchecked, new data is checked > > 3) ENFORCED -- all data is checked > > > > Transit

Re: NOT ENFORCED constraint feature

2025-02-12 Thread Ashutosh Bapat
On Wed, Feb 12, 2025 at 8:15 PM Peter Eisentraut wrote: > > On 12.02.25 12:13, Álvaro Herrera wrote: > > On 2025-Feb-12, Ashutosh Bapat wrote: > > > >> I have been asking a different question: What's the use of > >> not-enforced constraints if we don't allow VALID, NOT ENFORCED state > >> for them

Re: NOT ENFORCED constraint feature

2025-02-12 Thread Peter Eisentraut
On 12.02.25 12:13, Álvaro Herrera wrote: On 2025-Feb-12, Ashutosh Bapat wrote: I have been asking a different question: What's the use of not-enforced constraints if we don't allow VALID, NOT ENFORCED state for them? That's a question for the SQL standards committee. They may serve schema do

Re: NOT ENFORCED constraint feature

2025-02-12 Thread Peter Eisentraut
On 11.02.25 14:36, Álvaro Herrera wrote: On 2025-Feb-10, Isaac Morland wrote: I'm having a lot of trouble understanding the operational distinction between your 'u' and 'U'. If it's not enforced, it cannot be assumed to be valid, regardless of whether it was valid in the past. I'm not sure what

Re: NOT ENFORCED constraint feature

2025-02-12 Thread Álvaro Herrera
On 2025-Feb-12, Ashutosh Bapat wrote: > I have been asking a different question: What's the use of > not-enforced constraints if we don't allow VALID, NOT ENFORCED state > for them? That's a question for the SQL standards committee. They may serve schema documentation purposes, for example. http

Re: NOT ENFORCED constraint feature

2025-02-11 Thread Ashutosh Bapat
On Tue, Feb 11, 2025 at 9:09 PM Isaac Morland wrote: > > On Tue, 11 Feb 2025 at 08:36, Álvaro Herrera wrote: >> >> On 2025-Feb-10, Isaac Morland wrote: >> >> > I'm having a lot of trouble understanding the operational distinction >> > between your 'u' and 'U'. If it's not enforced, it cannot be a

Re: NOT ENFORCED constraint feature

2025-02-11 Thread Isaac Morland
On Tue, 11 Feb 2025 at 08:36, Álvaro Herrera wrote: > On 2025-Feb-10, Isaac Morland wrote: > > > I'm having a lot of trouble understanding the operational distinction > > between your 'u' and 'U'. If it's not enforced, it cannot be assumed to > be > > valid, regardless of whether it was valid in

Re: NOT ENFORCED constraint feature

2025-02-11 Thread Álvaro Herrera
On 2025-Feb-10, Isaac Morland wrote: > I'm having a lot of trouble understanding the operational distinction > between your 'u' and 'U'. If it's not enforced, it cannot be assumed to be > valid, regardless of whether it was valid in the past. I'm not sure what I > think of a single character vs. 2

Re: NOT ENFORCED constraint feature

2025-02-10 Thread Isaac Morland
On Mon, 10 Feb 2025 at 13:48, Álvaro Herrera wrote: I think this proposed state of affairs is problematic. Current queries > that assume that pg_constraint.convalidated means that a constraint is > validated would be broken. My suggestion at this point is that instead of > adding a separate boo

Re: NOT ENFORCED constraint feature

2025-02-10 Thread Álvaro Herrera
On Mon, Feb 10, 2025, at 7:03 AM, Amul Sul wrote: > Attached patch implemented this behaviour. To achieve this, we have to > revert (see 0007) some committed code and relax the restriction that > the NOT ENFORCED constraint must also be NOT VALID. Now, NOT ENFORCED > and NOT VALID are independent s

Re: NOT ENFORCED constraint feature

2025-02-04 Thread Alvaro Herrera
On 2025-Feb-04, Peter Eisentraut wrote: > On 03.02.25 08:50, Alvaro Herrera wrote: > > On 2025-Feb-03, Ashutosh Bapat wrote: > > > > > VALID, NOT ENFORCED changed to VALID, ENFORCED - data validation > > > required, constraint is enforced > > There's no such thing as a VALID NOT ENFORCED constrai

Re: NOT ENFORCED constraint feature

2025-02-04 Thread Peter Eisentraut
On 03.02.25 08:50, Alvaro Herrera wrote: On 2025-Feb-03, Ashutosh Bapat wrote: VALID, NOT ENFORCED changed to VALID, ENFORCED - data validation required, constraint is enforced There's no such thing as a VALID NOT ENFORCED constraint. It just cannot exist. The way I interpret this is that t

Re: NOT ENFORCED constraint feature

2025-02-04 Thread Peter Eisentraut
On 03.02.25 13:19, Alvaro Herrera wrote: On 2025-Feb-03, Ashutosh Bapat wrote: ``` If the constraint is NOT ENFORCED, the database system will not check the constraint. It is then up to the application code to ensure that the constraints are satisfied. The database

Re: NOT ENFORCED constraint feature

2025-02-04 Thread Peter Eisentraut
On 03.02.25 06:19, Ashutosh Bapat wrote: Here's how I see the state conversions happening. NOT VALID, NOT ENFORCED changed to NOT_VALID, ENFORCED - no data validation required, constraint is enforced on the new tuples/changes NOT VALID, ENFORCED changed to NOT VALID, NOT ENFORCED - no data valid

Re: NOT ENFORCED constraint feature

2025-02-03 Thread Ashutosh Bapat
On Mon, Feb 3, 2025 at 5:55 PM Alvaro Herrera wrote: > > On 2025-Feb-03, Ashutosh Bapat wrote: > > > ``` > > If the > > constraint is NOT ENFORCED, the database system > > will > > not check the constraint. It is then up to the application code to > > ensure that the cons

Re: NOT ENFORCED constraint feature

2025-02-03 Thread Alvaro Herrera
On 2025-Feb-03, Ashutosh Bapat wrote: > ``` > If the > constraint is NOT ENFORCED, the database system will > not check the constraint. It is then up to the application code to > ensure that the constraints are satisfied. The database system might > still assume tha

Re: NOT ENFORCED constraint feature

2025-02-03 Thread Ashutosh Bapat
On Mon, Feb 3, 2025 at 1:20 PM Alvaro Herrera wrote: > > On 2025-Feb-03, Ashutosh Bapat wrote: > > > VALID, NOT ENFORCED changed to VALID, ENFORCED - data validation > > required, constraint is enforced > > There's no such thing as a VALID NOT ENFORCED constraint. It just > cannot exist. The doc

Re: NOT ENFORCED constraint feature

2025-02-02 Thread Alvaro Herrera
On 2025-Feb-03, Ashutosh Bapat wrote: > VALID, NOT ENFORCED changed to VALID, ENFORCED - data validation > required, constraint is enforced There's no such thing as a VALID NOT ENFORCED constraint. It just cannot exist. > NOT VALID, NOT ENFORCED changed to NOT_VALID, ENFORCED - no data > valida

Re: NOT ENFORCED constraint feature

2025-02-02 Thread Amul Sul
On Mon, Feb 3, 2025 at 10:49 AM Ashutosh Bapat wrote: > > On Mon, Feb 3, 2025 at 9:57 AM Amul Sul wrote: > > > > On Fri, Jan 31, 2025 at 7:10 PM Alvaro Herrera > > wrote: > > > > > > On 2025-Jan-31, Ashutosh Bapat wrote: > > > > > > > But if the constraint is NOT VALID and later marked as NOT E

Re: NOT ENFORCED constraint feature

2025-02-02 Thread Ashutosh Bapat
On Mon, Feb 3, 2025 at 9:57 AM Amul Sul wrote: > > On Fri, Jan 31, 2025 at 7:10 PM Alvaro Herrera > wrote: > > > > On 2025-Jan-31, Ashutosh Bapat wrote: > > > > > But if the constraint is NOT VALID and later marked as NOT ENFORCED, > > > what is expected behaviour while changing it to ENFORCED?

Re: NOT ENFORCED constraint feature

2025-02-02 Thread Amul Sul
On Fri, Jan 31, 2025 at 7:10 PM Alvaro Herrera wrote: > > On 2025-Jan-31, Ashutosh Bapat wrote: > > > But if the constraint is NOT VALID and later marked as NOT ENFORCED, > > what is expected behaviour while changing it to ENFORCED? > > I think what you want is a different mode that would be ENFOR

Re: NOT ENFORCED constraint feature

2025-02-02 Thread Amul Sul
On Sat, Feb 1, 2025 at 8:31 PM jian he wrote: > > [...] > So the code should only call AlterConstrTriggerDeferrability, > not call ATExecAlterConstrEnforceability? Right. Thank you for the report. We need to know whether the enforceability and/or deferability has actually been set or not before c

Re: NOT ENFORCED constraint feature

2025-02-01 Thread jian he
hi. after applying the v11-0002 to v11-0006. there is a bug in ATExecAlterConstrRecurse, i think. in ATExecAlterConstrRecurse, after applying the patch, the code is if (currcon->condeferrable != cmdcon->deferrable || currcon->condeferred != cmdcon->initdeferred || currcon->conenforced !=

Re: NOT ENFORCED constraint feature

2025-01-31 Thread Alvaro Herrera
On 2025-Jan-31, Ashutosh Bapat wrote: > But if the constraint is NOT VALID and later marked as NOT ENFORCED, > what is expected behaviour while changing it to ENFORCED? I think what you want is a different mode that would be ENFORCED NOT VALID, which would be an extension of the standard, because

Re: NOT ENFORCED constraint feature

2025-01-31 Thread Ashutosh Bapat
On Wed, Jan 29, 2025 at 6:18 PM Amul Sul wrote: > > On Tue, Jan 28, 2025 at 9:47 PM Peter Eisentraut wrote: > > > > > In 0006, this change in the test output should be improved: > > > > > > -- XXX: error message is misleading here > > > ALTER TABLE unique_tbl ALTER CONSTRAINT unique_tbl_i_key

Re: NOT ENFORCED constraint feature

2025-01-28 Thread Peter Eisentraut
On 28.01.25 11:58, Amul Sul wrote: This behavior is not correct: +-- Changing it back to ENFORCED will leave the constraint in the NOT VALID state +ALTER TABLE FKTABLE ALTER CONSTRAINT fktable_ftest1_fkey ENFORCED; +-- Which needs to be explicitly validated. +ALTER TABLE FKTABLE VALIDATE CONSTRA

Re: NOT ENFORCED constraint feature

2025-01-28 Thread Amul Sul
On Tue, Jan 28, 2025 at 4:01 PM Peter Eisentraut wrote: > > On 20.01.25 17:53, Amul Sul wrote: > >> Attached is a new set of patches. Please ignore patch 0001 here, which > >> was posted separately [1] -- proposes allowing invalid foreign key > >> constraints on partitioned tables. Patch 0002 refa

Re: NOT ENFORCED constraint feature

2025-01-28 Thread Peter Eisentraut
On 20.01.25 17:53, Amul Sul wrote: Attached is a new set of patches. Please ignore patch 0001 here, which was posted separately [1] -- proposes allowing invalid foreign key constraints on partitioned tables. Patch 0002 refactors tryAttachPartitionForeignKey(), primarily needed by the new patch v9

Re: NOT ENFORCED constraint feature

2025-01-16 Thread Amul Sul
On Thu, Jan 16, 2025 at 6:07 PM Peter Eisentraut wrote: > > On 11.01.25 18:26, Amul Sul wrote: > > On Saturday, 11 January 2025, Peter Eisentraut > > wrote: > > > > I have applied v8-0001, with some editing of the documentation and > > in the tests. I'll cont

Re: NOT ENFORCED constraint feature

2025-01-16 Thread Peter Eisentraut
On 11.01.25 18:26, Amul Sul wrote: On Saturday, 11 January 2025, Peter Eisentraut > wrote: I have applied v8-0001, with some editing of the documentation and in the tests.  I'll continue reviewing the subsequent patches. Thank you for the improvement and co

Re: NOT ENFORCED constraint feature

2025-01-11 Thread Amul Sul
On Saturday, 11 January 2025, Peter Eisentraut wrote: > I have applied v8-0001, with some editing of the documentation and in the > tests. I'll continue reviewing the subsequent patches. > Thank you for the improvement and commit. Regards, Amul -- Regards, Amul Sul EDB: http://www.enterpris

Re: NOT ENFORCED constraint feature

2025-01-11 Thread Peter Eisentraut
I have applied v8-0001, with some editing of the documentation and in the tests. I'll continue reviewing the subsequent patches.

Re: NOT ENFORCED constraint feature

2025-01-07 Thread Triveni N
ENFORCED constraints. On Tue, Dec 17, 2024 at 12:23 PM tushar wrote: > FYI > > -- Forwarded message - > From: Amul Sul > Date: Tue, Dec 10, 2024 at 5:18 PM > Subject: Re: NOT ENFORCED constraint feature > To: jian he > Cc: Alvaro Herrera , Peter Eisentraut

Re: NOT ENFORCED constraint feature

2024-12-11 Thread Amul Sul
On Wed, Dec 11, 2024 at 6:12 PM jian he wrote: > > On Tue, Dec 10, 2024 at 7:48 PM Amul Sul wrote: > > > > > > > > static bool > > > MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr, > > > bool allow_merge, bool is_local, > > > + bool is_enforced, > > > bool is_initia

Re: NOT ENFORCED constraint feature

2024-12-11 Thread jian he
On Tue, Dec 10, 2024 at 7:48 PM Amul Sul wrote: > > > > > static bool > > MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr, > > bool allow_merge, bool is_local, > > + bool is_enforced, > > bool is_initially_valid, > > bool is_no_inherit) > > { > > @@ -2729,12 +2738,

Re: NOT ENFORCED constraint feature

2024-12-09 Thread jian he
hi. some minor issue about v7-0001. there are 5 appearances of "sizeof(CookedConstraint)" to make it safe, it would be nice to manual do ` cooked->is_enforced = true; ` for other kinds of constraints. static bool MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr, bool a

Re: NOT ENFORCED constraint feature

2024-12-09 Thread Amul Sul
On Mon, Dec 9, 2024 at 9:40 PM jian he wrote: > > hi. > only applied v7-0001. > > alter_table.sgml says we can specify enforceability > for ALTER TABLE ADD column_constraint > and ALTER TABLE ADD column_constraint table_constraint. > but we didn't have a test for column_constraint in alter_table.

Re: NOT ENFORCED constraint feature

2024-12-09 Thread jian he
hi. only applied v7-0001. alter_table.sgml says we can specify enforceability for ALTER TABLE ADD column_constraint and ALTER TABLE ADD column_constraint table_constraint. but we didn't have a test for column_constraint in alter_table.sql so segmental fault happened again: create table tx(a int

Re: NOT ENFORCED constraint feature

2024-12-06 Thread Amul Sul
On Thu, Dec 5, 2024 at 11:02 AM jian he wrote: > > hi. > accidentally hit segfault. > create table c11 (a int not enforced); > create table c11 (a int enforced); > we can solve it via the following or changing SUPPORTS_ATTRS accordingly. > > diff --git a/src/backend/parser/parse_utilcmd.c > b/src/

Re: NOT ENFORCED constraint feature

2024-12-05 Thread Alvaro Herrera
On 2024-Dec-03, Peter Eisentraut wrote: > The handling of merging check constraints seems incomplete. What > should be the behavior of this: > > => create table p1 (a int check (a > 0) not enforced); > CREATE TABLE > => create table c1 (a int check (a > 0) enforced) inherits (p1); > CREATE TABLE

Re: NOT ENFORCED constraint feature

2024-12-04 Thread jian he
hi. accidentally hit segfault. create table c11 (a int not enforced); create table c11 (a int enforced); we can solve it via the following or changing SUPPORTS_ATTRS accordingly. diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 5ab44149e5..fe1116c092 10064

Re: NOT ENFORCED constraint feature

2024-12-04 Thread Amul Sul
On Wed, Dec 4, 2024 at 1:40 PM jian he wrote: > > i just only apply v5-0001 for now. > > create table t(a int); > alter table t ADD CONSTRAINT cc CHECK (a > 0); > alter table t alter CONSTRAINT cc NOT ENFORCED; > alter table t alter CONSTRAINT cc ENFORCED; > > the last two queries will fail, which

Re: NOT ENFORCED constraint feature

2024-12-04 Thread jian he
> > errmsg("cannot validated NOT ENFORCED constraint"))); > should be > errmsg("cannot validate NOT ENFORCED constraint"))); > ? > looking at it again. if (!con->conenforced) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("cannot validated

Re: NOT ENFORCED constraint feature

2024-12-04 Thread jian he
i just only apply v5-0001 for now. create table t(a int); alter table t ADD CONSTRAINT cc CHECK (a > 0); alter table t alter CONSTRAINT cc NOT ENFORCED; alter table t alter CONSTRAINT cc ENFORCED; the last two queries will fail, which means ALTER CONSTRAINT constraint_name [ DEFERRABLE | NOT DEFE

Re: NOT ENFORCED constraint feature

2024-12-03 Thread Peter Eisentraut
On 03.12.24 13:00, Amul Sul wrote: create table t(a int); alter table t ADD CONSTRAINT the_constraint CHECK (a > 0) NOT ENFORCED; insert into t select -1; select conname, contype,condeferrable,condeferred, convalidated, conenforced,conkey,connoinherit frompg_constraint where conrelid = 't'

Re: NOT ENFORCED constraint feature

2024-11-18 Thread Peter Eisentraut
On 18.11.24 13:42, jian he wrote: i only played around with v4-0001-Add-support-for-NOT-ENFORCED-in-CHECK-constraints.patch. create table t(a int); alter table t ADD CONSTRAINT the_constraint CHECK (a > 0) NOT ENFORCED; insert into t select -1; select conname, contype,condeferrable,condeferred,

Re: NOT ENFORCED constraint feature

2024-11-18 Thread jian he
On Fri, Nov 15, 2024 at 6:21 PM Amul Sul wrote: > > Updated version attached. hi. i only played around with v4-0001-Add-support-for-NOT-ENFORCED-in-CHECK-constraints.patch. create table t(a int); alter table t ADD CONSTRAINT the_constraint CHECK (a > 0) NOT ENFORCED; insert into t select -1; sel

Re: NOT ENFORCED constraint feature

2024-11-12 Thread Peter Eisentraut
I started reviewing patch 0001 for check constraints. I think it's a good idea how you structured it so that we can start with this relatively simple feature and get all the syntax parsing etc. right. I also looked over the remaining patches a bit. The general structure looks right to me. But

Re: NOT ENFORCED constraint feature

2024-10-14 Thread Amul Sul
On Wed, Oct 9, 2024 at 6:45 PM Andrew Dunstan wrote: > > > On 2024-10-09 We 5:14 AM, Joel Jacobson wrote: > > On Tue, Oct 8, 2024, at 11:06, Amul Sul wrote: > > The attached patch proposes adding the ability to define CHECK and > FOREIGN KEY constraints as NOT ENFORCED. > > Thanks for working on t

Re: NOT ENFORCED constraint feature

2024-10-14 Thread Amul Sul
On Wed, Oct 9, 2024 at 2:44 PM Joel Jacobson wrote: > > On Tue, Oct 8, 2024, at 11:06, Amul Sul wrote: > > The attached patch proposes adding the ability to define CHECK and > > FOREIGN KEY constraints as NOT ENFORCED. > > Thanks for working on this! > > > Adding NOT ENFORCED to CHECK constraints

Re: NOT ENFORCED constraint feature

2024-10-09 Thread Andrew Dunstan
On 2024-10-09 We 5:14 AM, Joel Jacobson wrote: On Tue, Oct 8, 2024, at 11:06, Amul Sul wrote: The attached patch proposes adding the ability to define CHECK and FOREIGN KEY constraints as NOT ENFORCED. Thanks for working on this! Adding NOT ENFORCED to CHECK constraints is simple, see 0001 p

Re: NOT ENFORCED constraint feature

2024-10-09 Thread Joel Jacobson
On Tue, Oct 8, 2024, at 11:06, Amul Sul wrote: > The attached patch proposes adding the ability to define CHECK and > FOREIGN KEY constraints as NOT ENFORCED. Thanks for working on this! > Adding NOT ENFORCED to CHECK constraints is simple, see 0001 patch, I've looked at the 0001 patch and think