Re: Change COPY ... ON_ERROR ignore to ON_ERROR ignore_row

2025-03-24 Thread jian he
l); ^ will become COPY x from stdin (format null); ERROR: COPY format "null" not recognized LINE 1: COPY x from stdin (format null); ^ it will cause NULL_P from reserved word to non-reserved word in the COPY related comma

Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints

2025-03-23 Thread jian he
traint name properly, but that's fine for not-null constraint, i think. * regular table invalid not null constraint pg_dump also works fine. From fc4bf954772d25dfbf60774429d875f78e4fd69e Mon Sep 17 00:00:00 2001 From: jian he Date: Mon, 24 Mar 2025 09:21:10 +0800 Subject: [PATCH v5 1/1] NOT NULL NOT

Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints

2025-03-20 Thread jian he
-null constraint to check if this column exists NULL values or not. * partitioned table can not have NOT NULL NOT VALID. From 0106f2ded55a699324369412de859ab93f374960 Mon Sep 17 00:00:00 2001 From: jian he Date: Thu, 20 Mar 2025 22:43:08 +0800 Subject: [PATCH v3 1/1] NOT NULL NOT VALID MIME-Vers

Re: Doc: fix the rewrite condition when executing ALTER TABLE ADD COLUMN

2025-03-23 Thread jian he
hi. https://git.postgresql.org/cgit/postgresql.git/commit/?id=11bd8318602fc2282a6201f714c15461dc2009c6 + Adding a column with a volatile DEFAULT + (e.g., clock_timestamp()), a generated column + (e.g., GENERATED BY DEFAULT AS IDENTITY), a domain + data type with constraints will require the entir

Re: support fast default for domain with constraints

2025-03-24 Thread jian he
with empty rows aligned with master behavior. also will do table rewrite if the new column is domain with volatile check constraints, so less surprising behavior. From 09547bbc65f20846ac28efce035c016b21a75825 Mon Sep 17 00:00:00 2001 From: jian he Date: Mon, 24 Mar 2025 16:07:46 +0800 Subject

Re: speedup COPY TO for partitioned table.

2025-03-28 Thread jian he
On Fri, Mar 28, 2025 at 9:03 PM vignesh C wrote: > > On Fri, 28 Mar 2025 at 08:39, jian he wrote: > > > > hi. > > > > I made a mistake. > > The regress test sql file should have a new line at the end of the file. > > Couple of suggestions: > 1) Can

Re: in BeginCopyTo make materialized view using COPY TO instead of COPY (query).

2025-03-28 Thread jian he
On Thu, Mar 27, 2025 at 3:04 AM Kirill Reshke wrote: > > > > hi. > > patch attached. > > also cc to Tom, > > since at that time, you are against the idea of ``COPY matview TO``. > > Hi! With this patch it is possible to COPY matview TO, but not regular > view, which is surprising. Let's fix that?

Re: support ALTER TABLE DROP EXPRESSION for virtual generated column

2025-03-29 Thread jian he
On Thu, Mar 27, 2025 at 11:44 AM David G. Johnston wrote: > > On Wednesday, March 26, 2025, Tom Lane wrote: >> >> jian he writes: >> > the attached patch is to implement $subject. >> >> Why would this be a good idea? I don't see any principled fallb

Re: speedup COPY TO for partitioned table.

2025-04-03 Thread jian he
On Tue, Apr 1, 2025 at 1:38 PM vignesh C wrote: > > On Tue, 1 Apr 2025 at 06:31, jian he wrote: > > > > On Mon, Mar 31, 2025 at 4:05 PM Kirill Reshke > > wrote: > > > > Thanks for doing the benchmark. > > Few comments to improve the comments, error

Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints

2025-04-02 Thread jian he
c8hqnbjdhaixncs2vr3j_1...@mail.gmail.com From 5d6da8791aa46d63e872c5a9f463b05bb2d0f9e8 Mon Sep 17 00:00:00 2001 From: jian he Date: Wed, 2 Apr 2025 21:47:22 +0800 Subject: [PATCH v6 1/1] ensure pg_dump table constraint info remain the same resolve case where parent constraint convalidated is false

pg_dump does not dump domain not-null constraint's comments

