Re: function length(numeric) does not exist

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Ricardo Sardinha <ricardo(dot)sardinha(at)ti(dot)polynorte(dot)com(dot)br>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: function length(numeric) does not exist
Date: 2014-11-25 00:04:28
Message-ID: CAB7nPqRwWLQu=9ijB9S5KaggsL1Okd3bEAkxh74enmYr19S34w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sat, Nov 22, 2014 at 9:26 PM, Ricardo Sardinha <
ricardo(dot)sardinha(at)ti(dot)polynorte(dot)com(dot)br> wrote:

> "ERRO: 42883: função length(numeric) não existe" (*function
> length(numeric) **does not exist*).
>

length() is not able to accept numeric as input.
=# select length(123.45);
ERROR: 42883: function length(numeric) does not exist
LINE 1: select length(123.45);
You could cast it to text depending on what you want to do:
=# select length(123.45::text);
length
--------
6
(1 row)

Then I try to create *length* function:
>
>
>
> CREATE OR REPLACE FUNCTION length(tsvector)
>
> RETURNS int4 AS
>
> '$libdir/tsearch2', 'tsvector_length'
>
> LANGUAGE 'c' IMMUTABLE STRICT;
>
> ALTER FUNCTION length(tsvector) OWNER TO postgres;
>
That's because this function is not defined in the extension tsearch2, but
is part of core, so you actually do not need to redefine it:
=# \dfS length
List of functions
Schema | Name | Result data type | Argument data types | Type
------------+--------+------------------+---------------------+--------
pg_catalog | length | integer | bit | normal
pg_catalog | length | integer | bytea | normal
pg_catalog | length | integer | bytea, name | normal
pg_catalog | length | integer | character | normal
pg_catalog | length | double precision | lseg | normal
pg_catalog | length | double precision | path | normal
pg_catalog | length | integer | text | normal
pg_catalog | length | integer | tsvector | normal
(8 rows)

Regards,
--
Michael

Browse pgsql-bugs by date

  From Date Subject
Next Message David G Johnston 2014-11-25 00:17:07 Re: function length(numeric) does not exist
Previous Message jkoceniak 2014-11-24 20:18:15 BUG #12050: Orphaned base files