mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +03:00
Provide more-specific error details/hints for function lookup failures.
Up to now we've contented ourselves with a one-size-fits-all error hint when we fail to find any match to a function or procedure call. That was mostly okay in the beginning, but it was never great, and since the introduction of named arguments it's really not adequate. We at least ought to distinguish "function name doesn't exist" from "function name exists, but not with those argument names". And the rules for named-argument matching are arcane enough that some more detail seems warranted if we match the argument names but the call still doesn't work. This patch creates a framework for dealing with these problems: FuncnameGetCandidates and related code will now pass back a bitmask of flags showing how far the match succeeded. This allows a considerable amount of granularity in the reports. The set-bits-in-a-bitmask approach means that when there are multiple candidate functions, the report will reflect the match(es) that got the furthest, which seems correct. Also, we can avoid mentioning "maybe add casts" unless failure to match argument types is actually the issue. Extend the same return-a-bitmask approach to OpernameGetCandidates. The issues around argument names don't apply to operator syntax, but it still seems worth distinguishing between "there is no operator of that name" and "we couldn't match the argument types". While at it, adjust these messages and related ones to more strictly separate "detail" from "hint", following our message style guidelines' distinction between those. Reported-by: Dominique Devienne <ddevienne@gmail.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Discussion: https://postgr.es/m/1756041.1754616558@sss.pgh.pa.us
This commit is contained in:
@@ -27,7 +27,7 @@ B 4 ParseComplete
|
||||
B 4 BindComplete
|
||||
B 4 NoData
|
||||
B 15 CommandComplete "INSERT 0 1"
|
||||
B NN ErrorResponse S "ERROR" V "ERROR" C "42883" M "function no_such_function(integer) does not exist" H "No function matches the given name and argument types. You might need to add explicit type casts." P "8" F "SSSS" L "SSSS" R "SSSS" \x00
|
||||
B NN ErrorResponse S "ERROR" V "ERROR" C "42883" M "function no_such_function(integer) does not exist" D "There is no function of that name." P "8" F "SSSS" L "SSSS" R "SSSS" \x00
|
||||
B 5 ReadyForQuery I
|
||||
B 4 ParseComplete
|
||||
B 4 BindComplete
|
||||
|
||||
@@ -333,7 +333,7 @@ SELECT ext_cor_func();
|
||||
ERROR: function ext_cor_func() does not exist
|
||||
LINE 1: SELECT ext_cor_func();
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: There is no function of that name.
|
||||
SELECT * FROM ext_cor_view;
|
||||
col
|
||||
------------------------
|
||||
@@ -649,7 +649,6 @@ SELECT dep_req3b(); -- fails
|
||||
ERROR: function public.dep_req2() does not exist
|
||||
LINE 1: SELECT public.dep_req2() || ' req3b'
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
QUERY: SELECT public.dep_req2() || ' req3b'
|
||||
CONTEXT: SQL function "dep_req3b" statement 1
|
||||
DROP EXTENSION test_ext_req_schema3;
|
||||
|
||||
@@ -2041,7 +2041,8 @@ alter table anothertab alter column atcol1 drop default;
|
||||
alter table anothertab alter column atcol1 type boolean
|
||||
using case when atcol1 % 2 = 0 then true else false end; -- fails
|
||||
ERROR: operator does not exist: boolean <= integer
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
alter table anothertab drop constraint anothertab_chk;
|
||||
alter table anothertab drop constraint anothertab_chk; -- fails
|
||||
ERROR: constraint "anothertab_chk" of relation "anothertab" does not exist
|
||||
|
||||
@@ -2747,7 +2747,8 @@ SELECT width_bucket('5'::text, ARRAY[3, 4]::integer[]);
|
||||
ERROR: function width_bucket(text, integer[]) does not exist
|
||||
LINE 1: SELECT width_bucket('5'::text, ARRAY[3, 4]::integer[]);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
SELECT width_bucket(5, ARRAY[3, 4, NULL]);
|
||||
ERROR: thresholds array must not contain NULLs
|
||||
SELECT width_bucket(5, ARRAY[ARRAY[1, 2], ARRAY[3, 4]]);
|
||||
|
||||
@@ -28,14 +28,16 @@ SELECT casttestfunc('foo'::text); -- fails, as there's no cast
|
||||
ERROR: function casttestfunc(text) does not exist
|
||||
LINE 1: SELECT casttestfunc('foo'::text);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
-- Try binary coercion cast
|
||||
CREATE CAST (text AS casttesttype) WITHOUT FUNCTION;
|
||||
SELECT casttestfunc('foo'::text); -- doesn't work, as the cast is explicit
|
||||
ERROR: function casttestfunc(text) does not exist
|
||||
LINE 1: SELECT casttestfunc('foo'::text);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
SELECT casttestfunc('foo'::text::casttesttype); -- should work
|
||||
casttestfunc
|
||||
--------------
|
||||
|
||||
@@ -304,7 +304,8 @@ CREATE FUNCTION functest_S_xx(x date) RETURNS boolean
|
||||
ERROR: operator does not exist: date > integer
|
||||
LINE 3: RETURN x > 1;
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
-- tricky parsing
|
||||
CREATE FUNCTION functest_S_15(x int) RETURNS boolean
|
||||
LANGUAGE SQL
|
||||
|
||||
@@ -24,6 +24,25 @@ SELECT @#@ 24;
|
||||
620448401733239439360000
|
||||
(1 row)
|
||||
|
||||
-- Test error cases
|
||||
select @@##@@ 24; -- no such operator
|
||||
ERROR: operator does not exist: @@##@@ integer
|
||||
LINE 1: select @@##@@ 24;
|
||||
^
|
||||
DETAIL: There is no operator of that name.
|
||||
set search_path = pg_catalog;
|
||||
select @#@ 24; -- wrong schema
|
||||
ERROR: operator does not exist: @#@ integer
|
||||
LINE 1: select @#@ 24;
|
||||
^
|
||||
DETAIL: An operator of that name exists, but it is not in the search_path.
|
||||
reset search_path;
|
||||
select @#@ 24.0; -- wrong data type
|
||||
ERROR: operator does not exist: @#@ numeric
|
||||
LINE 1: select @#@ 24.0;
|
||||
^
|
||||
DETAIL: No operator of that name accepts the given argument type.
|
||||
HINT: You might need to add an explicit type cast.
|
||||
-- Test comments
|
||||
COMMENT ON OPERATOR ###### (NONE, int4) IS 'bad prefix';
|
||||
ERROR: operator does not exist: ###### integer
|
||||
|
||||
@@ -2,7 +2,7 @@ CALL nonexistent(); -- error
|
||||
ERROR: procedure nonexistent() does not exist
|
||||
LINE 1: CALL nonexistent();
|
||||
^
|
||||
HINT: No procedure matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: There is no procedure of that name.
|
||||
CALL random(); -- error
|
||||
ERROR: random() is not a procedure
|
||||
LINE 1: CALL random();
|
||||
@@ -299,7 +299,8 @@ CALL ptest9(1./0.); -- error
|
||||
ERROR: procedure ptest9(numeric) does not exist
|
||||
LINE 1: CALL ptest9(1./0.);
|
||||
^
|
||||
HINT: No procedure matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No procedure of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
-- check named-parameter matching
|
||||
CREATE PROCEDURE ptest10(OUT a int, IN b int, IN c int)
|
||||
LANGUAGE SQL AS $$ SELECT b - c $$;
|
||||
|
||||
@@ -1924,7 +1924,8 @@ select 'foo'::text = any((select array['abc','def','foo']::text[])); -- fail
|
||||
ERROR: operator does not exist: text = text[]
|
||||
LINE 1: select 'foo'::text = any((select array['abc','def','foo']::t...
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select 'foo'::text = any((select array['abc','def','foo']::text[])::text[]);
|
||||
?column?
|
||||
----------
|
||||
|
||||
@@ -415,7 +415,8 @@ select row(0,1)::dcomptype; -- fail
|
||||
ERROR: value for domain dcomptype violates check constraint "c1"
|
||||
alter type comptype alter attribute r type varchar; -- fail
|
||||
ERROR: operator does not exist: character varying > double precision
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
alter type comptype alter attribute r type bigint;
|
||||
alter type comptype drop attribute r; -- fail
|
||||
ERROR: cannot drop column r of composite type comptype because other objects depend on it
|
||||
|
||||
@@ -218,7 +218,8 @@ select '(0,0)'::point in ('(0,0,0,0)'::box, point(0,0));
|
||||
ERROR: operator does not exist: point = box
|
||||
LINE 1: select '(0,0)'::point in ('(0,0,0,0)'::box, point(0,0));
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
--
|
||||
-- Tests for ScalarArrayOpExpr with a hashfn
|
||||
--
|
||||
|
||||
@@ -1777,7 +1777,8 @@ SELECT p.f1, l.s, l.s # p.f1 AS intersection
|
||||
ERROR: operator does not exist: lseg # point
|
||||
LINE 1: SELECT p.f1, l.s, l.s # p.f1 AS intersection
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
-- Length
|
||||
SELECT s, @-@ s FROM LSEG_TBL;
|
||||
s | ?column?
|
||||
|
||||
@@ -605,7 +605,8 @@ SELECT date '1991-02-03' - time with time zone '04:05:06 UTC' AS "Subtract Time
|
||||
ERROR: operator does not exist: date - time with time zone
|
||||
LINE 1: SELECT date '1991-02-03' - time with time zone '04:05:06 UTC...
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
--
|
||||
-- timestamp, interval arithmetic
|
||||
--
|
||||
|
||||
@@ -171,12 +171,12 @@ SELECT num_nonnulls();
|
||||
ERROR: function num_nonnulls() does not exist
|
||||
LINE 1: SELECT num_nonnulls();
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given number of arguments.
|
||||
SELECT num_nulls();
|
||||
ERROR: function num_nulls() does not exist
|
||||
LINE 1: SELECT num_nulls();
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given number of arguments.
|
||||
--
|
||||
-- canonicalize_path()
|
||||
--
|
||||
|
||||
@@ -3096,7 +3096,8 @@ select multirange_of_text(textrange2('a','Z')); -- should fail
|
||||
ERROR: function multirange_of_text(textrange2) does not exist
|
||||
LINE 1: select multirange_of_text(textrange2('a','Z'));
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select multirange_of_text(textrange1('a','Z')) @> 'b'::text;
|
||||
ERROR: range lower bound must be less than or equal to range upper bound
|
||||
select unnest(multirange_of_text(textrange1('a','b'), textrange1('d','e')));
|
||||
@@ -3160,7 +3161,8 @@ select anyarray_anymultirange_func(ARRAY[1,2], nummultirange(numrange(10,20)));
|
||||
ERROR: function anyarray_anymultirange_func(integer[], nummultirange) does not exist
|
||||
LINE 1: select anyarray_anymultirange_func(ARRAY[1,2], nummultirange...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function anyarray_anymultirange_func(anyarray, anymultirange);
|
||||
-- should fail
|
||||
create function bogus_func(anyelement)
|
||||
@@ -3199,7 +3201,8 @@ select multirangetypes_sql(nummultirange(numrange(1,10)), ARRAY[2,20]); -- matc
|
||||
ERROR: function multirangetypes_sql(nummultirange, integer[]) does not exist
|
||||
LINE 1: select multirangetypes_sql(nummultirange(numrange(1,10)), AR...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
create function anycompatiblearray_anycompatiblemultirange_func(a anycompatiblearray, mr anycompatiblemultirange)
|
||||
returns anycompatible as 'select $1[1] + lower($2);' language sql;
|
||||
select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1,2], multirange(int4range(10,20)));
|
||||
@@ -3219,7 +3222,8 @@ select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1.1,2], multirange(
|
||||
ERROR: function anycompatiblearray_anycompatiblemultirange_func(numeric[], int4multirange) does not exist
|
||||
LINE 1: select anycompatiblearray_anycompatiblemultirange_func(ARRAY...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function anycompatiblearray_anycompatiblemultirange_func(anycompatiblearray, anycompatiblemultirange);
|
||||
create function anycompatiblerange_anycompatiblemultirange_func(r anycompatiblerange, mr anycompatiblemultirange)
|
||||
returns anycompatible as 'select lower($1) + lower($2);' language sql;
|
||||
@@ -3234,7 +3238,8 @@ select anycompatiblerange_anycompatiblemultirange_func(numrange(1,2), multirange
|
||||
ERROR: function anycompatiblerange_anycompatiblemultirange_func(numrange, int4multirange) does not exist
|
||||
LINE 1: select anycompatiblerange_anycompatiblemultirange_func(numra...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function anycompatiblerange_anycompatiblemultirange_func(anycompatiblerange, anycompatiblemultirange);
|
||||
-- should fail
|
||||
create function bogus_func(anycompatible)
|
||||
|
||||
@@ -1763,7 +1763,8 @@ select f1(point(3,4)); -- fail for lack of + operator
|
||||
ERROR: operator does not exist: point + integer
|
||||
LINE 1: x + 1
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
QUERY: x + 1
|
||||
CONTEXT: PL/pgSQL function f1(anyelement) line 3 at RETURN
|
||||
drop function f1(x anyelement);
|
||||
@@ -1848,7 +1849,8 @@ select f1(int4range(42, 49), 11, 4.5) as fail; -- range type doesn't fit
|
||||
ERROR: function f1(int4range, integer, numeric) does not exist
|
||||
LINE 1: select f1(int4range(42, 49), 11, 4.5) as fail;
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function f1(x anycompatiblerange, y anycompatible, z anycompatible);
|
||||
-- fail, can't infer type:
|
||||
create function f1(x anycompatible) returns anycompatiblerange as $$
|
||||
@@ -1902,7 +1904,8 @@ select x, pg_typeof(x), y, pg_typeof(y)
|
||||
ERROR: function f1(integer, numeric[], integer, numeric) does not exist
|
||||
LINE 2: from f1(11, array[1, 2.2], 42, 34.5);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function f1(a anyelement, b anyarray,
|
||||
c anycompatible, d anycompatible);
|
||||
--
|
||||
@@ -3072,7 +3075,7 @@ select shadowtest(1);
|
||||
ERROR: function shadowtest(integer) does not exist
|
||||
LINE 1: select shadowtest(1);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: There is no function of that name.
|
||||
reset plpgsql.extra_errors;
|
||||
reset plpgsql.extra_warnings;
|
||||
create or replace function shadowtest(f1 int)
|
||||
|
||||
@@ -15,7 +15,8 @@ select polyf(point(3,4)); -- fail for lack of + operator
|
||||
ERROR: operator does not exist: point + integer
|
||||
LINE 2: select x + 1
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
QUERY:
|
||||
select x + 1
|
||||
|
||||
@@ -95,7 +96,8 @@ select polyf(int4range(42, 49), 11, 4.5) as fail; -- range type doesn't fit
|
||||
ERROR: function polyf(int4range, integer, numeric) does not exist
|
||||
LINE 1: select polyf(int4range(42, 49), 11, 4.5) as fail;
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function polyf(x anycompatiblerange, y anycompatible, z anycompatible);
|
||||
create function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible) returns anycompatiblearray as $$
|
||||
select array[lower(x), upper(x), y, z]
|
||||
@@ -110,7 +112,8 @@ select polyf(multirange(int4range(42, 49)), 11, 4.5) as fail; -- range type doe
|
||||
ERROR: function polyf(int4multirange, integer, numeric) does not exist
|
||||
LINE 1: select polyf(multirange(int4range(42, 49)), 11, 4.5) as fail...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible);
|
||||
-- fail, can't infer type:
|
||||
create function polyf(x anycompatible) returns anycompatiblerange as $$
|
||||
@@ -176,7 +179,8 @@ select x, pg_typeof(x), y, pg_typeof(y)
|
||||
ERROR: function polyf(integer, numeric[], integer, numeric) does not exist
|
||||
LINE 2: from polyf(11, array[1, 2.2], 42, 34.5);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function polyf(a anyelement, b anyarray,
|
||||
c anycompatible, d anycompatible);
|
||||
create function polyf(anyrange) returns anymultirange
|
||||
@@ -990,7 +994,7 @@ select myleast(); -- fail
|
||||
ERROR: function myleast() does not exist
|
||||
LINE 1: select myleast();
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given number of arguments.
|
||||
-- test with variadic call parameter
|
||||
select myleast(variadic array[1,2,3,4,-1]);
|
||||
myleast
|
||||
@@ -1060,17 +1064,20 @@ select formarray(1.1, array[1.2,55.5]); -- fail without variadic
|
||||
ERROR: function formarray(numeric, numeric[]) does not exist
|
||||
LINE 1: select formarray(1.1, array[1.2,55.5]);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select formarray(1, 'x'::text); -- fail, type mismatch
|
||||
ERROR: function formarray(integer, text) does not exist
|
||||
LINE 1: select formarray(1, 'x'::text);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select formarray(1, variadic array['x'::text]); -- fail, type mismatch
|
||||
ERROR: function formarray(integer, text[]) does not exist
|
||||
LINE 1: select formarray(1, variadic array['x'::text]);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function formarray(anyelement, variadic anyarray);
|
||||
-- test pg_typeof() function
|
||||
select pg_typeof(null); -- unknown
|
||||
@@ -1154,7 +1161,7 @@ select dfunc(10, 20, 30); -- fail
|
||||
ERROR: function dfunc(integer, integer, integer) does not exist
|
||||
LINE 1: select dfunc(10, 20, 30);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given number of arguments.
|
||||
drop function dfunc(); -- fail
|
||||
ERROR: function dfunc() does not exist
|
||||
drop function dfunc(int); -- fail
|
||||
@@ -1203,7 +1210,8 @@ select dfunc(); -- fail: which dfunc should be called? int or text
|
||||
ERROR: function dfunc() is not unique
|
||||
LINE 1: select dfunc();
|
||||
^
|
||||
HINT: Could not choose a best candidate function. You might need to add explicit type casts.
|
||||
DETAIL: Could not choose a best candidate function.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select dfunc('Hi'); -- ok
|
||||
dfunc
|
||||
-----------
|
||||
@@ -1242,17 +1250,20 @@ select dfunc(); -- fail
|
||||
ERROR: function dfunc() is not unique
|
||||
LINE 1: select dfunc();
|
||||
^
|
||||
HINT: Could not choose a best candidate function. You might need to add explicit type casts.
|
||||
DETAIL: Could not choose a best candidate function.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select dfunc(1); -- fail
|
||||
ERROR: function dfunc(integer) is not unique
|
||||
LINE 1: select dfunc(1);
|
||||
^
|
||||
HINT: Could not choose a best candidate function. You might need to add explicit type casts.
|
||||
DETAIL: Could not choose a best candidate function.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select dfunc(1, 2); -- fail
|
||||
ERROR: function dfunc(integer, integer) is not unique
|
||||
LINE 1: select dfunc(1, 2);
|
||||
^
|
||||
HINT: Could not choose a best candidate function. You might need to add explicit type casts.
|
||||
DETAIL: Could not choose a best candidate function.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select dfunc(1, 2, 3); -- ok
|
||||
dfunc
|
||||
-------
|
||||
@@ -1310,7 +1321,7 @@ select dfunc(); -- fail
|
||||
ERROR: function dfunc() does not exist
|
||||
LINE 1: select dfunc();
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given number of arguments.
|
||||
select dfunc(10);
|
||||
dfunc
|
||||
-------
|
||||
@@ -1371,7 +1382,8 @@ select dfunc(1); -- fail
|
||||
ERROR: function dfunc(integer) is not unique
|
||||
LINE 1: select dfunc(1);
|
||||
^
|
||||
HINT: Could not choose a best candidate function. You might need to add explicit type casts.
|
||||
DETAIL: Could not choose a best candidate function.
|
||||
HINT: You might need to add explicit type casts.
|
||||
-- but this works since the ambiguous functions aren't preferred anyway
|
||||
select dfunc('Hi');
|
||||
dfunc
|
||||
@@ -1417,7 +1429,7 @@ select * from dfunc(0); -- fail
|
||||
ERROR: function dfunc(integer) does not exist
|
||||
LINE 1: select * from dfunc(0);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given number of arguments.
|
||||
select * from dfunc(1,2);
|
||||
a | b | c | d
|
||||
---+---+---+---
|
||||
@@ -1448,18 +1460,72 @@ select * from dfunc(x := 10, b := 20, c := 30); -- fail, unknown param
|
||||
ERROR: function dfunc(x => integer, b => integer, c => integer) does not exist
|
||||
LINE 1: select * from dfunc(x := 10, b := 20, c := 30);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument names.
|
||||
select * from dfunc(10, 10, a := 20); -- fail, a overlaps positional parameter
|
||||
ERROR: function dfunc(integer, integer, a => integer) does not exist
|
||||
LINE 1: select * from dfunc(10, 10, a := 20);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: In the closest available match, an argument was specified both positionally and by name.
|
||||
select * from dfunc(1,c := 2,d := 3); -- fail, no value for b
|
||||
ERROR: function dfunc(integer, c => integer, d => integer) does not exist
|
||||
LINE 1: select * from dfunc(1,c := 2,d := 3);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: In the closest available match, not all required arguments were supplied.
|
||||
drop function dfunc(int, int, int, int);
|
||||
create function xleast(x numeric, variadic arr numeric[])
|
||||
returns numeric as $$
|
||||
select least(x, min(arr[i])) from generate_subscripts(arr, 1) g(i);
|
||||
$$ language sql;
|
||||
select xleast(x => 1, variadic arr => array[2,3]);
|
||||
xleast
|
||||
--------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
select xleast(1, variadic arr => array[2,3]);
|
||||
xleast
|
||||
--------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
set search_path = pg_catalog;
|
||||
select xleast(1, variadic arr => array[2,3]); -- wrong schema
|
||||
ERROR: function xleast(integer, arr => integer[]) does not exist
|
||||
LINE 1: select xleast(1, variadic arr => array[2,3]);
|
||||
^
|
||||
DETAIL: A function of that name exists, but it is not in the search_path.
|
||||
reset search_path;
|
||||
select xleast(foo => 1, variadic arr => array[2,3]); -- wrong argument name
|
||||
ERROR: function xleast(foo => integer, arr => integer[]) does not exist
|
||||
LINE 1: select xleast(foo => 1, variadic arr => array[2,3]);
|
||||
^
|
||||
DETAIL: No function of that name accepts the given argument names.
|
||||
select xleast(x => 1, variadic array[2,3]); -- misuse of mixed notation
|
||||
ERROR: positional argument cannot follow named argument
|
||||
LINE 1: select xleast(x => 1, variadic array[2,3]);
|
||||
^
|
||||
select xleast(1, variadic x => array[2,3]); -- misuse of mixed notation
|
||||
ERROR: function xleast(integer, x => integer[]) does not exist
|
||||
LINE 1: select xleast(1, variadic x => array[2,3]);
|
||||
^
|
||||
DETAIL: In the closest available match, an argument was specified both positionally and by name.
|
||||
select xleast(arr => array[1], variadic x => 3); -- wrong arg is VARIADIC
|
||||
ERROR: function xleast(arr => integer[], x => integer) does not exist
|
||||
LINE 1: select xleast(arr => array[1], variadic x => 3);
|
||||
^
|
||||
HINT: The VARIADIC parameter must be placed last, even when using argument names.
|
||||
select xleast(arr => array[1], x => 3); -- failed to use VARIADIC
|
||||
ERROR: function xleast(arr => integer[], x => integer) does not exist
|
||||
LINE 1: select xleast(arr => array[1], x => 3);
|
||||
^
|
||||
HINT: This call would be correct if the variadic array were labeled VARIADIC and placed last.
|
||||
select xleast(arr => 1, variadic x => array[2,3]); -- mixed-up args
|
||||
ERROR: function xleast(arr => integer, x => integer[]) does not exist
|
||||
LINE 1: select xleast(arr => 1, variadic x => array[2,3]);
|
||||
^
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function xleast(x numeric, variadic arr numeric[]);
|
||||
-- test with different parameter types
|
||||
create function dfunc(a varchar, b numeric, c date = current_date)
|
||||
returns table (a varchar, b numeric, c date) as $$
|
||||
@@ -1499,7 +1565,8 @@ select * from dfunc('Hello World', c := 20, b := '2009-07-25'::date); -- fail
|
||||
ERROR: function dfunc(unknown, c => integer, b => date) does not exist
|
||||
LINE 1: select * from dfunc('Hello World', c := 20, b := '2009-07-25...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function dfunc(varchar, numeric, date);
|
||||
-- test out parameters with named params
|
||||
create function dfunc(a varchar = 'def a', out _a varchar, c numeric = NULL, out _c numeric)
|
||||
@@ -1844,7 +1911,8 @@ select x, pg_typeof(x) from anyctest(11, point(1,2)) x; -- fail
|
||||
ERROR: function anyctest(integer, point) does not exist
|
||||
LINE 1: select x, pg_typeof(x) from anyctest(11, point(1,2)) x;
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select x, pg_typeof(x) from anyctest('11', '12.3') x; -- defaults to text
|
||||
x | pg_typeof
|
||||
------+-----------
|
||||
@@ -1872,7 +1940,8 @@ select x, pg_typeof(x) from anyctest(11, array[1,2]) x; -- fail
|
||||
ERROR: function anyctest(integer, integer[]) does not exist
|
||||
LINE 1: select x, pg_typeof(x) from anyctest(11, array[1,2]) x;
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function anyctest(anycompatible, anycompatible);
|
||||
create function anyctest(anycompatible, anycompatiblearray)
|
||||
returns anycompatiblearray as $$
|
||||
@@ -1906,12 +1975,14 @@ select x, pg_typeof(x) from anyctest(11, array[point(1,2)]) x; -- fail
|
||||
ERROR: function anyctest(integer, point[]) does not exist
|
||||
LINE 1: select x, pg_typeof(x) from anyctest(11, array[point(1,2)]) ...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select x, pg_typeof(x) from anyctest(11, 12) x; -- fail
|
||||
ERROR: function anyctest(integer, integer) does not exist
|
||||
LINE 1: select x, pg_typeof(x) from anyctest(11, 12) x;
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function anyctest(anycompatible, anycompatiblearray);
|
||||
create function anyctest(anycompatible, anycompatiblerange)
|
||||
returns anycompatiblerange as $$
|
||||
@@ -1933,12 +2004,14 @@ select x, pg_typeof(x) from anyctest(11, 12) x; -- fail
|
||||
ERROR: function anyctest(integer, integer) does not exist
|
||||
LINE 1: select x, pg_typeof(x) from anyctest(11, 12) x;
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select x, pg_typeof(x) from anyctest(11.2, int4range(4,7)) x; -- fail
|
||||
ERROR: function anyctest(numeric, int4range) does not exist
|
||||
LINE 1: select x, pg_typeof(x) from anyctest(11.2, int4range(4,7)) x...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select x, pg_typeof(x) from anyctest(11.2, '[4,7)') x; -- fail
|
||||
ERROR: could not determine polymorphic type anycompatiblerange because input has type unknown
|
||||
drop function anyctest(anycompatible, anycompatiblerange);
|
||||
@@ -1956,7 +2029,8 @@ select x, pg_typeof(x) from anyctest(int4range(11,12), numrange(4,7)) x; -- fail
|
||||
ERROR: function anyctest(int4range, numrange) does not exist
|
||||
LINE 1: select x, pg_typeof(x) from anyctest(int4range(11,12), numra...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function anyctest(anycompatiblerange, anycompatiblerange);
|
||||
-- fail, can't infer result type:
|
||||
create function anyctest(anycompatible)
|
||||
@@ -1985,12 +2059,14 @@ select x, pg_typeof(x) from anyctest(11, 12) x; -- fail
|
||||
ERROR: function anyctest(integer, integer) does not exist
|
||||
LINE 1: select x, pg_typeof(x) from anyctest(11, 12) x;
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select x, pg_typeof(x) from anyctest(11.2, multirange(int4range(4,7))) x; -- fail
|
||||
ERROR: function anyctest(numeric, int4multirange) does not exist
|
||||
LINE 1: select x, pg_typeof(x) from anyctest(11.2, multirange(int4ra...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select x, pg_typeof(x) from anyctest(11.2, '{[4,7)}') x; -- fail
|
||||
ERROR: could not determine polymorphic type anycompatiblemultirange because input has type unknown
|
||||
drop function anyctest(anycompatible, anycompatiblemultirange);
|
||||
@@ -2008,7 +2084,8 @@ select x, pg_typeof(x) from anyctest(multirange(int4range(11,12)), multirange(nu
|
||||
ERROR: function anyctest(int4multirange, nummultirange) does not exist
|
||||
LINE 1: select x, pg_typeof(x) from anyctest(multirange(int4range(11...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function anyctest(anycompatiblemultirange, anycompatiblemultirange);
|
||||
-- fail, can't infer result type:
|
||||
create function anyctest(anycompatible)
|
||||
@@ -2037,7 +2114,8 @@ select x, pg_typeof(x) from anyctest(array[11], array[1,2]) x; -- fail
|
||||
ERROR: function anyctest(integer[], integer[]) does not exist
|
||||
LINE 1: select x, pg_typeof(x) from anyctest(array[11], array[1,2]) ...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function anyctest(anycompatiblenonarray, anycompatiblenonarray);
|
||||
create function anyctest(a anyelement, b anyarray,
|
||||
c anycompatible, d anycompatible)
|
||||
@@ -2066,7 +2144,8 @@ select x, pg_typeof(x) from anyctest(11, array[1, 2.2], 42, 34.5) x; -- fail
|
||||
ERROR: function anyctest(integer, numeric[], integer, numeric) does not exist
|
||||
LINE 1: select x, pg_typeof(x) from anyctest(11, array[1, 2.2], 42, ...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function anyctest(a anyelement, b anyarray,
|
||||
c anycompatible, d anycompatible);
|
||||
create function anyctest(variadic anycompatiblearray)
|
||||
|
||||
@@ -1630,7 +1630,8 @@ select anyarray_anyrange_func(ARRAY[1,2], numrange(10,20));
|
||||
ERROR: function anyarray_anyrange_func(integer[], numrange) does not exist
|
||||
LINE 1: select anyarray_anyrange_func(ARRAY[1,2], numrange(10,20));
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function anyarray_anyrange_func(anyarray, anyrange);
|
||||
-- should fail
|
||||
create function bogus_func(anyelement)
|
||||
@@ -1669,7 +1670,8 @@ select rangetypes_sql(numrange(1,10), ARRAY[2,20]); -- match failure
|
||||
ERROR: function rangetypes_sql(numrange, integer[]) does not exist
|
||||
LINE 1: select rangetypes_sql(numrange(1,10), ARRAY[2,20]);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
create function anycompatiblearray_anycompatiblerange_func(a anycompatiblearray, r anycompatiblerange)
|
||||
returns anycompatible as 'select $1[1] + lower($2);' language sql;
|
||||
select anycompatiblearray_anycompatiblerange_func(ARRAY[1,2], int4range(10,20));
|
||||
@@ -1689,7 +1691,8 @@ select anycompatiblearray_anycompatiblerange_func(ARRAY[1.1,2], int4range(10,20)
|
||||
ERROR: function anycompatiblearray_anycompatiblerange_func(numeric[], int4range) does not exist
|
||||
LINE 1: select anycompatiblearray_anycompatiblerange_func(ARRAY[1.1,...
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
drop function anycompatiblearray_anycompatiblerange_func(anycompatiblearray, anycompatiblerange);
|
||||
-- should fail
|
||||
create function bogus_func(anycompatible)
|
||||
|
||||
@@ -965,7 +965,8 @@ select text(fullname) from fullname; -- error
|
||||
ERROR: function text(fullname) does not exist
|
||||
LINE 1: select text(fullname) from fullname;
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select fullname.text from fullname; -- error
|
||||
ERROR: column fullname.text does not exist
|
||||
LINE 1: select fullname.text from fullname;
|
||||
@@ -987,7 +988,8 @@ select text(row('Jim', 'Beam')); -- error
|
||||
ERROR: function text(record) does not exist
|
||||
LINE 1: select text(row('Jim', 'Beam'));
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select (row('Jim', 'Beam')).text; -- error
|
||||
ERROR: could not identify column "text" in record data type
|
||||
LINE 1: select (row('Jim', 'Beam')).text;
|
||||
|
||||
@@ -1175,7 +1175,8 @@ select * from int8_tbl where q1 in (select c1 from inner_text);
|
||||
ERROR: operator does not exist: bigint = text
|
||||
LINE 1: select * from int8_tbl where q1 in (select c1 from inner_tex...
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
begin;
|
||||
-- make an operator to allow it to succeed
|
||||
create function bogus_int8_text_eq(int8, text) returns boolean
|
||||
|
||||
@@ -229,7 +229,7 @@ select nonempty('');
|
||||
ERROR: function nonempty(unknown) does not exist
|
||||
LINE 1: select nonempty('');
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: There is no function of that name.
|
||||
select pg_temp.nonempty('');
|
||||
ERROR: value for domain nonempty violates check constraint "nonempty_check"
|
||||
-- other syntax matches rules for tables
|
||||
|
||||
@@ -27,7 +27,8 @@ select length(42);
|
||||
ERROR: function length(integer) does not exist
|
||||
LINE 1: select length(42);
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No function of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
-- But as a special exception for usability's sake, we still allow implicit
|
||||
-- casting to text in concatenations, so long as the other input is text or
|
||||
-- an unknown literal. So these work:
|
||||
@@ -48,7 +49,8 @@ select 3 || 4.0;
|
||||
ERROR: operator does not exist: integer || numeric
|
||||
LINE 1: select 3 || 4.0;
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
/*
|
||||
* various string functions
|
||||
*/
|
||||
|
||||
@@ -157,7 +157,8 @@ SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;
|
||||
ERROR: operator is not unique: time without time zone + time without time zone
|
||||
LINE 1: SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;
|
||||
^
|
||||
HINT: Could not choose a best candidate operator. You might need to add explicit type casts.
|
||||
DETAIL: Could not choose a best candidate operator.
|
||||
HINT: You might need to add explicit type casts.
|
||||
--
|
||||
-- test EXTRACT
|
||||
--
|
||||
|
||||
@@ -174,7 +174,8 @@ SELECT f1 + time with time zone '00:01' AS "Illegal" FROM TIMETZ_TBL;
|
||||
ERROR: operator does not exist: time with time zone + time with time zone
|
||||
LINE 1: SELECT f1 + time with time zone '00:01' AS "Illegal" FROM TI...
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
--
|
||||
-- test EXTRACT
|
||||
--
|
||||
|
||||
@@ -175,7 +175,8 @@ SELECT n, pg_typeof(n) FROM t;
|
||||
ERROR: operator does not exist: text + integer
|
||||
LINE 4: SELECT n+1 FROM t WHERE n < 10
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
-- Deeply nested WITH caused a list-munging problem in v13
|
||||
-- Detection of cross-references and self-references
|
||||
WITH RECURSIVE w1(c1) AS
|
||||
|
||||
@@ -110,22 +110,26 @@ select '1'::xid < '2'::xid;
|
||||
ERROR: operator does not exist: xid < xid
|
||||
LINE 1: select '1'::xid < '2'::xid;
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select '1'::xid <= '2'::xid;
|
||||
ERROR: operator does not exist: xid <= xid
|
||||
LINE 1: select '1'::xid <= '2'::xid;
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select '1'::xid > '2'::xid;
|
||||
ERROR: operator does not exist: xid > xid
|
||||
LINE 1: select '1'::xid > '2'::xid;
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
select '1'::xid >= '2'::xid;
|
||||
ERROR: operator does not exist: xid >= xid
|
||||
LINE 1: select '1'::xid >= '2'::xid;
|
||||
^
|
||||
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||
DETAIL: No operator of that name accepts the given argument types.
|
||||
HINT: You might need to add explicit type casts.
|
||||
-- we want them for xid8 though
|
||||
select '1'::xid8 < '2'::xid8, '2'::xid8 < '2'::xid8, '2'::xid8 < '1'::xid8;
|
||||
?column? | ?column? | ?column?
|
||||
|
||||
@@ -22,6 +22,13 @@ CREATE OPERATOR #%# (
|
||||
-- Test operator created above
|
||||
SELECT @#@ 24;
|
||||
|
||||
-- Test error cases
|
||||
select @@##@@ 24; -- no such operator
|
||||
set search_path = pg_catalog;
|
||||
select @#@ 24; -- wrong schema
|
||||
reset search_path;
|
||||
select @#@ 24.0; -- wrong data type
|
||||
|
||||
-- Test comments
|
||||
COMMENT ON OPERATOR ###### (NONE, int4) IS 'bad prefix';
|
||||
COMMENT ON OPERATOR ###### (int4, NONE) IS 'bad postfix';
|
||||
|
||||
@@ -873,6 +873,26 @@ select * from dfunc(1,c := 2,d := 3); -- fail, no value for b
|
||||
|
||||
drop function dfunc(int, int, int, int);
|
||||
|
||||
create function xleast(x numeric, variadic arr numeric[])
|
||||
returns numeric as $$
|
||||
select least(x, min(arr[i])) from generate_subscripts(arr, 1) g(i);
|
||||
$$ language sql;
|
||||
|
||||
select xleast(x => 1, variadic arr => array[2,3]);
|
||||
select xleast(1, variadic arr => array[2,3]);
|
||||
|
||||
set search_path = pg_catalog;
|
||||
select xleast(1, variadic arr => array[2,3]); -- wrong schema
|
||||
reset search_path;
|
||||
select xleast(foo => 1, variadic arr => array[2,3]); -- wrong argument name
|
||||
select xleast(x => 1, variadic array[2,3]); -- misuse of mixed notation
|
||||
select xleast(1, variadic x => array[2,3]); -- misuse of mixed notation
|
||||
select xleast(arr => array[1], variadic x => 3); -- wrong arg is VARIADIC
|
||||
select xleast(arr => array[1], x => 3); -- failed to use VARIADIC
|
||||
select xleast(arr => 1, variadic x => array[2,3]); -- mixed-up args
|
||||
|
||||
drop function xleast(x numeric, variadic arr numeric[]);
|
||||
|
||||
-- test with different parameter types
|
||||
create function dfunc(a varchar, b numeric, c date = current_date)
|
||||
returns table (a varchar, b numeric, c date) as $$
|
||||
|
||||
Reference in New Issue
Block a user