2025-05-07 Thread jian he
ed struct TypeInfo fields, nDomChecks will be renamed to nDomConstrs; domChecks will be renamed to domConstrs. TypeInfo->domConstrs will also include not-null constraint information, changing from domChecks to domConstrs makes sense, IMHO. From fcaba2b44f62ae76404095352edcecd0cbc967ff Mon Sep 17 00

Re: PG 18 release notes draft committed

2025-05-08 Thread jian he
On Fri, May 2, 2025 at 10:44 AM Bruce Momjian wrote: > > release-18: 209 > > I will continue improving it until beta 1, and until the final release. > I will probably add markup in 1-3 weeks. Let the feedback begin. ;-) > > You can see the most current HTML-built version here: > >

make VALIDATE domain constraint lock on related relations as ShareUpdateExclusiveLock

2025-05-12 Thread jian he
001 From: jian he Date: Tue, 13 May 2025 11:04:37 +0800 Subject: [PATCH v1 1/1] reduce lock level when ALTER DOMAIN...VALIDATE CONSTRAINT ON TABLE LEVEL: create table t2(a int); alter table t2 add constraint cc10 check(a > 10) not valid; begin; alter table t2 validate constraint cc10; We can st

Re: using index to speedup add not null constraints to a table

2025-05-14 Thread jian he
On Mon, Apr 28, 2025 at 4:40 PM Álvaro Herrera wrote: > > On 2025-Apr-28, jian he wrote: > > > for tests, just found out i can imitate > > src/test/modules/test_misc/t/001_constraint_validation.pl, > > > > So I created a file: > > src/test/modules/test_m

Re: Virtual generated columns

2025-05-16 Thread jian he
On Fri, May 16, 2025 at 3:26 PM Richard Guo wrote: > > On Fri, May 16, 2025 at 1:00 PM Alexander Lakhin wrote: > > I've discovered yet another way to trigger that error: > > create table vt (a int, b int generated always as (a * 2), c int); > > insert into vt values(1); > > alter table vt alter c

Re: Prevent internal error at concurrent CREATE OR REPLACE FUNCTION

2025-05-21 Thread jian he
On Mon, Mar 31, 2025 at 7:22 PM Yugo Nagata wrote: > > On Mon, 31 Mar 2025 20:00:57 +0900 > Yugo Nagata wrote: > > > Hi, > > > > I found that multiple sessions concurrently execute CREATE OR REPLACE > > FUNCTION > > for a same function, the error "tuple concurrently updated" is raised. This > >

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-05-21 Thread jian he
On Thu, May 22, 2025 at 1:01 AM Dmitry Koval wrote: > > > for example: > > ... > > If in both examples you replace > > create role bob; > > with > > create role bob SUPERUSER; > > and in the second example add "set role bob;" before "alter table ..." > query, then no error will be occur. > That i

Re: pg_dump does not dump domain not-null constraint's comments

2025-05-22 Thread jian he
da0fe3c22b34c4433f1729e88495554b5331ed From aaa19222079d27c554c8b06a2e95b2f2581bccd8 Mon Sep 17 00:00:00 2001 From: jian he Date: Thu, 22 May 2025 14:25:58 +0800 Subject: [PATCH v4 1/2] Improve pg_dump handling of domain not-null constraints 1. If requested, we should dump comments for domain not-nu

Re: Prevent internal error at concurrent CREATE OR REPLACE FUNCTION

2025-05-22 Thread jian he
On Thu, May 22, 2025 at 10:25 AM jian he wrote: > hi. earlier, i didn't check patch 0002. i think in AlterFunction add /* Lock the function so nobody else can do anything with it. */ LockDatabaseObject(ProcedureRelationId, funcOid, 0, AccessExclusiveLock); right after

Disallow concurrent ALTER DOMAIN and DROP DOMAIN

2025-05-23 Thread jian he
changed domain oid. Other sessions must wait for the current transactions to finish modifying the domain definition before making changes on it. [1] https://postgr.es/m/20250331200057.00a62760966a821d484ea...@sraoss.co.jp From a1f928637d9bf796e7a62e260d844c127ddfa720 Mon Sep 17 00:00:00 2001 From: ji

Re: Avoid orphaned objects dependencies, take 3

