Changeset: e31621c83398 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e31621c83398
Modified Files:
        sql/backends/monet5/sql.c
        sql/test/miscellaneous/Tests/simple_selects.test
Branch: default
Log Message:

0 may be a valid sequence minvalue, so don't test it as a bailout condition.

I won't touch this code for now, just adding some tests maybe.


diffs (63 lines):

diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -957,15 +957,14 @@ mvc_next_value_bulk(Client cntxt, MalBlk
                be->last_id = end;
                sqlvar_set_number(find_global_var(be->mvc, 
mvc_bind_schema(be->mvc, "sys"), "last_id"), be->last_id);
                lng c = start;
-               for(BUN i = 0; i<card; i++) {
+               for(BUN i = 0; i<card; ) {
                        if (maxv && c > maxv) {
-                               if (minv)
-                                       c = minv;
-                               else
+                               if (!seq->cycle)
                                        break;
+                               c = minv;
                        }
-                       rb[i] = c;
-                       if ((i+1) < card)
+                       rb[i++] = c;
+                       if (i < card)
                                c += inc;
                }
                assert(c == end);
diff --git a/sql/test/miscellaneous/Tests/simple_selects.test 
b/sql/test/miscellaneous/Tests/simple_selects.test
--- a/sql/test/miscellaneous/Tests/simple_selects.test
+++ b/sql/test/miscellaneous/Tests/simple_selects.test
@@ -897,3 +897,35 @@ 1
 
 statement ok
 drop function dosomething
+
+statement ok
+start transaction
+
+statement ok
+create sequence ups INCREMENT BY 1 MINVALUE 0 MAXVALUE 10 CYCLE
+
+query I rowsort
+select next value for ups from generate_series(1,20)
+----
+0
+1
+1
+10
+2
+2
+3
+3
+4
+4
+5
+5
+6
+6
+7
+7
+8
+8
+9
+
+statement ok
+rollback
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to