Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-08-29 Thread jian he
On Tue, Aug 26, 2025 at 4:05 PM Dmitry Koval wrote: > > Hi! > Thanks for the notes and patches! > hi. ORDER BY regclass seems not stable, see https://git.postgresql.org/cgit/postgresql.git/commit/?id=17bcf4f5450430f67b744c225566c9e0e6413e95 some of the SQL tests seem not necessary, so I refactore

Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt

2025-08-28 Thread jian he
d be fine. please check the attached POC, regress tests also added. main idea is first check CreateStatsStmt->relations, then call transformStatsStmt, transformStatsStmt only to transform CreateStatsStmt->exprs. also the above complaint about the relation lock issue will be resolved. From 049

[patch] ALTER COLUMN SET EXPRESSION [GENERATED|STORED]

2025-08-27 Thread jian he
column values as 0, isnull as true). what do you think? From cc458eec71fd100ea420629ae9d84d9e80bbdd88 Mon Sep 17 00:00:00 2001 From: jian he Date: Thu, 28 Aug 2025 11:53:46 +0800 Subject: [PATCH v1 1/1] ALTER COLUMN SET EXPRESSION [GENERATED|STORED] example syntax explanation: ALTER TABLE gtest29

Re: Fix ALTER TABLE DROP EXPRESSION with inheritance hierarchy

2025-08-27 Thread jian he
On Mon, Aug 25, 2025 at 9:04 PM Kirill Reshke wrote: > > Hi! > > On Sun, 24 Aug 2025 at 14:05, jian he wrote: > > > > hi. > > > > --this ALTER COLUMN DROP EXPRESSION work as expected > > DROP TABLE IF EXISTS parent cascade; > > CREATE TABLE pare

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

2025-08-26 Thread jian he
On Tue, Aug 26, 2025 at 7:43 PM Fujii Masao wrote: > > > > > summary of attached patch: > > Thanks for the patches! > > > 01: make pg_restore not restore comments if comments associated > > objects are excluded. > > > TODO: need perl tests > > How about adding tests for pg_restore --no-policies in

Re: SQL:2023 JSON simplified accessor support

2025-08-26 Thread jian he
On Tue, Aug 26, 2025 at 11:53 AM Alexandra Wang wrote: > > Hi Jian, > > I’ve attached v14, which includes only indentation and comment changes > from v13. > hi. still reviewing v14-0001 to v14-0005. I am confused by the comments in jsonb_subscript_transform "" * (b) jsonb_subscript_make_jso

Re: CREATE SCHEMA ... CREATE DOMAIN support

2025-08-25 Thread jian he
n encoding, if fail, error message may different on different machines, So we have to put some of the tests to collate.icu.utf8.sql. Please check the latest attached. v7-0001-Don-t-try-to-re-order-the-subcommands-of-CREATE-SCHEMA.patch v7-0002-CREATE-SCHEMA-CREATE-DOMAIN.patch v7-0003-CREATE-SCHEMA

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

2025-08-25 Thread jian he
On Thu, Jul 10, 2025 at 2:00 AM jian he wrote: > > we can add a new boolean field, coerce_to_domain, to NewColumnValue. this > field > 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 tab

Re: Problem in 'ORDER BY' of a column using a created collation?

2025-08-25 Thread jian he
On Mon, Aug 25, 2025 at 3:52 PM Nishant Sharma wrote: > > > Experiment 1:- > SQL File : PG_Exp_1.sql > > Actual Output : PG_Exp_1.out > > Created COLLATION : CREATE COLLATION test_coll ( > provider = icu, locale = 'ja-u-kr-latn-digit'); > > Experiment 2:- > SQL File : PG_Exp_2.sql > > Actual Outpu

Re: SQL:2023 JSON simplified accessor support

2025-08-25 Thread jian he
On Sat, Aug 23, 2025 at 3:34 AM Alexandra Wang wrote: > > I don’t understand the question. In the case of an unsupported Node > type (not an Indices in patch 0001 or 0002), we break out of the loop > to stop transforming the remaining subscripts. So there won’t be any > ‘not contiguous’ indirectio

Re: disallow alter individual column if partition key contains wholerow reference

2025-08-24 Thread jian he
On Mon, Aug 25, 2025 at 11:58 AM Chao Li wrote: > > I tested this patch with “partition by range”, it works for me. > > Just have a few small comments: > > + if (bms_is_member(0 - > FirstLowInvalidHeapAttributeNumber, expr_attrs)) > > Can we simply check “if (Var *)expr->var

Re: bug: virtual generated column can be partition key

2025-08-24 Thread jian he
On Tue, May 6, 2025 at 6:49 PM Yura Sokolov wrote: > > 06.05.2025 13:31, 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

