Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rand(int) should not return NULL #2900

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

rand(int) should not return NULL #2900

monetdb-team opened this issue Nov 30, 2020 · 0 comments

Comments

@monetdb-team
Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2011-10-12 12:07:15 +0200
From: @swingbit
To: SQL devs <>
Version: 11.5.1 (Aug2011) [obsolete]
CC: @njnes

Last updated: 2011-10-26 13:22:04 +0200

Comment 16394

Date: 2011-10-12 12:07:15 +0200
From: @swingbit

User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.81 Safari/535.2
Build Identifier:

The SQL function rand(i int) (the version with seed!) is mapped to the MAL function srand, which maps in turn to this C function:

str
MATHsrandint(int *seed)
{
srand(*seed);
return MAL_SUCCEED;
}

Therefore, the SQL function returns NULL.
While this could be the expected behaviour in MAL (to return void), I don't think it is expected to return NULL in SQL.
What I would expect from the SQL call rand(100) is a call to srand(100) followed by a call to rand(), with its return valued passed to SQL.

Reproducible: Always

Steps to Reproduce:

  1. select rand(100),rand();

Actual Results:

+----------------------------------------------------------------------------------+------------+
| rand_single_value | rand |
+==================================================================================+============+
| null | 1804289383 |
+----------------------------------------------------------------------------------+------------+

Expected Results:

+------------+------------+
| rand | rand |
+============+============+
| 1804289383 | 846930886 |
+------------+------------+

Comment 16416

Date: 2011-10-14 09:02:26 +0200
From: @njnes

fixed by adding the combined srand/rand function

Comment 16417

Date: 2011-10-14 09:08:37 +0200
From: @njnes

Changeset 26cb61b1604b made by Niels Nes niels@cwi.nl in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=26cb61b1604b

Changeset description:

fixes for bug #2900

add sqlrand which maps to srand + rand call.

Comment 16418

Date: 2011-10-14 09:20:28 +0200
From: @drstmane

Changeset 2615851abad6 made by Stefan Manegold Stefan.Manegold@cwi.nl in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=2615851abad6

Changeset description:

added test for bug #2900
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant