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

RAND() function is not always random

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.0
    • 2.3
    • sql-exe
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: