[HACKERS] Two questions about Postgres parser - Mailing list pgsql-hackers

From Konstantin Knizhnik
Subject [HACKERS] Two questions about Postgres parser
Date
Msg-id f3c9d019-d12e-3f2b-1aea-73747e660513@postgrespro.ru
Whole thread Raw
Responses Re: [HACKERS] Two questions about Postgres parser
List pgsql-hackers
Hi hackers,

Working on vectorized extension for Postgres (VOPS) I faced with two 
things in Postgres compiler which break my expectations and force me to 
abandon my original implementation plan. I wonder if it is really 
principle and correct that:

1. Moving-aggregate implementation should return the same type as plain 
implementation. Yes, in most cases it is hard to find arguments why them 
should return different types. But it is not true for vectorized 
operations...

2. Implicit user defined type casts are not applied for COALESCE operator:
    create  type complex as (x float8, y float8);    create function float2complex(x float8) returns complex as $$ 
declare complex c; begin c.x := x; x.y = 0; return c; $$ language 
plpgsql strict immutable;    create cast (float8 as complex) with function float2complex(float8) 
as implicit;    create table foo(c complex);    select coalesce(c, 0.0) from foo;    ERROR:  COALESCE types complex and
numericcannot be matched    LINE 1: select coalesce(c, 0.0) from foo;
 
    select coalesce(c, 0.0::float8) from foo;    ERROR:  COALESCE types complex and double precision cannot be matched
 LINE 1: select coalesce(c, 0.0::float8) from foo;
 
    select coalesce(c, 0.0::float8::complex) from foo;     coalesce    ----------    (0 rows)

-- 
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company




pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [HACKERS] bytea_output output of base64
Next
From: David Steele
Date:
Subject: Re: [HACKERS] Creation of "Future" commit fest, named 2017-07