Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y1dGw-0007kx-As for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Dec 2014 15:45:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y1dGu-0000RM-JO for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Dec 2014 15:45:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y1cKB-0004vJ-DR for pgsql-bugs@postgresql.org; Thu, 18 Dec 2014 14:45:07 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y1cK7-0003KV-Er for pgsql-bugs@postgresql.org; Thu, 18 Dec 2014 14:45:05 +0000 MIME-Version: 1.0 Subject: BUG #12273: CASE Expression BUG To: pgsql-bugs@postgresql.org From: jaksits.tibor@gmail.com Date: Thu, 18 Dec 2014 14:44:36 +0000 Message-ID: <20141218144436.1237.96696@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.3 (/) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 12273 Logged by: Tibor Jaksits Email address: jaksits.tibor@gmail.com PostgreSQL version: 9.3.4 Operating system: Linux Debian 64-bit 4.7.2-5 Description: I created a simple function that returns the number received parameter. CREATE OR REPLACE FUNCTION __is_numeric_test(a_double_param double precision) RETURNS double precision AS $BODY$DECLARE BEGIN RETURN a_double_param; END;$BODY$ LANGUAGE plpgsql VOLATILE; I created two other functions: CREATE OR REPLACE FUNCTION __is_numeric_test_work(a_text_param text) RETURNS double precision AS $BODY$DECLARE BEGIN RETURN __is_numeric_test((CASE WHEN is_numeric(a_text_param) THEN a_text_param::double precision ELSE 0.0::double precision END)); END;$BODY$ LANGUAGE plpgsql VOLATILE; CREATE OR REPLACE FUNCTION __is_numeric_test_does_not_work(a_text_param text) RETURNS double precision AS $BODY$DECLARE ret double precision; BEGIN SELECT __is_numeric_test INTO ret FROM __is_numeric_test((CASE WHEN is_numeric(a_text_param) THEN a_text_param::double precision ELSE 0.0::double precision END)); RETURN ret; END;$BODY$ LANGUAGE plpgsql VOLATILE; The return value of the "SELECT * FROM __is_numeric_test_work('')" query is 0 (correct operation) But the query "SELECT * FROM __is_numeric_test_does_not_work('')" I get an error message: invalid input syntax for type double precision: "" CONTEXT: SQL statement "SELECT __is_numeric_test FROM __is_numeric_test((CASE WHEN is_numeric(a_text_param) THEN a_text_param::double precision ELSE 0.0::double precision END))" PL/pgSQL function __is_numeric_test_does_not_work(text) line 5 at SQL statement ********** Error ********** ERROR: invalid input syntax for type double precision: "" SQL state: 22P02 Context: SQL statement "SELECT __is_numeric_test FROM __is_numeric_test((CASE WHEN is_numeric(a_text_param) THEN a_text_param::double precision ELSE 0.0::double precision END))" PL/pgSQL function __is_numeric_test_does_not_work(text) line 5 at SQL statement -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs