Uploaded image for project: 'Apache Trafodion'
  1. Apache Trafodion
  2. TRAFODION-3042

RAND() function is not always random

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.3
    • Component/s: sql-exe
    • Labels:
      None

      Description

      When trying the RAND() function, I found that it does not always behave as I would expect. I tried this example:

      >>select rand(), rand(), rand() from dual;
      
      (EXPR)      (EXPR)      (EXPR)    
      ----------  ----------  ----------
      
        78242471    78511383    78612225
      
      --- 1 row(s) selected.
      >>select rand(), rand(), rand() from dual;
      
      (EXPR)      (EXPR)      (EXPR)    
      ----------  ----------  ----------
      
      1589208276  1589460381  1589561223
      
      --- 1 row(s) selected.
      >>select rand(), rand(), rand() from dual;
      
      (EXPR)      (EXPR)      (EXPR)    
      ----------  ----------  ----------
      
      134371215   134724162   134858618
      
      --- 1 row(s) selected.
      >>
      

      So, it seems that if we call rand() within a very short time, the value will be non-random.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hzeller Hans Zeller
                Reporter:
                hzeller Hans Zeller
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: