Re: BUG #13652: Function names as a table prefiex by underscore, confused with array - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #13652: Function names as a table prefiex by underscore, confused with array
Date
Msg-id 15232.1443540944@sss.pgh.pa.us
Whole thread Raw
In response to BUG #13652: Function names as a table prefiex by underscore, confused with array  (marisradu@gmail.com)
List pgsql-bugs
marisradu@gmail.com writes:
> Creating a method "_c()" as:
> create or replace function _c(text) returns text as $$
>     select $1;
> $$ language sql immutable;

> and a table "c" as:
> create table c (id int);

> Select by _c(text) returns unexpected error:

> # select _c('text');
> ERROR:  malformed array literal: "text"
> LINE 1: select _c('text');
>                   ^
> DETAIL:  Array value must start with "{" or dimension information.

The reason that happens is that the internal name of the array type c[]
is "_c", and the order of search for ambiguous function names is such
that a function-style cast interpretation will be selected over an
actual function; see
http://www.postgresql.org/docs/9.4/static/typeconv-func.html
particularly step 3.

I'm afraid that there's not much we can do about this without breaking
cases that people are accustomed to have working.

            regards, tom lane

pgsql-bugs by date:

Previous
From: marisradu@gmail.com
Date:
Subject: BUG #13652: Function names as a table prefiex by underscore, confused with array
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #13651: trigger security invoker attack