Re: support for MERGE

2022-02-27 Thread Zhihong Yu
On Sun, Feb 27, 2022 at 9:25 AM Alvaro Herrera wrote: > I attach v12 of MERGE. Significant effort went into splitting > ExecUpdate and ExecDelete into parts that can be reused from the MERGE > routines in a way that doesn't involve jumping out in the middle of > TM_Result processing to merge-spe

casting operand to proper type in BlockIdGetBlockNumber

2022-03-03 Thread Zhihong Yu
Hi, In test output, I saw: src/backend/utils/adt/tid.c:112:16: runtime error: left shift of 65535 by 16 places cannot be represented in type 'int' I think this was due to the left shift in BlockIdGetBlockNumber not properly casting its operand. Please see the proposed change in patch. Thanks

Re: casting operand to proper type in BlockIdGetBlockNumber

2022-03-03 Thread Zhihong Yu
On Thu, Mar 3, 2022 at 7:44 AM Tom Lane wrote: > Zhihong Yu writes: > > In test output, I saw: > > src/backend/utils/adt/tid.c:112:16: runtime error: left shift of 65535 by > > 16 places cannot be represented in type 'int' > > What compiler is that? > >

Re: casting operand to proper type in BlockIdGetBlockNumber

2022-03-03 Thread Zhihong Yu
On Thu, Mar 3, 2022 at 8:24 AM Tom Lane wrote: > Zhihong Yu writes: > > On Thu, Mar 3, 2022 at 7:44 AM Tom Lane wrote: > >> Zhihong Yu writes: > >>> In test output, I saw: > >>> src/backend/utils/adt/tid.c:112:16: runtime error: left shift of 65535

Re: casting operand to proper type in BlockIdGetBlockNumber

2022-03-03 Thread Zhihong Yu
On Thu, Mar 3, 2022 at 9:13 AM Tom Lane wrote: > Zhihong Yu writes: > > On Thu, Mar 3, 2022 at 8:24 AM Tom Lane wrote: > >> Oh, I misread this as a compile-time warning, but it must be from ASAN. > >> Was the test case one of your own, or just our normal regressi

Re: casting operand to proper type in BlockIdGetBlockNumber

2022-03-03 Thread Zhihong Yu
On Thu, Mar 3, 2022 at 1:11 PM Andres Freund wrote: > Hi, > > On 2022-03-03 15:31:51 -0500, Tom Lane wrote: > > Andres Freund writes: > > > On 2022-03-03 14:00:14 -0500, Tom Lane wrote: > > > For the buildfarm, I could enable it on flaviventris? That runs an > > > experimental gcc, without optim

timestamp for query in pg_stat_statements

2022-03-05 Thread Zhihong Yu
Hi, Looking at pg_stat_statements, there doesn't seem to be timestamp column for when the underlying query is performed. Since the same query can be run multiple times, the absence of timestamp column makes finding the most recent invocation of the query difficult. Does it make sense to add such a

Re: timestamp for query in pg_stat_statements

2022-03-06 Thread Zhihong Yu
On Sat, Mar 5, 2022 at 8:17 PM Julien Rouhaud wrote: > On Sat, Mar 05, 2022 at 06:10:44PM -0800, Zhihong Yu wrote: > > > > Looking at pg_stat_statements, there doesn't seem to be timestamp column > > for when the underlying query is performed. > > Since the same

Re: timestamp for query in pg_stat_statements

2022-03-06 Thread Zhihong Yu
On Sun, Mar 6, 2022 at 6:23 PM Julien Rouhaud wrote: > On Sun, Mar 06, 2022 at 12:37:00PM -0800, Zhihong Yu wrote: > > The current design of pg_stat_statements doesn't have the concept of > > observation. > > > > By observation I mean scenarios where pg_sta

refreshing query id for pg_stat_statements based on comment in sql

2022-03-07 Thread Zhihong Yu
Hi, Currently the query id for pg_stat_statements gets calculated based on the parse nodes specifics. This means that the user cannot add a comment to a SQL query to test something. (though some other RDBMS allows this practice). Consider this use case: for query q, admin looks at stats and perfor

Re: support for MERGE

2022-03-07 Thread Zhihong Yu
On Mon, Mar 7, 2022 at 12:04 PM Álvaro Herrera wrote: > On Mon, Mar 7, 2022, at 4:59 PM, Álvaro Herrera wrote: > > I attach v13 here. This version includes a 0002 that's does the split of > nodeModifyTable.c routines, then 0003 implements MERGE on top of that. > 0001 is as before. > > > In 0002,

minor change for create_list_bounds()

2022-03-08 Thread Zhihong Yu
Hi, I was looking at commit db632fbca and noticed that, in create_list_bounds(), if index is added to boundinfo->interleaved_parts in the first if statement, there is no need to perform the second check involving call to partition_bound_accepts_nulls(). Here is a short patch. Cheers list-bound-

Re: support for MERGE

2022-03-09 Thread Zhihong Yu
On Wed, Mar 9, 2022 at 9:38 AM Alvaro Herrera wrote: > I attach MERGE v14. This includes a fix from Amit Langote for the > problem I described previously, with EvalPlanQual not working correctly. > (I had failed to short-circuit the cross-partition update correctly.) > Now the test case is enabl