Re: disallow alter individual column if partition key contains wholerow reference

2025-08-24 Thread jian he
On Tue, Apr 22, 2025 at 7:39 PM jian he wrote: > > demo: > drop table if exists t4; > CREATE TABLE t4(f1 int, f2 bigint) PARTITION BY list ((t4)); > create table t4_1 partition of t4 for values in ((1,2)); > alter table t4 alter column f2 set data type text using f2; > >

minor refactor on src/test/modules/test_ddl_deparse/sql/alter_table.sql

2025-08-24 Thread jian he
ALTER COLUMN SET EXPRESSION, so I added a test on it. From 55fed544cab5addb108d61f43fe6d2286fcb6f40 Mon Sep 17 00:00:00 2001 From: jian he Date: Sun, 24 Aug 2025 22:51:30 +0800 Subject: [PATCH v1 1/1] refactor test_ddl_deparse/sql/alter_table.sql 1. The test initially focuses on the "parent&

Fix ALTER TABLE DROP EXPRESSION with inheritance hierarchy

2025-08-24 Thread jian he
generated error: ERROR: 0A000: ALTER TABLE / DROP EXPRESSION must be applied to child tables too LOCATION: ATPrepDropExpression, tablecmds.c:8734 The attached patch fixes this potential issue. From 78f2d0734d492296289671cc0b740329d1f2da30 Mon Sep 17 00:00:00 2001 From: jian he Date: Sun, 24 Aug

Re: PoC: pg_dump --filter-data (like Oracle Where Clause on RMAN for specific tables)

2025-08-23 Thread jian he
hi. I just found this https://www.postgresql.org/message-id/flat/CALAY4q8o00Sg5nemi2AuqNuLvmGLaR6br%2BYrvM41ZuSPjM2Qvg%40mail.gmail.com maybe it's not that very helpful. IMV, pg_dump --option="view_name" is better than pg_dump -d cary --where="test1:a3 = ( select max(aa1) from test2 )" > testdump

Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt

