proposal - plpgsql - all plpgsql auto variables should be constant

2020-04-23 Thread Pavel Stehule
Hi plpgsql generate lot of auto variables - FOUND, SQLERRM, cycle's control variable, TG_WHEN, TG_OP, .. Currently these variables are not protected, what can be source of problems, mainly for not experienced users. I propose mark these variables as constant. -- today postgres=# do $$ begin for

Re: 2pc leaks fds

2020-04-23 Thread Kyotaro Horiguchi
At Thu, 23 Apr 2020 19:16:03 -0400, Alvaro Herrera wrote in > On 2020-Apr-22, Andres Freund wrote: > > > I'm in favor of doing so. Not necessarily primarily to avoid repeated > > API changes, but because I don't think the v13 changes went in the quite > > right direction. > > > > ISTM that we

Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions

2020-04-23 Thread Dilip Kumar
On Thu, Apr 23, 2020 at 2:28 PM Erik Rijkers wrote: > > On 2020-04-23 05:24, Dilip Kumar wrote: > > On Wed, Apr 22, 2020 at 9:31 PM Erik Rijkers wrote: > >> > >> The 'ddl' one is apparently not quite fixed - I get this in (cd > >> contrib; make check)' (in both assert-enabled and non-assert-enab

Re: PG compilation error with Visual Studio 2015/2017/2019

2020-04-23 Thread davinder singh
On Thu, Apr 23, 2020 at 6:49 PM Juan José Santamaría Flecha < juanjo.santama...@gmail.com> wrote: > > On Thu, Apr 23, 2020 at 3:00 PM Amit Kapila > wrote: > >> >> Thanks, I will verify these. BTW, have you done something special to >> get the error messages which are not in English because on my

Re: [Proposal] Global temporary tables

2020-04-23 Thread Prabhat Sahu
Hi Wenjing, Please check, the server getting crash with the below scenario(CLUSTER gtt using INDEX). *-- Session1:* postgres=# create global temporary table gtt (c1 integer) on commit preserve rows; CREATE TABLE postgres=# create index idx1 on gtt (c1); CREATE INDEX *-- Session2:* postgres=# cre

Re: Trying to pull up EXPR SubLinks

2020-04-23 Thread Andy Fan
Actually I have a different opinion to handle this issue, to execute the a > (select avg(a) from tinner where x = touer.x); The drawback of current path is because it may calculates the same touer.x value multi-times. So if we cache the values we have calculated before, we can avoid the cost. Mat

Re: [Proposal] Add accumulated statistics for wait event

2020-04-23 Thread Atsushi Torikoshi
Hi Imai-san, I feel your 'pg_stat_waitaccum' will help us investigate the bottleneck. So I'd like to do some benchmarks but unfortunately, the latest v6 patch couldn't be applied to HEAD anymore. Is it possible to share the latest patches? If not, I'll make v6 applicable to the HEAD. Regards, -

Why are wait events not reported even though it reads/writes a timeline history file?

2020-04-23 Thread Masahiro Ikeda
Hi,  There are two unexpected codes for me about wait events for timeline history file. Please let me know your thoughts whether if we need to change. 1. readTimeLineHistory() function in timeline.c The readTimeLineHistory() reads a timeline history file,  but it doesn't report “WAIT_EVENT_T

Re: xid wraparound danger due to INDEX_CLEANUP false

2020-04-23 Thread Peter Geoghegan
On Wed, Apr 22, 2020 at 9:05 PM Peter Geoghegan wrote: > > Given hint bits it seems fairly hard to make that a reliable check. > > I don't follow. It doesn't have to be a perfect check. Detecting if > there is *any* buffer lock held at all would be a big improvement. It is true that the assumptio

Re: [PATCH] Implement INSERT SET syntax

2020-04-23 Thread Gareth Palmer
Hi Movead, > On 22/04/2020, at 2:40 PM, movead li wrote: > > The following review has been posted through the commitfest application: > make installcheck-world: tested, passed > Implements feature: tested, passed > Spec compliant: tested, passed > Documentation:teste

Re: 2pc leaks fds