Re: generic plans and "initial" pruning

2022-03-11 Thread Zhihong Yu
Hi, w.r.t. v5-0003-Teach-AcquireExecutorLocks-to-skip-locking-pruned.patch : (pruning steps containing expressions that can be computed before before the executor proper has started) the word 'before' was repeated. For ExecInitParallelPlan(): + char *execlockrelsinfo_data; + char

Re: BufferAlloc: don't take two simultaneous locks

2022-03-13 Thread Zhihong Yu
On Sun, Mar 13, 2022 at 3:25 AM Yura Sokolov wrote: > В Пт, 11/03/2022 в 17:21 +0900, Kyotaro Horiguchi пишет: > > At Fri, 11 Mar 2022 15:49:49 +0900 (JST), Kyotaro Horiguchi < > horikyota@gmail.com> wrote in > > > At Fri, 11 Mar 2022 15:30:30 +0900 (JST), Kyotaro Horiguchi < > horikyota@

Re: BufferAlloc: don't take two simultaneous locks

2022-03-13 Thread Zhihong Yu
On Sun, Mar 13, 2022 at 3:27 PM Yura Sokolov wrote: > В Вс, 13/03/2022 в 07:05 -0700, Zhihong Yu пишет: > > > > Hi, > > In the description: > > > > There is no need to hold both lock simultaneously. > > > > both lock -> both locks > > Thanks

Re: simplifying foreign key/RI checks

2022-03-14 Thread Zhihong Yu
On Mon, Mar 14, 2022 at 1:33 AM Amit Langote wrote: > On Tue, Jan 18, 2022 at 3:30 PM Amit Langote > wrote: > > v13 is attached. > > I noticed that the recent 641f3dffcdf's changes to > get_constraint_index() made it basically unusable for this patch's > purposes. > > Reading in the thread that

Re: Concurrent deadlock scenario with DROP INDEX on partitioned index

2022-03-16 Thread Zhihong Yu
On Wed, Mar 16, 2022 at 11:20 AM Jimmy Yih wrote: > Tom Lane wrote: > > 1. RangeVarCallbackForDropRelation can get called more than once > > during a lookup (in case of concurrent rename and suchlike). > > If so it needs to be prepared to drop the lock(s) it got last time. > > You have not imple

Re: a misbehavior of partition row movement (?)

2022-03-18 Thread Zhihong Yu
On Fri, Mar 18, 2022 at 9:38 AM Alvaro Herrera wrote: > I rebased this patch; v15 attached. Other than fixing the (very large) > conflicts due to nodeModifyTable.c rework, the most important change is > moving GetAncestorResultRels into execMain.c and renaming it to have the > "Exec-" prefix. T

Re: freeing bms explicitly

2022-03-21 Thread Zhihong Yu
> > Hi, > I was looking at calls to bms_free() in PG code. > > e.g. src/backend/commands/publicationcmds.c line 362 > > bms_free(bms); > > The above is just an example, there're other calls to bms_free(). > Since the bms is allocated from some execution context, I wonder why this > call is

Re: freeing bms explicitly

2022-03-21 Thread Zhihong Yu
On Mon, Mar 21, 2022 at 3:05 PM Tom Lane wrote: > Zhihong Yu writes: > >> I was looking at calls to bms_free() in PG code. > >> e.g. src/backend/commands/publicationcmds.c line 362 > >> bms_free(bms); > >> The above is just an example, there're o

Re: Window Function "Run Conditions"

2022-03-22 Thread Zhihong Yu
On Tue, Mar 22, 2022 at 3:24 PM David Rowley wrote: > On Thu, 26 Aug 2021 at 14:54, Andy Fan wrote: > > > > On Thu, Aug 19, 2021 at 2:35 PM David Rowley > wrote: > > > > > > On Thu, 19 Aug 2021 at 00:20, Andy Fan > wrote: > > > > In the current master, the result is: > > > > > > > > empno | s

Re: freeing bms explicitly

2022-03-22 Thread Zhihong Yu
On Tue, Mar 22, 2022 at 8:45 PM Amit Kapila wrote: > On Tue, Mar 22, 2022 at 3:39 AM Zhihong Yu wrote: > > > > On Mon, Mar 21, 2022 at 3:05 PM Tom Lane wrote: > >> > >> Zhihong Yu writes: > >> >> I was looking at calls to bms_free

Re: freeing bms explicitly

2022-03-23 Thread Zhihong Yu
On Tue, Mar 22, 2022 at 9:04 PM Zhihong Yu wrote: > > > On Tue, Mar 22, 2022 at 8:45 PM Amit Kapila > wrote: > >> On Tue, Mar 22, 2022 at 3:39 AM Zhihong Yu wrote: >> > >> > On Mon, Mar 21, 2022 at 3:05 PM Tom Lane wrote: >> >> >>

Re: Skip partition tuple routing with constant partition key

