remove unnecessary assignment to tmask in DecodeDateTime

2022-11-03 Thread Zhihong Yu
Hi, I was looking at the code in DecodeDateTime() around line 1382: tmask = DTK_M(type); In case type is UNKNOWN_FIELD, the above macro would shift 1 left 31 bits which cannot be represented in type 'int'. Looking down in the same function, we can see that tmask is assigned for

Re: restoring user id and SecContext before logging error in ri_PlanCheck

2022-11-02 Thread Zhihong Yu
Looking down in ri_PerformCheck(), I see there may be case where error from SPI_execute_snapshot() would skip restoring UID. Please look at patch v2 which tried to handle such case. Thanks v2-restore-uid-trigger.patch Description: Binary data

restoring user id and SecContext before logging error in ri_PlanCheck

2022-11-02 Thread Zhihong Yu
Hi, I was looking at the code in ri_PlanCheck of src/backend/utils/adt/ri_triggers.c starting at line 2289. When qplan is NULL, we log an error. This would skip calling SetUserIdAndSecContext(). I think the intention of the code should be restoring user id and SecContext regardless of the

Re: heavily contended lwlocks with long wait queues scale badly

2022-10-31 Thread Zhihong Yu
On Mon, Oct 31, 2022 at 5:19 PM Andres Freund wrote: > Hi, > > On 2022-10-31 17:17:03 -0700, Zhihong Yu wrote: > > On Mon, Oct 31, 2022 at 4:51 PM Andres Freund > wrote: > > > > > Hi, > > > > > > On 2022-10-31 16:21:06 +0530, Bharath Rupir

Re: heavily contended lwlocks with long wait queues scale badly

2022-10-31 Thread Zhihong Yu
On Mon, Oct 31, 2022 at 4:51 PM Andres Freund wrote: > Hi, > > On 2022-10-31 16:21:06 +0530, Bharath Rupireddy wrote: > > BTW, I've seen a sporadic crash (SEGV) with the patch in bg writer > > with the same set up [1], I'm not sure if it's really because of the > > patch. I'm unable to reproduce

Reusing return value from planner_rt_fetch

2022-10-31 Thread Zhihong Yu
Hi, I was reading examine_variable in src/backend/utils/adt/selfuncs.c It seems we already have the rte coming out of the loop which starts on line 5181. Here is a patch which reuses the return value from `planner_rt_fetch`. Please take a look. Thanks parent-rel-rte.patch Description: Binary

Re: fixing typo in comment for restriction_is_or_clause

2022-10-24 Thread Zhihong Yu
On Mon, Oct 24, 2022 at 7:58 PM Japin Li wrote: > > On Tue, 25 Oct 2022 at 10:48, Richard Guo wrote: > > On Tue, Oct 25, 2022 at 10:05 AM John Naylor < > john.nay...@enterprisedb.com> > > wrote: > > > >> > >> On Tue, Oct 25, 2022 at 12:19 AM

fixing typo in comment for restriction_is_or_clause

2022-10-24 Thread Zhihong Yu
Hi, When I was looking at src/backend/optimizer/util/restrictinfo.c, I found a typo in one of the comments. I also took the chance to simplify the code a little bit. Please take a look at the patch. Thanks is-or.patch Description: Binary data

Re: Missing update of all_hasnulls in BRIN opclasses

2022-10-22 Thread Zhihong Yu
Hi, Tomas: For 0002-fixup-brin-has_nulls-20221022.patch : + first_row = (bval->bv_hasnulls && bval->bv_allnulls); + + if (bval->bv_hasnulls && bval->bv_allnulls) It seems the if condition can be changed to `if (first_row)` which is more readable. Chhers

Re: PATCH: Using BRIN indexes for sorted output

2022-10-16 Thread Zhihong Yu
On Sun, Oct 16, 2022 at 7:33 AM Tomas Vondra wrote: > > > On 10/16/22 16:01, Zhihong Yu wrote: > > > > > > On Sun, Oct 16, 2022 at 6:51 AM Tomas Vondra > > mailto:tomas.von...@enterprisedb.com>> > > wrote: > > > >

Re: PATCH: Using BRIN indexes for sorted output

2022-10-16 Thread Zhihong Yu
On Sun, Oct 16, 2022 at 6:51 AM Tomas Vondra wrote: > On 10/15/22 14:33, Tomas Vondra wrote: > > Hi, > > > > ... > > > > There's a bunch of issues with this initial version of the patch, > > usually described in XXX comments in the relevant places.6) > > > > ... > > I forgot to mention one

Re: PATCH: Using BRIN indexes for sorted output

2022-10-15 Thread Zhihong Yu
On Sat, Oct 15, 2022 at 8:23 AM Tomas Vondra wrote: > On 10/15/22 15:46, Zhihong Yu wrote: > >... > > 8) Parallel version is not supported, but I think it shouldn't be > > possible. Just make the leader build the range info, and then let the > > wor

Re: PATCH: Using BRIN indexes for sorted output