2025-05-22 Thread jian he
On Tue, Feb 4, 2025 at 9:24 PM Bertrand Drouvot wrote: > > Hi, > > On Thu, Jan 02, 2025 at 08:15:13AM +, Bertrand Drouvot wrote: > > rebased (v18 attached). > > Thanks to all of you that have discussed this patch during the developer > meeting > at FOSDEM PGDay last week [1]. I'm attaching a

Re: pg18: Virtual generated columns are not (yet) safe when superuser selects from them

2025-05-23 Thread jian he
On Fri, May 23, 2025 at 4:43 PM Feike Steenbergen wrote: > > > Hi, > > While evaluating the PostgreSQL 18 beta, I had a thought experiment where I > thought it might be possible to use the new virtual generated columns to gain > superuser privileges for a regular user. > > Attached is a sample exp

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-05-21 Thread jian he
On Wed, May 21, 2025 at 8:30 PM Dmitry Koval wrote: > > Hi! > > >per https://www.postgresql.org/docs/current/sql-altertable.html > >"You must own the table to use ALTER TABLE." > >That means the current user must own the to be SPLITed partition. > > Last statement may be incorrect (if the logic

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-05-20 Thread jian he
On Mon, May 12, 2025 at 4:31 PM Dmitry Koval wrote: > > Hi! > > We (with colleagues) discussed further improvements to SPLIT/MERGE > PARTITION(S). As a result of the discussion, the following answers to > the questions remained: > > 1. Who should be the owner of new partitions (SPLIT PARTITION com

Re: domain over virtual generated column

2025-05-20 Thread jian he
On Mon, Apr 28, 2025 at 10:45 AM jian he wrote: > > summary of attached patch: > v1-0001 > we need to compute the generation expression for the domain with constraints, > thus rename ExecComputeStoredGenerated to ExecComputeGenerated. > > v1-0002 > soft error va

Re: Regression in statement locations

2025-05-19 Thread jian he
On Tue, May 20, 2025 at 11:59 AM Michael Paquier wrote: > > On Tue, May 20, 2025 at 08:38:47AM +0900, Michael Paquier wrote: > > With the semicolon in place, stmt_len gets set for the last query of > > the string. Still digging more.. > > And got it. The problem is that we are failing to update

cookConstraint dead code

2025-05-20 Thread jian he
hi. in cookConstraint /* * Make sure no outside relations are referred to (this is probably dead * code now that add_missing_from is history). */ if (list_length(pstate->p_rtable) != 1) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE),

make ALTER DOMAIN VALIDATE CONSTRAINT no-op when constraint is validated

2025-05-20 Thread jian he
in such cases. ALTER TABLE VALIDATE CONSTRAINT is already a no-op when the constraint is VALID. From b9356b888d397c48b993dbb7fc093ffd3f9fa65c Mon Sep 17 00:00:00 2001 From: jian he Date: Wed, 21 May 2025 14:18:53 +0800 Subject: [PATCH v1 1/1] make ALTER DOMAIN VALIDATE CONSTRAINT no-op when

ALTER DOMAIN ADD NOT NULL NOT VALID

2025-05-21 Thread jian he
things | integer | | not null not valid | | CHECK (VALUE < 11) From bdea7a60eab6e46d7f0b59b9a5602d6a2421f60d Mon Sep 17 00:00:00 2001 From: jian he Date: Wed, 21 May 2025 18:43:17 +0800 Subject: [PATCH v1 1/1] ALTER DOMAIN ADD NOT NULL NOT VALID we have NOT NULL NO VALID for table c

finish TODOs in to_json_is_immutable, to_jsonb_is_immutable also add tests on it

2025-05-18 Thread jian he
7f2de2fa77182ae57d2c9069351a7b91c1cfede8 Mon Sep 17 00:00:00 2001 From: jian he Date: Sun, 18 May 2025 15:03:30 +0800 Subject: [PATCH v1 1/1] enhance json_array, json_object expression is immutable or not this will make to_json_is_immutable, to_jsonb_is_immutable does recurse to composite data type or array type elements. also

Re: regdatabase

2025-05-18 Thread jian he
On Thu, May 8, 2025 at 11:20 PM Nathan Bossart wrote: > > On Thu, May 08, 2025 at 10:38:04PM +0900, Ian Lawrence Barwick wrote: > > Revised patch attached which adds coverage of that and also for the > > "constant of the type reg(role|database) cannot be used here" error. > > LGTM. I've marked it

