Re: PoC/WIP: Extended statistics on expressions

2021-01-16 Thread Zhihong Yu
Hi, +* Check that only the base rel is mentioned. (This should be dead code +* now that add_missing_from is history.) +*/ + if (list_length(pstate->p_rtable) != 1) If it is dead code, it can be removed, right ? For statext_mcv_clauselist_selectivity: + // bms_fre

Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit

2021-01-17 Thread Zhihong Yu
Hi, This patch introduces new function postgres_fdw_disconnect() when called with a foreign server name discards the associated connections with the server name. I think the following would read better: This patch introduces *a* new function postgres_fdw_disconnect(). When called with a foreign

Re: Transactions involving multiple postgres foreign servers, take 2

2021-01-18 Thread Zhihong Yu
AM Zhihong Yu wrote: > > > > For v32-0002-postgres_fdw-supports-commit-and-rollback-APIs.patch : > > > > + entry->changing_xact_state = true; > > ... > > + entry->changing_xact_state = abort_cleanup_failure; > > > > I don't see return

Re: New IndexAM API controlling index vacuum strategies

2021-01-18 Thread Zhihong Yu
Hi, Masahiko-san: For v2-0001-Introduce-IndexAM-API-for-choosing-index-vacuum-s.patch : For blvacuumstrategy(): + if (params->index_cleanup == VACOPT_TERNARY_DISABLED) + return INDEX_VACUUM_STRATEGY_NONE; + else + return INDEX_VACUUM_STRATEGY_BULKDELETE; The 'else' can be omitte

Re: POC: postgres_fdw insert batching

2021-01-18 Thread Zhihong Yu
Hi, Takayuki-san: + if (batch_size <= 0) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), +errmsg("%s requires a non-negative integer value", It seems the message doesn't match the check w.r.t. the batch size of 0. + int

Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly

2021-01-18 Thread Zhihong Yu
Hi, For 0001-Allow-REINDEX-to-change-tablespace.patch : + * InvalidOid, use the tablespace in-use instead. 'in-use' seems a bit redundant in the sentence. How about : InvalidOid, use the tablespace of the index instead. Cheers On Mon, Jan 18, 2021 at 12:38 AM Justin Pryzby wrote: > On Mon, Ja

Re: simplifying foreign key/RI checks

2021-01-18 Thread Zhihong Yu
Hi, I was looking at this statement: insert into f select generate_series(1, 200, 2); Since certain generated values (the second half) are not in table p, wouldn't insertion for those values fail ? I tried a scaled down version (1000th) of your example: yugabyte=# insert into f select genera

Re: search_plan_tree(): handling of non-leaf CustomScanState nodes causes segfault

2021-01-18 Thread Zhihong Yu
Hi, +* Custom scan nodes can be leaf nodes or inner nodes and therfore need special treatment. The special treatment applies to inner nodes. The above should be better phrased to clarify. Cheers On Mon, Jan 18, 2021 at 2:43 AM David Geier wrote: > Hi hackers, > > While working wit

Re: search_plan_tree(): handling of non-leaf CustomScanState nodes causes segfault

2021-01-18 Thread Zhihong Yu
Hi, It seems sstate->ss_currentRelation being null can only occur for T_ForeignScanState and T_CustomScanState. What about the following change ? Cheers diff --git a/src/backend/executor/execCurrent.c b/src/backend/executor/execCurrent.c index 0852bb9cec..56e31951d1 100644 --- a/src/backend/exec

Re: search_plan_tree(): handling of non-leaf CustomScanState nodes causes segfault

2021-01-18 Thread Zhihong Yu
ertion in the diff. Cheers On Mon, Jan 18, 2021 at 12:16 PM Tom Lane wrote: > Zhihong Yu writes: > > It seems sstate->ss_currentRelation being null can only > > occur for T_ForeignScanState and T_CustomScanState. > > What about the following change ? > > Seems li

Re: simplifying foreign key/RI checks

2021-01-18 Thread Zhihong Yu
uess a counter other than i would be better for this purpose. Cheers On Mon, Jan 18, 2021 at 6:45 PM Amit Langote wrote: > On Tue, Jan 19, 2021 at 2:47 AM Zhihong Yu wrote: > > > > Hi, > > I was looking at this statement: > > > > insert into f select generate_s

Re: POC: postgres_fdw insert batching

2021-01-20 Thread Zhihong Yu
Hi, The assignment to resultRelInfo is done when junk_filter_needed is true: if (junk_filter_needed) { resultRelInfo = mtstate->resultRelInfo; Should the code for determining batch size access mtstate->resultRelInfo directly ? diff --git a/src/backend/executor/nodeMod

Re: POC: postgres_fdw insert batching

2021-01-20 Thread Zhihong Yu
disabled for the * server/table). My patch would reflect that change. I guess this was the reason the if / else block was placed there in the first place. Cheers On Wed, Jan 20, 2021 at 4:56 PM Tomas Vondra wrote: > > > On 1/21/21 1:17 AM, Zhihong Yu wrote: > > Hi, > &

Re: POC: postgres_fdw insert batching

2021-01-20 Thread Zhihong Yu
: > > > On 1/21/21 2:02 AM, Zhihong Yu wrote: > > Hi, Tomas: > > In my opinion, my patch is a little better. > > Suppose one of the conditions in the if block changes in between the > > start of loop and the end of the loop: > > > > * Determine if th

Re: POC: postgres_fdw insert batching

2021-01-20 Thread Zhihong Yu
Hi, Takayuki-san: My first name is Zhihong. You can call me Ted if you want to save some typing :-) Cheers On Wed, Jan 20, 2021 at 5:37 PM tsunakawa.ta...@fujitsu.com < tsunakawa.ta...@fujitsu.com> wrote: > From: Zhihong Yu > > > Do we need to consider how this p