2020-04-23 Thread Alvaro Herrera
On 2020-Apr-22, Andres Freund wrote: > I'm in favor of doing so. Not necessarily primarily to avoid repeated > API changes, but because I don't think the v13 changes went in the quite > right direction. > > ISTM that we should: > - have the three callbacks you mention above > - change WALSegmentO

Re: Binary search in ScalarArrayOpExpr for OR'd constant arrays

2020-04-23 Thread Andres Freund
Hi, On 2020-04-24 10:09:36 +1200, David Rowley wrote: > If single comparison for a binary search costs about the same as an > equality check, then wouldn't the crossover point be much lower than > 64? The costs aren't quite as simple as that though. Binary search usually has issues with cache mis

Re: Binary search in ScalarArrayOpExpr for OR'd constant arrays

2020-04-23 Thread David Rowley
On Fri, 24 Apr 2020 at 02:56, Tomas Vondra wrote: > > On Thu, Apr 23, 2020 at 09:02:26AM -0400, James Coleman wrote: > >On Thu, Apr 23, 2020 at 8:47 AM Tomas Vondra > > wrote: > >As to the choice of 9 elements: I just picked that as a starting > >point; Andres had previously commented off hand tha

Re: backup manifests

2020-04-23 Thread Andres Freund
Hi, On 2020-04-23 08:57:39 -0400, Robert Haas wrote: > On Sun, Apr 5, 2020 at 3:31 PM Andres Freund wrote: > > The warnings don't seem too unreasonable. The compiler can't see that > > the error_cb inside json_manifest_parse_failure() is not expected to > > return. Probably worth adding a wrapper

Re: [PATCH] Fix division by zero (explain.c)