2022-10-15 Thread Zhihong Yu
On Sat, Oct 15, 2022 at 5:34 AM Tomas Vondra wrote: > Hi, > > There have been a couple discussions about using BRIN indexes for > sorting - in fact this was mentioned even in the "Improving Indexing > Performance" unconference session this year (don't remember by whom). > But I haven't seen any

Re: Allow WindowFuncs prosupport function to use more optimal WindowClause options

2022-10-13 Thread Zhihong Yu
On Wed, Oct 12, 2022 at 5:35 PM David Rowley wrote: > On Wed, 12 Oct 2022 at 16:33, Vik Fearing wrote: > > Per spec, the ROW_NUMBER() window function is not even allowed to have a > > frame specified. > > > > b) The window framing clause of WDX shall not be present. > > > > Also, the

Re: remove redundant memset() call

2022-10-13 Thread Zhihong Yu
On Thu, Oct 13, 2022 at 12:10 PM Bruce Momjian wrote: > On Thu, Oct 13, 2022 at 10:55:08AM -0700, Zhihong Yu wrote: > > Hi, > > I was looking at combo_init in contrib/pgcrypto/px.c . > > > > There is a memset() call following palloc0() - the call is redundant. &

remove redundant memset() call

2022-10-13 Thread Zhihong Yu
Hi, I was looking at combo_init in contrib/pgcrypto/px.c . There is a memset() call following palloc0() - the call is redundant. Please see the patch for the proposed change. Thanks remove-redundant-memset-call.patch Description: Binary data

Re: Bloom filter Pushdown Optimization for Merge Join

2022-10-13 Thread Zhihong Yu
On Thu, Oct 13, 2022 at 7:30 AM Zhihong Yu wrote: > > > On Wed, Oct 12, 2022 at 4:35 PM Zhihong Yu wrote: > >> >> >> On Wed, Oct 12, 2022 at 3:36 PM Lyu Pan wrote: >> >>> Hello Zhihong Yu & Tomas Vondra, >>> >>> Thank you so mu

Re: Bloom filter Pushdown Optimization for Merge Join

2022-10-13 Thread Zhihong Yu
On Wed, Oct 12, 2022 at 4:35 PM Zhihong Yu wrote: > > > On Wed, Oct 12, 2022 at 3:36 PM Lyu Pan wrote: > >> Hello Zhihong Yu & Tomas Vondra, >> >> Thank you so much for your review and feedback! >> >> We made some updates based on previous feedback

Re: Bloom filter Pushdown Optimization for Merge Join

2022-10-12 Thread Zhihong Yu
On Wed, Oct 12, 2022 at 3:36 PM Lyu Pan wrote: > Hello Zhihong Yu & Tomas Vondra, > > Thank you so much for your review and feedback! > > We made some updates based on previous feedback and attached the new > patch set. Due to time constraints, we didn't get to reso

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2022-10-11 Thread Zhihong Yu
On Tue, Oct 11, 2022 at 9:58 AM Zhihong Yu wrote: > > > On Tue, Oct 11, 2022 at 9:22 AM Dmitry Koval > wrote: > >> Hi! >> >> Fixed couple warnings (for cfbot). >> >> -- >> With best regards, >> Dmitry Koval >> >> Postgres Pr

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2022-10-11 Thread Zhihong Yu
On Tue, Oct 11, 2022 at 9:22 AM Dmitry Koval wrote: > Hi! > > Fixed couple warnings (for cfbot). > > -- > With best regards, > Dmitry Koval > > Postgres Professional: http://postgrespro.com Hi, For v12-0001-PGPRO-ALTER-TABLE-MERGE-PARTITIONS-command.patch: + if (equal(name, cmd->name)) +

subtransaction performance

2022-10-07 Thread Zhihong Yu
Hi, I stumbled over: https://about.gitlab.com/blog/2021/09/29/why-we-spent-the-last-month-eliminating-postgresql-subtransactions/ I wonder if SAVEPOINT / subtransaction performance has been boosted since the blog was written. Cheers

Re: Add support for DEFAULT specification in COPY FROM

2022-10-07 Thread Zhihong Yu
On Fri, Oct 7, 2022 at 12:09 PM Israel Barth Rubio wrote: > Hello Zhihong, > > > + /* attribute is NOT to be copied from input */ > > > > I think saying `is NOT copied from input` should suffice. > > > > + /* fieldno is 0-index and attnum is 1-index */ > > > > 0-index ->

Re: [POC] Allow flattening of subquery with a link to upper query

