Re: CREATE TABLE NOT VALID for check and foreign key

2025-01-15 Thread Alvaro Herrera
On 2025-Jan-15, Amul Sul wrote: > I might be mistaken, but I believe this behavior is reasonable since > we're creating a new table with no data initially. Future inserts will > be validated against the constraint, ensuring all data added complies > with it. Given that any data in the table at any

Re: CREATE TABLE NOT VALID for check and foreign key

2025-01-14 Thread Amul Sul
On Thu, Dec 5, 2024 at 3:06 PM Alvaro Herrera wrote: > > Hello, > > On 2024-Dec-05, jian he wrote: > > > I found for foreign keys, check constraints, > > you specify it as NOT VALID, it will not be marked as NOT VALID in the > > CREATE TABLE statement. > > Uhmm, okay. > > > reading transformCheckC

Re: CREATE TABLE NOT VALID for check and foreign key

2025-01-14 Thread Alvaro Herrera
On 2025-Jan-08, Alvaro Herrera wrote: > On 2025-Jan-07, Yasuo Honda wrote: > > > I'd like PostgreSQL to raise errors and/or warnings for the NOT VALID > > check constraint for CREATE TABLE. > > Ruby on Rails supports creating check constraints with the NOT VALID > > option and I was not aware tha

Re: CREATE TABLE NOT VALID for check and foreign key

2025-01-08 Thread Alvaro Herrera
Hello, On 2025-Jan-07, Yasuo Honda wrote: > I'd like PostgreSQL to raise errors and/or warnings for the NOT VALID > check constraint for CREATE TABLE. > Ruby on Rails supports creating check constraints with the NOT VALID > option and I was not aware that it is just ignored until > https://github

Re: CREATE TABLE NOT VALID for check and foreign key

2025-01-07 Thread Yasuo Honda
Hi, On Mon, Dec 23, 2024 at 10:10 AM Alvaro Herrera wrote: > Maybe it would have been wise to forbid NOT VALID when used with CREATE > TABLE. But we didn't. Should we do that now? Maybe we can just > document that you can specify it but it doesn't do anything. I'd like PostgreSQL to raise er

Re: CREATE TABLE NOT VALID for check and foreign key

2024-12-05 Thread jian he
turns out this has already been discussed at [1] NOT VALID only applies to table_constraint. Amit Langote actually wrote the doc at[1], so I copied some text from there. in create_table.sgml, i placed right below INITIALLY IMMEDIATE INITIALLY DEFERRED so it looks like this: NOT VALID

Re: CREATE TABLE NOT VALID for check and foreign key

2024-12-05 Thread Kirill Reshke
On Thu, 5 Dec 2024 at 14:36, Alvaro Herrera wrote: > Maybe it would have been wise to forbid NOT VALID when used with CREATE > TABLE. But we didn't. Should we do that now? Maybe we can just > document that you can specify it but it doesn't do anything. +1 on that -- Best regards, Kirill Reshk

CREATE TABLE NOT VALID for check and foreign key

2024-12-05 Thread jian he
hi. I found for foreign keys, check constraints, you specify it as NOT VALID, it will not be marked as NOT VALID in the CREATE TABLE statement. CREATE TABLE s6(id bigint , CONSTRAINT con1 check(id > 1) not valid); src2=# \d s6 Table "public.s6" Column | Type | Collation | Nullab

Re: CREATE TABLE NOT VALID for check and foreign key

2024-12-05 Thread Alvaro Herrera
Hello, On 2024-Dec-05, jian he wrote: > I found for foreign keys, check constraints, > you specify it as NOT VALID, it will not be marked as NOT VALID in the > CREATE TABLE statement. Uhmm, okay. > reading transformCheckConstraints, transformFKConstraints comments > appearingly this is intentio