Re: Parallel INSERT (INTO ... SELECT ...)

2021-01-20 Thread Zhihong Yu
Hi, For v12-0001-Enable-parallel-SELECT-for-INSERT-INTO-.-SELECT.patch : is found from the additional parallel-safety checks, or from the existing parallel-safety checks for SELECT that it currently performs. existing and 'it currently performs' are redundant. You can omit 'that it currently perf

Re: Parallel INSERT (INTO ... SELECT ...)

2021-01-20 Thread Zhihong Yu
orrectly, it seems it can be dropped (use pei->processed_count directly). Cheers On Wed, Jan 20, 2021 at 6:29 PM Zhihong Yu wrote: > Hi, > For v12-0001-Enable-parallel-SELECT-for-INSERT-INTO-.-SELECT.patch : > > is found from the additional parallel-safety checks, or from the exi

Re: PATCH: Batch/pipelining support for libpq

2021-01-21 Thread Zhihong Yu
Hi, + commandFailed(st, "SQL", "\\gset and \\aset are not allowed in a batch section"); It seems '\\gset or \\aset is not ' would correspond to the check more closely. + if (my_command->argc != 1) + syntax_error(source, lineno, my_command->first_line, my_com

Re: POC: postgres_fdw insert batching

2021-01-23 Thread Zhihong Yu
Amit: Good catch. bq. ExecInitRoutingInfo() that is in the charge of initialing Should be 'ExecInitRoutingInfo() that is in charge of initializing' Cheers On Sat, Jan 23, 2021 at 12:31 AM Amit Langote wrote: > On Thu, Jan 21, 2021 at 11:36 AM Tomas Vondra > wrote: > > On 1/21/21 3:09 AM, tsu

Re: [HACKERS] GSoC 2017: Foreign Key Arrays

2021-01-23 Thread Zhihong Yu
Hi, Mark: + CREATE TABLE races ( Maybe 'racings' is a better name for the table (signifying the activities). + if (ARR_NDIM(arr) != 1 || + ARR_DIMS(arr)[0] != numkeys || + ARR_HASNULL(arr) || + ARR_ELEMTYPE(arr) != CHAROID) + elog(ERROR, "confref

Re: simplifying foreign key/RI checks

2021-01-23 Thread Zhihong Yu
Hi, + for (i = 0; i < riinfo->nkeys; i++) + { + Oid eq_opr = eq_oprs[i]; + Oid typeid = RIAttType(fk_rel, riinfo->fk_attnums[i]); + RI_CompareHashEntry *entry = ri_HashCompareOp(eq_opr, typeid); + + if (pk_nulls[i] != 'n' && OidIsValid(en

Re: New IndexAM API controlling index vacuum strategies

2021-01-25 Thread Zhihong Yu
ing breaks > the logic of a thread.) > > On Tue, Jan 19, 2021 at 12:02 AM Zhihong Yu wrote: > > > > Hi, Masahiko-san: > > Thank you for reviewing the patch! > > > > > For v2-0001-Introduce-IndexAM-API-for-choosing-index-vacuum-s.patch : > > > > For

Re: Tid scan improvements

2021-01-25 Thread Zhihong Yu
Hi, bq. within this range. Table AMs where scanning ranges of TIDs does not make sense or is difficult to implement efficiently may choose to not implement Is there criterion on how to judge efficiency ? + if (tidopexpr->exprtype == TIDEXPR_LOWER_BOUND) ... + if (tidopexpr->exprtype

Re: logical replication worker accesses catalogs in error context callback

2021-01-26 Thread Zhihong Yu
For 0002, a few comments on the description: bq. Avoid accessing system catalogues inside conversion_error_callback catalogues -> catalog bq. error context callback, because the the entire transaction might There is redundant 'the' bq. Since get_attname() and get_rel_name() could search the sy

Re: [HACKERS] GSoC 2017: Foreign Key Arrays

2021-01-27 Thread Zhihong Yu
Hi, Mark: + if (ARR_NDIM(arr) != 1 || + ARR_HASNULL(arr) || + ARR_ELEMTYPE(arr) != CHAROID) + elog(ERROR, "confreftype is not a 1-D char array"); I think the ARR_HASNULL(arr) condition is not reflected in the error message. +* Array foreign keys support on

Re: [sqlsmith] Failed assertion during partition pruning

2021-01-29 Thread Zhihong Yu
Hi, I wonder if the (failed) assertion should be converted to an if statement: diff --git a/src/backend/partitioning/partprune.c b/src/backend/partitioning/partprune.c index fac921eea5..d646f08a07 100644 --- a/src/backend/partitioning/partprune.c +++ b/src/backend/partitioning/partprune.c @@ -585,

Re: Determine parallel-safety of partition relations for Inserts

2021-02-01 Thread Zhihong Yu
Hi, For v3_0003-reloption-parallel_dml-src.patch : +* Check if parallel_dml_enabled is enabled for the target table, +* if not, skip the safety checks and return PARALLEL_UNSAFE. Looks like the return value is true / false. So the above comment should be adjusted. + if (!RelationGetPar

Re: Dumping/restoring fails on inherited generated column

2021-02-03 Thread Zhihong Yu
Hi, + if (attribute->attgenerated && !childatt->attgenerated) + ereport(ERROR, ... + if (attribute->attgenerated && childatt->attgenerated) + { Looks like for the second if statement, checking attribute->attgenerated should be enough (due to the check fr

Re: WIP: BRIN multi-range indexes

2021-02-03 Thread Zhihong Yu
Hi, For 0007-Remove-the-special-batch-mode-use-a-larger--20210203.patch : + /* same as preceding value, so store it */ + if (compare_values(&range->values[start + i - 1], + &range->values[start + i], + (void *) &cxt) == 0) + c

Re: WIP: BRIN multi-range indexes

2021-02-03 Thread Zhihong Yu
Hi, bq. Not sure why would that be an issue Moving the (start > end) check is up to your discretion. But the midpoint computation should follow text book :-) Cheers On Wed, Feb 3, 2021 at 4:59 PM Tomas Vondra wrote: > > > On 2/4/21 1:49 AM, Zhihong Yu wrote: > > Hi, >

Re: [HACKERS] GSoC 2017: Foreign Key Arrays

2021-02-04 Thread Zhihong Yu
Hi, For Array-containselem-gin-v4.patch , one small comment: + * array_contains_elem : checks an array for a spefific element typo: specific Cheers On Thu, Feb 4, 2021 at 4:03 PM Mark Rofail wrote: > Hello Joel, > > No error, even though bigint[] isn't compatible with smallint. >> > I added a

Re: TRUNCATE on foreign table

2021-02-06 Thread Zhihong Yu
Hi, + if (strcmp(defel->defname, "truncatable") == 0) + server_truncatable = defGetBoolean(defel); Looks like we can break out of the loop when the condition is met. + /* ExecForeignTruncate() is invoked for each server */ The method name in the comment

Re: CLUSTER on partitioned index

2021-02-06 Thread Zhihong Yu
Hi, For v7-0002-Implement-CLUSTER-of-partitioned-table.patch: +* We have to build the list in a different memory context so it will +* survive the cross-transaction processing +*/ + old_context = MemoryContextSwitchTo(cluster_context); cluster_context is not modified

Re: REINDEX backend filtering

2021-02-07 Thread Zhihong Yu
Hi, For index_has_deprecated_collation(), + object.objectSubId = 0; The objectSubId field is not accessed by do_check_index_has_deprecated_collation(). Does it need to be assigned ? For RelationGetIndexListFiltered(), it seems when (options & REINDEXOPT_COLL_NOT_CURRENT) == 0, the full_list wo

Re: jsonb_array_elements_recursive()

2021-02-07 Thread Zhihong Yu
Hi, # SELECT '[[5,2],"a",[8,[3,2],6]]'::jsonb; jsonb --- [[5, 2], "a", [8, [3, 2], 6]] (1 row) unnest(array[[3,2],"a",[1,4]]) is not accepted currently. Would the enhanced unnest accept the above array ? Cheers On Sun, Feb 7, 2021 at 8:31 AM Joel Jacobs

Re: jsonb_array_elements_recursive()

2021-02-07 Thread Zhihong Yu
Joel Jacobson wrote: > On Sun, Feb 7, 2021, at 18:33, Zhihong Yu wrote: > >Hi, > ># SELECT '[[5,2],"a",[8,[3,2],6]]'::jsonb; > > jsonb > >--- > > [[5, 2], "a", [8, [3, 2], 6]] > >(1 row) &

Re: [PATCH] Improve amcheck to also check UNIQUE constraint in btree index.

2021-02-09 Thread Zhihong Yu
Hi, Minor comment: + if (errflag == true) + ereport(ERROR, I think 'if (errflag)' should suffice. Cheers On Tue, Feb 9, 2021 at 10:44 AM Pavel Borisov wrote: > вт, 9 февр. 2021 г. в 01:46, Mark Dilger : > >> >> >> > On Feb 8, 2021, at 2:46 AM, Pavel Borisov >> wrote: >> > >> > 0002 -

Re: [PROPOSAL] new diagnostic items for the dynamic sql

2021-12-03 Thread Zhihong Yu
On Fri, Dec 3, 2021 at 3:15 AM Dinesh Chemuduru wrote: > Hi Michael, > > Attaching the latest patch here(It's the recent patch), and looking for > more suggestions/inputs from the team. > > On Fri, 3 Dec 2021 at 13:09, Michael Paquier wrote: > >> On Wed, Nov 10, 2021 at 01:58:58PM +0530, Dinesh

Re: extended stats on partitioned tables

2021-12-03 Thread Zhihong Yu
On Thu, Dec 2, 2021 at 9:24 PM Justin Pryzby wrote: > On Thu, Nov 04, 2021 at 12:44:45AM +0100, Tomas Vondra wrote: > > >> And I'm not sure we do the right thing after removing children, for > example > > >> (that should drop the inheritance stats, I guess). > > > > Do you mean for inheritance on

Re: Add sub-transaction overflow status in pg_stat_activity

2021-12-06 Thread Zhihong Yu
On Mon, Dec 6, 2021 at 8:17 PM Dilip Kumar wrote: > If the subtransaction cache is overflowed in some of the transactions > then it will affect all the concurrent queries as they need to access > the SLRU for checking the visibility of each tuple. But currently > there is no way to identify whet

Re: Re: 回复:Re: Is it worth pushing conditions to sublink/subplan?

2021-12-11 Thread Zhihong Yu
On Sat, Dec 11, 2021 at 7:31 AM 曾文旌(义从) wrote: > > > --原始邮件 -- > *发件人:*Tomas Vondra > *发送时间:*Wed Dec 8 11:26:35 2021 > *收件人:*曾文旌(义从) , shawn wang < > shawn.wang...@gmail.com>, ggys...@gmail.com , > PostgreSQL Hackers > *抄送:*wjzeng > *主题:*Re: 回复:Re: Is it worth p

Re: extended stats on partitioned tables

2021-12-11 Thread Zhihong Yu
On Sat, Dec 11, 2021 at 8:17 PM Tomas Vondra wrote: > Hi, > > Attached is a rebased and cleaned-up version of these patches, with more > comments, refactorings etc. Justin and Zhihong, can you take a look? > > > 0001 - Ignore extended statistics for inheritance trees > > 0002 - Build inherited ex

Re: extended stats on partitioned tables

2021-12-12 Thread Zhihong Yu
On Sat, Dec 11, 2021 at 9:14 PM Tomas Vondra wrote: > > > On 12/12/21 05:38, Zhihong Yu wrote: > > > > > > On Sat, Dec 11, 2021 at 8:17 PM Tomas Vondra > > mailto:tomas.von...@enterprisedb.com>> > > wrote: > > > > Hi, > > > &

Re: extended stats on partitioned tables

2021-12-12 Thread Zhihong Yu
On Sat, Dec 11, 2021 at 8:17 PM Tomas Vondra wrote: > Hi, > > Attached is a rebased and cleaned-up version of these patches, with more > comments, refactorings etc. Justin and Zhihong, can you take a look? > > > 0001 - Ignore extended statistics for inheritance trees > > 0002 - Build inherited ex

Re: Use extended statistics to estimate (Var op Var) clauses

2021-12-12 Thread Zhihong Yu
On Sun, Dec 12, 2021 at 6:04 PM Tomas Vondra wrote: > On 8/31/21 00:14, Zhihong Yu wrote: > > Hi, > > For patch 0002, > > > > + s1 = statext_clauselist_selectivity(root, clauses, > > varRelid, > > +

Re: simplifying foreign key/RI checks

2021-12-20 Thread Zhihong Yu
On Sun, Dec 19, 2021 at 10:20 PM Amit Langote wrote: > On Mon, Dec 20, 2021 at 2:00 PM Corey Huinker > wrote: > > Sorry for the delay. This patch no longer applies, it has some conflict > with d6f96ed94e73052f99a2e545ed17a8b2fdc1fb8a > > Thanks Corey for the heads up. Rebased with some cosmetic

Re: simplifying foreign key/RI checks

2021-12-21 Thread Zhihong Yu
On Mon, Dec 20, 2021 at 5:17 AM Amit Langote wrote: > On Mon, Dec 20, 2021 at 6:19 PM Zhihong Yu wrote: > > On Sun, Dec 19, 2021 at 10:20 PM Amit Langote > wrote: > >> > >> On Mon, Dec 20, 2021 at 2:00 PM Corey Huinker > wrote: > >> > Sorry for th

Re: 回复:Re: Re: 回复:Re: Is it worth pushing conditions to sublink/subplan?

2021-12-24 Thread Zhihong Yu
On Thu, Dec 23, 2021 at 3:52 AM 曾文旌(义从) wrote: > > Fixed a bug found during testing. > > > Wenjing > > >>> Hi, + if (condition_is_safe_pushdown_to_sublink(rinfo, expr_info->outer)) + { + /* replace qual expr from outer var = const to var = const and push down to

Re: Add Boolean node

2021-12-27 Thread Zhihong Yu
Hi, For buildDefItem(): + if (strcmp(val, "true") == 0) + return makeDefElem(pstrdup(name), + (Node *) makeBoolean(true), + -1); + if (strcmp(val, "false") == 0) Should 'TRUE' / 'FALSE' be considered above ? -

Re: UNIQUE null treatment option

2021-12-29 Thread Zhihong Yu
Hi, boolisunique; + boolnulls_not_distinct; } BTSpool; Looking at the other fields in BTSpool, there is no underscore in field name. I think the new field can be named nullsdistinct. This way, the double negative is avoided. Similar comment for new fields in BTShared and B

Re: Speed up transaction completion faster after many relations are accessed in a transaction

2021-12-31 Thread Zhihong Yu
On Fri, Dec 31, 2021 at 5:45 PM David Rowley wrote: > On Fri, 3 Dec 2021 at 20:36, Michael Paquier wrote: > > Two months later, this has been switched to RwF. > > I was discussing this patch with Andres. He's not very keen on my > densehash hash table idea and suggested that instead of relying o

Re: Collecting statistics about contents of JSONB columns

2022-01-01 Thread Zhihong Yu
On Fri, Dec 31, 2021 at 2:07 PM Tomas Vondra wrote: > Hi, > > One of the complaints I sometimes hear from users and customers using > Postgres to store JSON documents (as JSONB type, of course) is that the > selectivity estimates are often pretty poor. > > Currently we only really have MCV and hi

Re: Collecting statistics about contents of JSONB columns

2022-01-01 Thread Zhihong Yu
On Sat, Jan 1, 2022 at 7:33 AM Zhihong Yu wrote: > > > On Fri, Dec 31, 2021 at 2:07 PM Tomas Vondra < > tomas.von...@enterprisedb.com> wrote: > >> Hi, >> >> One of the complaints I sometimes hear from users and customers using >> Postgres to store

Re: Patch to avoid orphaned dependencies

2022-01-04 Thread Zhihong Yu
Hi, For genam.c: + UseDirtyCatalogSnapshot = dirtysnap; + Does the old value of UseDirtyCatalogSnapshot need to be restored at the end of the func ? +systable_recheck_tuple(SysScanDesc sysscan, HeapTuple tup, bool dirtysnap) Considering that parameter dirtysnap is a bool, I think it should be

Re: [Proposal] Add foreign-server health checks infrastructure

2022-01-05 Thread Zhihong Yu
On Tue, Jan 4, 2022 at 10:21 PM Shinya Kato wrote: > Thank you for the new patch! > > On 2021-12-15 15:40, kuroda.hay...@fujitsu.com wrote: > > Dear Kato-san, > > > > Thank you for giving comments! And sorry for late reply. > > I rebased my patches. > > > >> Even for local-only transaction, I tho

null iv parameter passed to combo_init()

2022-01-07 Thread Zhihong Yu
Hi, In contrib/pgcrypto/pgcrypto.c : err = px_combo_init(c, (uint8 *) VARDATA_ANY(key), klen, NULL, 0); Note: NULL is passed as iv. When combo_init() is called, if (ivlen > ivs) memcpy(ivbuf, iv, ivs); else memcpy(ivbuf, iv, ivlen); It seems we need

Re: null iv parameter passed to combo_init()

2022-01-08 Thread Zhihong Yu
On Sat, Jan 8, 2022 at 5:52 PM Noah Misch wrote: > On Fri, Jan 07, 2022 at 04:32:01PM -0800, Zhihong Yu wrote: > > In contrib/pgcrypto/pgcrypto.c : > > > > err = px_combo_init(c, (uint8 *) VARDATA_ANY(key), klen, NULL, 0); > > > > Note: NULL is passed as

Re: null iv parameter passed to combo_init()

2022-01-08 Thread Zhihong Yu
On Sat, Jan 8, 2022 at 7:11 PM Noah Misch wrote: > On Sat, Jan 08, 2022 at 06:52:14PM -0800, Zhihong Yu wrote: > > On Sat, Jan 8, 2022 at 5:52 PM Noah Misch wrote: > > > On Fri, Jan 07, 2022 at 04:32:01PM -0800, Zhihong Yu wrote: > > > > I agree it's

Re: null iv parameter passed to combo_init()

2022-01-09 Thread Zhihong Yu
On Sat, Jan 8, 2022 at 11:32 PM Tom Lane wrote: > Noah Misch writes: > > On further thought, I would write it this way: > > > - else > > + else if (ivlen != 0) > > memcpy(ivbuf, iv, ivlen); > > FWIW, I liked the "ivlen > 0" formulation better. They

Re: null iv parameter passed to combo_init()

2022-01-09 Thread Zhihong Yu
On Sun, Jan 9, 2022 at 8:48 AM Noah Misch wrote: > On Sun, Jan 09, 2022 at 04:37:32AM -0800, Zhihong Yu wrote: > > On Sat, Jan 8, 2022 at 11:32 PM Tom Lane wrote: > > > Noah Misch writes: > > > > On further thought, I would write it this way: &g

Re: null iv parameter passed to combo_init()

2022-01-09 Thread Zhihong Yu
On Sun, Jan 9, 2022 at 12:38 PM Zhihong Yu wrote: > > > On Sun, Jan 9, 2022 at 8:48 AM Noah Misch wrote: > >> On Sun, Jan 09, 2022 at 04:37:32AM -0800, Zhihong Yu wrote: >> > On Sat, Jan 8, 2022 at 11:32 PM Tom Lane wrote: >> > > Noah Misch writes: >

Re: null iv parameter passed to combo_init()

2022-01-09 Thread Zhihong Yu
On Sun, Jan 9, 2022 at 1:27 PM Zhihong Yu wrote: > > > On Sun, Jan 9, 2022 at 12:38 PM Zhihong Yu wrote: > >> >> >> On Sun, Jan 9, 2022 at 8:48 AM Noah Misch wrote: >> >>> On Sun, Jan 09, 2022 at 04:37:32AM -0800, Zhihong Yu wrote: >>

Re: null iv parameter passed to combo_init()

2022-01-10 Thread Zhihong Yu
On Sun, Jan 9, 2022 at 6:45 PM Zhihong Yu wrote: > > > On Sun, Jan 9, 2022 at 1:27 PM Zhihong Yu wrote: > >> >> >> On Sun, Jan 9, 2022 at 12:38 PM Zhihong Yu wrote: >> >>> >>> >>> On Sun, Jan 9, 2022 at 8:48 AM Noah Misch wrote

Re: null iv parameter passed to combo_init()

2022-01-12 Thread Zhihong Yu
On Wed, Jan 12, 2022 at 6:49 PM Noah Misch wrote: > On Mon, Jan 10, 2022 at 03:34:27PM -0800, Zhihong Yu wrote: > > On Sun, Jan 9, 2022 at 6:45 PM Zhihong Yu wrote: > > > gcc -Wall -Wmissing-prototypes -Wpointer-arith > > > -Wdeclaration-after-statement

Re: null iv parameter passed to combo_init()

2022-01-13 Thread Zhihong Yu
On Wed, Jan 12, 2022 at 7:08 PM Zhihong Yu wrote: > > > On Wed, Jan 12, 2022 at 6:49 PM Noah Misch wrote: > >> On Mon, Jan 10, 2022 at 03:34:27PM -0800, Zhihong Yu wrote: >> > On Sun, Jan 9, 2022 at 6:45 PM Zhihong Yu wrote: >> > > gcc -Wa

Re: support for MERGE

2022-01-13 Thread Zhihong Yu
On Thu, Jan 13, 2022 at 4:43 AM Alvaro Herrera wrote: > Apologies, there was a merge failure and I failed to notice. Here's the > correct patch. > > (This is also in github.com/alvherre/postgres/tree/merge-15) > > Hi, For v6-0001-MERGE-SQL-Command-following-SQL-2016.patch : +* Either we wer

Re: null iv parameter passed to combo_init()

2022-01-13 Thread Zhihong Yu
On Thu, Jan 13, 2022 at 8:09 PM Noah Misch wrote: > On Sun, Jan 09, 2022 at 06:45:09PM -0800, Zhihong Yu wrote: > > On Sun, Jan 9, 2022 at 1:27 PM Zhihong Yu wrote: > > > After installing gcc-11, ./configure passed (with > 0003-memcpy-null.patch). > > > In the o

Re: null iv parameter passed to combo_init()

2022-01-13 Thread Zhihong Yu
On Thu, Jan 13, 2022 at 9:09 PM Zhihong Yu wrote: > > > On Thu, Jan 13, 2022 at 8:09 PM Noah Misch wrote: > >> On Sun, Jan 09, 2022 at 06:45:09PM -0800, Zhihong Yu wrote: >> > On Sun, Jan 9, 2022 at 1:27 PM Zhihong Yu wrote: >> > > After installing g

Re: Partial aggregates pushdown

2022-01-17 Thread Zhihong Yu
On Sun, Jan 16, 2022 at 11:47 PM Alexander Pyhalov wrote: > Julien Rouhaud писал 2022-01-14 15:16: > > Hi, > > > > On Mon, Nov 15, 2021 at 04:01:51PM +0300, Alexander Pyhalov wrote: > >> > >> I've updated patch - removed catversion dump. > > > > This version of the patchset doesn't apply anymore:

Re: Getting better results from valgrind leak tracking

2021-03-16 Thread Zhihong Yu
Hi, For the second last trace involving SearchCatCacheList (catcache.c:1691), the ctlist's members are stored in cl->members array where cl is returned at the end of SearchCatCacheList. Maybe this was not accounted for by valgrind ? Cheers On Tue, Mar 16, 2021 at 7:31 PM Andres Freund wrote: >

Re: Transactions involving multiple postgres foreign servers, take 2

2021-03-17 Thread Zhihong Yu
Hi, For v35-0007-Prepare-foreign-transactions-at-commit-time.patch : With this commit, the foreign server modified within the transaction marked as 'modified'. transaction marked -> transaction is marked +#define IsForeignTwophaseCommitRequested() \ +(foreign_twophase_commit > FOREIGN_TWOPHA

Re: A new function to wait for the backend exit after termination

2021-03-17 Thread Zhihong Yu
Hi, w.r.t. WaitLatch(), if its return value is WL_TIMEOUT, we know the specified timeout has elapsed. It seems WaitLatch() can be enhanced to also return the actual duration of the wait. This way, the caller can utilize the duration directly. As for other places where WaitLatch() is called, simila

Re: should INSERT SELECT use a BulkInsertState?

2021-03-18 Thread Zhihong Yu
Hi, + mtstate->ntuples > bulk_insert_ntuples && + bulk_insert_ntuples >= 0) I wonder why bulk_insert_ntuples == 0 is included in the above. It seems bulk_insert_ntuples having value of 0 should mean not enabling bulk insertions. + } + else + { nit: the else should be on

Re: Columns correlation and adaptive query optimization

2021-03-19 Thread Zhihong Yu
Hi, In AddMultiColumnStatisticsForQual(), + /* Loop until we considered all vars */ + while (vars != NULL) ... + /* Contruct list of unique vars */ + foreach (cell, vars) What if some cell / node, gets into the else block: + else + { +

Re: [HACKERS] GSoC 2017: Foreign Key Arrays

2021-03-20 Thread Zhihong Yu
Hi, In v11-0004-fk_arrays_elems_edits.patch : + riinfo->fk_reftypes[i] == FKCONSTR_REF_EACH_ELEMENT ? OID_ARRAY_ELEMCONTAINED_OP : riinfo->pf_eq_oprs[i], // XXX Is XXX placeholder for some comment you will fill in later ? Cheers On Sat, Mar 20, 2021 at 11:42 AM Mark Ro

Re: Built-in connection pooler

2021-03-21 Thread Zhihong Yu
Hi, + With load-balancing policy postmaster choose proxy with lowest load average. + Load average of proxy is estimated by number of clients connection assigned to this proxy with extra weight for SSL connections. I think 'load-balanced' may be better than 'load-balancing'. post

Re: pg_upgrade failing for 200+ million Large Objects

2021-03-22 Thread Zhihong Yu
> > Hi, > w.r.t. pg_upgrade_improvements.v2.diff. + blobBatchCount = 0; + blobInXact = false; The count and bool flag are always reset in tandem. It seems variable blobInXact is not needed. Cheers

Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view?

2021-03-22 Thread Zhihong Yu
Hi, For queryjumble.c : + * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group The year should be updated. Same with queryjumble.h Cheers On Mon, Mar 22, 2021 at 2:56 PM Bruce Momjian wrote: > On Sat, Mar 20, 2021 at 02:12:34PM +0800, Julien Rouhaud wrote: > > On Fri, Mar 1

Re: [POC] Fast COPY FROM command for the table with foreign partitions

2021-03-22 Thread Zhihong Yu
Hi, In the description: with data_dest_cb callback. It is used for send text representation of a tuple to a custom destination. send text -> sending text struct PgFdwModifyState *aux_fmstate; /* foreign-insert state, if * created */ + CopyToSt

Re: Add client connection check during the execution of the query

2021-03-23 Thread Zhihong Yu
Hi, In the description: Provide a new optional GUC that can be used to check whether the client connection has gone away periodically while running very long queries. I think moving 'periodically' to the vicinity of 'to check' would make the sentence more readable. +the operating system,

name of enum used in 'Cache if PathTarget and RestrictInfos contain volatile functions'

2021-03-28 Thread Zhihong Yu
Hi, I was looking at: Cache if PathTarget and RestrictInfos contain volatile functions VOLATILITY_NOVOLATILE caught my attention. Since the enum values don't start with HAS, I think VOLATILITY_NO*N*VOLATILE would be easier to read. Actually I think since the enums are defined in VolatileFunction

Re: Hybrid Hash/Nested Loop joins and caching results from subplans

2021-03-28 Thread Zhihong Yu
Hi, For show_resultcache_info() + if (rcstate->shared_info != NULL) + { The negated condition can be used with a return. This way, the loop can be unindented. + * ResultCache nodes are intended to sit above a parameterized node in the + * plan tree in order to cache results from them. Since

Re: Hybrid Hash/Nested Loop joins and caching results from subplans

2021-03-30 Thread Zhihong Yu
rno); This way, when we return early, var_relids doesn't need to be populated. Cheers On Tue, Mar 30, 2021 at 4:42 AM David Rowley wrote: > On Mon, 29 Mar 2021 at 15:56, Zhihong Yu wrote: > > For show_resultcache_info() > > > > + if (rcstate->shared_info != NUL

Re: What to call an executor node which lazily caches tuples in a hash table?

2021-03-30 Thread Zhihong Yu
Hi, I was reading this part of the description: the Result Cache's hash table is much smaller than the hash join's due to result cache only caching useful values rather than all tuples from the inner side of the join. I think the word 'Result' should be part of the cache name considering the abov

Re: Crash in BRIN minmax-multi indexes

2021-03-31 Thread Zhihong Yu
Hi, In build_distances(): a1 = eranges[i].maxval; a2 = eranges[i + 1].minval; It seems there was overlap between the successive ranges, leading to delta = -678500 FYI On Wed, Mar 31, 2021 at 10:30 AM Jaime Casanova < jcasa...@systemguards.com.ec> wrote: > Hi, > > Just found

Re: Crash in BRIN minmax-multi indexes

2021-03-31 Thread Zhihong Yu
Hi, For inet data type fix: + unsigned char a = addra[i]; + unsigned char b = addrb[i]; + + if (i >= lena) + a = 0; + + if (i >= lenb) + b = 0; Should the length check precede the addra[i] ? Something like: unsigned char a; if (i >= lena)

Re: using extended statistics to improve join estimates

2021-03-31 Thread Zhihong Yu
Hi, + * has_matching_mcv + * Check whether the list contains statistic of a given kind The method name is find_matching_mcv(). It seems the method initially returned bool but later the return type was changed. + StatisticExtInfo *found = NULL; found normally is associated with bool return

Re: Crash in BRIN minmax-multi indexes

2021-03-31 Thread Zhihong Yu
Hi, - delta += (float8) addrb[i] - (float8) addra[i]; - delta /= 256; ... + delta /= 255; May I know why the divisor was changed ? Thanks On Wed, Mar 31, 2021 at 3:25 PM Tomas Vondra wrote: > Hi, > > I think I found the issue - it's kinda obvious, really. We need to > conside

Re: Crash in BRIN minmax-multi indexes

2021-04-01 Thread Zhihong Yu
Hi, Can you try this patch ? Thanks diff --git a/src/backend/access/brin/brin_minmax_multi.c b/src/backend/access/brin/brin_minmax_multi.c index 70109960e8..25d6d2e274 100644 --- a/src/backend/access/brin/brin_minmax_multi.c +++ b/src/backend/access/brin/brin_minmax_multi.c @@ -2161,7 +2161,7 @@

Re: Crash in BRIN minmax-multi indexes

2021-04-01 Thread Zhihong Yu
Hi, Tomas: Thanks for the correction. I think switching to interval_cmp_value() would be better (with a comment explaining why). Cheers On Thu, Apr 1, 2021 at 6:23 AM Tomas Vondra wrote: > On 4/1/21 3:09 PM, Zhihong Yu wrote: > > Hi, > > Can you try this patch ? > > &g

Re: simplifying foreign key/RI checks

2021-04-02 Thread Zhihong Yu
Hi, + skip = !ExecLockTableTuple(erm->relation, &tid, markSlot, + estate->es_snapshot, estate->es_output_cid, + lockmode, erm->waitPolicy, &epq_needed); + if (skip) It seems the variable skip is only used above. The var

Re: Parallel Full Hash Join

2021-04-02 Thread Zhihong Yu
Hi, For v6-0003-Parallel-Hash-Full-Right-Outer-Join.patch +* current_chunk_idx: index in current HashMemoryChunk The above comment seems to be better fit for ExecScanHashTableForUnmatched(), instead of ExecParallelPrepHashTableForUnmatched. I wonder where current_chunk_idx should belong (cons

Re: Making wait events a bit more efficient

2021-04-02 Thread Zhihong Yu
Hi, +extern PGDLLIMPORT uint32 *my_wait_event_info; It seems volatile should be added to the above declaration. Since later: + *(volatile uint32 *) my_wait_event_info = wait_event_info; Cheers On Fri, Apr 2, 2021 at 12:45 PM Andres Freund wrote: > Hi, > > This grew out of my patch to split

Re: Have I found an interval arithmetic bug?

2021-04-02 Thread Zhihong Yu
Bruce: Thanks for tackling this issue. The patch looks good to me. When you have time, can you include the places which were not covered by the current diff ? Cheers On Fri, Apr 2, 2021 at 11:06 AM Bruce Momjian wrote: > On Thu, Apr 1, 2021 at 09:46:58PM -0700, Bryn Llewellyn wrote: > > Or am

Re: Making wait events a bit more efficient

2021-04-02 Thread Zhihong Yu
13:06:35 -0700, Zhihong Yu wrote: > > +extern PGDLLIMPORT uint32 *my_wait_event_info; > > > > It seems volatile should be added to the above declaration. Since later: > > > > + *(volatile uint32 *) my_wait_event_info = wait_event_info; > > Why? We really jus

Re: Have I found an interval arithmetic bug?

2021-04-02 Thread Zhihong Yu
Hi, bq. My new code returns 0.2 months for this, not zero Can you clarify (the output below that was 2 mons, not 0.2) ? Thanks On Fri, Apr 2, 2021 at 4:58 PM Bruce Momjian wrote: > On Fri, Apr 2, 2021 at 02:00:03PM -0700, John W Higgins wrote: > > On Fri, Apr 2, 2021 at 11:05 AM Bruce Momjian

Re: Have I found an interval arithmetic bug?

2021-04-02 Thread Zhihong Yu
On Fri, Apr 2, 2021 at 5:07 PM Zhihong Yu wrote: > Hi, > bq. My new code returns 0.2 months for this, not zero > > Can you clarify (the output below that was 2 mons, not 0.2) ? > > Thanks > > On Fri, Apr 2, 2021 at 4:58 PM Bruce Momjian wrote: > >> On Fri, Apr

Re: Have I found an interval arithmetic bug?

2021-04-02 Thread Zhihong Yu
0.4 * '1 year'::interval - 0.7 * '1 year'::interval = '0.0833 year'::interval; ?column? -- f As long as Bruce's patch makes improvements over the current behavior, I think that's fine. Cheers On Fri, Apr 2, 2021 at 6:24 PM Isaac Morland wrote: >

Re: Have I found an interval arithmetic bug?

2021-04-02 Thread Zhihong Yu
->tm_year += val; tm->tm_mon += (fval * MONTHS_PER_YEAR); Is rint() needed for these two cases ? Cheers On Fri, Apr 2, 2021 at 7:21 PM Bruce Momjian wrote: > On Fri, Apr 2, 2021 at 07:06:08PM -0700, Zhihong Yu wrote: > > Hi, > > The mix of interval and compariso

Re: TRUNCATE on foreign table

2021-04-03 Thread Zhihong Yu
Hi, + TRUNCATE for each foreign server being involved + in one TRUNCATE command (note that invocations The 'being' in above sentence can be omitted. + the context where the foreign-tables are truncated. It is a list of integers and same length with There should be a verb between 'and

<    1   2   3   4   5   6   >