2022-10-05 Thread Zhihong Yu
On Wed, Oct 5, 2022 at 4:38 AM Andrey Lepikhov wrote: > On 5/10/2022 02:45, Zhihong Yu wrote: > > Hi, > > For contain_placeholders(): > > > > + if (IsA(node, Query)) > > + return query_tree_walker((Query *) node, contain_placeholders, > >

Re: [POC] Allow flattening of subquery with a link to upper query

2022-10-04 Thread Zhihong Yu
Hi, For contain_placeholders(): + if (IsA(node, Query)) + return query_tree_walker((Query *) node, contain_placeholders, context, 0); + else if (IsA(node, PlaceHolderVar)) The `else` is not needed. For correlated_t struct, it would be better if the fields have comments. +

Re: [PATCH] Fix build with LLVM 15 or above

2022-10-03 Thread Zhihong Yu
On Mon, Oct 3, 2022 at 2:41 PM Andres Freund wrote: > Hi, > > On 2022-10-03 12:16:12 -0700, Andres Freund wrote: > > I haven't yet run through the whole regression test with an assert > enabled > > llvm because an assert-enabled llvm is *SLOW*, but it got through the > first > > few parallel

Re: Bloom filter Pushdown Optimization for Merge Join

2022-10-02 Thread Zhihong Yu
On Sun, Oct 2, 2022 at 6:40 AM Zhihong Yu wrote: > > > On Sat, Oct 1, 2022 at 12:45 AM Zhihong Yu wrote: > >> >> >> On Fri, Sep 30, 2022 at 9:20 PM Zhihong Yu wrote: >> >>> >>> >>> On Fri, Sep 30, 2022 at 8:40 PM Zhihong Yu wro

Re: Bloom filter Pushdown Optimization for Merge Join

2022-10-02 Thread Zhihong Yu
On Sat, Oct 1, 2022 at 12:45 AM Zhihong Yu wrote: > > > On Fri, Sep 30, 2022 at 9:20 PM Zhihong Yu wrote: > >> >> >> On Fri, Sep 30, 2022 at 8:40 PM Zhihong Yu wrote: >> >>> >>> >>> On Fri, Sep 30, 2022 at 3:44 PM Zheng Li

Re: Bloom filter Pushdown Optimization for Merge Join

2022-10-01 Thread Zhihong Yu
On Fri, Sep 30, 2022 at 9:20 PM Zhihong Yu wrote: > > > On Fri, Sep 30, 2022 at 8:40 PM Zhihong Yu wrote: > >> >> >> On Fri, Sep 30, 2022 at 3:44 PM Zheng Li wrote: >> >>> Hello, >>> >>> A bloom filter provides early filtering of

Re: Bloom filter Pushdown Optimization for Merge Join

2022-09-30 Thread Zhihong Yu
On Fri, Sep 30, 2022 at 8:40 PM Zhihong Yu wrote: > > > On Fri, Sep 30, 2022 at 3:44 PM Zheng Li wrote: > >> Hello, >> >> A bloom filter provides early filtering of rows that cannot be joined >> before they would reach the join operator, the optimization

Re: Bloom filter Pushdown Optimization for Merge Join

2022-09-30 Thread Zhihong Yu
On Fri, Sep 30, 2022 at 3:44 PM Zheng Li wrote: > Hello, > > A bloom filter provides early filtering of rows that cannot be joined > before they would reach the join operator, the optimization is also > called a semi join filter (SJF) pushdown. Such a filter can be created > when one child of

Re: [BUG] parenting a PK constraint to a self-FK one (Was: Self FK oddity when attaching a partition)

2022-09-30 Thread Zhihong Yu
On Fri, Sep 30, 2022 at 3:30 PM Jehan-Guillaume de Rorthais wrote: > Hi, > > Please, find in attachment a small serie of patch: > > 0001 fix the constraint parenting bug. Not much to say. It's basically > your > patch we discussed with some more comments and the check on contype > equals to

Re: Add support for DEFAULT specification in COPY FROM

2022-09-26 Thread Zhihong Yu
On Mon, Sep 26, 2022 at 8:12 AM Israel Barth Rubio wrote: > Hello Andrew, > > > . There needs to be a check that this is being used with COPY FROM, and > > the restriction needs to be stated in the docs and tested for. c.f. > > FORCE NULL. > > > > . There needs to be support for this in psql's

default sorting behavior for index

2022-09-20 Thread Zhihong Yu
Hi, I was looking at this check in src/backend/parser/parse_utilcmd.c w.r.t. constraint: if (indclass->values[i] != defopclass || attform->attcollation != index_rel->rd_indcollation[i] || attoptions != (Datum) 0 ||

Re: cataloguing NOT NULL constraints

2022-09-09 Thread Zhihong Yu
Hi, w.r.t. the while loop in findNotNullConstraintAttnum(): + if (multiple == NULL) + break; I think `pfree(arr)` should be called before breaking. + if (constraint->cooked_expr != NULL) + return tryExtractNotNullFromNode(stringToNode(constraint->cooked_expr),

Re: Table AM modifications to accept column projection lists

2022-09-05 Thread Zhihong Yu
On Mon, Sep 5, 2022 at 9:51 AM Nikita Malakhov wrote: > Hi hackers! > > This is the original patch rebased onto v15 master with conflicts > resolved. I'm currently > studying it and latest comments in the original thread, and would try go > the way that > was mentioned in the thread (last

Re: freeing LDAPMessage in CheckLDAPAuth

2022-09-05 Thread Zhihong Yu
On Sun, Sep 4, 2022 at 10:37 PM Michael Paquier wrote: > On Sun, Sep 04, 2022 at 06:52:37AM -0700, Zhihong Yu wrote: > > Please take a look at patch v3. > > Fine as far as it goes. I would have put the initialization of > search_message closer to ldap_search_s() for cons

Re: freeing LDAPMessage in CheckLDAPAuth

2022-09-04 Thread Zhihong Yu
On Sun, Sep 4, 2022 at 3:58 AM Zhihong Yu wrote: > > > On Sun, Sep 4, 2022 at 12:25 AM Michael Paquier > wrote: > >> On Sun, Sep 04, 2022 at 01:52:10AM -0400, Tom Lane wrote: >> > I can't get too excited about this. All of the error exit paths in >> >

Re: freeing LDAPMessage in CheckLDAPAuth

2022-09-04 Thread Zhihong Yu
On Sun, Sep 4, 2022 at 12:25 AM Michael Paquier wrote: > On Sun, Sep 04, 2022 at 01:52:10AM -0400, Tom Lane wrote: > > I can't get too excited about this. All of the error exit paths in > > backend authentication code will lead immediately to process exit, so > > the possibility of some memory

freeing LDAPMessage in CheckLDAPAuth

2022-09-03 Thread Zhihong Yu
Hi, In CheckLDAPAuth(), around line 2606: if (r != LDAP_SUCCESS) { ereport(LOG, (errmsg("could not search LDAP for filter \"%s\" on server \"%s\": %s", It seems that the call to ldap_msgfree() is missing in the above case. According to

Re: On login trigger: take three

2022-09-02 Thread Zhihong Yu
On Fri, Sep 2, 2022 at 8:37 AM Daniel Gustafsson wrote: > This had bitrotted a fair bit, attached is a rebase along with (mostly) > documentation fixes. 0001 adds a generic GUC for ignoring event triggers > and > 0002 adds the login event with event trigger support, and hooks it up to > the >

Re: cataloguing NOT NULL constraints

2022-08-31 Thread Zhihong Yu
On Wed, Aug 31, 2022 at 4:08 PM Zhihong Yu wrote: > > > On Wed, Aug 31, 2022 at 3:19 PM Alvaro Herrera > wrote: > >> So I was wrong in thinking that "this case was simple to implement" as I >> replied upthread. Doing that actually required me to rewrite

Re: cataloguing NOT NULL constraints

2022-08-31 Thread Zhihong Yu
On Wed, Aug 31, 2022 at 3:19 PM Alvaro Herrera wrote: > So I was wrong in thinking that "this case was simple to implement" as I > replied upthread. Doing that actually required me to rewrite large > parts of the patch. I think it ended up being a good thing, because in > hindsight the

Re: Removing unneeded self joins

2022-08-28 Thread Zhihong Yu
On Fri, Aug 26, 2022 at 3:02 PM Zhihong Yu wrote: > Hi, > For v36-0001-Remove-self-joins.patch : > > bq removes inner join of plane table to itself > > plane table -> plain table > > For relation_has_unique_index_ext(), it seems when extra_clauses is NULL, > ther

Re: Removing unneeded self joins

2022-08-26 Thread Zhihong Yu
Hi, For v36-0001-Remove-self-joins.patch : bq removes inner join of plane table to itself plane table -> plain table For relation_has_unique_index_ext(), it seems when extra_clauses is NULL, there is no need to compute `exprs`. Cheers >

Re: POC PATCH: copy from ... exceptions to: (was Re: VLDB Features)

2022-08-24 Thread Zhihong Yu
Hi, I was looking at 0004-COPY_IGNORE_ERRORS.patch + * Ignore constraints if IGNORE_ERRORS is enabled + */ +static void +safeExecConstraints(CopyFromState cstate, ResultRelInfo *resultRelInfo, TupleTableSlot *myslot, EState *estate) I think the existing ExecConstraints() can be expanded by

Re: handling multiple matching constraints in DetachPartitionFinalize()

2022-08-23 Thread Zhihong Yu
On Tue, Aug 23, 2022 at 10:53 AM Alvaro Herrera wrote: > On 2022-Aug-23, Zhihong Yu wrote: > > > This is what I came up with. > > I suggest you provide a set of SQL commands that provoke some wrong > behavior with the original code, and show that they generate good >

Re: handling multiple matching constraints in DetachPartitionFinalize()

2022-08-23 Thread Zhihong Yu
On Tue, Aug 23, 2022 at 10:10 AM Zhihong Yu wrote: > Hi, > I was looking at the following code in DetachPartitionFinalize(): > > /* If there's a constraint associated with the index, detach it > too */ > constrOid = > get_relation_idx_constraint_oid(Rel

handling multiple matching constraints in DetachPartitionFinalize()

2022-08-23 Thread Zhihong Yu
Hi, I was looking at the following code in DetachPartitionFinalize(): /* If there's a constraint associated with the index, detach it too */ constrOid = get_relation_idx_constraint_oid(RelationGetRelid(partRel), idxid); As

Re: [BUG] parenting a PK constraint to a self-FK one (Was: Self FK oddity when attaching a partition)

2022-08-23 Thread Zhihong Yu
On Tue, Aug 23, 2022 at 9:47 AM Alvaro Herrera wrote: > On 2022-Aug-23, Zhihong Yu wrote: > > > I was thinking of the following patch. > > Basically, if there is only one matching constraint. we still return it. > > > > diff --git a/src/postgres/src/backend/cat

Re: [BUG] parenting a PK constraint to a self-FK one (Was: Self FK oddity when attaching a partition)

2022-08-23 Thread Zhihong Yu
On Tue, Aug 23, 2022 at 9:30 AM Alvaro Herrera wrote: > On 2022-Aug-23, Jehan-Guillaume de Rorthais wrote: > > Hi, > > [...] > > > However, it seems get_relation_idx_constraint_oid(), introduced in > eb7ed3f3063, > > assume there could be only ONE constraint depending to an index. But in > fact,

Re: [BUG] parenting a PK constraint to a self-FK one (Was: Self FK oddity when attaching a partition)

2022-08-23 Thread Zhihong Yu
On Tue, Aug 23, 2022 at 8:07 AM Jehan-Guillaume de Rorthais wrote: > Hi all, > > I've been able to work on this issue and isolate where in the code the > oddity > is laying. > > During ATExecAttachPartition(), AttachPartitionEnsureIndexes() look for > existing > required index on the partition

Re: including pid's for `There are XX other sessions using the database`

2022-08-21 Thread Zhihong Yu
On Sun, Aug 21, 2022 at 6:39 AM Julien Rouhaud wrote: > Hi, > > On Sat, Aug 20, 2022 at 02:52:29AM -0700, Zhihong Yu wrote: > > On Fri, Aug 19, 2022 at 9:31 PM Euler Taveira wrote: > > > > > > > Thanks for responding. > > > > Since pg_stat_act

timing information for switching database

2022-08-21 Thread Zhihong Yu
Hi, In sqlsh, I issued `\timing on`. I don't see timing information displayed for `\c database`. Does someone know how I can obtain such information ? Thanks

Re: including pid's for `There are XX other sessions using the database`

2022-08-20 Thread Zhihong Yu
On Fri, Aug 19, 2022 at 9:31 PM Euler Taveira wrote: > On Fri, Aug 19, 2022, at 2:10 PM, Zhihong Yu wrote: > > I want to poll the community on whether including proc->pid's in the error > message would be useful for troubleshooting. > > Such message is only u

including pid's for `There are XX other sessions using the database`

2022-08-19 Thread Zhihong Yu
Hi, Currently errdetail_busy_db() only shows the number of other sessions using the database but doesn't give any detail about them. For one of the customers,pg_stat_activity is showing lower number of connections compared to the number revealed in the error message. Looking at

Re: avoid negating LONG_MIN in cash_out()

2022-08-11 Thread Zhihong Yu
On Thu, Aug 11, 2022 at 6:28 PM Tom Lane wrote: > Zhihong Yu writes: > > How about patch v2 which uses the same check from cash_in() ? > > I'm not sure which part of this statement you're not getting: > it is completely unacceptable for cash_out to fail on valid &g

Re: avoid negating LONG_MIN in cash_out()

2022-08-11 Thread Zhihong Yu
On Thu, Aug 11, 2022 at 12:55 PM David Rowley wrote: > On Fri, 12 Aug 2022 at 05:58, Zhihong Yu wrote: > > Here is sample output with patch: > > > > # SELECT '-92233720368547758.085'::money; > > ERROR: value "-92233720368547758.085" is out of ra

Re: avoid negating LONG_MIN in cash_out()

2022-08-11 Thread Zhihong Yu
On Thu, Aug 11, 2022 at 10:55 AM Zhihong Yu wrote: > > > On Thu, Aug 11, 2022 at 10:40 AM Tom Lane wrote: > >> Zhihong Yu writes: >> > In cash_out(), we have the following code: >> > if (value < 0) >> > { >> >

Re: avoid negating LONG_MIN in cash_out()

2022-08-11 Thread Zhihong Yu
On Thu, Aug 11, 2022 at 10:40 AM Tom Lane wrote: > Zhihong Yu writes: > > In cash_out(), we have the following code: > > if (value < 0) > > { > > /* make the amount positive for digit-reconstruction loop */ > > value = -value; >

avoid negating LONG_MIN in cash_out()

2022-08-11 Thread Zhihong Yu
Hi, In cash_out(), we have the following code: if (value < 0) { /* make the amount positive for digit-reconstruction loop */ value = -value; The negation cannot be represented in type long when the value is LONG_MIN. It seems we can error out when LONG_MIN is detected

Re: dropping datumSort field

2022-08-09 Thread Zhihong Yu
On Tue, Aug 9, 2022 at 9:04 PM David Rowley wrote: > On Wed, 10 Aug 2022 at 03:16, Zhihong Yu wrote: > > On Tue, Aug 9, 2022 at 8:01 AM Robert Haas > wrote: > >> > >> One problem with this patch is that, if I apply it, PostgreSQL does not > compile: >

Re: Fast COPY FROM based on batch insert

2022-08-09 Thread Zhihong Yu
On Tue, Aug 9, 2022 at 4:45 AM Etsuro Fujita wrote: > On Tue, Jul 26, 2022 at 7:19 PM Etsuro Fujita > wrote: > > Yeah, I think the patch is getting better, but I noticed some issues, > > so I'm working on them. I think I can post a new version in the next > > few days. > > * When running AFTER

Re: dropping datumSort field

2022-08-09 Thread Zhihong Yu
On Tue, Aug 9, 2022 at 8:24 AM Robert Haas wrote: > On Tue, Aug 9, 2022 at 11:16 AM Zhihong Yu wrote: > > tupDesc is declared inside `if (!node->sort_Done)` block whereas the > last reference to tupDesc is outside the if block. > > Yep. > > > I take your review

Re: dropping datumSort field

2022-08-09 Thread Zhihong Yu
On Tue, Aug 9, 2022 at 8:01 AM Robert Haas wrote: > On Mon, Aug 8, 2022 at 5:51 PM Zhihong Yu wrote: > > Hi, > > I was looking at ExecSort() w.r.t. datum sort. > > > > I wonder if the datumSort field can be dropped. > > Here is a patch illustrating the potenti

dropping datumSort field

2022-08-08 Thread Zhihong Yu
Hi, I was looking at ExecSort() w.r.t. datum sort. I wonder if the datumSort field can be dropped. Here is a patch illustrating the potential simplification. Please take a look. Thanks drop-datum-sort-field.patch Description: Binary data

Re: Parallel Aggregates for string_agg and array_agg

2022-08-02 Thread Zhihong Yu
On Tue, Aug 2, 2022 at 4:46 PM David Rowley wrote: > On Wed, 20 Jun 2018 at 19:08, David Rowley > wrote: > > I'll submit it again when there more consensus that we want this. > > Waking up this old thread again. If you don't have a copy, the entire > thread is in [1]. > > The remaining item

Re: Add proper planner support for ORDER BY / DISTINCT aggregates

2022-08-02 Thread Zhihong Yu
On Tue, Aug 2, 2022 at 11:02 AM Zhihong Yu wrote: > >> Hi, David: > > I was looking at the final patch and noticed that setno field > in agg_presorted_distinctcheck struct is never used. > > Looks like it was copied from neighboring struct. > > Can you take a

Re: Add proper planner support for ORDER BY / DISTINCT aggregates

2022-08-02 Thread Zhihong Yu
> > > Hi, David: I was looking at the final patch and noticed that setno field in agg_presorted_distinctcheck struct is never used. Looks like it was copied from neighboring struct. Can you take a look at the patch ? Thanks > drop-setno-from-agg_presorted_distinctcheck.patch Description:

Re: Making Vars outer-join aware

2022-08-01 Thread Zhihong Yu
On Mon, Aug 1, 2022 at 12:51 PM Tom Lane wrote: > Here's a rebase up to HEAD, mostly to placate the cfbot. > I accounted for d8e34fa7a (s/all_baserels/all_query_rels/ > in those places) and made one tiny bug-fix change. > Nothing substantive as yet. > > regards, tom lane

Re: Skip partition tuple routing with constant partition key

2022-07-26 Thread Zhihong Yu
On Tue, Jul 26, 2022 at 3:28 PM David Rowley wrote: > Thank for looking at this. > > On Sat, 23 Jul 2022 at 01:23, Amit Langote > wrote: > > + /* > > +* The Datum has changed. Zero the number of times > we've > > +* found

Question about ExplainOneQuery_hook

2022-07-26 Thread Zhihong Yu
Hi, I was looking at ExplainOneQuery() where ExplainOneQuery_hook is called. Currently the call to the hook is in if block and normal processing is in else block. What if the hook doesn't want to duplicate the whole code printing execution plan ? Please advise. Thanks

Re: Add proper planner support for ORDER BY / DISTINCT aggregates

2022-07-25 Thread Zhihong Yu
On Mon, Jul 25, 2022 at 4:39 PM David Rowley wrote: > On Fri, 22 Jul 2022 at 21:33, Richard Guo wrote: > > I can see this problem with > > the query below: > > > > select max(b order by b), max(a order by a) from t group by a; > > > > When processing the first aggregate, we compose the

Re: redacting password in SQL statement in server log

2022-07-24 Thread Zhihong Yu
On Sat, Jul 23, 2022 at 5:27 PM Tom Lane wrote: > Zhihong Yu writes: > > Currently, in situation such as duplicate role creation, the server log > > would show something such as the following: > > > 2022-07-22 13:48:18.251 UTC [330] STATEMENT: CREATE ROLE test WITH LO

Re: redacting password in SQL statement in server log

2022-07-23 Thread Zhihong Yu
On Sat, Jul 23, 2022 at 5:27 PM Tom Lane wrote: > Zhihong Yu writes: > > Currently, in situation such as duplicate role creation, the server log > > would show something such as the following: > > > 2022-07-22 13:48:18.251 UTC [330] STATEMENT: CREATE ROLE test WITH LO

redacting password in SQL statement in server log

2022-07-23 Thread Zhihong Yu
Hi, Currently, in situation such as duplicate role creation, the server log would show something such as the following: 2022-07-22 13:48:18.251 UTC [330] STATEMENT: CREATE ROLE test WITH LOGIN PASSWORD 'foobar'; The password itself should be redacted before logging the statement. Here is

potential memory leak in pg_regcomp()

2022-07-22 Thread Zhihong Yu
Hi, I was looking at pg_regcomp(): re->re_guts = VS(MALLOC(sizeof(struct guts))); I did some search trying to find where re_guts is freed but haven't found it. Can someone enlighten me? Thanks

Re: Freeing sortgroupatts in use_physical_tlist

2022-07-15 Thread Zhihong Yu
On Fri, Jul 15, 2022 at 8:33 PM Tom Lane wrote: > Zhihong Yu writes: > > I was looking at the code in use_physical_tlist(). > > In the code block checking CP_LABEL_TLIST, I noticed that > > the Bitmapset sortgroupatts is not freed before returning from the

Freeing sortgroupatts in use_physical_tlist

2022-07-15 Thread Zhihong Yu
Hi, I was looking at the code in use_physical_tlist(). In the code block checking CP_LABEL_TLIST, I noticed that the Bitmapset sortgroupatts is not freed before returning from the method. Looking at create_foreignscan_plan() (in the same file): bms_free(attrs_used); It seems the

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2022-07-13 Thread Zhihong Yu
On Wed, Jul 13, 2022 at 1:05 PM Dmitry Koval wrote: > Thanks you! > I've fixed all things mentioned. > > -- > With best regards, > Dmitry Koval > > Postgres Professional: http://postgrespro.com Hi, Toward the end of ATExecSplitPartition(): + /* Unlock new partition. */ +

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2022-07-13 Thread Zhihong Yu
On Wed, Jul 13, 2022 at 11:28 AM Dmitry Koval wrote: > Hi! > > Patch stop applying due to changes in upstream. > Here is a rebased version. > > -- > With best regards, > Dmitry Koval > > Postgres Professional: http://postgrespro.com Hi, +attachPartTable(List **wqueue, Relation rel, Relation

Re: should check interrupts in BuildRelationExtStatistics ?

2022-07-12 Thread Zhihong Yu
On Tue, Jul 12, 2022 at 1:31 PM Tom Lane wrote: > I wrote: > > Thomas Munro writes: > >> On Wed, Jul 6, 2022 at 11:37 AM Tom Lane wrote: > >>> qsort_interruptible > > >> +1 > > > So here's a patch that does it that way. > > Hearing no comments, pushed. > > regards, tom

Re: Making Vars outer-join aware

2022-07-10 Thread Zhihong Yu
On Sun, Jul 10, 2022 at 12:39 PM Tom Lane wrote: > Here's v2 of this patch series. It's functionally identical to v1, > but I've rebased it over the recent auto-node-support-generation > changes, and also extracted a few separable bits in hopes of making > the main planner patch smaller. (It's

Re: Making the subquery alias optional in the FROM clause

2022-07-09 Thread Zhihong Yu
On Sat, Jul 9, 2022 at 5:18 AM Dean Rasheed wrote: > On Sat, 9 Jul 2022 at 12:24, Zhihong Yu wrote: > > > > It seems the code would be more readable if you keep the assignment in > else block below: > > > > + else if

Re: Making the subquery alias optional in the FROM clause

2022-07-09 Thread Zhihong Yu
On Sat, Jul 9, 2022 at 3:28 AM Dean Rasheed wrote: > On Wed, 6 Jul 2022 at 15:09, Dean Rasheed > wrote: > > > > I'll post an update in a little while, but first, I found a bug, which > > revealed a pre-existing bug in transformLockingClause(). I'll start a > > new thread for that, since it'd be

Re: Aggregate leads to superfluous projection from the scan

2022-07-08 Thread Zhihong Yu
On Fri, Jul 8, 2022 at 12:48 PM Zhihong Yu wrote: > > > On Fri, Jul 8, 2022 at 12:30 PM Tom Lane wrote: > >> Ibrar Ahmed writes: >> > I give a quick look and I think in case whenever data is extracted from >> the >> > heap it shows all the columns.

Re: Aggregate leads to superfluous projection from the scan

2022-07-08 Thread Zhihong Yu
On Fri, Jul 8, 2022 at 12:30 PM Tom Lane wrote: > Ibrar Ahmed writes: > > I give a quick look and I think in case whenever data is extracted from > the > > heap it shows all the columns. Therefore when columns are extracted from > > the index only it shows the indexed column only. > > This is

Re: Aggregate leads to superfluous projection from the scan

2022-07-08 Thread Zhihong Yu
On Fri, Jul 8, 2022 at 9:40 AM Zhihong Yu wrote: > Hi, > Here is the query which involves aggregate on a single column: > > > https://dbfiddle.uk/?rdbms=postgres_13=44bfd8f6b6b5aad34d00d449c04c5a96 > > As you can see from `Output:`, there are many columns added w

Aggregate leads to superfluous projection from the scan

2022-07-08 Thread Zhihong Yu
Hi, Here is the query which involves aggregate on a single column: https://dbfiddle.uk/?rdbms=postgres_13=44bfd8f6b6b5aad34d00d449c04c5a96 As you can see from `Output:`, there are many columns added which are not needed by the query executor. I wonder if someone has noticed this in the past. If

index for inet column

2022-07-07 Thread Zhihong Yu
Hi, I was able to create gin index on inet column in PG. GIN is good with points/elements in sets. Is gin a good index for inet column ? It seems gist index would be better. Comments are welcome.

Re: Bugs in copyfuncs/equalfuncs support for JSON node types

2022-07-04 Thread Zhihong Yu
On Mon, Jul 4, 2022 at 6:23 PM Tom Lane wrote: > In reviewing Peter's patch to auto-generate the backend/nodes > support files, I compared what the patch's script produces to > what is in the code now. I found several discrepancies in the > recently-added parse node types for JSON functions,

Re: Removing unneeded self joins

2022-07-04 Thread Zhihong Yu
On Mon, Jul 4, 2022 at 6:52 AM Ronan Dunklau wrote: > Le jeudi 30 juin 2022, 16:11:51 CEST Andrey Lepikhov a écrit : > > On 19/5/2022 16:47, Ronan Dunklau wrote: > > > I'll take a look at that one. > > > > New version of the patch, rebased on current master: > > 1. pgindent over the patch have

Re: Patch proposal: New hooks in the connection path

2022-07-04 Thread Zhihong Yu
On Mon, Jul 4, 2022 at 5:54 AM Drouvot, Bertrand wrote: > Hi, > > On 7/2/22 1:00 AM, Nathan Bossart wrote: > > Could we model this after fmgr_hook? The first argument in that hook > > indicates where it is being called from. This doesn't alleviate the need > > for several calls to the hook in

Re: pgsql: dshash: Add sequential scan support.

2022-07-04 Thread Zhihong Yu
On Sun, Jul 3, 2022 at 7:56 PM Thomas Munro wrote: > [Re-directing to -hackers] > > On Fri, Mar 11, 2022 at 2:27 PM Andres Freund wrote: > > On 2022-03-10 20:09:56 -0500, Tom Lane wrote: > > > Andres Freund writes: > > > > dshash: Add sequential scan support. > > > > Add ability to scan all

Re: [PATCH] Optimize json_lex_string by batching character copying

2022-06-24 Thread Zhihong Yu
Hi, Looking at the patch, + if (copyable_characters_length) + { + /* flush copyable characters */ + appendBinaryStringInfo( + lex->strval, + s - copyable_characters_length, +

Re: Defer selection of asynchronous subplans until the executor initialization stage

2022-06-02 Thread Zhihong Yu
On Thu, Jun 2, 2022 at 5:08 AM Etsuro Fujita wrote: > On Wed, Apr 6, 2022 at 3:58 PM Etsuro Fujita > wrote: > > I have committed the patch after modifying it as such. > > The patch calls trivial_subqueryscan() during create_append_plan() to > determine the triviality of a SubqueryScan that is a

showing effective max_connections

2022-06-01 Thread Zhihong Yu
Hi, For non superusers, the max connections would be lower than what max_connections specifies. Should we display the effective value when non superuser issues `SHOW max_connections` ? Thanks

Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

2022-06-01 Thread Zhihong Yu
On Wed, Jun 1, 2022 at 11:58 AM Dmitry Koval wrote: > Hi, > > 1) > > For attachPartTable, the parameter wqueue is missing from comment. > > The parameters of CloneRowTriggersToPartition are called parent and > partition. > > I think it is better to name the parameters to attachPartTable in a >

Re: silence compiler warning in brin.c

2022-06-01 Thread Zhihong Yu
On Wed, Jun 1, 2022 at 10:06 AM Tom Lane wrote: > Zhihong Yu writes: > > On Wed, Jun 1, 2022 at 9:35 AM Nathan Bossart > > wrote: > >> I'm seeing a compiler warning in brin.c with an older version of gcc. > >> Specifically, it seems worried that a variable migh

Re: silence compiler warning in brin.c

2022-06-01 Thread Zhihong Yu
On Wed, Jun 1, 2022 at 9:35 AM Nathan Bossart wrote: > Hi hackers, > > I'm seeing a compiler warning in brin.c with an older version of gcc. > Specifically, it seems worried that a variable might not be initialized. > AFAICT there is no real risk, so I've attached a small patch to silence the >

  1   2   3   4   5   6   >