2022-03-23 Thread Zhihong Yu
On Wed, Mar 23, 2022 at 5:52 AM Amit Langote wrote: > Hi Greg, > > On Wed, Mar 16, 2022 at 6:54 AM Greg Stark wrote: > > There are a whole lot of different patches in this thread. > > > > However this last one https://commitfest.postgresql.org/37/3270/ > > created by Amit seems like a fairly str

Re: ExecRTCheckPerms() and many prunable partitions

2022-03-23 Thread Zhihong Yu
On Wed, Mar 23, 2022 at 12:03 AM Amit Langote wrote: > On Mon, Mar 14, 2022 at 4:36 PM Amit Langote > wrote: > > Also needed fixes when rebasing. > > Needed another rebase. > > As the changes being made with the patch are non-trivial and the patch > hasn't been reviewed very significantly since

runtime error copying oids field

2020-11-30 Thread Zhihong Yu
Hi, In our testPgRegressTrigger test log, I saw the following (this was for a relatively old version of PG): 197859 [ts-1] ../../../../../../src/postgres/src/backend/commands/indexcmds.c:1062:22: runtime error: null pointer passed as argument 2, which is declared to never be null 197860 [ts-1]

Re: runtime error copying oids field

2020-11-30 Thread Zhihong Yu
Hi, See attached patch which is along the line Alvaro outlined. Cheers On Mon, Nov 30, 2020 at 3:01 PM Alvaro Herrera wrote: > On 2020-Nov-30, Zhihong Yu wrote: > > > This was the line runtime error was raised: > > > > memcpy(part_oids, partdesc->

Re: runtime error copying oids field

2020-11-30 Thread Zhihong Yu
Alvaro, et al: Please let me know how to proceed with the patch. Running test suite with the patch showed no regression. Cheers On Mon, Nov 30, 2020 at 3:24 PM Zhihong Yu wrote: > Hi, > See attached patch which is along the line Alvaro outlined. > > Cheers > > On Mon, Nov 3

Hybrid Hash/Nested Loop joins and caching results from subplans

2020-12-04 Thread Zhihong Yu
Hi, David: For nodeResultCache.c : +#define SH_EQUAL(tb, a, b) ResultCacheHash_equal(tb, a, b) == 0 I think it would be safer if the comparison is enclosed in parentheses (in case the macro appears in composite condition). +ResultCacheHash_equal(struct resultcache_hash *tb, const ResultCacheKey

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

2020-12-04 Thread Zhihong Yu
good for debugging. Cheers On Fri, Dec 4, 2020 at 5:09 PM Zhihong Yu wrote: > Hi, David: > For nodeResultCache.c : > > +#define SH_EQUAL(tb, a, b) ResultCacheHash_equal(tb, a, b) == 0 > > I think it would be safer if the comparison is enclosed in parenthes

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

2020-12-06 Thread Zhihong Yu
would trust your judgment in choosing the percentage. It is fine not to expose this constant until the need arises. Cheers On Sun, Dec 6, 2020 at 5:15 PM David Rowley wrote: > On Sat, 5 Dec 2020 at 16:51, Zhihong Yu wrote: > > > > There are two blocks with almost identical code (

Re: Parallel Inserts in CREATE TABLE AS

2020-12-06 Thread Zhihong Yu
Hi, Bharath : + (void) SetCurrentCommandIdUsedForWorker(); + myState->output_cid = GetCurrentCommandId(false); SetCurrentCommandIdUsedForWorker already has void as return type. The '(void)' is not needed. +* rd_createSubid is marked invalid, otherwise, the table is +

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

2020-12-07 Thread Zhihong Yu
at 14:25, Zhihong Yu wrote: > > > > > + /* Make a guess at a good size when we're not given a valid size. > */ > > > + if (size == 0) > > > + size = 1024; > > > > > > Should the default size be logged ? > > > > > I'

Re: Parallel Inserts in CREATE TABLE AS

2020-12-09 Thread Zhihong Yu
Hi, + if (!OidIsValid(col->collOid) && + type_is_collatable(col->typeName->typeOid)) + ereport(ERROR, ... + attrList = lappend(attrList, col); Should attrList be freed when ereport is called ? + query->CTASParallelInsInfo &= CTAS_PARALLEL_INS

Re: Deleting older versions in unique indexes to avoid page splits

2020-12-09 Thread Zhihong Yu
Hi, In v11-0001-Pass-down-logically-unchanged-index-hint.patch : + if (hasexpression) + return false; + + return true; The above can be written as 'return !hasexpression;' For +index_unchanged_by_update_var_walker: + * Returns true when Var that appears within allUpdatedCols located.

query on smallint array column

2020-12-13 Thread Zhihong Yu
Hi, I was experimenting with the following query. create table sint1(k int primary key, arr smallint[]); create index s1 on sint1(arr); insert into sint1 select s, array[s*s, s] FROM generate_series(1, 10) AS s; select * from sint1 where arr @> array[4]; ERROR: operator does not exist: smallint[]

Re: query on smallint array column

2020-12-13 Thread Zhihong Yu
Thanks Pavel for fast response. On Sun, Dec 13, 2020 at 9:51 AM Pavel Stehule wrote: > Hi > > ne 13. 12. 2020 v 18:42 odesílatel Zhihong Yu napsal: > >> Hi, >> I was experimenting with the following query. >> >> create table sint1(k int primary key, arr smal

Re: Parallel Inserts in CREATE TABLE AS

2020-12-14 Thread Zhihong Yu
For set_append_rel_size(), it seems this is the difference between query_level != 1 and query_level == 1: + (root->parent_root->parse->CTASParallelInsInfo & CTAS_PARALLEL_INS_IGN_TUP_COST_APPEND) && Maybe extract the common conditions into its own expression / variable so that t

Re: postgres_fdw - cached connection leaks if the associated user mapping/foreign server is dropped

2020-12-14 Thread Zhihong Yu
Is the following sequence possible ? In pgfdw_inval_callback(): entry->invalidated = true; + have_invalid_connections = true; At which time the loop in pgfdw_xact_callback() is already running (but past the above entry). Then: + /* We are done closing all the invalidated

range_agg

2020-12-16 Thread Zhihong Yu
Hi, w.r.t. patch v27. +* The idea is to prepend underscores as needed until we make a name that +* doesn't collide with anything ... I wonder if other characters (e.g. [a-z0-9]) can be used so that name without collision can be found without calling truncate_identifier(). + else if

Re: range_agg

2020-12-16 Thread Zhihong Yu
Letting user manually name the multirange (after a few automatic attempts) seems reasonable. Cheers On Wed, Dec 16, 2020 at 3:34 PM Alexander Korotkov wrote: > On Thu, Dec 17, 2020 at 1:03 AM Alexander Korotkov > wrote: > > On Thu, Dec 17, 2020 at 12:54 AM Zhihong Yu wrote: >

Re: On login trigger: take three

2020-12-16 Thread Zhihong Yu
Hi, For EventTriggerOnConnect(): + PG_CATCH(); + { ... + AbortCurrentTransaction(); + return; Should runlist be freed in the catch block ? + gettext_noop("In case of errors in the ON client_connection EVENT TRIGGER procedure, this paramet

Re: Double partition lock in bufmgr

2020-12-18 Thread Zhihong Yu
Hi, w.r.t. the code in BufferAlloc(), the pointers are compared. Should we instead compare the tranche Id of the two LWLock ? Cheers

Re: proposal: schema variables

2020-12-20 Thread Zhihong Yu
Hi, I took a look at the rebased patch. + varisnotnull + boolean + + + True if the schema variable doesn't allow null value. The default value is false. I wonder whether the field can be named in positive tense: e.g. varallowsnull with default of true. + vareoxac

Re: proposal: schema variables

2020-12-20 Thread Zhihong Yu
ly existence of some variables. Often error can be using simply occurred twice above - I think one should be enough. If you want to keep the second, it should be 'simple'. Cheers On Sun, Dec 20, 2020 at 11:25 AM Zhihong Yu wrote: > Hi, > I took a look at the rebased patch. >

Re: Weird special case in jsonb_concat()

2020-12-20 Thread Zhihong Yu
Hi, w.r.t. the patch, +select '[3]'::jsonb || '{}'::jsonb; + ?column? +-- + [3, {}] +(1 row) + +select '3'::jsonb || '[]'::jsonb; Should cases where the empty array precedes non-empty jsonb be added ? select '[]'::jsonb || '3'::jsonb; select '{}'::jsonb || '[3]'::jsonb; Cheers

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

2020-12-22 Thread Zhihong Yu
Justin: For reindex_index() : + if (options->tablespaceOid == MyDatabaseTableSpace) + options->tablespaceOid = InvalidOid; ... + if (set_tablespace && + (options->tablespaceOid != oldTablespaceOid || + (options->tablespaceOid == MyDatabaseTableSpace && OidIsValid(oldTablespac

Re: [Patch] Optimize dropping of relation buffers using dlist

2020-12-22 Thread Zhihong Yu
Hi, It is possible to come out of the nested loop without goto. + boolcached = true; ... +* to that fork during recovery. +*/ + for (i = 0; i < n && cached; i++) ... + if (!cached) +. break; Here I changed the initial value for cached to true so that we

Postgres Spark connector

2020-12-23 Thread Zhihong Yu
Hi, I searched for Postgres support in Apache Spark. I found Spark doc related to JDBC. I wonder if the community is aware of Spark connector for Postgres (hopefully open source) where predicate involving jsonb columns can be pushed down. Your input is appreciated. Thanks

Re: SQL/JSON: functions

2020-12-25 Thread Zhihong Yu
For 0001-Common-SQL-JSON-clauses-v51.patch : + /* | implementation_defined_JSON_representation_option (BSON, AVRO etc) */ I don't find implementation_defined_JSON_representation_option in the patchset. Maybe rephrase the above as a comment without implementation_defined_JSON_representation

Re: pg_stat_statements and "IN" conditions

2020-12-26 Thread Zhihong Yu
Hi, A few comments. + "After this number of duplicating constants start to merge them.", duplicating -> duplicate + foreach(lc, (List *) expr) + { + Node * subExpr = (Node *) lfirst(lc); + + if (!IsA(subExp

Re: SQL/JSON: functions

2020-12-26 Thread Zhihong Yu
; ERROR", " EMPTY", ... }; Cheers On Fri, Dec 25, 2020 at 5:19 PM Zhihong Yu wrote: > For 0001-Common-SQL-JSON-clauses-v51.patch : > > + /* | implementation_defined_JSON_representation_option (BSON, > AVRO etc) */ > > I don't find implementation_d

Re: SQL/JSON: JSON_TABLE

2020-12-26 Thread Zhihong Yu
For new files introduced in the patches: + * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group 2021 is a few days ahead. It would be good to update the year range. For transformJsonTableColumn: + jfexpr->op = + jtc->coltype == JTC_REGULAR ? IS_JSON_VALUE : + jt

Re: range_agg

2020-12-27 Thread Zhihong Yu
Hi, This is not an ideal way to index multirages, but something we can easily have. typo: multiranges Cheers On Sun, Dec 27, 2020 at 1:50 AM Alexander Korotkov wrote: > On Thu, Dec 17, 2020 at 10:10 PM Alexander Korotkov > wrote: > > > > I think this patch is very close to committable. I'm

Re: Parallel Inserts in CREATE TABLE AS

2020-12-27 Thread Zhihong Yu
For v16-0002-Tuple-Cost-Adjustment-for-Parallel-Inserts-in-CTAS.patch: + if (ignore && + (root->parse->CTASParallelInsInfo & +CTAS_PARALLEL_INS_TUP_COST_CAN_IGN)) I wonder why CTAS_PARALLEL_INS_TUP_COST_CAN_IGN is checked again in the above if since when ignore_paralle

Re: Parallel Inserts in CREATE TABLE AS

2020-12-29 Thread Zhihong Yu
w.r.t. v17-0004-Enable-CTAS-Parallel-Inserts-For-Append.patch + * Push the dest receiver to Gather node when it is either at the top of the + * plan or under top Append node unless it does not have any projections to do. I think the 'unless' should be 'if'. As can be seen from the body of the met

Re: Deleting older versions in unique indexes to avoid page splits

2020-12-31 Thread Zhihong Yu
Hi, Peter: Happy New Year. For v12-0001-Pass-down-logically-unchanged-index-hint.patch + if (hasexpression) + return false; + + return true; The above can be written as return !hasexpression; The negation is due to the return value from index_unchanged_by_update_var_walker() is inverse

Re: Table AM modifications to accept column projection lists

2020-12-31 Thread Zhihong Yu
Hi, Soumyadeep: Happy New Year. +typedef struct neededColumnContext +{ + Bitmapset **mask; + int n; + * n specifies the number of allowed entries in mask: we use + * it for bounds-checking in the walker above. I think the code would be easier to read if the above comment is moved or copied f

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

2021-01-01 Thread Zhihong Yu
Hi, Bharath: Happy new year. + appendStringInfo(&buf, "(%s, %s)", server->servername, +entry->invalidated ? "false" : "true"); Is it better to use 'invalidated' than 'false' in the string ? For the first if block of postgres_fdw_disconnect(): +* Check if t

Re: poc - possibility to write window function in PL languages

2021-01-01 Thread Zhihong Yu
Hi, Pavel: Happy New Year. + command with clause WINDOW. The specific feature of + this functions is a possibility to two special storages with this functions -> this function possibility to two special storages: there is no verb. 'store with stored one value': store is repeated. + * Porti

Re: faster ETL / bulk data load for heap tables

2021-01-01 Thread Zhihong Yu
Hi, Luc: Happy New Year. Looking at BufferAllocExtend() in v1-0002-WIP-buffer-alloc-specialized-for-relation-extensi.patch. it seems there is duplicate code with the existing BufferAlloc(). It would be good if some refactoring is done by extracting common code into a helper function. Thanks On

Re: Implement for window functions

2021-01-01 Thread Zhihong Yu
Krasiyan: Happy New Year. For WinGetFuncArgInPartition(): + if (target > 0) + step = 1; + else if (target < 0) + step = -1; + else + step = 0; When would the last else statement execute ? Since the above code is for WINDOW_S

Re: poc - possibility to write window function in PL languages

2021-01-04 Thread Zhihong Yu
Hi, Pavel: Thanks for the update. I don't have other comment. Cheers On Mon, Jan 4, 2021 at 3:15 AM Pavel Stehule wrote: > Hi > > pá 1. 1. 2021 v 18:57 odesílatel Zhihong Yu napsal: > >> Hi, Pavel: >> Happy New Year. >> >> + command with clause WI

Re: pg_stat_statements and "IN" conditions

2021-01-05 Thread Zhihong Yu
the current formation. Cheers On Tue, Jan 5, 2021 at 4:51 AM Dmitry Dolgov <9erthali...@gmail.com> wrote: > > On Sat, Dec 26, 2020 at 08:53:28AM -0800, Zhihong Yu wrote: > > Hi, > > A few comments. > > > > + foreach(lc, (List *) expr) > > +

Re: Parallel Inserts in CREATE TABLE AS

2021-01-05 Thread Zhihong Yu
For v20-0001-Parallel-Inserts-in-CREATE-TABLE-AS.patch : ParallelInsCmdEstimate : + Assert(pcxt && ins_info && + (ins_cmd == PARALLEL_INSERT_CMD_CREATE_TABLE_AS)); + + if (ins_cmd == PARALLEL_INSERT_CMD_CREATE_TABLE_AS) Sinc the if condition is covered by the assertion, I wonder why

Re: Parallel Inserts in CREATE TABLE AS

2021-01-05 Thread Zhihong Yu
PM Bharath Rupireddy < bharath.rupireddyforpostg...@gmail.com> wrote: > On Wed, Jan 6, 2021 at 8:19 AM Zhihong Yu wrote: > > For v20-0001-Parallel-Inserts-in-CREATE-TABLE-AS.patch : > > > > ParallelInsCmdEstimate : > > > > + A

Re: Parallel Inserts in CREATE TABLE AS

2021-01-06 Thread Zhihong Yu
Hi, For v20-0002-Tuple-Cost-Adjustment-for-Parallel-Inserts-in-CTAS.patch : workers to Gather node to 0. With this change, there are chances that the planner may choose the parallel plan. It would be nice if the scenarios where parallel plan is not chosen are listed. + if ((root->parse->parall

Re: Transactions involving multiple postgres foreign servers, take 2

2021-01-06 Thread Zhihong Yu
Hi, For pg-foreign/v31-0004-Add-PrepareForeignTransaction-API.patch : However these functions are not neither committed nor aborted at I think the double negation was not intentional. Should be 'are neither ...' For FdwXactShmemSize(), is another MAXALIGN(size) needed prior to the return stateme

Re: Parallel Inserts in CREATE TABLE AS

2021-01-06 Thread Zhihong Yu
at 8:01 PM Bharath Rupireddy < bharath.rupireddyforpostg...@gmail.com> wrote: > On Thu, Jan 7, 2021 at 5:12 AM Zhihong Yu wrote: > > > > Hi, > > For v20-0002-Tuple-Cost-Adjustment-for-Parallel-Inserts-in-CTAS.patch : > > > > workers to Gather node to 0. With

Re: Implement for window functions

2021-01-09 Thread Zhihong Yu
rning: ‘step’ may be used uninitialized in this function > [-Wmaybe-uninitialized] > 3531 | relpos += step; > | ~~~^~~~~~~ > > > > На пт, 8.01.2021 г. в 2:02 ч. Vik Fearing > написа: > >> On 1/1/21 10:21 PM, Zhihong Yu wrote: >> > Krasiyan: >>

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

2021-02-11 Thread Zhihong Yu
Hi, For v17-0001-Enable-parallel-SELECT-for-INSERT-INTO-.-SELECT.patch : + /* Assume original queries have hasModifyingCTE set correctly */ + if (parsetree->hasModifyingCTE) + hasModifyingCTE = true; Since hasModifyingCTE is false by the time the above is run, it can be simp

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

2021-02-11 Thread Zhihong Yu
of the if (!hasModifyingCTE) block. In your reply, did you mean that the if (!hasModifyingCTE) block is no longer needed ? (I guess not) Cheers On Thu, Feb 11, 2021 at 8:14 PM Greg Nancarrow wrote: > On Fri, Feb 12, 2021 at 2:33 PM Zhihong Yu wrote: > > > > For v17-0001-Enable-pa

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

2021-02-12 Thread Zhihong Yu
Greg: Thanks for more debugging. Cheers On Thu, Feb 11, 2021 at 9:43 PM Greg Nancarrow wrote: > On Fri, Feb 12, 2021 at 3:21 PM Zhihong Yu wrote: > > > > Greg: > > bq. we should just return parsetree->hasModifyingCTE at this point, > > > > Maybe you can

Re: Why do we have MakeSingleTupleTableSlot instead of not using MakeTupleTableSlot?

2021-02-12 Thread Zhihong Yu
Hi, MakeSingleTupleTableSlot can be defined as a macro, calling MakeTupleTableSlot(). Cheers On Fri, Feb 12, 2021 at 5:44 AM Bharath Rupireddy < bharath.rupireddyforpostg...@gmail.com> wrote: > Hi, > > I wonder, is there a specific reason that MakeTupleTableSlot is > wrapped up in MakeSingleTupl

Re: Possible dereference null return (src/backend/replication/logical/reorderbuffer.c)

2021-02-12 Thread Zhihong Yu
Hi, How about the following patch ? ReorderBufferSetBaseSnapshot() can return a bool to indicate whether the base snapshot is set up. For the call by SnapBuildCommitTxn(), it seems xid is top transaction. So the return value doesn't need to be checked. Cheers On Fri, Feb 12, 2021 at 6:40 PM Mic

Re: Possible dereference null return (src/backend/replication/logical/reorderbuffer.c)

2021-02-13 Thread Zhihong Yu
On Sat, Feb 13, 2021 at 12:34 PM Ranier Vilela wrote: > > Em sáb., 13 de fev. de 2021 às 01:07, Zhihong Yu > escreveu: > >> Hi, >> How about the following patch ? >> >> ReorderBufferSetBaseSnapshot() can return a bool to indicate whether the >> base sna

Re: Possible dereference null return (src/backend/replication/logical/reorderbuffer.c)

2021-02-13 Thread Zhihong Yu
Hi, Patch v4 corrects a small typo: + (errmsg("BaseSnapshot cant't be setup at point %X/%X", Cheers On Sat, Feb 13, 2021 at 12:58 PM Ranier Vilela wrote: > Em sáb., 13 de fev. de 2021 às 17:48, Zhihong Yu > escreveu: > >> Hi, >> +

Re: CREATE INDEX CONCURRENTLY on partitioned index

2021-02-15 Thread Zhihong Yu
Hi, For v13-0006-More-refactoring.patch : + /* It's not a shared catalog, so refuse to move it to shared tablespace */ + if (params->tablespaceOid == GLOBALTABLESPACE_OID && false) + ereport(ERROR, Do you intend to remove the ineffective check ? + else + heapRelation =

Re: PATCH: Batch/pipelining support for libpq

2021-02-16 Thread Zhihong Yu
Hi, + if (querymode == QUERY_SIMPLE) + { + commandFailed(st, "startpipeline", "cannot use pipeline mode with the simple query protocol"); + st->state = CSTATE_ABORTED; + return CSTATE_ABORTED; I wonder why the st->state is only assigned for this if block.

Re: PoC Refactor AM analyse API

2021-02-18 Thread Zhihong Yu
Hi, + *totalrows = floor((liverows / bs.m) * totalblocks + 0.5); Is the above equivalent to: + *totalrows = ceil((liverows / bs.m) * totalblocks); For compare_rows(), it seems the computation of oa and ob can be delayed to when ba == bb (after the first two if statements). Cheers

Re: PoC Refactor AM analyse API

2021-02-19 Thread Zhihong Yu
Denis: Thanks for considering my suggestion. For #1, I didn't take your example into account. Thanks for pointing that out. Cheers On Thu, Feb 18, 2021 at 11:59 PM Denis Smirnov wrote: > Hello, Zhihong. > > Thanks for your comments. > > 1. I am afraid that an equivalence of "floor(val + 0.5)"

Re: PATCH: Batch/pipelining support for libpq

2021-02-19 Thread Zhihong Yu
Hi, +static int pqBatchProcessQueue(PGconn *conn); I was suggesting changing: +int +PQexitBatchMode(PGconn *conn) to: +static int +PQexitBatchMode(PGconn *conn) Cheers On Fri, Feb 19, 2021 at 10:43 AM Alvaro Herrera wrote: > On 2021-Jan-21, Zhihong Yu wrote: > > > It seem

Re: PATCH: Batch/pipelining support for libpq

2021-02-19 Thread Zhihong Yu
Hi, Thanks for the response. On Fri, Feb 19, 2021 at 12:46 PM Alvaro Herrera wrote: > Hi, > > On 2021-Feb-19, Zhihong Yu wrote: > > > Hi, > > +static int pqBatchProcessQueue(PGconn *conn); > > > > I was suggesting changing: > > > > +i

Re: New Table Access Methods for Multi and Single Inserts

2021-02-20 Thread Zhihong Yu
Hi, bq. case 3 - 2 integer(of 4 bytes each) columns, tuple size 32 bytes Is there some other column(s) per row apart from the integer columns ? Since the 2 integer columns only occupy 8 bytes. I wonder where the other 32-8=24 bytes come from. Thanks On Fri, Feb 19, 2021 at 9:45 PM Bharath Rupire

Re: [PATCH] refactor ATExec{En,Dis}ableRowSecurity

2021-02-28 Thread Zhihong Yu
Hi, For 0002-Further-refactoring.patch, should there be assertion inside ATExecSetRowSecurity() on the values for rls and force_rls ? There could be 3 possible values: -1, 0 and 1. Cheers On Sun, Feb 28, 2021 at 1:19 PM Justin Pryzby wrote: > tablecmds.c is 17k lines long, this makes it ~30 lin

Re: Table AM modifications to accept column projection lists

2021-03-02 Thread Zhihong Yu
Hi, + /* Make sure the the new slot is not dependent on the original tuple */ There is duplicate 'the'. For neededColumnContextWalker(), + else if(var->varattno == 0) { I think the if following the else is not needed - I assume var->varattno wouldn't be negative. Similar comment for ex

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

2021-03-03 Thread Zhihong Yu
Hi, This feature enables bulk COPY into foreign table in the case of multi inserts is possible 'is possible' -> 'if possible' FDWAPI was extended by next routines: next routines -> the following routines For postgresExecForeignCopy(): + if ((!OK && PQresultStatus(res) != PGRES_FATAL_ERR

Re: [HACKERS] PATCH: Batch/pipelining support for libpq

2021-03-05 Thread Zhihong Yu
Hi, + \gset and \aset cannot be used + pipeline mode, since query results are not immediately 'used pipeline mode' -> 'used in pipeline mode' --- /dev/null +++ b/src/test/modules/libpq_pipeline/libpq_pipeline.c @@ -0,0 +1,1144 @@ +/* + * src/test/modules/libpq_pipeline/libpq_pipeline.c

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

2021-03-05 Thread Zhihong Yu
For v4-0002-some-fixups.patch : + if (client_connection_check_interval > 0) + enable_timeout_after(CLIENT_CONNECTION_CHECK_TIMEOUT, + /* Start timeout for checking if the client has gone away if necessary. */ + if (client_connection_check_interval) It would be better if the s

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

2021-03-06 Thread Zhihong Yu
Hi, Does CATALOG_VERSION_NO need to be bumped (introduction of partitionOids field) ? Cheers On Sat, Mar 6, 2021 at 2:19 AM Amit Kapila wrote: > On Fri, Mar 5, 2021 at 6:34 PM Greg Nancarrow wrote: > > > > For the time being at least, I am posting an updated set of patches, > > as I found that

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

2021-03-06 Thread Zhihong Yu
{' check, I was curious whether CATALOG_VERSION_NO should be bumped. Cheers On Sat, Mar 6, 2021 at 6:31 PM Amit Kapila wrote: > On Sat, Mar 6, 2021 at 9:13 PM Zhihong Yu wrote: > > > > Hi, > > Does CATALOG_VERSION_NO need to be bumped (introduction of partitionOids &g

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

2021-03-06 Thread Zhihong Yu
previous release. If the new releases did have a higher cat version, I guess there was no issue, by chance. Cheers On Sat, Mar 6, 2021 at 8:12 PM Amit Kapila wrote: > On Sun, Mar 7, 2021 at 8:24 AM Zhihong Yu wrote: > > > > I was looking at src/backend/nodes/readfuncs.c >

Re: EXPLAIN/EXPLAIN ANALYZE REFRESH MATERIALIZED VIEW

2021-03-07 Thread Zhihong Yu
Hi, +* EXPLAIN ANALYZE CREATE TABLE AS or REFRESH MATERIALIZED VIEW +* WITH NO DATA is weird. Maybe it is clearer to spell out WITH NO DATA for both statements, instead of sharing it. - if (!stmt->skipData) + if (!stmt->skipData && !explainInfo) ... + else if (explainInfo)

Re: "has_column_privilege()" issue with attnums and non-existent columns

2021-03-07 Thread Zhihong Yu
Joe: I don't seem to find attachment. Maybe attach again ? Thanks On Sun, Mar 7, 2021 at 11:12 AM Joe Conway wrote: > On 3/3/21 9:43 AM, Joe Conway wrote: > > On 3/3/21 8:50 AM, David Steele wrote: > >> On 1/29/21 4:56 AM, Joe Conway wrote: > >>> On 1/29/21 12:13 AM, Ian Lawrence Barwick wrote

Re: A qsort template

2021-03-13 Thread Zhihong Yu
Hi, For 0001-Add-bsearch-and-unique-templates-to-sort_template.h.patch : + * Remove duplicates from an array. Return the new size. + */ +ST_SCOPE size_t +ST_UNIQUE(ST_ELEMENT_TYPE *array, The array is supposed to be sorted, right ? The comment should mention this. Cheers On Sat, Mar 13, 2021

Re: make the stats collector shutdown without writing the statsfiles if the immediate shutdown is requested.

2021-03-16 Thread Zhihong Yu
Hi, + * Simple signal handler for processes HAVE NOT yet touched or DO NOT I think there should be a 'which' between processes and HAVE. It seems the words in Capital letters should be in lower case. + * Simple signal handler for processes have touched shared memory to + * exit quickly. Add 'wh

Re: Transactions involving multiple postgres foreign servers, take 2

2021-01-14 Thread Zhihong Yu
capable of two-phase commit"))); The lines are really long. Please wrap into more lines. On Wed, Jan 13, 2021 at 9:50 PM Masahiko Sawada wrote: > On Thu, Jan 7, 2021 at 11:44 AM Zhihong Yu wrote: > > > > Hi, > > Thank you for reviewing the patch! > > >

Re: Transactions involving multiple postgres foreign servers, take 2

2021-01-14 Thread Zhihong Yu
Fdw and Xact are repeated twice each in the method name. Probably the method name can be made shorter. Cheers On Thu, Jan 14, 2021 at 11:04 AM Zhihong Yu wrote: > Hi, > For v32-0008-Prepare-foreign-transactions-at-commit-time.patch : > > + boolhave_notwophase = false; > &

Re: Transactions involving multiple postgres foreign servers, take 2

2021-01-15 Thread Zhihong Yu
break; Instead of breaking and returning, you can return within the loop directly. Cheers On Thu, Jan 14, 2021 at 9:17 PM Masahiko Sawada wrote: > On Fri, Jan 15, 2021 at 4:03 AM Zhihong Yu wrote: > > > > Hi, > > For v32-0008-Prepare-foreign-transactions-at-commit-

  1   2   3   4   5   6   >