Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 27F0F1019D for ; Mon, 2 Dec 2013 13:39:47 +0000 (UTC) Received: (qmail 75012 invoked by uid 500); 2 Dec 2013 13:38:53 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 74988 invoked by uid 500); 2 Dec 2013 13:38:46 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 74965 invoked by uid 99); 2 Dec 2013 13:38:37 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Dec 2013 13:38:37 +0000 Date: Mon, 2 Dec 2013 13:38:37 +0000 (UTC) From: "Rick Hillegas (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DERBY-5901) You can declare user-defined functions which shadow builtin functions by the same name. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-5901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13836511#comment-13836511 ] Rick Hillegas commented on DERBY-5901: -------------------------------------- Emptying the statement cache when a shadowing function is created sounds like a cheap, adequate fix for this rare edge-case. Thanks. > You can declare user-defined functions which shadow builtin functions by the same name. > --------------------------------------------------------------------------------------- > > Key: DERBY-5901 > URL: https://issues.apache.org/jira/browse/DERBY-5901 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.10.1.1 > Reporter: Rick Hillegas > Labels: derby_triage10_10 > > You can override a Derby builtin function by creating a function with the same name. This can give rise to wrong results. > Consider the following user code: > public class FakeSin > { > public static Double sin( Double input ) { return new Double( 3.0 ); } > } > Now run the following script: > connect 'jdbc:derby:memory:db;create=true'; > values sin( 0.5 ); > create function sin( a double ) returns double language java parameter style java no sql external name 'FakeSin.sin'; > values sin( 0.5 ); > values sin( 0.5 ); > Note the following: > 1) The first invocation of sin() returns the expected result. > 2) You are allowed to create a user-defined function named "sin" which can shadow the builtin function. > 3) The second invocation of sin() returns the result of running the builtin function. This is because the second invocation is character-for-character identical to the first, so Derby just uses the previously prepared statement. > 4) But the third invocation of sin() returns the result of running the user-defined function. Note that the third invocation has an extra space in it, which causes Derby to compile it from scratch, picking up the user-defined function instead of the builtin one. -- This message was sent by Atlassian JIRA (v6.1#6144)