Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-16 Thread jian he
for v45. + foreach_ptr(CookedConstraint, ccon, cookedConstraints) + { + if (!ccon->skip_validation && ccon->contype == CONSTR_CHECK) + { + Bitmapset *attnums = NULL; + + pull_varattnos((Node *) ccon->expr, 1, &attnums); + + /* + * Add check only if it contains tableoid + * (TableOidAttributeNumbe

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-15 Thread jian he
hi. static void checkPartition(Relation rel, Oid partRelOid) function name checkPartition is not ideal, maybe we can change it to CheckPartitionForMerge or MergePartitionCheck. (attached v45-002 is error message refactoring for checkPartition, I didn't change the name though.) For the command: A

Re: ALTER TABLE ALTER CONSTRAINT misleading error message

2025-06-13 Thread jian he
On Wed, Jun 11, 2025 at 10:20 PM Fujii Masao wrote: > > >> We discussed this already, didn't we? There's a thread with IIRC three > >> proposed patches for this. I think I liked this one the most: > >> > >> https://postgr.es/m/caaj_b97hd-jmts7ajgu6tdbczdx_kyukxg+k-dtymoieg+g...@mail.gmail.com >

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-12 Thread jian he
On Fri, Jun 13, 2025 at 4:36 AM Dmitry Koval wrote: > > Hi, Jian He! > > Thanks for the notes and patches (again). > I read a part of emails, I hope to read the rest emails tomorrow. > hi. in doc/src/sgml/ref/alter_table.sgml Parameters section, we also need explain p

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-12 Thread jian he
hi. one more minor issue. + * defaultPart: true if one of split partitions is DEFAULT + * pstate: pointer to ParseState struct for determining error position + */ +static void +check_two_partitions_bounds_range(Relation parent, + RangeVar *first_name, + PartitionBoundSpec *first_bound, + RangeV

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-12 Thread jian he
hi. +/* + * check_two_partitions_bounds_range + * + * (function for BY RANGE partitioning) + * + * This is a helper function for check_partitions_for_split() and + * calculate_partition_bound_for_merge(). check_partitions_for_split does not exist in v43-0001. + /* + * Rename the existing partiti

confusing message in check_tuple

2025-06-11 Thread jian he
hi. in contrib/amcheck/verify_heapam.c, check_tuple report_corruption(ctx, psprintf("number of attributes %u exceeds maximum expected for table %u", ctx->natts, RelationGetDescr(ctx->rel)->natts

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-11 Thread jian he
hi. + /* Copy data from merged partitions to new partition. */ + moveMergedTablesRows(rel, mergingPartitionsList, newPartRel); + + /* Drop the current partitions before attaching the new one. */ + foreach_ptr(RelationData, mergingPartition, mergingPartitionsList) + { + ObjectAddress object; + + /*

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-11 Thread jian he
On Wed, Jun 11, 2025 at 8:06 AM Dmitry Koval wrote: > > >Do getAttributesList need to care about pg_attribute.attidentity? > >currently MERGE PARTITION seems to work fine with identity columns, > >this issue i didn't dig deeper. > > Probably after commit [3] partition's identity columns shares

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-10 Thread jian he
hi. we generally no need to worry about the partitioned table check constraint, generated column does not apply to newly merged partitions. since partitioned table constraints apply to each individual partition, including newly created partitions. However, there are corner cases: constraints incl

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-10 Thread jian he
On Tue, Jun 10, 2025 at 6:48 AM Dmitry Koval wrote: > 3. > >i think, we can do the following way: > >if (modelRel->rd_rel->relam) > > elog(ERROR, "error"); > >relamId = modelRel->rd_rel->relam; > > Can you clarify what is reason to change the current AM-logic for > creating a new partition? >

add column (query_start timestamptz) to progress report views

2025-06-09 Thread jian he
hi. for all the progress report views[1], we can add a timestamptz column, maybe named as query_start. People generally want to track the progress of operations and the time spent on them. While pg_stat_activity already provides column query_start, including query_start in pg_stat_get_progress_i

Re: doc pg_constraint.convalidated column description need update

2025-06-08 Thread jian he
On Thu, Jun 5, 2025 at 4:47 AM Robert Treat wrote: > > I think some of those changes are worth a second stab, so here is an > updated patch which removes the ancillary tagging and corresponding > line wrappings and focuses just on the wording/grammer improvements; > hopefully it will be easier to

Re: why there is not VACUUM FULL CONCURRENTLY?

2025-06-08 Thread jian he
hi. some more minor comments about v13-0001. GetCommandLogLevel also needs to specify LogStmtLevel for T_RepackStmt? /* * (CLUSTER might change the order of * rows on disk, which could affect the ordering of pg_dump * output, but that's not semantically significant.) */ do we need adjust this

Re: why there is not VACUUM FULL CONCURRENTLY?

2025-06-07 Thread jian he
On Fri, Apr 11, 2025 at 5:28 PM Antonin Houska wrote: > > Please check the next version [1]. Thanks for your input. > > [1] https://www.postgresql.org/message-id/97795.1744363522%40localhost > Hi, I’ve briefly experimented with v13-0001. EXPLAIN tab complete: explain (verbose O OFF ON since we

Re: [PATCH] Support for basic ALTER TABLE progress reporting.

2025-06-06 Thread jian he
On Mon, Jun 2, 2025 at 3:35 PM Jiří Kavalík wrote: > What I changed: > > `commands/tablecmds.c` > - start and end reporting inside `ATRewriteTables()` > - report blocks total, blocks and tuples scanned and possibly tuples written > in `ATRewriteTable` > - add at least phase info in `validateForei

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-06 Thread jian he
hi. in createTableConstraints + /* Add a pre-cooked default expression. */ + StoreAttrDefault(newRel, num, def, true); + + /* Store CHECK constraints. */ + StoreConstraints(newRel, cookedConstraints, false); Here, StoreConstraints last argument should be set to true? see also StoreAttrDefault. +

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-05 Thread jian he
hi. one more patch for regress tests. ALTER TABLE salespeople MERGE PARTITIONS (salespeople10_20, salespeople20_30, salespeople30_40) INTO salespeople10_40; the trigger on the merged partition will be dropped. For example, here, trigger on salespeople10_20 will be dropped. I am surprised that pa

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

2025-06-05 Thread jian he
On Thu, Jun 5, 2025 at 10:39 PM Robert Haas wrote: > > On Thu, Jun 5, 2025 at 6:49 AM Peter Eisentraut wrote: > > I propose to address this by not allowing the use of user-defined > > functions in generation expressions for now. The attached patch > > implements this. This assumes that all buil

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-05 Thread jian he
hi. When using ALTER TABLE ... MERGE PARTITIONS, some of the new partition's properties will not be inherited from to be merged partitions; instead, they will be directly copied from the root partitioned table. so we need to test this behavior. The attached test file is for test table properties:

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-05 Thread jian he
hi. bug in transformPartitionCmdForMerge "equal(name, name2))" +static void +transformPartitionCmdForMerge(CreateStmtContext *cxt, PartitionCmd *partcmd) +{ + + + foreach(listptr, partcmd->partlist) + { + RangeVar *name = (RangeVar *) lfirst(listptr); + + /* Partitions in the list should have di

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-04 Thread jian he
hi. the following are review of v40-0001-Implement-ALTER-TABLE-.-MERGE-PARTITIONS-.-comma.patch ALTER TABLE sales_range MERGE PARTITIONS (sales_feb2022, sales_mar2022) INTO sales_feb_mar_apr2022; There are no tests when sales_feb2022 or sales_mar2022 have any constraints. a partition can have its

Re: speedup COPY TO for partitioned table.

2025-06-04 Thread jian he
on: application/sql From fca7b87718264cb5ea52f3b4462f4d6e52d58cdc Mon Sep 17 00:00:00 2001 From: jian he Date: Thu, 5 Jun 2025 08:44:13 +0800 Subject: [PATCH v11 1/1] support COPY partitioned_table TO this is for implementatoin of ``COPY (partitioned_table) TO``. it will be faster th

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-04 Thread jian he
On Wed, Jun 4, 2025 at 4:53 AM Dmitry Koval wrote: > Added some changes to documentation. > Patches are attached to the email. > hi. I haven't touched v39-0002 yet. The following are reviews of v39-0001. +CREATE INDEX sales_range_sales_date_idx ON sales_range USING btree (sales_date); +INSERT IN

Re: Foreign key validation failure in 18beta1

2025-06-03 Thread jian he
On Tue, Jun 3, 2025 at 12:14 PM Amul Sul wrote: > > > > I found a third approach that requires only a few changes. The key > idea is to determine the root referenced table and pass it to > QueueFKConstraintValidation(). We would then enqueue phase 3 > validation only if the constraint tuple’s conf

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

2025-06-02 Thread jian he
On Tue, Jun 3, 2025 at 9:19 AM Tom Lane wrote: > > In any case, this doesn't feel like something to be defining and > implementing post-beta1. Even if it were not security-critical, > the amount of complication involved is well past our standards > for what can go in post-feature-freeze. > > I'm

alter check constraint enforceability

2025-06-02 Thread jian he
:00:00 2001 From: jian he Date: Mon, 2 Jun 2025 21:54:53 +0800 Subject: [PATCH v1 1/1] alter check constraint enforceability context: https://git.postgresql.org/cgit/postgresql.git/commit/?id=ca87c415e2fccf81cec6fd45698dde9fae0ab570 discussion: https://postgr.es/m/ --- doc/src/sgml/ref

Re: support fast default for domain with constraints

2025-06-02 Thread jian he
hi. attached is to fix the regress test failure[0] in V5. I also did some test simplification. [0] https://api.cirrus-ci.com/v1/artifact/task/6014753866252288/log/src/test/regress/regression.diffs From 1df9fc6e8e645463e864f44492d532def74c8437 Mon Sep 17 00:00:00 2001 From: jian he Date: Mon

tab complete for ALTER TABLE ALTER CONSTRAINT

2025-06-01 Thread jian he
://www.postgresql.org/docs/devel/sql-altertable.html From bf01db5085901f179fa83b4cca12ba55c9bd0a64 Mon Sep 17 00:00:00 2001 From: jian he Date: Mon, 2 Jun 2025 14:45:47 +0800 Subject: [PATCH v1 1/1] tab complte for ALTER TABLE ALTER CONSTRAINT ALTER TABLE tab complte for ALTER CONSTRAINT constraint_name

Re: Virtual generated columns

2025-06-01 Thread jian he
On Thu, May 29, 2025 at 11:06 AM Richard Guo wrote: > > On Fri, May 16, 2025 at 5:35 PM jian he wrote: > > we have used the USING expression in ATPrepAlterColumnType, > > ATColumnChangeRequiresRewrite. > > expanding it on ATPrepAlterColumnType seems to make more se

Re: CREATE DOMAIN create two not null constraints

2025-06-01 Thread jian he
On Mon, Jun 2, 2025 at 12:13 AM Álvaro Herrera wrote: > > Hmm, I think it would be more consistent to reject the case of duplicate > constraints, instead of silently ignoring it. So you'd do it in the > loop that checks for constraints before creating anything, like > > > diff --git a/src/backend

Re: ALTER TABLE ALTER CONSTRAINT misleading error message

2025-06-01 Thread jian he
On Wed, May 28, 2025 at 7:59 PM Álvaro Herrera wrote: > > On 2025-May-28, jian he wrote: > > > 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 mar

CREATE DOMAIN create two not null constraints

2025-06-01 Thread jian he
hi. CREATE DOMAIN int_domain1 AS INT CONSTRAINT nn1 NOT NULL CONSTRAINT nn2 NOT NULL; will install two not-null pg_constraint entries. we should have only one? From 8328340ac98daa3e26ac13cc06348560a468abf0 Mon Sep 17 00:00:00 2001 From: jian he Date: Sun, 1 Jun 2025 11:32:28 +0800 Subject

Re: Foreign key validation failure in 18beta1

2025-06-01 Thread jian he
On Fri, May 30, 2025 at 6:32 PM Amul Sul wrote: > > > Kindly take a look at the attached version. I've also added the tests. > Thanks for your script -- all tests are passing with this patch. > hi. + * Note that validation should be performed against the referencing + * root table only, not its

Re: Foreign key validation failure in 18beta1

2025-05-30 Thread jian he
On Thu, May 29, 2025 at 8:58 PM Amul Sul wrote: > > > > I just realized we have the same problem with ALTER FOREIGN KEY ENFORCED. > > for example: > > Yeah, I think adding a "currcon->confrelid == pkrelid" check before > enqueueing validation in ATExecAlterConstrEnforceability() would > address th

Re: Foreign key validation failure in 18beta1

2025-05-29 Thread jian he
On Thu, May 29, 2025 at 8:12 PM Amul Sul wrote: > > > >> > [...] > > The attached *draft* patch is based on your idea. > > > > The idea is that we only need to conditionally do > > ``tab->constraints = lappend(tab->constraints, newcon);`` within > > QueueFKConstraintValidation. > > but the catalog

Re: Foreign key validation failure in 18beta1

2025-05-29 Thread jian he
On Wed, May 28, 2025 at 8:38 PM Tender Wang wrote: > > > > Alvaro Herrera 于2025年5月28日周三 20:26写道: >> >> On 2025-May-28, Tender Wang wrote: >> >> > I dided the codes, in QueueFKConstraintValidation(), we add three >> > newconstraint for the >> > fk rel, because the pk rel is partition table. >> >

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: 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

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: 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

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: 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

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: 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: 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: 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

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: 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: 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 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

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

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

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: 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

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),

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

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: 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

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: 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: 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

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: 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: > >

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

2025-05-07 Thread jian he
ble? Anyway, the attachment is for PG18 only now, it will fix the domain constraint name loss and domain not-null comments loss issue together. From 2db869fc212867e74f61f4e5b2aef1fda017e9f7 Mon Sep 17 00:00:00 2001 From: jian he Date: Thu, 8 May 2025 12:48:25 +0800 Subject: [PATCH v3 2/2] sa

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

2025-05-07 Thread jian he
On Wed, May 7, 2025 at 5:25 PM Álvaro Herrera wrote: > > On 2025-May-07, jian he wrote: > > > in PG17 and master, pg_dump (--schema=test --no-owner) > > [...] > > didn't produce > > COMMENT ON CONSTRAINT nn ON DOMAIN test.d1 IS 'not null constraint on &g

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-06 Thread jian he
Allow partitions to be pruned more efficienty (Ashutosh Bapat, Yuya Watari, David Rowley) § § typo, "efficienty" should be "efficiently"?

Re: PG 18 release notes draft committed

2025-05-06 Thread jian he
On Fri, May 2, 2025 at 10:44 AM Bruce Momjian wrote: > > release-16: 206 > release-17: 182 > 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 ca

Re: bug: virtual generated column can be partition key

2025-05-06 Thread jian he
On Tue, May 6, 2025 at 5:57 PM Yura Sokolov wrote: > > 21.04.2025 05:30, jian he пишет: > > hi. > > While trying to make the virtual generated column be part of the partition > > key, > > I found this bug. > > it also influences the stored gen

Re: 2025-05-08 release announcement draft

2025-05-06 Thread jian he
On Tue, May 6, 2025 at 11:32 AM Jonathan S. Katz wrote: > > Hi, > > Attached is the draft of the release announcement for the 2025-05-08 > release. Please review for correctness and omissions. > > Please provide feedback no later than 2025-05-08 12:00 UTC. > * Prevent failure in [`INSERT`](https:

Re: doc pg_constraint.convalidated column description need update

2025-05-06 Thread jian he
On Sat, May 3, 2025 at 11:42 PM Robert Treat wrote: > As such, attached patch removes the above, and attempts some clean up > of the documentation in ALTER TABLE to better clarify the behavior > around valid/not valid, enforced/not enforced, and how it affects > different constraints, with some ad

Re: bug: virtual generated column can be partition key

2025-05-06 Thread jian he
I have added this thread and [1] into https://wiki.postgresql.org/wiki/PostgreSQL_18_Open_Items#Live_issues In case we've lost track of it. [1]: https://www.postgresql.org/message-id/CACJufxG5wLiATocRTaC%3Dz%2Bkw4mUaasC-50%2Bq9K%3DfOdAr3%3DOGRw%40mail.gmail.com

Re: First-draft back-branch release notes are up

2025-05-03 Thread jian he
On Sat, May 3, 2025 at 12:39 AM Tom Lane wrote: > > Much less exciting than the v18 release notes, but we > still gotta do 'em. See > > https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=176877f461a8b55e921f597fb217f6ab89ee019f > > As usual, please send corrections by Sunday. > +

Re: PG 18 release notes draft committed

2025-05-03 Thread jian he
On Fri, May 2, 2025 at 10:44 AM Bruce Momjian wrote: > > I have committd the first draft of the PG 18 release notes. The item > count looks strong: > release-17: 182 > release-18: 209 > > I will continue improving it until beta 1, and until the final release. > I will probably

doc pg_constraint.convalidated column description need update

2025-05-01 Thread jian he
hi. catalog.sgml: convalidated bool Has the constraint been validated? Currently, can be false only for foreign keys and CHECK constraints with NOT NULL NOT VALID, we need rephrase it to something like: "Currently, can be false only fo

expand on_error ignore error handling scope

2025-04-29 Thread jian he
hi. Currently, (on_error ignore) only handles data type incompatibility errors. However, we can extend its functionality to also handle errors caused by extra data (additional columns) or missing data (fewer columns), I think. on_error is only applicable to non-binary formats. In non-binary forma

add tab-complete for ALTER DOMAIN ADD...

2025-04-29 Thread jian he
hi. per https://www.postgresql.org/docs/current/sql-alterdomain.html we can add tab-complete for ALTER DOMAIN ADD variants: ALTER DOMAIN sth ADD CHECK ALTER DOMAIN sth ADD CONSTRAINT ALTER DOMAIN sth ADD NOT NULL v1-0001-add-tab-complete-for-ALTER-DOMAIN-ADD.patch Description: Binary data

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

2025-04-27 Thread jian he
On Fri, Apr 18, 2025 at 4:07 PM jian he wrote: > > I don't have any good ideas to do the regress tests. > I use > ereport(NOTICE, > errmsg("all not-null constraints on relation > \"

domain over virtual generated column

2025-04-27 Thread jian he
R: column "b" of table "gtest24" contains values that violate the new constraint v1-0003 virtual generation columns over domain. From 70a9fb80fb63561a66b2427bf3829e3667ce1569 Mon Sep 17 00:00:00 2001 From: jian he Date: Thu, 13 Mar 2025 20:15:46 +0800 Subject: [PATCH v1 1/

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

2025-04-25 Thread jian he
On Fri, Apr 25, 2025 at 3:36 AM Alvaro Herrera wrote: > > On 2025-Apr-09, jian he wrote: > > > hi. > > > > attached patch is for address pg_dump inconsistency > > when parent is "not null not valid" while child is "not null". > &

Re: on_error table, saving error info to a table

2025-04-25 Thread jian he
e should error out case like: COPY err_tbl FROM STDIN WITH (DELIMITER ',', on_error table, table err_tbl); also by changing copy_generic_opt_arg, now we can COPY err_tbl FROM STDIN WITH (DELIMITER ',', on_error table, table x); previously, we can only do COPY err_tbl FROM STDIN WITH (DELIMITER &

Re: [PATCH] Re: Proposal to Enable/Disable Index using ALTER INDEX

2025-04-24 Thread jian he
hi, two more minor issues. src/bin/pg_dump/pg_dump.c if (fout->remoteVersion >= 18) need change to if (fout->remoteVersion >= 19) +-- Test index visibility with partitioned tables +CREATE TABLE part_tbl(id int, data text) PARTITION BY RANGE(id); +CREATE TABLE part1 PARTITION OF part_tbl

Re: [PATCH] Re: Proposal to Enable/Disable Index using ALTER INDEX

2025-04-23 Thread jian he
hi. The following is a review of version 17. ATExecSetIndexVisibility if (indexForm->indisvisible != visible) { indexForm->indisvisible = visible; CatalogTupleUpdate(pg_index, &indexTuple->t_self, indexTuple); CacheInvalidateRelcache(heapRel); InvokeObjectPo

Re: support ALTER COLUMN SET EXPRESSION over virtual generated column with check constraint

2025-04-23 Thread jian he
On Tue, Mar 11, 2025 at 12:17 PM jian he wrote: > hi. > in summary: ATExecSetExpression, RememberAllDependentForRebuilding > will do all the work to change the generation expression, > whether it's virtual or stored. > while working on another patch, I found out this can b

virtual generated column as partition key

2025-04-23 Thread jian he
:00:00 2001 From: jian he Date: Wed, 23 Apr 2025 19:54:03 +0800 Subject: [PATCH v1 1/1] virtual generated column as partition key demo: CREATE TABLE t(f1 bigint, f2 bigint GENERATED ALWAYS AS (f1 * 2) VIRTUAL) PARTITION BY RANGE (f2); but partition key can not be expression on top of virtual

Re: bug: virtual generated column can be partition key

2025-04-23 Thread jian he
On Tue, Apr 22, 2025 at 4:55 PM Ashutosh Bapat wrote: > > Sorry I missed this email while sending the patches - our emails crossed in > the air. > > On Tue, Apr 22, 2025 at 2:15 PM jian he wrote: >> >> On Tue, Apr 22, 2025 at 3:02 PM jian he wrote: >> > Othe

disallow alter individual column if partition key contains wholerow reference

2025-04-22 Thread jian he
ion keys have column references, then has_partition_attrs should return true. [1]: https://postgr.es/m/CACJufxF=wdgthxsaqr9thyusfx_1_t9e6n8te3b8eqxcvov...@mail.gmail.com From 7a4c9bc1cb65c3aedc92a4bf31352ba19f1135b9 Mon Sep 17 00:00:00 2001 From: jian he Date: Tue, 22 Apr 2025 19:37:24 +0800 Su

Re: bug: virtual generated column can be partition key

2025-04-22 Thread jian he
On Tue, Apr 22, 2025 at 3:02 PM jian he wrote: > Other than that, it looks good to me for fixing this bug. The error message seems not that intuitive. +CREATE TABLE gtest_part_key (f1 date NOT NULL, f2 bigint, f3 bigint GENERATED ALWAYS AS (f2 * 2) VIRTUAL) PARTITION BY RANGE ((gtest_part_

Re: bug: virtual generated column can be partition key

2025-04-22 Thread jian he
On Tue, Apr 22, 2025 at 11:45 AM Ashutosh Bapat wrote: > > I have included your original tests, but ended up rewriting code. Please let > me know what do you think. > + if (attno < 0) + ereport(ERROR, + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("partition key expressions cannot conta

Re: bug: virtual generated column can be partition key

2025-04-21 Thread jian he
On Tue, Apr 22, 2025 at 11:45 AM Ashutosh Bapat wrote: > > > While looking at this I realised that a generated column may end up being > part of the partition key if the partition key expression contains a whole > row reference. Attached patch also has a fix and a testcase for the same. > PARTI

Re: bug: virtual generated column can be partition key

2025-04-21 Thread jian he
On Mon, Apr 21, 2025 at 4:02 PM Fujii Masao wrote: > > > > On 2025/04/21 11:30, jian he wrote: > > hi. > > While trying to make the virtual generated column be part of the partition > > key, > > I found this bug. > > I haven't looked at the patch

bug: virtual generated column can be partition key

2025-04-20 Thread jian he
EATE TABLE gtest_part_key ( f1 date NOT NULL, f2 bigint, f3 bigint GENERATED ALWAYS AS (f2 * 2) VIRTUAL) PARTITION BY RANGE ((f3)); From 10f8c6a1c59a31c2ba6d77d69fdc740e094d9cd3 Mon Sep 17 00:00:00 2001 From: jian he Date: Mon, 21 Apr 2025 10:28:26 +0800 Subject: [PATCH v1 1/1] virtual generated

Re: ALTER COLUMN SET DATA TYPE does not change the generation expression's collation

2025-04-18 Thread jian he
On Wed, Mar 26, 2025 at 1:01 PM jian he wrote: > > hi. > > ATPrepAlterColumnType forbids us to ALTER COLUMN SET DATA TYPE USING (expr) > for generated columns. > however we can still change the generated column type from non-text to text > or text type from one collation

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

2025-04-18 Thread jian he
On Wed, Feb 5, 2025 at 4:24 PM jian he wrote: > > rebased new patch attached. > I also did some cosmetic changes. comments refined. > make sure using index_scan mechanism to fast check column not-null can > only be used via btree index. > isolation tests are simplified.

Re: pg_dump --if-exists --clean when drop index that is partition of a partitioned index

2025-04-15 Thread jian he
On Wed, Apr 16, 2025 at 6:51 AM Tom Lane wrote: > > Or we could do what Jian suggested and just not emit any dropStmt > for child indexes. I continue to fear that that will have > undesirable side-effects, but I have to admit that I'm not sure > what. The fact that the backend will automatically

Re: pg_dump --if-exists --clean when drop index that is partition of a partitioned index

2025-04-15 Thread jian he
On Tue, Apr 15, 2025 at 1:45 PM Pavel Stehule wrote: >> >> seems pretty easy to fix. >> we only need dropStmt when IndxInfo->parentidx oid is invalid. >> >> +if (!OidIsValid(indxinfo->parentidx)) >> +appendPQExpBuffer(delq, "DROP INDEX %s;\n", qqindxname); > > > I don't think i

  1   2   3   4   5   6   7   8   9   10   >