BUG #15218: compilation of a function is correct while its executionis in error - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15218: compilation of a function is correct while its executionis in error
Date
Msg-id 152767459637.1291.307356044025822766@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #15218: compilation of a function is correct while itsexecution is in error  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      15218
Logged by:          Didier ROS
Email address:      didier.ros@edf.fr
PostgreSQL version: 10.4
Operating system:   CentOS Linux release 7.3.1611 (Core)
Description:

Hi
I create the following function with an error in it :
CREATE OR REPLACE FUNCTION public.fnc_count_vowels (p_input text)
RETURNS integer LANGUAGE plpgsql AS
$function$
DECLARE
  str text;
  ret integer;
  i   integer;
  len integer;
  tmp text;
BEGIN
  str := upperXXX(p_input);
  ret := 0;
  i := 1;
  len := length(p_input);
  WHILE i <= len LOOP
    IF substr(str, i, 1) in ('A', 'E', 'I', 'O', 'U') THEN
      SELECT pg_sleep(1) INTO tmp;
      ret := ret + 1;
    END IF;
    i := i + 1;
  END LOOP;
  RETURN ret;
END;
$function$
;
-> I use upperXXX which does not exist. normally the compilation should
crash
When I execute the function :
devops=# select fnc_count_vowels('Hello') ;
ERROR:  function upperxxx(text) does not exist
LINE 1: SELECT upperXXX(p_input)
               ^
HINT:  No function matches the given name and argument types. You might need
to add explicit type casts.
QUERY:  SELECT upperXXX(p_input)
CONTEXT:  PL/pgSQL function fnc_count_vowels(text) line 9 at assignment

-> I get the error. 
normally this error should have been detected at compilation. (cf Oracle for
instance).
Thanks in advance
Best Regards
Didier ROS


pgsql-bugs by date:

Previous
From: Alexander Lakhin
Date:
Subject: Re: BUG #15217: Valgrind - writing uninitialised byte(s) in FileWrite
Next
From: Heikki Linnakangas
Date:
Subject: Re: BUG #15218: compilation of a function is correct while itsexecution is in error