Re: BUG #13652: Function names as a table prefiex by underscore, confused with array

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: marisradu(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13652: Function names as a table prefiex by underscore, confused with array
Date: 2015-09-29 15:35:44
Message-ID: 15232.1443540944@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

marisradu(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2015-09-29 15:48:12 Re: BUG #13651: trigger security invoker attack
Previous Message Tom Lane 2015-09-29 14:55:20 Re: BUG #13638: Exception texts from plperl has bad encoding