Changeset: 21f3dd4219d9 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=21f3dd4219d9 Added Files: sql/test/sciql2sql/Tests/update_fixed_arrays.sql Modified Files: sql/test/sciql2sql/Tests/All Branch: SciQL-2 Log Message:
Update of fixed-range arrays diffs (109 lines): diff --git a/sql/test/sciql2sql/Tests/All b/sql/test/sciql2sql/Tests/All --- a/sql/test/sciql2sql/Tests/All +++ b/sql/test/sciql2sql/Tests/All @@ -6,7 +6,9 @@ create_step_int_array.sql create_step_flt_array.sql create_unbound_step_array.sql -# update dimensional attributs +# update non-dimensional attributes +update_fixed_array +# update dimensional attributes # selections with target is relation diff --git a/sql/test/sciql2sql/Tests/update_fixed_arrays.sql b/sql/test/sciql2sql/Tests/update_fixed_arrays.sql new file mode 100644 --- /dev/null +++ b/sql/test/sciql2sql/Tests/update_fixed_arrays.sql @@ -0,0 +1,90 @@ +-- Update of a fixed array, initialization first +CREATE ARRAY array1D(x INTEGER DIMENSION[4], v INTEGER DEFAULT 1, w INTEGER DEFAULT 0); +INSERT INTO array1D VALUES(0,2,2); +SELECT * FROM array1D; +-- overwrite last value +INSERT INTO array1D VALUES(0,3,3); +SELECT * FROM array1D; +DROP ARRAY array1D; + +-- relational equivalent +CREATE TABLE array1D(x INTEGER CHECK(x >=0 and x < 4), v INTEGER DEFAULT 1, w INTEGER DEFAULT 0); +INSERT INTO array1D values +( 0, 1, 0), +( 1, 1, 0), +( 2, 1, 0), +( 3, 1, 0); + +--delete old cell value first +DELETE FROM array1D WHERE x = 0; +INSERT INTO array1D VALUES(0,2,2); + +--delete old cell value first +DELETE FROM array1D WHERE x = 0; +INSERT INTO array1D VALUES(0,3,3); + +SELECT * FROM array1D ORDER BY x; +DROP ARRAY array1D; + +-- an update triggered by a query +CREATE ARRAY array1D(x INTEGER DIMENSION[4], v INTEGER DEFAULT 1, w INTEGER DEFAULT 0); +UPDATE array1D SET v= NULL, w= w+x; +SELECT * FROM array1D; +DROP ARRAY array1D; + +-- relational equivalent +CREATE TABLE array1D(x INTEGER CHECK(x >=0 and x < 4), v INTEGER DEFAULT 1, w INTEGER DEFAULT 0); +INSERT INTO array1D values +( 0, 1, 0), +( 1, 1, 0), +( 2, 1, 0), +( 3, 1, 0); +UPDATE array1D SET v= NULL, w= w+x; +SELECT * FROM array1D; +DROP ARRAY array1D; + +-- deletion non-dimensional attribute turns into a reset to default +CREATE ARRAY array1D(x INTEGER DIMENSION[4], v INTEGER DEFAULT 1, w INTEGER DEFAULT 0); +DELETE FROM array1D where v = 1; +SELECT * FROM array1D; +DROP ARRAY array1D; + +-- relational equivalent turns it into reset to default +CREATE TABLE array1D(x INTEGER CHECK(x >=0 and x < 4), v INTEGER DEFAULT 1, w INTEGER DEFAULT 0); +INSERT INTO array1D values +( 0, 1, 0), +( 1, 1, 0), +( 2, 1, 0), +( 3, 1, 0); +UPDATE array1D SET v = 1 where v =1; +SELECT * FROM array1D; +DROP ARRAY array1D; + +-- deletion of dimension values lead to a value reset OR ERROR?a +CREATE ARRAY array1D(x INTEGER DIMENSION[4], v INTEGER DEFAULT 1, w INTEGER DEFAULT 0); +UPDATE array1D SET v= NULL, w= w+x; +SELECT * FROM array1D; +DELETE FROM array1D WHERE x =3; +SELECT * FROM array1D; +DROP ARRAY array1D; + +-- Relational equivalent +CREATE TABLE array1D(x INTEGER CHECK(x >=0 and x < 4), v INTEGER DEFAULT 1, w INTEGER DEFAULT 0); +UPDATE array1D SET v= NULL, w= w+x; +SELECT * FROM array1D; +UPDATE array1D SET x=1, w= 0 WHERE x= 3; +SELECT * FROM array1D; +DROP TABLE array1D; + +-- semantic errors (YET not catched) +CREATE ARRAY array1D(x INTEGER DIMENSION[4], v INTEGER DEFAULT 1, w INTEGER DEFAULT 0); +INSERT INTO array1D VALUES(-1,1,0); +SELECT * FROM array1D; +INSERT INTO array1D VALUES(4,1,0); +SELECT * FROM array1D; +UPDATE array1D SET x = x -1; +SELECT * FROM array1D; + +UPDATE array1D SET x= 2 WHERE x=1; -- no assignment to dimension in fixed array +SELECT * FROM array1D; +DROP ARRAY array1D; _______________________________________________ checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