2020-04-23 Thread James Coleman
On Thu, Apr 23, 2020 at 8:38 AM Ranier Vilela wrote: > > Hi, > > Per Coverity. > > If has 0 full groups, "we don't need to do anything" and need goes to next. > Otherwise a integer division by zero, can raise. > > comments extracted trom explain.c: > /* > * Since we never have any prefix groups u

Re: [PATCH] Fix possible overflow on tuplesort.c

2020-04-23 Thread Ranier Vilela
Em qui., 23 de abr. de 2020 às 16:43, Alvaro Herrera < alvhe...@2ndquadrant.com> escreveu: > On 2020-Apr-16, Ranier Vilela wrote: > > > When multiplying variables, the overflow will take place anyway, and only > > then will the meaningless product be explicitly promoted to type int64. > > It is on

Re: [PATCH] FIx resource leaks (pg_resetwal.c)

2020-04-23 Thread Ranier Vilela
Em qui., 23 de abr. de 2020 às 16:43, Robert Haas escreveu: > On Thu, Apr 23, 2020 at 2:41 PM Ranier Vilela wrote: > > I do not agree in any way. At the very least what I am reporting is > suspect. And if I already propose a solution even if it is not the best, it > is much better than being sil

Re: [PATCH] Fix possible overflow on tuplesort.c

2020-04-23 Thread Tom Lane
Alvaro Herrera writes: >> When multiplying variables, the overflow will take place anyway, and only >> then will the meaningless product be explicitly promoted to type int64. >> It is one of the operands that should have been cast instead to avoid the >> overflow. >> >> - if (state->availMem <

Re: [PATCH] FIx resource leaks (pg_resetwal.c)

2020-04-23 Thread Ranier Vilela
Em qui., 23 de abr. de 2020 às 16:27, Peter Geoghegan escreveu: > On Thu, Apr 23, 2020 at 11:41 AM Ranier Vilela > wrote: > > And if I already propose a solution even if it is not the best, it is > much better than being silent and missing the opportunity to fix a bug. > > The problem with that

Re: [PATCH] FIx resource leaks (pg_resetwal.c)

2020-04-23 Thread Robert Haas
On Thu, Apr 23, 2020 at 2:41 PM Ranier Vilela wrote: > I do not agree in any way. At the very least what I am reporting is suspect. > And if I already propose a solution even if it is not the best, it is much > better than being silent and missing the opportunity to fix a bug. > Ridiculous is yo

Re: [PATCH] Fix possible overflow on tuplesort.c

2020-04-23 Thread Alvaro Herrera
On 2020-Apr-16, Ranier Vilela wrote: > When multiplying variables, the overflow will take place anyway, and only > then will the meaningless product be explicitly promoted to type int64. > It is one of the operands that should have been cast instead to avoid the > overflow. > > - if (state->avai

Re: HEAPDEBUGALL is broken

2020-04-23 Thread Tom Lane
I wrote: > Looking at this, I'm tempted to nuke ACLDEBUG as well, which > is the only remaining undocumented symbol in pg_config_manual.h. > The code it controls looks equally forlorn and not-useful-as-is. Did that, too. regards, tom lane

[PATCH] Fix possible Uninitialized variables (parse_manifest.c)

2020-04-23 Thread Ranier Vilela
Hi, Per Coverity. verify_manifest_checksum, declare and can utilize array of uint8, without initializing it. While here, I applied the quick exit technique, to avoid unnecessary computations, if it is possible to avoid them. regards, Ranier Vilela fix_uninitialized_array_parse_manifest.patch De

Re: HEAPDEBUGALL is broken

2020-04-23 Thread Tom Lane
I wrote: > Alexander Lakhin writes: >> So I would just remove this debug macro. The proposed patch is attached. > I didn't review this in close detail, but I think it's a good idea. I checked this more closely and pushed it. regards, tom lane

Re: [PATCH] FIx resource leaks (pg_resetwal.c)

2020-04-23 Thread Peter Geoghegan
On Thu, Apr 23, 2020 at 11:41 AM Ranier Vilela wrote: > And if I already propose a solution even if it is not the best, it is much > better than being silent and missing the opportunity to fix a bug. The problem with that theory is that you're not creating any value over simply running Coverity

Re: +(pg_lsn, int8) and -(pg_lsn, int8) operators

2020-04-23 Thread Robert Haas
On Thu, Apr 23, 2020 at 12:28 PM Ashutosh Bapat wrote: > As it's presented in the patch I don't see much value in calling it as > LSN arithmetic. If we could do something like LSN of Nth WAL record > +/- = LSN of N+/- n th log record that > would be interesting. :) Well, that would mean that the

Re: [PATCH] FIx resource leaks (pg_resetwal.c)

2020-04-23 Thread Ranier Vilela
Em qui., 23 de abr. de 2020 às 15:27, Andres Freund escreveu: > Hi, > > On 2020-04-23 15:20:59 -0300, Ranier Vilela wrote: > > Per Coverity. > > > > read_controlfile alloc memory with pg_malloc and fail in releasing the > > memory. > > Seriously, this is getting really ridiculous. You're posting

Re: [PATCH] FIx resource leaks (pg_resetwal.c)

2020-04-23 Thread Andres Freund
Hi, On 2020-04-23 15:20:59 -0300, Ranier Vilela wrote: > Per Coverity. > > read_controlfile alloc memory with pg_malloc and fail in releasing the > memory. Seriously, this is getting really ridiculous. You're posting badly vetted, often nearly verbatim, coverity reports. Many of them are obvious

[PATCH] FIx resource leaks (pg_resetwal.c)

2020-04-23 Thread Ranier Vilela
Hi, Per Coverity. read_controlfile alloc memory with pg_malloc and fail in releasing the memory. regards, Ranier Vilela fix_resource_leaks_pg_resetwal.patch Description: Binary data

Re: Poll: are people okay with function/operator table redesign?

2020-04-23 Thread Tom Lane
Alvaro Herrera writes: > If we're doing nicer markup+CSS for this, then it might make sense to > find a better solution for this kind of entry with multiple signatures > (which was already an issue in the previous version): Yeah, agreed. I would like to be able to have multiple signature blocks

Re: Poll: are people okay with function/operator table redesign?

2020-04-23 Thread Alvaro Herrera
If we're doing nicer markup+CSS for this, then it might make sense to find a better solution for this kind of entry with multiple signatures (which was already an issue in the previous version): text || anynonarray or anynonarray || text → text Converts the non-string input to text, then c

Re: Poll: are people okay with function/operator table redesign?

2020-04-23 Thread Tom Lane
Bruce Momjian writes: > On Thu, Apr 23, 2020 at 12:04:01PM -0400, Tom Lane wrote: >> As I said, I'm happy to do the legwork of improving the markup if someone >> will point me in the right direction. But I know next to zip about CSS, >> so it would not be productive for me to do the basic design

Re: +(pg_lsn, int8) and -(pg_lsn, int8) operators

2020-04-23 Thread Ashutosh Bapat
On Thu, Apr 23, 2020 at 2:51 PM Fujii Masao wrote: > > Hi, > > I'd like to propose to introduce the +(pg_lsn, int8) and -(pg_lsn, int8) > operators. The + operator allows us to add the number of bytes into pg_lsn, > resulting new pg_lsn. The - operator allows us to substract the number > of bytes

Re: Poll: are people okay with function/operator table redesign?

2020-04-23 Thread Bruce Momjian
On Thu, Apr 23, 2020 at 12:04:01PM -0400, Tom Lane wrote: > Peter Eisentraut writes: > > I've played with this a bit, and there are certainly a lot of > > interesting things that you can do with CSS nowadays that would preserve > > some semblance of semantic markup on both the DocBook side and t

Re: Poll: are people okay with function/operator table redesign?

2020-04-23 Thread Tom Lane
Peter Eisentraut writes: > I've played with this a bit, and there are certainly a lot of > interesting things that you can do with CSS nowadays that would preserve > some semblance of semantic markup on both the DocBook side and the HTML > side. As I said, I'm happy to do the legwork of improv

Re: [PATCH] Fix Null pointer dereferences (pgoutput.c)

2020-04-23 Thread Amit Langote
On Thu, Apr 23, 2020 at 10:48 PM Ranier Vilela wrote: > > Hi, > > Per Coverity. > > If test oldtuple can be NULL, I mean it can really be NULL. > On DELETE process, if oldtuple is NULL, log error and continue. > So UPDATE must have the same treatment. I think I too had noticed this when working o

Re: More efficient RI checks - take 2

2020-04-23 Thread Amit Langote
On Thu, Apr 23, 2020 at 2:18 AM Alvaro Herrera wrote: > On 2020-Apr-22, Andres Freund wrote: > > I assume that with constructing plans "manually" you don't mean to > > create a plan tree, but to invoke parser/planner directly? I think > > that'd likely be better than going through SPI, and there's

Re: sqlsmith crash incremental sort

2020-04-23 Thread Tom Lane
Tomas Vondra writes: > On Thu, Apr 23, 2020 at 03:28:21PM +0800, Richard Guo wrote: >> A minor comment is that I don't think we need to strip relabel >> explicitly before calling pull_varnos(), because this function would >> recurse into T_RelabelType nodes. > Hmmm, yeah. I think you're right tha

Re: Binary search in ScalarArrayOpExpr for OR'd constant arrays

2020-04-23 Thread Tomas Vondra
On Thu, Apr 23, 2020 at 09:02:26AM -0400, James Coleman wrote: On Thu, Apr 23, 2020 at 8:47 AM Tomas Vondra wrote: On Mon, Apr 20, 2020 at 09:27:34PM -0400, James Coleman wrote: >Over in "execExprInterp() questions / How to improve scalar array op >expr eval?" [1] I'd mused about how we might

Re: More efficient RI checks - take 2

2020-04-23 Thread Tom Lane
Robert Haas writes: > On Wed, Apr 22, 2020 at 6:40 PM Tom Lane wrote: >> But it's not entirely clear to me that we know the best plan for a >> statement-level RI action with sufficient certainty to go that way. > Well, I guess I'd naively think we want an index scan on a plain > table. It is bar

[PATCH] Fix Null pointer dereferences (pgoutput.c)

2020-04-23 Thread Ranier Vilela
Hi, Per Coverity. If test oldtuple can be NULL, I mean it can really be NULL. On DELETE process, if oldtuple is NULL, log error and continue. So UPDATE must have the same treatment. regards, Ranier Vilela fix_null_pointer_dereference_pgoutput.patch Description: Binary data

Re: PG compilation error with Visual Studio 2015/2017/2019

2020-04-23 Thread Juan José Santamaría Flecha
On Thu, Apr 23, 2020 at 3:00 PM Amit Kapila wrote: > > Thanks, I will verify these. BTW, have you done something special to > get the error messages which are not in English because on my Windows > box I am not getting that in spite of setting it to the appropriate > locale. Did you use ICU or

Re: Binary search in ScalarArrayOpExpr for OR'd constant arrays

2020-04-23 Thread James Coleman
On Thu, Apr 23, 2020 at 8:47 AM Tomas Vondra wrote: > > On Mon, Apr 20, 2020 at 09:27:34PM -0400, James Coleman wrote: > >Over in "execExprInterp() questions / How to improve scalar array op > >expr eval?" [1] I'd mused about how we might be able to optimized > >scalar array ops with OR'd semantic

Re: PG compilation error with Visual Studio 2015/2017/2019

2020-04-23 Thread Amit Kapila
On Thu, Apr 23, 2020 at 5:37 PM Juan José Santamaría Flecha wrote: > > > On Thu, Apr 23, 2020 at 5:30 AM Amit Kapila wrote: >> >> >> I think we can check with simple error messages. So, basically after >> setting a particular value of LC_MESSAGES, execute a query which >> returns syntax or any o

Re: backup manifests

2020-04-23 Thread Robert Haas
On Sun, Apr 5, 2020 at 3:31 PM Andres Freund wrote: > The warnings don't seem too unreasonable. The compiler can't see that > the error_cb inside json_manifest_parse_failure() is not expected to > return. Probably worth adding a wrapper around the calls to > context->error_cb and mark that as nore

Re: Binary search in ScalarArrayOpExpr for OR'd constant arrays

2020-04-23 Thread Tomas Vondra
On Mon, Apr 20, 2020 at 09:27:34PM -0400, James Coleman wrote: Over in "execExprInterp() questions / How to improve scalar array op expr eval?" [1] I'd mused about how we might be able to optimized scalar array ops with OR'd semantics. This patch implements a binary search for such expressions w

Re: More efficient RI checks - take 2

2020-04-23 Thread Stephen Frost
Greetings, * Robert Haas (robertmh...@gmail.com) wrote: > On Wed, Apr 22, 2020 at 6:40 PM Tom Lane wrote: > > But it's not entirely clear to me that we know the best plan for a > > statement-level RI action with sufficient certainty to go that way. > > Is it really the case that the plan would no

[PATCH] Fix division by zero (explain.c)

2020-04-23 Thread Ranier Vilela
Hi, Per Coverity. If has 0 full groups, "we don't need to do anything" and need goes to next. Otherwise a integer division by zero, can raise. comments extracted trom explain.c: /* * Since we never have any prefix groups unless we've first sorted * a full groups and transitioned modes (copying

Re: +(pg_lsn, int8) and -(pg_lsn, int8) operators

2020-04-23 Thread Robert Haas
On Thu, Apr 23, 2020 at 5:21 AM Fujii Masao wrote: > I'd like to propose to introduce the +(pg_lsn, int8) and -(pg_lsn, int8) > operators. The + operator allows us to add the number of bytes into pg_lsn, > resulting new pg_lsn. The - operator allows us to substract the number > of bytes from pg_ls

Re: PG compilation error with Visual Studio 2015/2017/2019

2020-04-23 Thread Juan José Santamaría Flecha
On Thu, Apr 23, 2020 at 5:30 AM Amit Kapila wrote: > > Okay, I hope we will see better comments in the next version. > I have focused on improving comments in this version. > Hmm, if you really want to log the value then do it in the caller. I > don't think making special arrangements just fo

Re: Parallel Append can break run-time partition pruning

2020-04-23 Thread David Rowley
On Thu, 23 Apr 2020 at 02:37, Amit Langote wrote: > Regarding the patch, I had been assuming that the "pa" in > pa_subpaths_valid stands for "parallel append", so it using the > variable as is in the new code structure would be misleading. Maybe, > parallel_subpaths_valid? I started making anoth

Re: Poll: are people okay with function/operator table redesign?

2020-04-23 Thread Peter Eisentraut
On 2020-04-19 15:23, Tom Lane wrote: If somebody's got an idea how to obtain this painfully-agreed-to visual appearance from more robust markup, I'm all ears. This stuff is a bit outside my skill set, so I don't claim to have found the best possible implementation. I've played with this a bit,

Re: sqlsmith crash incremental sort

2020-04-23 Thread Tomas Vondra
On Thu, Apr 23, 2020 at 03:28:21PM +0800, Richard Guo wrote: On Thu, Apr 23, 2020 at 6:59 AM Tomas Vondra wrote: I've pushed fix with the DEFAULT_NUM_DISTINCT. The input comes from a set operation (which is where we call generate_append_tlist), so it's probably fairly unique, so maybe we shoul

Re: WIP/PoC for parallel backup

2020-04-23 Thread Rajkumar Raghuwanshi
On Thu, Apr 23, 2020 at 1:47 PM Asif Rehman wrote: > > > On Thu, Apr 23, 2020 at 11:43 AM Rajkumar Raghuwanshi < > rajkumar.raghuwan...@enterprisedb.com> wrote: > >> >> >> On Wed, Apr 22, 2020 at 7:48 PM Asif Rehman >> wrote: >> >>> >>> Hi Dipesh, >>> >>> The rebased and updated patch is attache

+(pg_lsn, int8) and -(pg_lsn, int8) operators

2020-04-23 Thread Fujii Masao
Hi, I'd like to propose to introduce the +(pg_lsn, int8) and -(pg_lsn, int8) operators. The + operator allows us to add the number of bytes into pg_lsn, resulting new pg_lsn. The - operator allows us to substract the number of bytes from pg_lsn, resulting new pg_lsn. Thought? I sometimes need the

Re: WAL usage calculation patch

2020-04-23 Thread Amit Kapila
On Thu, Apr 23, 2020 at 12:16 PM Peter Eisentraut wrote: > > On 2020-04-23 07:31, Julien Rouhaud wrote: > > I agree that full page writes can be used in this case, but I'm > > wondering if that can be misleading for some reader which might e.g. > > confuse with the full_page_writes GUC. And as Ju

Re: WIP/PoC for parallel backup

2020-04-23 Thread Asif Rehman
On Thu, Apr 23, 2020 at 11:43 AM Rajkumar Raghuwanshi < rajkumar.raghuwan...@enterprisedb.com> wrote: > > > On Wed, Apr 22, 2020 at 7:48 PM Asif Rehman > wrote: > >> >> Hi Dipesh, >> >> The rebased and updated patch is attached. Its rebased to (9f2c4ede). >> > > Make is failing for v15 patch. > >

Re: [Proposal] Global temporary tables

2020-04-23 Thread Pavel Stehule
čt 23. 4. 2020 v 9:10 odesílatel 曾文旌 napsal: > > > 2020年4月22日 下午10:50,Pavel Stehule 写道: > > > > st 22. 4. 2020 v 16:38 odesílatel Prabhat Sahu < > prabhat.s...@enterprisedb.com> napsal: > >> >> >> On Wed, Apr 22, 2020 at 2:49 PM 曾文旌 wrote: >> >>> >>> Although the implementation of GTT is differ

Re: sqlsmith crash incremental sort

2020-04-23 Thread Richard Guo
On Thu, Apr 23, 2020 at 6:59 AM Tomas Vondra wrote: > I've pushed fix with the DEFAULT_NUM_DISTINCT. The input comes from a > set operation (which is where we call generate_append_tlist), so it's > probably fairly unique, so maybe we should use input_tuples. But it's > not guaranteed, so DEFAULT_

Re: [Proposal] Global temporary tables

2020-04-23 Thread 曾文旌
> 2020年4月22日 下午10:50,Pavel Stehule 写道: > > > > st 22. 4. 2020 v 16:38 odesílatel Prabhat Sahu > napsal: > > > On Wed, Apr 22, 2020 at 2:49 PM 曾文旌 > wrote: >> >> Although the implementation of GTT is different, I th