Re: support fast default for domain with constraints

2025-05-19 Thread jian he
On Mon, Mar 24, 2025 at 7:14 PM jian he wrote: > > v4-0003 table with empty rows aligned with master behavior. > also will do table rewrite if the new column is domain with volatile > check constraints, > so less surprising behavior. I found out that my v4-0003 is wrong. F

Re: pg18: Virtual generated columns are not (yet) safe when superuser selects from them

2025-05-24 Thread jian he
On Sat, May 24, 2025 at 2:39 PM Feike Steenbergen wrote: > > The loophole is this: > > - the generated virtual column can use a user-defined function > - when running SELECT against that column by a superuser > the function is called within the context of a superuser > - this in turn allows the

Re: pg18: Virtual generated columns are not (yet) safe when superuser selects from them

2025-05-26 Thread jian he
On Mon, May 26, 2025 at 4:56 PM Feike Steenbergen wrote: > > > > On Sat, 24 May 2025 at 15:43, jian he wrote: > > sorry, I am not fully sure what this means. a minimum sql reproducer would > > be > > great. > > The initial email contains a fully self

Re: MERGE issues around inheritance

2025-05-26 Thread jian he
On Mon, May 26, 2025 at 4:11 AM Dean Rasheed wrote: > > On Sun, 25 May 2025 at 13:41, Dean Rasheed wrote: > > > > 2. ExecInitModifyTable() does not initialize the WCO lists or > RETURNING list for rootResultRelInfo, so those never get executed. > > As it happens, it is possible to construct cases

CREATE OR REPLACE FUNCTION now validates it's dependents

2025-05-25 Thread jian he
ION take way longer time compared to the current. Similar to domain constraints, attached patch also apply to table check constraints too. Is this what we want to do? [1]: https://postgr.es/m/12539.1544107316%40sss.pgh.pa.us From d3356a2485143dc81e5b4d4e0311ffeaec56153c Mon Sep 17 00:00:00 2001 Fr

Re: Prevent internal error at concurrent CREATE OR REPLACE FUNCTION

2025-05-26 Thread jian he
On Tue, May 27, 2025 at 1:35 AM Yugo Nagata wrote: > > > + /* Lock the function so nobody else can do anything with it. */ > > + LockDatabaseObject(ProcedureRelationId, oldproc->oid, 0, > > AccessExclusiveLock); > > + > > + /* > > + * It is possible that by the time we acquire the lock on functio

ALTER TABLE ALTER CONSTRAINT misleading error message

2025-05-28 Thread jian he
hi. create table t(a int, constraint cc check(a = 1)); ALTER TABLE t ALTER CONSTRAINT cc not valid; ERROR: FOREIGN KEY constraints cannot be marked NOT VALID LINE 1: ALTER TABLE t ALTER CONSTRAINT cc not valid; ^ the error message seems misleading, shou

Re: finish TODOs in to_json_is_immutable, to_jsonb_is_immutable also add tests on it

2025-05-28 Thread jian he
On Mon, May 19, 2025 at 9:09 AM jian he wrote: > > hi. > > somehow, I accidentally saw the TODOs (commits [3]) on jsonb.c and json.c > for functions: to_json_is_immutable and to_jsonb_is_immutable. > The attached patch is to finalize these TODOs. > > per coverage [

foreign key on virtual generated column

2025-05-27 Thread jian he
constraint validation. [1] https://git.postgresql.org/cgit/postgresql.git/commit/?id=83ea6c54025bea67bcd4949a6d58d3fc11c3e21b From 6acff5606b6181442eac7a1128c879c378adcb05 Mon Sep 17 00:00:00 2001 From: jian he Date: Tue, 27 May 2025 21:24:18 +0800 Subject: [PATCH v1 2/2] foreign key on virtual

Re: ALTER DOMAIN ADD NOT NULL NOT VALID

2025-05-28 Thread jian he
onname COLLATE "C";" to stabilize tests. [0] https://api.cirrus-ci.com/v1/artifact/task/6676676240736256/testrun/build/testrun/pg_upgrade/002_pg_upgrade/data/regression.diffs From a840278f579b57cab4c13b91abfcc4f44a6d8a83 Mon Sep 17 00:00:00 2001 From: jian he Date: Wed, 2

<    6   7   8   9   10   11