2025-08-22 Thread jian he
hi. will + if (!IsA(rln, RangeVar)) + ereport(ERROR, + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("CREATE STATISTICS only supports regular tables, materialized views, foreign table

Re: SQL:2023 JSON simplified accessor support

2025-08-22 Thread jian he
On Thu, Aug 21, 2025 at 12:54 PM Alexandra Wang wrote: > > Hi Jian, > > Thanks for reviewing! I’ve attached v13, which addresses your > feedback. > hi. in the context of v13-0001 and v13-0002. In transformIndirection: while (subscripts) { Node *newresult = (Node *) = transformContainer

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-08-21 Thread jian he
On Thu, Aug 21, 2025 at 2:45 PM jian he wrote: > > On Thu, Aug 21, 2025 at 10:53 AM jian he wrote: > > > > > this time, I only checked > > > v52-0001-Implement-ALTER-TABLE-.-MERGE-PARTITIONS-.-comma.patch hi. +static void +check_two_partitions_bounds_range(Relati

misleading error message in ProcessUtilitySlow T_CreateStatsStmt

2025-08-21 Thread jian he
hi. while reviewing other work, some error messages in src/backend/tcop/utility.c seem not accurate. static void ProcessUtilitySlow(ParseState *pstate, PlannedStmt *pstmt, const char *queryString, ProcessUtilityContext context,

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-08-20 Thread jian he
On Thu, Aug 21, 2025 at 10:53 AM jian he wrote: > > > this time, I only checked > > v52-0001-Implement-ALTER-TABLE-.-MERGE-PARTITIONS-.-comma.patch > > hi. we may need to change checkPartition. +-- ERROR: "sales_apr2022" is not a table +ALTER TABLE sales_range

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-08-20 Thread jian he
On Wed, Aug 20, 2025 at 5:22 PM jian he wrote: > > this time, I only checked > v52-0001-Implement-ALTER-TABLE-.-MERGE-PARTITIONS-.-comma.patch > > typedef struct PartitionCmd > { > NodeTagtype; > RangeVar *name;/* name of partitio

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2025-08-20 Thread jian he
hi. this time, I only checked v52-0001-Implement-ALTER-TABLE-.-MERGE-PARTITIONS-.-comma.patch typedef struct PartitionCmd { NodeTagtype; RangeVar *name;/* name of partition to attach/detach/merge */ PartitionBoundSpec *bound;/* FOR VALUES, if attaching */

Re: UPDATE with invalid domain constraint

2025-08-19 Thread jian he
On Tue, Aug 19, 2025 at 10:08 PM jian he wrote: > > drop table if exists dt1; > drop domain if exists d1; > create domain d1 as int; > create table dt1(i int, c d1); > insert into dt1 values(1,2); > alter domain d1 add constraint cc check(value <> 2) not valid; &g

UPDATE with invalid domain constraint

2025-08-19 Thread jian he
hi. should UPDATE statement need to verify that the domain value is satisfied with invalid domain constraints? Álvaro Herrera already mentioned this in [1], but I just want to confirm it. drop table if exists dt1; drop domain if exists d1; create domain d1 as int; create table dt1(i int, c d1); i

Re: CREATE SCHEMA ... CREATE DOMAIN support

2025-08-18 Thread jian he
N.patch v6-0001-Don-t-try-to-re-order-the-subcommands-of-CREATE-SCHEMA.patch is refactor/rebase based on v1-0001-Don-t-try-to-re-order-the-subcommands-of-CREATE-S.patch v6-0002-CREATE-SCHEMA-CREATE-DOMAIN.patch for CREATE SCHEMA ... CREATE-DOMAIN v6-0003-CREATE-SCHEMA-CREATE-COLLATION.patch for C

Re: ALTER DOMAIN ADD NOT NULL NOT VALID

2025-08-17 Thread jian he
On Thu, Aug 14, 2025 at 5:02 PM Kirill Reshke wrote: > > I have few observations. > One is whether we should now support CREATE DOMAIN ... NOT NULL NOT > VALID syntax? This could be a separate patch though. > in gram.y: CreateDomainStmt: CREATE DOMAIN_P any_name opt_as Typename ColQu

Re: someone else to do the list of acknowledgments

2025-08-16 Thread jian he
hi. maybe we should start working on this? https://www.postgresql.org/developer/roadmap says 18 will be released in September 2025.

Re: Making jsonb_agg() faster

2025-08-15 Thread jian he
On Sat, Aug 16, 2025 at 12:57 AM Tom Lane wrote: > > I think you're missing the point: per the commit message for 0001, > > The real reason for doing it is to provide a mechanism whereby > pushJsonbValue() can be told to construct the JsonbValue tree > in a context that is not CurrentM

Re: Making jsonb_agg() faster

2025-08-14 Thread jian he
On Thu, Aug 14, 2025 at 4:59 PM jian he wrote: > > > 0001 is a somewhat invasive refactoring of the API for > > pushJsonbValue and friends. in pushJsonbValue: /* * pushJsonbValueScalar handles all cases not involving pushing a * container object as an ELEM or VALUE.

Re: Making jsonb_agg() faster

2025-08-14 Thread jian he
On Wed, Jul 23, 2025 at 12:37 AM Tom Lane wrote: > > There have been some complaints recently about how jsonb_agg() > is a lot slower than json_agg() [1]. That's annoying considering > that the whole selling point of JSONB is to have faster processing > than the original JSON type, so I poked int

Re: ALTER DOMAIN ADD NOT NULL NOT VALID

2025-08-13 Thread jian he
hi. rebase and minor cosmetic change. From b87caa1b2f78d3f1e94e1055219c97e038d2fe61 Mon Sep 17 00:00:00 2001 From: jian he Date: Thu, 14 Aug 2025 10:40:49 +0800 Subject: [PATCH v3 1/1] ALTER DOMAIN ADD NOT NULL NOT VALID We have NOT NULL NO VALID for table constraints, we can make domain have

Re: on_error table, saving error info to a table

2025-08-12 Thread jian he
aving_table); > but where "error_saving_table_type" TYPE/TABLE will come from? "error_saving_table_type" either comes from built-in or makes it user defined. Preserving it as a built-in type would require broader consensus, which is likely difficult to achieve. user-define

Re: implement CAST(expr AS type FORMAT 'template')

2025-08-11 Thread jian he
m/CACJufxF4OW=x2rcwa+zmcgopdwgkdxha09qtftpcj3qstg6...@mail.gmail.com From ef719a5fcf2e96d7fc756a021aebd8caf5b0b385 Mon Sep 17 00:00:00 2001 From: jian he Date: Tue, 12 Aug 2025 14:23:02 +0800 Subject: [PATCH v4 1/1] CAST(val AS type FORMAT 'template') MIME-Version: 1.0 Content-Type: text/plain;

Re: alter check constraint enforceability

2025-08-11 Thread jian he
so here you don't need to consider RELKIND_PARTITIONED_TABLE. From a54609c8aa66174e171fdfd7c08519e587561d85 Mon Sep 17 00:00:00 2001 From: jian he Date: Mon, 11 Aug 2025 17:51:56 +0800 Subject: [PATCH v3 1/1] alter check constraint enforceability syntax: ALTER TABLE ALTER CONSTRAINT [NOT] ENFOR

Re: Emitting JSON to file using COPY TO

2025-08-10 Thread jian he
e9104bcc0a6c4ca96df5ff3fdd3ae659885dd664 Mon Sep 17 00:00:00 2001 From: jian he Date: Wed, 30 Jul 2025 19:50:41 +0800 Subject: [PATCH v18 3/3] Add option force_array for COPY JSON FORMAT force_array option can only be used in COPY TO with JSON format. it make the output json output behave like json array type

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

2025-08-04 Thread jian he
On Mon, Aug 4, 2025 at 1:09 PM Corey Huinker wrote: >> >> so we need to handle numeric source types with fractional points with >> special care. >> currently, this applies only to numeric, float4, and float8. >> (hope this is all the corner case we need to catch...) > > > I'm fairly certain that t

Re: implement CAST(expr AS type FORMAT 'template')

2025-08-03 Thread jian he
hi. one more question: For binary coercible type casts, no formatted related function for it, should we error out? For example, should the following error out or return text '1'. select cast('1'::text as text format ''::text);

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

2025-08-03 Thread jian he
hi. fix the regress tests failure in https://api.cirrus-ci.com/v1/artifact/task/5894868779663360/testrun/build/testrun/regress/regress/regression.diffs From e60e5190511326568eba8e6748062adb47f1134c Mon Sep 17 00:00:00 2001 From: jian he Date: Fri, 18 Jul 2025 13:00:19 +0800 Subject: [PATCH v4 2

Re: implement CAST(expr AS type FORMAT 'template')

2025-08-01 Thread jian he
On Tue, Jul 29, 2025 at 11:54 AM David G. Johnston wrote: > > The slight variation to this would be to specify these 2/4 and 1-arg > functions as optional “format_in” and “format_out” optional properties (like > typmod_in). The format-aware code can look for these which will end up > having th

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

2025-07-31 Thread jian he
because it will call numeric_mul. so I made these 16 function errors safe. see v3-0001-make-some-numeric-cast-function-error-safe.patch From 0fa2361b7d7692a9c032d8a8a7f2b04ab4302849 Mon Sep 17 00:00:00 2001 From: jian he Date: Fri, 18 Jul 2025 13:00:19 +0800 Subject: [PATCH

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

2025-07-29 Thread jian he
hi. rebase. From b3b2d794c83b36cf129d917d527ebf2cac46ca3b Mon Sep 17 00:00:00 2001 From: jian he Date: Wed, 30 Jul 2025 11:06:17 +0800 Subject: [PATCH v19 1/1] COPY (on_error set_null) Current grammar makes us unable to use "on_error null". if we did it, then in all the COPY command

Re: speedup COPY TO for partitioned table.

2025-07-29 Thread jian he
On Mon, Jul 28, 2025 at 9:22 AM torikoshia wrote: > > I think the behavior for materialized views can be described along with > that for partitioned tables. For example: > > COPY TO can be used with plain > tables, populated materialized views and partitioned tables. > For exampl

Re: split func.sgml to separated individual sgml files

2025-07-28 Thread jian he
hi. after run the v2 python script and ``git apply v2-0001-update-filelist.sgml-allfiles.sgml.no-cfbot`` git status -u shows: Changes not staged for commit: (use "git add/rm ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified

Re: implement CAST(expr AS type FORMAT 'template')

2025-07-28 Thread jian he
$ BEGIN RETURN '1'; END; $$ LANGUAGE plpgsql VOLATILE FORMAT; this function "test" format text based on second argument(template) and return json type. POC attached. what do you think? From c944169304c3922c3cc76166ccd7a54cfcf595ba Mon Sep 17 00:00:00 2001 From: jian he Date: Tue,

Re: implement CAST(expr AS type FORMAT 'template')

2025-07-28 Thread jian he
On Mon, Jul 28, 2025 at 2:31 AM Vik Fearing wrote: > > > On 27/07/2025 17:43, jian he wrote: > > hi. > > > > while working on CAST(... DEFAULT ON ERROR), I came across link[1]. I don't > > have access to the SQL standard, but based on the information in

implement CAST(expr AS type FORMAT 'template')

2025-07-27 Thread jian he
D'); --error select cast('2018-13-12' as date format '-DD-MM'); --no error select to_char(cast('2018-13-12' as date format '-DD-MM'), '-Mon-DD'); returns 2018-Dec-13 [1]: https://wiki.postgresql.org/wiki/PostgreSQL_vs_SQL_Standard#Major

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

  1   2   3   4   5   6   7   8   9   10   >