Changeset: 26cb61b1604b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=26cb61b1604b
Modified Files:
        monetdb5/modules/kernel/mmath.mx
        sql/common/sql_types.c
Branch: Aug2011
Log Message:

fixes for bug 2900

add sqlrand which maps to srand + rand call.


diffs (54 lines):

diff --git a/monetdb5/modules/kernel/mmath.mx b/monetdb5/modules/kernel/mmath.mx
--- a/monetdb5/modules/kernel/mmath.mx
+++ b/monetdb5/modules/kernel/mmath.mx
@@ -215,10 +215,15 @@ comment "The finite(x) function returns 
 command rand{unsafe} () :int 
 address MATHrandint
 comment "return a random number";
+
 command srand(seed:int) :void 
 address MATHsrandint
 comment "initialize the rand() function with a seed";
 
+command sqlrand(seed:int) :int 
+address MATHsqlrandint
+comment "initialize the rand() function with a seed and call rand()";
+
 command pi():dbl
 address MATHpi
 comment "return an important mathematical value";
@@ -297,6 +302,7 @@ mmath_export str MATHunary_ISINF(int *re
 mmath_export str MATHunary_FINITE(bit *res, dbl *a);
 mmath_export str MATHrandint(int *res);
 mmath_export str MATHsrandint(int *seed);
+mmath_export str MATHsqlrandint(int *res, int *seed);
 mmath_export str MATHpi(dbl *pi);
 #endif /* __MMATH_H__ */
 
@@ -555,6 +561,14 @@ MATHsrandint(int *seed)
 }
 
 str
+MATHsqlrandint(int *res, int *seed)
+{
+       srand(*seed);
+       *res = rand();
+       return MAL_SUCCEED;
+}
+
+str
 MATHpi(dbl *pi)
 {
        *pi = 3.14159265358979323846;
diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -1393,7 +1393,7 @@ sqltypeinit(void)
        sql_create_func("pi", "mmath", "pi", NULL, NULL, DBL, SCALE_NONE);
 
        sql_create_funcSE("rand", "mmath", "rand", NULL, NULL, INT, SCALE_NONE);
-       sql_create_funcSE("rand", "mmath", "srand", INT, NULL, INT, SCALE_NONE);
+       sql_create_funcSE("rand", "mmath", "sqlrand", INT, NULL, INT, 
SCALE_NONE);
 
        /* Date functions */
        sql_create_func("curdate", "mtime", "current_date", NULL, NULL, DTE, 
SCALE_NONE);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to