Re: JSON constructors and window functions

2022-05-10 Thread Jonathan S. Katz
On 5/10/22 10:25 AM, Andrew Dunstan wrote: I believe all the issues here have been fixed. See commit 112fdb3528 Thanks! I have updated Open Items. Jonathan OpenPGP_signature Description: OpenPGP digital signature

Re: JSON constructors and window functions

2022-05-10 Thread Andrew Dunstan
On 2022-05-10 Tu 09:51, Jonathan S. Katz wrote: > Hi, > > On 4/4/22 2:19 PM, Andrew Dunstan wrote: >> >> On 4/4/22 12:33, Andres Freund wrote: > >> It can, as Jaime's original post showed. >> >> But on further consideration I'm thinking this area needs some rework. >> ISTM that it might be a

Re: JSON constructors and window functions

2022-05-10 Thread Jonathan S. Katz
Hi, On 4/4/22 2:19 PM, Andrew Dunstan wrote: On 4/4/22 12:33, Andres Freund wrote: It can, as Jaime's original post showed. But on further consideration I'm thinking this area needs some rework. ISTM that it might be a whole lot simpler and comprehensible to generate the json first without

Re: JSON constructors and window functions

2022-04-04 Thread Andrew Dunstan
On 4/4/22 11:43, Tom Lane wrote: > Andrew Dunstan writes: >> On 4/3/22 22:46, Andrew Dunstan wrote: >>> On 4/3/22 20:11, Andres Freund wrote: I don't think you're allowed to free stuff in a finalfunc - we might reuse the transition state for further calls to the aggregate. >>>

Re: JSON constructors and window functions

2022-04-04 Thread Andrew Dunstan
On 4/4/22 12:33, Andres Freund wrote: > Hi, > > On 2022-04-04 11:54:23 -0400, Greg Stark wrote: >> Are we missing regression tests using these functions as window functions? > So far, yes. > > ISTM that 4eb97988796 should have at least included the crashing statement as > a test... The statement

Re: JSON constructors and window functions

2022-04-04 Thread Andres Freund
Hi, On 2022-04-04 11:54:23 -0400, Greg Stark wrote: > Are we missing regression tests using these functions as window functions? So far, yes. ISTM that 4eb97988796 should have at least included the crashing statement as a test... The statement can be simpler too: SELECT json_objectagg(k : v

Re: JSON constructors and window functions

2022-04-04 Thread Andres Freund
Hi, On 2022-04-04 11:43:31 -0400, Tom Lane wrote: > Andrew Dunstan writes: > > On 4/3/22 22:46, Andrew Dunstan wrote: > >> On 4/3/22 20:11, Andres Freund wrote: > >>> I don't think you're allowed to free stuff in a finalfunc - we might > >>> reuse the > >>> transition state for further calls to

Re: JSON constructors and window functions

2022-04-04 Thread Greg Stark
Are we missing regression tests using these functions as window functions? Hm. I suppose it's possible to write a general purpose regression test that loops over all aggregate functions and runs them as window functions and aggregates over the same data sets and compares results. At least for the

Re: JSON constructors and window functions

2022-04-04 Thread Tom Lane
Andrew Dunstan writes: > On 4/3/22 22:46, Andrew Dunstan wrote: >> On 4/3/22 20:11, Andres Freund wrote: >>> I don't think you're allowed to free stuff in a finalfunc - we might reuse >>> the >>> transition state for further calls to the aggregate. >> Doh! Of course! I'll fix it in the morning.

Re: JSON constructors and window functions

2022-04-04 Thread Andrew Dunstan
On 4/3/22 22:46, Andrew Dunstan wrote: > On 4/3/22 20:11, Andres Freund wrote: >> Hi, >> >> On 2022-04-03 18:56:39 -0400, Andrew Dunstan wrote: >>> Haven't found the issue yet :-( It happens on the second call for the >>> partition to  json_check_unique_key(). >>> >>> Here's a more idiomatic and

Re: JSON constructors and window functions

2022-04-03 Thread Andrew Dunstan
On 4/3/22 20:11, Andres Freund wrote: > Hi, > > On 2022-04-03 18:56:39 -0400, Andrew Dunstan wrote: >> Haven't found the issue yet :-( It happens on the second call for the >> partition to  json_check_unique_key(). >> >> Here's a more idiomatic and self-contained query that triggers the problem.

Re: JSON constructors and window functions

2022-04-03 Thread Andres Freund
Hi, On 2022-04-03 18:56:39 -0400, Andrew Dunstan wrote: > Haven't found the issue yet :-( It happens on the second call for the > partition to  json_check_unique_key(). > > Here's a more idiomatic and self-contained query that triggers the problem. > > > select json_objectagg('10' : ref_0.level2

Re: JSON constructors and window functions

2022-04-03 Thread Andrew Dunstan
On 4/2/22 15:40, Andrew Dunstan wrote: > On 4/2/22 01:25, Jaime Casanova wrote: >> I got a crash running the below query on the regression database: >> >> """ >> select pg_catalog.json_object_agg_unique(10, >> cast(ref_0.level2_no as int4)) >> over (partition by

Re: JSON constructors and window functions

2022-04-02 Thread Andrew Dunstan
On 4/2/22 01:25, Jaime Casanova wrote: > I got a crash running the below query on the regression database: > > """ > select pg_catalog.json_object_agg_unique(10, > cast(ref_0.level2_no as int4)) > over (partition by ref_0.parent_no > order by

JSON constructors and window functions

2022-04-01 Thread Jaime Casanova
I got a crash running the below query on the regression database: """ select pg_catalog.json_object_agg_unique(10, cast(ref_0.level2_no as int4)) over (partition by ref_0.parent_no order by ref_0.level2_no) from public.transition_table_level2