[ 
https://issues.apache.org/jira/browse/DERBY-5901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13841258#comment-13841258
 ] 

Knut Anders Hatlen commented on DERBY-5901:
-------------------------------------------

One case that won't be handled by clearing the cache, is when an internal 
recompilation of an already prepared statement happens. Take for example this 
ij session:

{noformat}
ij> create table t(x int);
0 rows inserted/updated/deleted
ij> insert into t values 1;
1 row inserted/updated/deleted
ij> prepare ps as 'select sin(x) from t';
ij> execute ps;
1                       
------------------------
0.8414709848078965      

1 row selected
ij> create function sin(x int) returns int language java parameter style java 
external name 'java.lang.Math.abs';
0 rows inserted/updated/deleted
ij> execute ps;
1                       
------------------------
0.8414709848078965      

1 row selected
ij> call syscs_util.syscs_compress_table('APP', 'T', 0);
0 rows inserted/updated/deleted
ij> execute ps;
1          
-----------
1          

1 row selected
{noformat}

Here, I think the value returned by ps should not change after the call to 
syscs_compress_table.

> 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)

Reply via email to