db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel John Debrunner (JIRA)" <j...@apache.org>
Subject [jira] Created: (DERBY-3314) RAND(SEED INTEGER) builtin function always returns the same random value for a given seed.
Date Thu, 10 Jan 2008 18:43:34 GMT
RAND(SEED INTEGER) builtin function always returns the same random value for a given seed.
------------------------------------------------------------------------------------------

                 Key: DERBY-3314
                 URL: https://issues.apache.org/jira/browse/DERBY-3314
             Project: Derby
          Issue Type: Bug
          Components: SQL
    Affects Versions: 10.3.2.1, 10.3.1.4, 10.4.0.0
            Reporter: Daniel John Debrunner
            Priority: Minor


RAND or {fn RAND(seed)} exists to match the JDBC specification (section C.1)
   RAND(integer) Random floating point for seed integer

Trouble is that Derby creates a new Random() instance for every call leading to the same return
value for the same seed. Seems to be useful, the function should return a new random number
even when handed the same seed.

Some more specification is probably needed, when does a sequence based upon a seed start?
   - first call by any connection
   - sequence within a connection
   - sequence within a sql context (e.g. procedure call, statement etc.)

Also need to be wary of memory leaks if the engine needs to hold onto Random objects beyond
the lifetime of the RAND call.


ij> values rand(3);
1
----------------------
0.731057369148862

1 row selected
ij> values rand(3);
1
----------------------
0.731057369148862

1 row selected
ij> values {fn rand(3)};
1
----------------------
0.731057369148862

1 row selected

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message