Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions

2025-07-24 Thread jian he
On Tue, Jul 22, 2025 at 8:26 PM Vik Fearing wrote: > > > On 22/07/2025 12:19, jian he wrote: > > On Tue, Jul 22, 2025 at 2:45 PM Vik Fearing > > wrote: > >> It was accepted into the standard after 2023 was released. I am the > >> author of this change

Re: support create index on virtual generated column.

2025-07-24 Thread jian he
ression or virtual generated column data type changes will cause the index to rebuild. Is this we want? Or should changing the generation expression or data type of a virtual generated column mark the associated index as invalid, without triggering a rebuild? From bbc6f3bd7daf53fe97e72bf92a6f9e1f1d71e

Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions

2025-07-23 Thread jian he
7}'::text[] AS integer[] DEFAULT '{-1011}' ON CONVERSION ERROR); + int4 +- + {-1011} +(1 row) I didn't implement the [ FORMAT ] part for now. please check the attached regress test and tests expected result. From 47c181eee593468c3d7b7cb57aec3a1ea8cb3c1d Mon Sep 17

Re: Fix tab completion in v18 for ALTER DATABASE/USER/ROLE ... RESET

2025-07-22 Thread jian he
On Thu, Jul 17, 2025 at 1:41 AM Dagfinn Ilmari Mannsåker wrote: > > Hi hackers, > > These two patches are split out from my earlier thread about improving > tab completion for varous RESET forms > (https://postgr.es/m/87bjqwwtic@wibble.ilmari.org), so that the bug > fixes can be tracked as an

icu_validation_level INFO message level not displayed in pg_settings.enumvals

2025-07-22 Thread jian he
hi. src/backend/utils/misc/guc_tables.c: static const struct config_enum_entry icu_validation_level_options[] = { {"disabled", -1, false}, {"debug5", DEBUG5, false}, {"debug4", DEBUG4, false}, {"debug3", DEBUG3, false}, {"debug2", DEBUG2, false}, {"debug1", DEBUG1, false},

Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions

2025-07-22 Thread jian he
On Tue, Jul 22, 2025 at 2:45 PM Vik Fearing wrote: > > It was accepted into the standard after 2023 was released. I am the > author of this change in the standard, so feel free to ask me anything > you're unsure about. > is the generally syntax as mentioned in this thread: CAST(source_expression

Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions

2025-07-21 Thread jian he
ml [4] https://peter.eisentraut.org/blog/2023/04/04/sql-2023-is-finished-here-is-whats-new From 47c181eee593468c3d7b7cb57aec3a1ea8cb3c1d Mon Sep 17 00:00:00 2001 From: jian he Date: Fri, 18 Jul 2025 13:00:19 +0800 Subject: [PATCH v1 1/2] make ArrayCoerceExpr error safe similar to https://git.postgr

Re: sql/json query function JsonBehavior default expression's collation may differ from returning type's collation

2025-07-21 Thread jian he
On Mon, Jul 14, 2025 at 7:39 PM jian he wrote: > > overall, raising an error if the collation of the > JsonBehavior DEFAULT clause differs from that of the RETURNING clause > is the best option. > > what do you think? in exprSetCollation, the node can be T_CollateExpr. In that

Re: add function argument name to substring and substr

2025-07-20 Thread jian he
function argument name to function substr v6-0002: add function argument name to function substring v6-0002 incorporated some of the changes in v5-0002-v3-delta.patch. some of the changes in v5-0002-v3-delta.patch are not related to this thread, so I didn't incorporate them, right now. F

Re: array_random

2025-07-20 Thread jian he
On Fri, Jul 11, 2025 at 3:49 PM Dean Rasheed wrote: > > On Tue, 8 Jul 2025 at 15:26, Aleksander Alekseev > wrote: > > > > The proposed function seems to do two things at a time - generating > > random values and transforming them into an array of desired > > dimensions. Generally we try to avoid

get_rule_expr RelabelType node does not print COLLATE clause

2025-07-19 Thread jian he
hi. I found in some cases, we need to print COLLATE clauses for RelabelType Node. CREATE TABLE ttsa (c1 text[]); CREATE COLLATION case_sensitive (provider = icu, locale = ''); explain (verbose, cost off) SELECT count(*) FROM ttsa WHERE c1 = (array[1,2]::int[]::text[]) collate case_sensitive;

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

2025-07-18 Thread jian he
On Fri, Jul 18, 2025 at 5:11 AM Álvaro Herrera wrote: > > Anyway, here's a patch. > one minor issue in getDomainConstraints: for (int i = 0, j = 0; i < ntups; i++) { charcontype = (PQgetvalue(res, i, i_contype))[0]; constraint->contype = *(PQgetvalue(res, i,

duplicate line in ExecEvalJsonCoercionFinish

2025-07-16 Thread jian he
hi. ExecEvalJsonCoercionFinish duplicate line: jsestate->escontext.error_occurred = false; jsestate->escontext.error_occurred = false; https://git.postgresql.org/cgit/postgresql.git/tree/src/backend/executor/execExprInterp.c#n5230

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-07-16 Thread jian he
bug: begin; drop table if exists pks cascade; create table pks(i int primary key, b int) partition by range (i); create table pks_34 partition of pks for values from (3) to (6); create table pks_d partition of pks default; insert into pks values (0), (1), (3), (4), (5); commit; alter table pks_d a

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

2025-07-15 Thread jian he
On Tue, Jul 15, 2025 at 2:10 PM jian he wrote: > > accidently found another existing bug. > > create schema test; > CREATE DOMAIN test.d1 AS integer NOT NULL default 11; > alter domain test.d1 add constraint a2 check(value > 1) not valid; > comment on CONSTRAINT a2 ON

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

2025-07-14 Thread jian he
On Tue, Jul 15, 2025 at 2:24 AM Álvaro Herrera wrote: > > On 2025-May-22, jian he wrote: > > > I actually found another bug. > > create schema test; > > CREATE DOMAIN test.d1 AS integer NOT NULL default 11; > > pg_dump --schema=test > 1.sql > >

Re: speedup COPY TO for partitioned table.

2025-07-14 Thread jian he
is in > scope here. > It might be better handled in a follow-up patch focused on improving > test coverage for such unsupported cases, if we decide that's > worthwhile. > i guess it should be fine. since we are only adding one somehow related test case. +-- Test COPY TO with a forei

Re: speedup COPY TO for partitioned table.

2025-07-14 Thread jian he
On Mon, Jul 14, 2025 at 10:02 PM Álvaro Herrera wrote: > > On 2025-Jul-02, jian he wrote: > > > @@ -673,11 +680,34 @@ BeginCopyTo(ParseState *pstate, > >errmsg("cannot co

sql/json query function JsonBehavior default expression's collation may differ from returning type's collation

2025-07-14 Thread jian he
hi. create domain d1 as text collate case_insensitive; select json_value('{"a": "A"}', '$.a' returning d1 default 'C' on empty) = 'a'; --return true select json_value('{"a": "A"}', '$.c' returning d1 default 'A' on empty) = 'a'; --return true select json_value('{"a": "A"}', '$.c' returning d1 def

domain check constraint should also consider domain's collation

2025-07-14 Thread jian he
d1; ``SELECT 'A'::d1`` should error out as domain check constraint not satisfied? If so, attached is the POC trying to implement it. From 8d0b94976c5c1c0cf16f70f7d740ea4f37698340 Mon Sep 17 00:00:00 2001 From: jian he Date: Mon, 14 Jul 2025 16:14:32 +0800 Subject: [PATCH v1 1/1] C

comment in index_create "text_eq" should be "texteq"

2025-07-13 Thread jian he
hi. index_create comments: /* * Btree text_pattern_ops uses text_eq as the equality operator, which is * fine as long as the collation is deterministic; text_eq then reduces to * bitwise equality and so it is semantically compatible with the other * operators and functions

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-07-12 Thread jian he
On Wed, Jun 25, 2025 at 5:28 AM Dmitry Koval wrote: > > Hi! > Thanks for notes! > hi. +static void +transformPartitionCmdForMerge(CreateStmtContext *cxt, PartitionCmd *partcmd) +{ + + /* Is current partition a DEFAULT partition? */ + defaultPartOid = get_default_oid_from_partdesc(RelationGetParti

Re: SQL:2023 JSON simplified accessor support

2025-07-10 Thread jian he
On Thu, Jul 10, 2025 at 9:34 PM jian he wrote: > > -- > in jsonb_subscript_make_jsonpath we have > foreach(lc, *indirection) > { > if (IsA(accessor, String)) > > else if (IsA(accessor, A_

Re: SQL:2023 JSON simplified accessor support

2025-07-10 Thread jian he
On Thu, Jul 10, 2025 at 4:53 PM jian he wrote: > > src7=# select ('{"a": 1, "b": "c", "d": [1, 2, 3]}'::jsonb).d['1'::int8]; > WARNING: mixed usage of jsonb simplified accessor syntax and jsonb > subscripting.

Re: SQL:2023 JSON simplified accessor support

2025-07-10 Thread jian he
On Wed, Jul 9, 2025 at 4:02 PM Alexandra Wang wrote: > > Thanks again for the patch! It was really helpful! I didn't directly > apply it as I made a few different choices, but I think I have > addressed all the points you covered in it. > > Let me know your thoughts! > hi. in v12-0001 and v12-00

Re: support create index on virtual generated column.

2025-07-09 Thread jian he
On Tue, Jul 8, 2025 at 2:37 PM jian he wrote: > > On Tue, Apr 15, 2025 at 4:36 PM jian he wrote: > > > > comment out tests are for to be implemented feature. > > There are some test changes that are indeed not necessary, I restored it > > back, > > please ch

[PATCH] no table rewrite when set column type to constrained domain

2025-07-09 Thread jian he
is set to true only when changing an existing column's type to a constrained domain. In such cases, a table scan is enough—no table rewrite is needed. coerce_to_domain will set to false, if table rewrite is required. From cad4a214c46dfd95fa2ee5c34e5804bd565bd4fb Mon Sep 17 00:00:00 2001 From:

Re: [PATCH] Prevent replacement of a function if it's used in an index expression and is not IMMUTABLE

2025-07-08 Thread jian he
On Mon, Jun 30, 2025 at 5:34 PM sundayjiang(蒋浩天) wrote: > > The purpose of this patch is to prevent replacing a function via `CREATE OR > REPLACE FUNCTION` with a new definition that is not marked as `IMMUTABLE`, if > the existing function is referenced by an index expression. > > Replacing such

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

2025-07-08 Thread jian he
hi. within ATRewriteTable we have: pgstat_progress_update_param(PROGRESS_CLUSTER_TOTAL_HEAP_BLKS, RelationGetNumberOfBlocks(oldrel)); pgstat_progress_update_param(PROGRESS_CLUSTER_TOTAL_HEAP_BLKS, heapScan->rs_nblocks); PROGRESS_CLUSTER_TOTAL_HE

Re: array_random

2025-07-08 Thread jian he
On Sat, Jul 5, 2025 at 3:32 PM Vik Fearing wrote: > > On 30/06/2025 17:04, jian he wrote: > > reasons for adding array_random is: > 1. This is better than array_fill. This can fill random and constant > values (random, min and max the same). > 2. Building a multi-dimensio

Re: support create index on virtual generated column.

2025-07-07 Thread jian he
On Tue, Apr 15, 2025 at 4:36 PM jian he wrote: > > comment out tests are for to be implemented feature. > There are some test changes that are indeed not necessary, I restored it back, > please check attached. hi. refactor and rebase. From d61f21e6fc410827d152a633e5699197c802870a M

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

2025-07-06 Thread jian he
hi. rebased only. From 3ff7dd0fd260a6b3a35f8652f0840ab96bc68c70 Mon Sep 17 00:00:00 2001 From: jian he Date: Mon, 7 Jul 2025 10:07:25 +0800 Subject: [PATCH v2 1/1] allow change generated expression while check constraint on it currently, if we have check constraints over virtual generated

Re: array_random

2025-07-04 Thread jian he
On Mon, Jun 30, 2025 at 11:04 PM jian he wrote: > > demo: > SELECT array_random(1, 6, array[2,5], array[2,4]); > array_random > -- > [2:3][4:8]={{6,2,2,5,4},{4,5,6,4,6}} > > reasons for adding array_random is: > 1. Thi

Re: alter check constraint enforceability

2025-07-04 Thread jian he
On Mon, Jun 2, 2025 at 9:57 PM jian he wrote: > > Currently in pg18, we can add not enforced check constraints. > but we can not do ALTER TABLE ALTER CONSTRAINT [NOT] ENFORCED > for check constraint. > > The attached patch is implementation of changing enforceability of >

Re: Emitting JSON to file using COPY TO

2025-07-03 Thread jian he
On Tue, Mar 11, 2025 at 4:23 PM jian he wrote: > hi. rebase and minor tweaks. From 44c494fd8d7fdb9d8fd5d2d2a48f49b779d1bcb9 Mon Sep 17 00:00:00 2001 From: jian he Date: Fri, 4 Jul 2025 13:25:00 +0800 Subject: [PATCH v17 2/2] Add option force_array for COPY JSON FORMAT force_array option

Re: pg_restore --no-policies should not restore policies' comment

2025-07-03 Thread jian he
store security labels if the associated object is excluded. From 62055ddac9cf73def7e9d3af275f58180707 Mon Sep 17 00:00:00 2001 From: jian he Date: Thu, 3 Jul 2025 11:18:06 +0800 Subject: [PATCH v2 2/3] make pg_dump dump security label for shared database objects MIME-Version: 1.0 Content-Type:

Re: gcc 15 "array subscript 0" warning at level -O3

2025-07-02 Thread jian he
On Thu, Jun 5, 2025 at 3:00 AM Andres Freund wrote: > > > > The dereference is not reachable > > > because of the preceding "var->datatype->typlen == -1" check, > > > but that's not stopping the optimizer from bitching. > > > > > I experimented with modifying exec_set_found thus: > > > > > > v

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

2025-07-02 Thread jian he
error_null, line 1, column a: null input > > It might be better to consider standardizing casing across all COPY > statements (e.g., COPY ... TO, COPY ... FROM STDIN) for consistency. > I followed near code conventions, changing the casing here seems not necessary. From feded9f7562f608e

Re: speedup COPY TO for partitioned table.

2025-07-01 Thread jian he
YPE), errmsg("cannot copy from foreign table \"%s\"", relation_name), errdetail("Partition \"%s\" is a foreign table in the partitioned table \"%s\"",

Re: pg_restore --no-policies should not restore policies' comment

2025-07-01 Thread jian he
ons locally. However, I haven’t tested --no-security-labels option, so no changes were made for it. Testing --no-security-labels appears to need more setup, which didn’t seem trivial. writing Perl tests is not easier for me, I didn’t add those either. (seems in master, we didn't have --no-publi

Re: New function normal_rand_array function to contrib/tablefunc.

2025-06-30 Thread jian he
hi. I don't want to disrupt this thread too much. so I created a separate thread ([1]) for my attached patch. [1] https://www.postgresql.org/message-id/CACJufxF8_VzCFRHRt4OHHF74QtB8tj5Z%3Ddjsy7Y31OHKG5s1-w%40mail.gmail.com

array_random

2025-06-30 Thread jian he
id/CACJufxGRCP19Rm66%3DTSBwmEuVr92FwL_e6YFjmCpJrgu6Km9hQ%40mail.gmail.com From 0fb93c0edf7c100178794396bc5f09a9696e03ce Mon Sep 17 00:00:00 2001 From: jian he Date: Mon, 30 Jun 2025 23:02:57 +0800 Subject: [PATCH v1 1/1] array_random we can not use function signature as array_random(anyelem

Re: ALTER TABLE ALTER CONSTRAINT misleading error message

2025-06-27 Thread jian he
On Fri, Jun 27, 2025 at 2:11 PM Fujii Masao wrote: > > I had this concern because other commands, like ALTER SEQUENCE ALTER > CONSTRAINT NOT VALID, > can also hit this error, and seeing an error message that starts with ALTER > TABLE ... > in that context can be confusing. That's why I thought a

Re: speedup COPY TO for partitioned table.

2025-06-27 Thread jian he
h the actual data will be copied. * root_rel: if not NULL, it indicates that we are copying partitioned relation * data to the destination, and "rel" is the partition of "root_rel". * processed: number of tuples processed. */ static void CopyThisRelTo(CopyToState cstate, Rela

pg_restore --no-policies should not restore policies' comment

2025-06-26 Thread jian he
COMMENT command whose TocEntry->tag also starts with "POLICY". which is also true, per https://www.postgresql.org/docs/current/sql-comment.html after "COMMENT ON", the next word is fixed, and "POLICY" only occurs once. If this is what we want, we can do the same fo

Re: SQL:2023 JSON simplified accessor support

2025-06-26 Thread jian he
hi. in gram.y we have: indirection_el: '.' attr_name { $$ = (Node *) makeString($2); } we can be sure that dot notation, following dot is a plain string. then in jsonb_subscript_transform, we can transform the String Node to a TEXTOI

Re: SQL:2023 JSON simplified accessor support

2025-06-25 Thread jian he
On Wed, Jun 25, 2025 at 1:56 PM jian he wrote: > > hi. CREATE TABLE test_jsonb_dot_notation AS SELECT '{"a": [1, 2, {"b": "c"}, {"b": "d", "e": "f", "x": {"y": "yyy", "z":

Re: pg_dump misses comments on NOT NULL constraints

2025-06-25 Thread jian he
On Wed, Jun 25, 2025 at 11:04 PM Fujii Masao wrote: > >> > >> This commit corrects the behavior by ensuring CREATE TABLE LIKE to also > >> copy > >> the comments on NOT NULL constraints when INCLUDING COMMENTS is specified. > > > > LGTM. I'd add a line in the test showing that these comments are

Re: SQL:2023 JSON simplified accessor support

2025-06-24 Thread jian he
hi. in src/backend/catalog/sql_features.txt should we mark any T860, T861, T862, T863, T864 items as YES? typedef struct SubscriptingRef { /* expressions that evaluate to upper container indexes */ List *refupperindexpr; } SubscriptingRef.refupperindexpr meaning changed, So the abo

Re: SQL:2023 JSON simplified accessor support

2025-06-24 Thread jian he
hi. I have applied for 0001 to 0006. static void jsonb_subscript_transform(SubscriptingRef *sbsref, List **indirection, ParseState *pstate, bool isSlice, bool isAssignment) { List *up

Re: split func.sgml to separated individual sgml files

2025-06-24 Thread jian he
On Thu, Mar 20, 2025 at 10:16 AM David G. Johnston wrote: > > In short, ready to commit (see last paragraph below however), but the > committer will need to run the python script at the time of commit on the > then-current tree. > hi. more explanation, since the python script seems quite large.

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-24 Thread jian he
hi. + /* Sort array of lower bounds. */ + qsort_arg(lower_bounds, nparts, sizeof(PartitionRangeBound *), + qsort_partition_rbound_cmp, (void *) key); here, we don't need ``(void *)`` +ALTER TABLE [ IF EXISTS ] name +MERGE PARTITIONS (partition_name1, partition_name2 [, ...]) +INTO p

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

2025-06-23 Thread jian he
On Mon, Jun 23, 2025 at 9:13 PM Peter Eisentraut wrote: > > > > > Note: Support for composite types in virtual generated columns is > > currently partial. > > for example: > > > > CREATE TYPE double_int as (a int, b int); > > --ok > > CREATE TABLE gtest4 ( > > a int, > > b double_int GEN

Re: New function normal_rand_array function to contrib/tablefunc.

2025-06-23 Thread jian he
bigint[] | min bigint, max bigint, dims integer[], lbounds integer[] DEFAULT NULL::integer[] | func pg_catalog | array_random | integer[]| min integer, max integer, dims integer[], lbounds integer[] DEFAULT NULL::integer[] | func pg_catalog | array_random | numeric[]|

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

2025-06-21 Thread jian he
On Sat, Jun 21, 2025 at 1:29 PM jian he wrote: > > ( the following excerpted from create_type.sql) > > BEGIN; > CREATE TYPE int42; > -- Make dummy I/O routines using the existing internal support for int4, text > CREATE FUNCTION int42_in(cstring) >RETURNS int42 >

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

2025-06-20 Thread jian he
On Thu, Jun 19, 2025 at 5:11 AM Peter Eisentraut wrote: > Here is a new patch. > > My previous patch was a bit too simple. I had thought that > check_functions_in_node() does the node walking itself, but that was > wrong, so the patch only worked at the top-level of the expression. So > I had to

Re: pg_dump misses comments on NOT NULL constraints

2025-06-18 Thread jian he
ffa5c5? > hi. in transformTableLikeClausem, let cxt(CreateStmtContext) to add CommentStmt should just work. Please check attached, tests also added. From 41fd109bd75451cadc347cc37be56228e85f3417 Mon Sep 17 00:00:00 2001 From: jian he Date: Thu, 19 Jun 2025 13:40:06 +0800 Subject: [PATCH v1 1/1

Re: pg_dump misses comments on NOT NULL constraints

2025-06-18 Thread jian he
nt name. if tbinfo->notnull_constrs is an empty string, we need to use the above "%s_%s_not_null" trick to get the default no-null constraint name. From 4cce00779490001f4e40fb3055c7bddd539e1ad2 Mon Sep 17 00:00:00 2001 From: jian he Date: Thu, 19 Jun 2025 10:26:44 +0800 Subject: [PATCH

Re: pg_dump misses comments on NOT NULL constraints

2025-06-18 Thread jian he
n print_notnull is true. Since we already know which columns have had their not-null constraints printed, it makes sense to dump inline not-null comments here too. Please check the attached POC patch. From c586c07a2c2b473f88453c12de0a08190db42a2f Mon Sep 17 00:00:00 2001 From: jian he Date: Wed,

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-17 Thread jian he
hi. The following are changes I made based on v47. mainly comments refactoring, variable/argument renaming. please see the attached patch. + + /* Create the relation. */ + newRelId = heap_create_with_catalog(newPartName->relname, + namespaceId, + modelRel->rd_rel->reltablespace, + + allowSyst

Re: wrong comments in rewriteTargetListIU

2025-06-17 Thread jian he
On Tue, Jun 17, 2025 at 7:42 PM Peter Eisentraut wrote: > > However, I see your point that it contrasts with the attidentity code > just above. > > Perhaps a way to resolve this would be to rewrite the comment something > like: > > /* > * Although inserting into a GENERATED BY DEFAULT i

Re: confusing message in check_tuple

2025-06-17 Thread jian he
On Tue, Jun 17, 2025 at 1:21 PM Peter Eisentraut wrote: > > On 12.06.25 08:26, jian he wrote: > > in contrib/amcheck/verify_heapam.c, check_tuple > > report_corruption(ctx, > >psprintf("number of attributes %u exceeds >

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-06-17 Thread jian he
On Tue, Jun 17, 2025 at 4:15 AM Dmitry Koval wrote: > > Added patch and a bit modified test. > hi. Please check the attached patch for addressing the following issues. + else + { + ereport(ERROR, + errcode(ERRCODE_DUPLICATE_TABLE), + errmsg("relation \"%s\" already exists", cmd->name->relname));

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

  1   2   3   4   5   6   7   8   9   10   >