>>
>>obey TESTMV630(SET_UP);
>>-- ==================================================================
>>set schema catmvs.mvschm;

--- SQL operation complete.
>>
>>create table Num_Obj(schema_name CHARACTER(50), num_of_objects int);

--- SQL operation complete.
>>ALTER TABLE Num_Obj attribute all mvs allowed;

--- SQL operation complete.
>>
>>set param ?schema_name 'MVSCHM';
>>obey INSERT_NUM_OF_OBJ;
>>insert into catmvs.mvschm.Num_Obj
+>select Substring(schemata.SCHEMA_NAME,1,20) as SCHEMA_NAME,
+>	count(objects.object_uid)  num_of_objcets
+>from HP_DEFINITION_SCHEMA.objects objects,
+>     HP_SYSTEM_CATALOG.SYSTEM_SCHEMA.SCHEMATA SCHEMATA
+>     where schemata.schema_uid = objects.schema_uid
+>     and objects.OBJECT_NAME_SPACE <> 'CN'and ?schema_name =SCHEMA_NAME
+>group by SCHEMA_NAME;

--- 1 row(s) inserted.
>>
>>
>>create table T_630_T1 ( a int      NOT NULL NOT DROPPABLE, 
+>                        b int      NOT NULL NOT DROPPABLE, 
+>                        c largeint NOT NULL NOT DROPPABLE, 
+>                        d char(1860),
+>                        PRIMARY KEY (a))
+>       store by primary key
+>	   location $$partition2$$
+>	   attribute automatic rangelog;

--- SQL operation complete.
>>ALTER TABLE T_630_T1 attribute all mvs allowed;

--- SQL operation complete.
>>
>>create table T_630_T2 ( a int      NOT NULL NOT DROPPABLE, 
+>                        b int      NOT NULL NOT DROPPABLE, 
+>                        c largeint NOT NULL NOT DROPPABLE, 
+>                        d char(1860),
+>                        PRIMARY KEY (a))
+>       store by primary key;

--- SQL operation complete.
>>ALTER TABLE T_630_T2 attribute all mvs allowed;

--- SQL operation complete.
>>
>>create table T_630_T3 ( a int      NOT NULL NOT DROPPABLE, 
+>                        b int      NOT NULL NOT DROPPABLE, 
+>                        c largeint NOT NULL NOT DROPPABLE, 
+>                        d char(1860),
+>                        PRIMARY KEY (a))
+>       store by primary key;

--- SQL operation complete.
>>ALTER TABLE T_630_T3 attribute all mvs allowed;

--- SQL operation complete.
>>
>>create table T_630_T4 ( a int      NOT NULL NOT DROPPABLE,
+>                        b int      NOT NULL NOT DROPPABLE,
+>                        c largeint NOT NULL NOT DROPPABLE,
+>                        d char(1860),
+>                        PRIMARY KEY (a))
+>       attribute automatic rangelog;

--- SQL operation complete.
>>ALTER TABLE T_630_T4 attribute all mvs allowed;

--- SQL operation complete.
>>
>>
>>insert into T_630_T2 values (   1, 10,  101,  'a' ),
+>                            (   2,  9,  120,  'b' ),
+>                            (   3,  8,  130,  'c' ),
+>                            (   4,  7,  400,  'd' ),
+>                            (   5,  6,  150,  'e' ),
+>                            (   6,  5,  100,  'f' ),
+>                            (   7,  4,  106,  'g' ),
+>                            (   8,  3,  122,  'h' ),
+>                            (   9,  2,  103,  'i' ),
+>                            (  10,  1,  115,  'j' );

--- 10 row(s) inserted.
>>
>>insert into T_630_T3 select        a,      b,      c, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 10,  b + 9,  c + 2, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 20,  b + 8,  c - 6, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 30,  b + 7,  c + 2, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 40,  b + 6,  c - 6, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 50,  b + 5,  c + 2, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 60,  b + 3,  c - 6, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 70,  b + 4,  c + 2, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 80,  b + 2,  c - 6, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 90,  b + 1,  c + 2, d from T_630_T2;

--- 10 row(s) inserted.
>>
>>delete from T_630_T2;

--- 10 row(s) deleted.
>>
>>insert into T_630_T2 select        a,      b,      c, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 100,  b - 1,  c + 5, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 200,  b - 2,  c + 2, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 300,  b - 3,  c + 5, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 400,  b - 4,  c + 4, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 500,  b - 5,  c + 5, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 600,  b - 6,  c + 6, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 700,  b - 7,  c + 5, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 800,  b - 8,  c + 8, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 900,  b - 9,  c + 5, d from T_630_T3;

--- 100 row(s) inserted.
>>
>>delete from T_630_T3;

--- 100 row(s) deleted.
>>
>>insert into T_630_T3 select         a,      b,      c, d from T_630_T2;

--- 1000 row(s) inserted.
>>insert into T_630_T3 select  a + 1000,  b + 7,  c - 1, d from T_630_T2;

--- 1000 row(s) inserted.
>>insert into T_630_T3 select  a + 2000,  b + 6,  c - 2, d from T_630_T2;

--- 1000 row(s) inserted.
>>insert into T_630_T3 select  a + 3000,  b + 5,  c - 1, d from T_630_T2;

--- 1000 row(s) inserted.
>>--insert into T_630_T3 select  a + 4000,  b + 6,  c - 4, d from T_630_T2;
>>--insert into T_630_T3 select  a + 5000,  b + 5,  c - 5, d from T_630_T2;
>>--insert into T_630_T3 select  a + 6000,  b + 4,  c - 6, d from T_630_T2;
>>--insert into T_630_T3 select  a + 7000,  b + 2,  c - 4, d from T_630_T2;
>>--insert into T_630_T3 select  a + 8000,  b + 4,  c - 2, d from T_630_T2;
>>--insert into T_630_T3 select  a + 9000,  b + 2,  c + 1, d from T_630_T2;
>>
>>create mv T_630_MV1 
+>    refresh on request
+>initialize on create
+>    as
+>        select b, 
+>               count(*) as cnt, 
+>               avg(c) as average,
+>               sum(a) as suma
+>        from T_630_T1
+>        group by b;

--- SQL operation complete.
>>ALTER MV T_630_MV1 attribute all mvs allowed;

--- SQL operation complete.
>>
>>create mv T_630_MV7
+>    refresh on request
+>initialize on create
+>    as
+>        select b,
+>               count(*) as cnt,
+>               avg(c) as average,
+>               sum(a) as suma
+>        from T_630_T4
+>        group by b;

--- SQL operation complete.
>>ALTER MV T_630_MV7 attribute all mvs allowed;

--- SQL operation complete.
>>
>>prepare select_iud_log from
+> select "@EPOCH"
+>        , case "@OPERATION_TYPE" when 0 then 'INSERT' 
+>				 when 1 then 'DELETE' 
+>				 when 2 then 'I-UPDATE'
+>				 when 3 then 'D-UPDATE'
+>				 when 4 then 'END-RANGE'
+>				 when 12 then 'BEGIN-RANGE'
+>          end
+>	, "@RANGE_SIZE"
+>	, a
+> from table(iud_log_table T_630_T1)
+> order by a, syskey;

--- SQL command prepared.
>>
>>prepare compare_BR_ER from
+>select sum("@RANGE_SIZE") as Num_OF_ROWS,
+>       (select count("@OPERATION_TYPE")
+>             from table (iud_log_table T_630_T1)
+>             where "@OPERATION_TYPE" =  4)  as NUM_OF_BR,
+>       (select count("@OPERATION_TYPE")
+>             from table (iud_log_table T_630_T1)
+>             where "@OPERATION_TYPE" = 12)  as NUM_OF_ER,
+>       (select sum(case when (("@OPERATION_TYPE" = 4) AND OFFSET("@OPERATION_TYPE", 1) = 12)
+>                        then 1 else 0 end) as ER_AFTER_BR
+>             from table(iud_log_table T_630_T1)
+>             sequence by syskey) as ER_AFTER_BR
+>  from table(iud_log_table T_630_T1);

--- SQL command prepared.
>>
>>--prepare compare_BR_ER from
>>-- select count("@OPERATION_TYPE") - 
>>--            (select count("@OPERATION_TYPE")
>>--             from table (iud_log_table T_630_T1)
>>--            where "@OPERATION_TYPE" = 12)  as br_minus_er
>>--from table (iud_log_table T_630_T1)
>>-- where "@OPERATION_TYPE" = 4;
>>
>>prepare check_range_size from 
+>    select sum("@RANGE_SIZE") - ?size
+>    from table (iud_log_table T_630_T1);

--- SQL command prepared.
>>
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>-- ==================================================================
>>
>>control query default insert_vsbb 'USER';

--- SQL operation complete.
>>control query default vsbb_test_mode 'ON';

--- SQL operation complete.
>>
>>-- Run Tests
>>    obey TESTMV630(TEST1A);
>>-- ==================================================================
>>-- range size < buffer size.
>>
>>-- 3 rows -> 1st buf, 8 rows -> 2nd buf. 
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 11;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a <= 10;

--- 10 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        101  INSERT                 1            1
        101  INSERT                 1            2
        101  INSERT                 1            3
       -101  BEGIN-RANGE            0            4
       -101  END-RANGE              7           10
        101  INSERT                 1           11

--- 6 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  11                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 11;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 101 and 101 
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>-- ==================================================================
>>    obey TESTMV630(TEST2A);
>>-- ==================================================================
>>
>>-- 36 rows -> buffers
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 50;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 55;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 60;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 65;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 70;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 75;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 77;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 12 and 90 
+>       and a <> 50 and a <> 55 and a <> 60 and a <> 65 and a <> 70 and a <> 75 and a <> 77;

--- 72 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        102  INSERT                 1           12
        102  INSERT                 1           13
        102  INSERT                 1           14
        102  INSERT                 1           15
       -102  BEGIN-RANGE            0           16
       -102  END-RANGE             34           49
        102  INSERT                 1           50
        102  INSERT                 1           51
        102  INSERT                 1           52
        102  INSERT                 1           53
        102  INSERT                 1           54
        102  INSERT                 1           55
        102  INSERT                 1           56
        102  INSERT                 1           57
        102  INSERT                 1           58
        102  INSERT                 1           59
        102  INSERT                 1           60
        102  INSERT                 1           61
        102  INSERT                 1           62
        102  INSERT                 1           63
        102  INSERT                 1           64
        102  INSERT                 1           65
        102  INSERT                 1           66
        102  INSERT                 1           67
        102  INSERT                 1           68
        102  INSERT                 1           69
        102  INSERT                 1           70
        102  INSERT                 1           71
        102  INSERT                 1           72
        102  INSERT                 1           73
        102  INSERT                 1           74
        102  INSERT                 1           75
        102  INSERT                 1           76
        102  INSERT                 1           77
        102  INSERT                 1           78
        102  INSERT                 1           79
        102  INSERT                 1           80
        102  INSERT                 1           81
       -102  BEGIN-RANGE            0           82
       -102  END-RANGE              9           90

--- 40 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  79                     2                     2                     2

--- 1 row(s) selected.
>>set param ?size 79;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 102 and 102 
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>-- ==================================================================
>>    obey TESTMV630(TEST3A);
>>-- ==================================================================
>>
>>-- 1. without EOF after range
>>
>>-- 16 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 154;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 158;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 161;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 172;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 151 and 171 
+>       and a <> 154 and a <> 158 and a <> 161;

--- 18 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        103  INSERT                 1          151
        103  INSERT                 1          152
        103  INSERT                 1          153
        103  INSERT                 1          154
        103  INSERT                 1          155
        103  INSERT                 1          156
        103  INSERT                 1          157
        103  INSERT                 1          158
        103  INSERT                 1          159
        103  INSERT                 1          160
        103  INSERT                 1          161
        103  INSERT                 1          162
        103  INSERT                 1          163
        103  INSERT                 1          164
        103  INSERT                 1          165
       -103  BEGIN-RANGE            0          166
       -103  END-RANGE              6          171
        103  INSERT                 1          172

--- 18 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  22                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 22;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 103 and 103 
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>
>>-- 2. with EOF after range
>>
>>-- 16 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 304;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 308;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 311;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 301 and 321
+>       and a <> 304 and a <> 308 and a <> 311;

--- 18 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        104  INSERT                 1          301
        104  INSERT                 1          302
        104  INSERT                 1          303
        104  INSERT                 1          304
        104  INSERT                 1          305
        104  INSERT                 1          306
        104  INSERT                 1          307
        104  INSERT                 1          308
        104  INSERT                 1          309
        104  INSERT                 1          310
        104  INSERT                 1          311
        104  INSERT                 1          312
        104  INSERT                 1          313
        104  INSERT                 1          314
        104  INSERT                 1          315
       -104  BEGIN-RANGE            0          316
       -104  END-RANGE              6          321

--- 17 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  21                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 21;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 104 and 104 
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>-- ==================================================================
>>    obey TESTMV630(TEST4A);
>>-- ==================================================================
>>
>>-- 1. without EOF aftr range
>>
>>-- 17 rows -> buffers => end range falls on 1st row in following buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 504;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 508;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 512;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 523;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 501 and 522
+>       and a <> 504 and a <> 508 and a <> 512;

--- 19 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        105  INSERT                 1          501
        105  INSERT                 1          502
        105  INSERT                 1          503
        105  INSERT                 1          504
        105  INSERT                 1          505
        105  INSERT                 1          506
        105  INSERT                 1          507
        105  INSERT                 1          508
        105  INSERT                 1          509
        105  INSERT                 1          510
        105  INSERT                 1          511
        105  INSERT                 1          512
        105  INSERT                 1          513
        105  INSERT                 1          514
        105  INSERT                 1          515
        105  INSERT                 1          516
       -105  BEGIN-RANGE            0          517
       -105  END-RANGE              6          522
        105  INSERT                 1          523

--- 19 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  23                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 23;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 105 and 105 
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>
>>-- 2. with EOF after range
>>
>>-- 17 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 654;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 658;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 662;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 651 and 672
+>       and a <> 654 and a <> 658 and a <> 662;

--- 19 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        106  INSERT                 1          651
        106  INSERT                 1          652
        106  INSERT                 1          653
        106  INSERT                 1          654
        106  INSERT                 1          655
        106  INSERT                 1          656
        106  INSERT                 1          657
        106  INSERT                 1          658
        106  INSERT                 1          659
        106  INSERT                 1          660
        106  INSERT                 1          661
        106  INSERT                 1          662
        106  INSERT                 1          663
        106  INSERT                 1          664
        106  INSERT                 1          665
        106  INSERT                 1          666
       -106  BEGIN-RANGE            0          667
       -106  END-RANGE              6          672

--- 18 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  22                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 22;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 106 and 106 
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>-- ==================================================================
>>    obey TESTMV630(TEST5A);
>>-- ==================================================================
>>-- range size = 2 on buffer boundaries
>>
>>-- 1. without EOF after range
>>
>>-- 17 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 904;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 908;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 912;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 917;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 924;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 901 and 923 
+>       and a <> 904 and a <> 908 and a <> 912 and a <> 917;

--- 19 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        107  INSERT                 1          901
        107  INSERT                 1          902
        107  INSERT                 1          903
        107  INSERT                 1          904
        107  INSERT                 1          905
        107  INSERT                 1          906
        107  INSERT                 1          907
        107  INSERT                 1          908
        107  INSERT                 1          909
        107  INSERT                 1          910
        107  INSERT                 1          911
        107  INSERT                 1          912
        107  INSERT                 1          913
        107  INSERT                 1          914
        107  INSERT                 1          915
        107  INSERT                 1          916
        107  INSERT                 1          917
        107  INSERT                 1          918
        107  INSERT                 1          919
        107  INSERT                 1          920
        107  INSERT                 1          921
       -107  BEGIN-RANGE            0          922
       -107  END-RANGE              2          923
        107  INSERT                 1          924

--- 24 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  24                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 24;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 107 and 107 
+>	de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>
>>-- 2. with EOF after range
>>
>>-- 17 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 934;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 938;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 942;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 947;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 931 and 953 
+>       and a <> 934 and a <> 938 and a <> 942 and a <> 947;

--- 19 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        108  INSERT                 1          931
        108  INSERT                 1          932
        108  INSERT                 1          933
        108  INSERT                 1          934
        108  INSERT                 1          935
        108  INSERT                 1          936
        108  INSERT                 1          937
        108  INSERT                 1          938
        108  INSERT                 1          939
        108  INSERT                 1          940
        108  INSERT                 1          941
        108  INSERT                 1          942
        108  INSERT                 1          943
        108  INSERT                 1          944
        108  INSERT                 1          945
        108  INSERT                 1          946
        108  INSERT                 1          947
        108  INSERT                 1          948
        108  INSERT                 1          949
        108  INSERT                 1          950
        108  INSERT                 1          951
       -108  BEGIN-RANGE            0          952
       -108  END-RANGE              2          953

--- 23 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  23                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 23;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 108 and 108
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>-- ==================================================================
>>    obey TESTMV630(TEST6A);
>>-- ==================================================================
>>-- begin range on end of buffer
>>
>>-- 1. followed by Single insert
>>
>>-- 16 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1004;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1008;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1012;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1017;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1023;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 1001 and 1022
+>       and a <> 1004 and a <> 1008 and a <> 1012 and a <> 1017;

--- 18 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        109  INSERT                 1         1001
        109  INSERT                 1         1002
        109  INSERT                 1         1003
        109  INSERT                 1         1004
        109  INSERT                 1         1005
        109  INSERT                 1         1006
        109  INSERT                 1         1007
        109  INSERT                 1         1008
        109  INSERT                 1         1009
        109  INSERT                 1         1010
        109  INSERT                 1         1011
        109  INSERT                 1         1012
        109  INSERT                 1         1013
        109  INSERT                 1         1014
        109  INSERT                 1         1015
        109  INSERT                 1         1016
        109  INSERT                 1         1017
        109  INSERT                 1         1018
        109  INSERT                 1         1019
        109  INSERT                 1         1020
        109  INSERT                 1         1021
        109  INSERT                 1         1022
        109  INSERT                 1         1023

--- 23 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  23                     0                     0                     0

--- 1 row(s) selected.
>>set param ?size 23;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 109 and 109
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>
>>-- 2. followd by EOF
>>
>>-- 16 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1034;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1038;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1042;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1047;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 1031 and 1052
+>       and a <> 1034 and a <> 1038 and a <> 1042 and a <> 1047;

--- 18 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        110  INSERT                 1         1031
        110  INSERT                 1         1032
        110  INSERT                 1         1033
        110  INSERT                 1         1034
        110  INSERT                 1         1035
        110  INSERT                 1         1036
        110  INSERT                 1         1037
        110  INSERT                 1         1038
        110  INSERT                 1         1039
        110  INSERT                 1         1040
        110  INSERT                 1         1041
        110  INSERT                 1         1042
        110  INSERT                 1         1043
        110  INSERT                 1         1044
        110  INSERT                 1         1045
        110  INSERT                 1         1046
        110  INSERT                 1         1047
        110  INSERT                 1         1048
        110  INSERT                 1         1049
        110  INSERT                 1         1050
        110  INSERT                 1         1051
        110  INSERT                 1         1052

--- 22 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  22                     0                     0                     0

--- 1 row(s) selected.
>>set param ?size 22;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 110 and 110
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>-- ==================================================================
>>-- ==================================================================
>>-- ==================================================================
>>-- ==================================================================
>>-- ==================================================================
>>
>>-- ==================================================================
>>    obey TESTMV630(TEST7);
>>-- ==================================================================
>>-- for compare
>>PREPARE stat1 FROM 
+>    select b,
+>           count(*) as cnt,
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T4
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV7
+>    order by b;

--- SQL command prepared.
>>
>>
>>-- bulk insert
>>
>>insert into T_630_T4 select a, b, c, d from T_630_T3 where a <= 2000;

--- 2000 row(s) inserted.
>>
>>select "@EPOCH"
+>        , case "@OPERATION_TYPE" when 0 then 'INSERT' 
+>				 when 1 then 'DELETE' 
+>				 when 2 then 'I-UPDATE'
+>				 when 3 then 'D-UPDATE'
+>				 when 4 then 'END-RANGE'
+>				 when 12 then 'BEGIN-RANGE'
+>          end
+>	, "@RANGE_SIZE"
+>	, a
+> from table(iud_log_table T_630_T4)
+> order by a, syskey;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        101  INSERT                 1            1
        101  INSERT                 1            2
        101  INSERT                 1            3
        101  INSERT                 1            4
        101  INSERT                 1            5
       -101  BEGIN-RANGE            0            6
       -101  END-RANGE           1995         2000

--- 7 row(s) selected.
>>
>>select count("@OPERATION_TYPE") - 
+>            (select count("@OPERATION_TYPE")
+>             from table (iud_log_table T_630_T4)
+>             where "@OPERATION_TYPE" = 12)  as br_minus_er
+> from table (iud_log_table T_630_T4)
+> where "@OPERATION_TYPE" = 4;

BR_MINUS_ER         
--------------------

                   0

--- 1 row(s) selected.
>>
>>select sum("@RANGE_SIZE") - 2000 as range_size_minus_rows_inserted
+>    from table (iud_log_table T_630_T4);

RANGE_SIZE_MINUS_ROWS_INSERTED
------------------------------

                             0

--- 1 row(s) selected.
>>
>>
>>
>>refresh T_630_MV7 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV7
+>    from singledelta T_630_T4 between 101 and 101
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>
>>-- ==================================================================
>>
>>
>>	obey TESTMV630(CLEAN_UP);
>>-- ==================================================================
>>set schema catmvs.mvschm;

--- SQL operation complete.
>>
>>create MVGroup MVG1_630;

--- SQL operation complete.
>>ALTER MVGroup MVG1_630 ADD T_630_MV1 ,T_630_MV7;

--- SQL operation complete.
>>refresh MVGroup MVG1_630 cancel;

--- SQL operation complete.
>>
>>drop mv T_630_MV7;

--- SQL operation complete.
>>drop mv T_630_MV1;

--- SQL operation complete.
>>drop table T_630_T4;

--- SQL operation complete.
>>drop table T_630_T3;

--- SQL operation complete.
>>drop table T_630_T2;

--- SQL operation complete.
>>drop table T_630_T1;

--- SQL operation complete.
>>
>>drop mvgroup MVG1_630;

--- SQL operation complete.
>>
>>
>>set param ?schema_name 'MVSCHM';
>>
>>obey COMPARE_NUM_OF_OBJ;
>>-- expected 'EQUAL'
>>select 'EQUAL' as rel
+>from catmvs.mvschm.Num_Obj
+>where  SCHEMA_NAME = ?schema_name and 
+>       num_of_objects
+>	=
+>	(select count(objects.object_uid)  num_of_objcts
+>	from HP_DEFINITION_SCHEMA.objects objects,
+>    HP_SYSTEM_CATALOG.SYSTEM_SCHEMA.SCHEMATA SCHEMATA
+>    	where schemata.schema_uid = objects.schema_uid
+>   	and objects.OBJECT_NAME_SPACE <> 'CN'and ?schema_name =SCHEMA_NAME
+>	group by SCHEMA_NAME);

REL  
-----

EQUAL

--- 1 row(s) selected.
>>
>>drop table Num_Obj;

--- SQL operation complete.
>>
>>
>>	obey TESTMV630(SET_UP);
>>-- ==================================================================
>>set schema catmvs.mvschm;

--- SQL operation complete.
>>
>>create table Num_Obj(schema_name CHARACTER(50), num_of_objects int);

--- SQL operation complete.
>>ALTER TABLE Num_Obj attribute all mvs allowed;

--- SQL operation complete.
>>
>>set param ?schema_name 'MVSCHM';
>>obey INSERT_NUM_OF_OBJ;
>>insert into catmvs.mvschm.Num_Obj
+>select Substring(schemata.SCHEMA_NAME,1,20) as SCHEMA_NAME,
+>	count(objects.object_uid)  num_of_objcets
+>from HP_DEFINITION_SCHEMA.objects objects,
+>     HP_SYSTEM_CATALOG.SYSTEM_SCHEMA.SCHEMATA SCHEMATA
+>     where schemata.schema_uid = objects.schema_uid
+>     and objects.OBJECT_NAME_SPACE <> 'CN'and ?schema_name =SCHEMA_NAME
+>group by SCHEMA_NAME;

--- 1 row(s) inserted.
>>
>>
>>create table T_630_T1 ( a int      NOT NULL NOT DROPPABLE, 
+>                        b int      NOT NULL NOT DROPPABLE, 
+>                        c largeint NOT NULL NOT DROPPABLE, 
+>                        d char(1860),
+>                        PRIMARY KEY (a))
+>       store by primary key
+>	   location $$partition2$$
+>	   attribute automatic rangelog;

--- SQL operation complete.
>>ALTER TABLE T_630_T1 attribute all mvs allowed;

--- SQL operation complete.
>>
>>create table T_630_T2 ( a int      NOT NULL NOT DROPPABLE, 
+>                        b int      NOT NULL NOT DROPPABLE, 
+>                        c largeint NOT NULL NOT DROPPABLE, 
+>                        d char(1860),
+>                        PRIMARY KEY (a))
+>       store by primary key;

--- SQL operation complete.
>>ALTER TABLE T_630_T2 attribute all mvs allowed;

--- SQL operation complete.
>>
>>create table T_630_T3 ( a int      NOT NULL NOT DROPPABLE, 
+>                        b int      NOT NULL NOT DROPPABLE, 
+>                        c largeint NOT NULL NOT DROPPABLE, 
+>                        d char(1860),
+>                        PRIMARY KEY (a))
+>       store by primary key;

--- SQL operation complete.
>>ALTER TABLE T_630_T3 attribute all mvs allowed;

--- SQL operation complete.
>>
>>create table T_630_T4 ( a int      NOT NULL NOT DROPPABLE,
+>                        b int      NOT NULL NOT DROPPABLE,
+>                        c largeint NOT NULL NOT DROPPABLE,
+>                        d char(1860),
+>                        PRIMARY KEY (a))
+>       attribute automatic rangelog;

--- SQL operation complete.
>>ALTER TABLE T_630_T4 attribute all mvs allowed;

--- SQL operation complete.
>>
>>
>>insert into T_630_T2 values (   1, 10,  101,  'a' ),
+>                            (   2,  9,  120,  'b' ),
+>                            (   3,  8,  130,  'c' ),
+>                            (   4,  7,  400,  'd' ),
+>                            (   5,  6,  150,  'e' ),
+>                            (   6,  5,  100,  'f' ),
+>                            (   7,  4,  106,  'g' ),
+>                            (   8,  3,  122,  'h' ),
+>                            (   9,  2,  103,  'i' ),
+>                            (  10,  1,  115,  'j' );

--- 10 row(s) inserted.
>>
>>insert into T_630_T3 select        a,      b,      c, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 10,  b + 9,  c + 2, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 20,  b + 8,  c - 6, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 30,  b + 7,  c + 2, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 40,  b + 6,  c - 6, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 50,  b + 5,  c + 2, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 60,  b + 3,  c - 6, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 70,  b + 4,  c + 2, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 80,  b + 2,  c - 6, d from T_630_T2;

--- 10 row(s) inserted.
>>insert into T_630_T3 select   a + 90,  b + 1,  c + 2, d from T_630_T2;

--- 10 row(s) inserted.
>>
>>delete from T_630_T2;

--- 10 row(s) deleted.
>>
>>insert into T_630_T2 select        a,      b,      c, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 100,  b - 1,  c + 5, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 200,  b - 2,  c + 2, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 300,  b - 3,  c + 5, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 400,  b - 4,  c + 4, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 500,  b - 5,  c + 5, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 600,  b - 6,  c + 6, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 700,  b - 7,  c + 5, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 800,  b - 8,  c + 8, d from T_630_T3;

--- 100 row(s) inserted.
>>insert into T_630_T2 select  a + 900,  b - 9,  c + 5, d from T_630_T3;

--- 100 row(s) inserted.
>>
>>delete from T_630_T3;

--- 100 row(s) deleted.
>>
>>insert into T_630_T3 select         a,      b,      c, d from T_630_T2;

--- 1000 row(s) inserted.
>>insert into T_630_T3 select  a + 1000,  b + 7,  c - 1, d from T_630_T2;

--- 1000 row(s) inserted.
>>insert into T_630_T3 select  a + 2000,  b + 6,  c - 2, d from T_630_T2;

--- 1000 row(s) inserted.
>>insert into T_630_T3 select  a + 3000,  b + 5,  c - 1, d from T_630_T2;

--- 1000 row(s) inserted.
>>--insert into T_630_T3 select  a + 4000,  b + 6,  c - 4, d from T_630_T2;
>>--insert into T_630_T3 select  a + 5000,  b + 5,  c - 5, d from T_630_T2;
>>--insert into T_630_T3 select  a + 6000,  b + 4,  c - 6, d from T_630_T2;
>>--insert into T_630_T3 select  a + 7000,  b + 2,  c - 4, d from T_630_T2;
>>--insert into T_630_T3 select  a + 8000,  b + 4,  c - 2, d from T_630_T2;
>>--insert into T_630_T3 select  a + 9000,  b + 2,  c + 1, d from T_630_T2;
>>
>>create mv T_630_MV1 
+>    refresh on request
+>initialize on create
+>    as
+>        select b, 
+>               count(*) as cnt, 
+>               avg(c) as average,
+>               sum(a) as suma
+>        from T_630_T1
+>        group by b;

--- SQL operation complete.
>>ALTER MV T_630_MV1 attribute all mvs allowed;

--- SQL operation complete.
>>
>>create mv T_630_MV7
+>    refresh on request
+>initialize on create
+>    as
+>        select b,
+>               count(*) as cnt,
+>               avg(c) as average,
+>               sum(a) as suma
+>        from T_630_T4
+>        group by b;

--- SQL operation complete.
>>ALTER MV T_630_MV7 attribute all mvs allowed;

--- SQL operation complete.
>>
>>prepare select_iud_log from
+> select "@EPOCH"
+>        , case "@OPERATION_TYPE" when 0 then 'INSERT' 
+>				 when 1 then 'DELETE' 
+>				 when 2 then 'I-UPDATE'
+>				 when 3 then 'D-UPDATE'
+>				 when 4 then 'END-RANGE'
+>				 when 12 then 'BEGIN-RANGE'
+>          end
+>	, "@RANGE_SIZE"
+>	, a
+> from table(iud_log_table T_630_T1)
+> order by a, syskey;

--- SQL command prepared.
>>
>>prepare compare_BR_ER from
+>select sum("@RANGE_SIZE") as Num_OF_ROWS,
+>       (select count("@OPERATION_TYPE")
+>             from table (iud_log_table T_630_T1)
+>             where "@OPERATION_TYPE" =  4)  as NUM_OF_BR,
+>       (select count("@OPERATION_TYPE")
+>             from table (iud_log_table T_630_T1)
+>             where "@OPERATION_TYPE" = 12)  as NUM_OF_ER,
+>       (select sum(case when (("@OPERATION_TYPE" = 4) AND OFFSET("@OPERATION_TYPE", 1) = 12)
+>                        then 1 else 0 end) as ER_AFTER_BR
+>             from table(iud_log_table T_630_T1)
+>             sequence by syskey) as ER_AFTER_BR
+>  from table(iud_log_table T_630_T1);

--- SQL command prepared.
>>
>>--prepare compare_BR_ER from
>>-- select count("@OPERATION_TYPE") - 
>>--            (select count("@OPERATION_TYPE")
>>--             from table (iud_log_table T_630_T1)
>>--            where "@OPERATION_TYPE" = 12)  as br_minus_er
>>--from table (iud_log_table T_630_T1)
>>-- where "@OPERATION_TYPE" = 4;
>>
>>prepare check_range_size from 
+>    select sum("@RANGE_SIZE") - ?size
+>    from table (iud_log_table T_630_T1);

--- SQL command prepared.
>>
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>-- ==================================================================
>>	obey TESTMV630(ADD_INDEX);
>>-- ==================================================================
>>CREATE INDEX index1
+>  ON T_630_T1 (a asc, b desc);

--- SQL operation complete.
>>
>>CREATE INDEX index2
+> ON T_630_T2 (c , b );

--- SQL operation complete.
>>
>>CREATE INDEX index3
+>ON T_630_T3 (a asc, b desc);

--- SQL operation complete.
>>
>>CREATE INDEX index4
+>  ON T_630_T4 (a asc, b desc);

--- SQL operation complete.
>>
>>-- ==================================================================
>>
>>
>>	obey TESTMV630(TEST1A);
>>-- ==================================================================
>>-- range size < buffer size.
>>
>>-- 3 rows -> 1st buf, 8 rows -> 2nd buf. 
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 11;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a <= 10;

--- 10 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        101  INSERT                 1            1
        101  INSERT                 1            2
        101  INSERT                 1            3
       -101  BEGIN-RANGE            0            4
       -101  END-RANGE              7           10
        101  INSERT                 1           11

--- 6 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  11                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 11;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 101 and 101 
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>-- ==================================================================
>>    obey TESTMV630(CHECK_INDEX1);
>>-- ==================================================================
>>SELECT a,b FROM TABLE(INDEX_TABLE index1);

A            B          
-----------  -----------

          1           10
          2            9
          3            8
          4            7
          5            6
          6            5
          7            4
          8            3
          9            2
         10            1
         11           19

--- 11 row(s) selected.
>>
>>
>>-- ==================================================================
>>	obey TESTMV630(TEST2A);
>>-- ==================================================================
>>
>>-- 36 rows -> buffers
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 50;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 55;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 60;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 65;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 70;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 75;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 77;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 12 and 90 
+>       and a <> 50 and a <> 55 and a <> 60 and a <> 65 and a <> 70 and a <> 75 and a <> 77;

--- 72 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        102  INSERT                 1           12
        102  INSERT                 1           13
        102  INSERT                 1           14
        102  INSERT                 1           15
       -102  BEGIN-RANGE            0           16
       -102  END-RANGE             34           49
        102  INSERT                 1           50
        102  INSERT                 1           51
        102  INSERT                 1           52
        102  INSERT                 1           53
        102  INSERT                 1           54
        102  INSERT                 1           55
        102  INSERT                 1           56
        102  INSERT                 1           57
        102  INSERT                 1           58
        102  INSERT                 1           59
        102  INSERT                 1           60
        102  INSERT                 1           61
        102  INSERT                 1           62
        102  INSERT                 1           63
        102  INSERT                 1           64
        102  INSERT                 1           65
        102  INSERT                 1           66
        102  INSERT                 1           67
        102  INSERT                 1           68
        102  INSERT                 1           69
        102  INSERT                 1           70
        102  INSERT                 1           71
        102  INSERT                 1           72
        102  INSERT                 1           73
        102  INSERT                 1           74
        102  INSERT                 1           75
        102  INSERT                 1           76
        102  INSERT                 1           77
        102  INSERT                 1           78
        102  INSERT                 1           79
        102  INSERT                 1           80
        102  INSERT                 1           81
       -102  BEGIN-RANGE            0           82
       -102  END-RANGE              9           90

--- 40 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  79                     2                     2                     2

--- 1 row(s) selected.
>>set param ?size 79;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 102 and 102 
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>-- ==================================================================
>>	obey TESTMV630(CHECK_INDEX1);
>>-- ==================================================================
>>SELECT a,b FROM TABLE(INDEX_TABLE index1);

A            B          
-----------  -----------

          1           10
          2            9
          3            8
          4            7
          5            6
          6            5
          7            4
          8            3
          9            2
         10            1
         11           19
         12           18
         13           17
         14           16
         15           15
         16           14
         17           13
         18           12
         19           11
         20           10
         21           18
         22           17
         23           16
         24           15
         25           14
         26           13
         27           12
         28           11
         29           10
         30            9
         31           17
         32           16
         33           15
         34           14
         35           13
         36           12
         37           11
         38           10
         39            9
         40            8
         41           16
         42           15
         43           14
         44           13
         45           12
         46           11
         47           10
         48            9
         49            8
         50            7
         51           15
         52           14
         53           13
         54           12
         55           11
         56           10
         57            9
         58            8
         59            7
         60            6
         61           13
         62           12
         63           11
         64           10
         65            9
         66            8
         67            7
         68            6
         69            5
         70            4
         71           14
         72           13
         73           12
         74           11
         75           10
         76            9
         77            8
         78            7
         79            6
         80            5
         81           12
         82           11
         83           10
         84            9
         85            8
         86            7
         87            6
         88            5
         89            4
         90            3

--- 90 row(s) selected.
>>
>>
>>-- ==================================================================
>>    obey TESTMV630(TEST3A);
>>-- ==================================================================
>>
>>-- 1. without EOF after range
>>
>>-- 16 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 154;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 158;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 161;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 172;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 151 and 171 
+>       and a <> 154 and a <> 158 and a <> 161;

--- 18 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        103  INSERT                 1          151
        103  INSERT                 1          152
        103  INSERT                 1          153
        103  INSERT                 1          154
        103  INSERT                 1          155
        103  INSERT                 1          156
        103  INSERT                 1          157
        103  INSERT                 1          158
        103  INSERT                 1          159
        103  INSERT                 1          160
        103  INSERT                 1          161
        103  INSERT                 1          162
        103  INSERT                 1          163
        103  INSERT                 1          164
        103  INSERT                 1          165
       -103  BEGIN-RANGE            0          166
       -103  END-RANGE              6          171
        103  INSERT                 1          172

--- 18 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  22                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 22;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 103 and 103 
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>
>>-- 2. with EOF after range
>>
>>-- 16 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 304;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 308;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 311;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 301 and 321
+>       and a <> 304 and a <> 308 and a <> 311;

--- 18 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        104  INSERT                 1          301
        104  INSERT                 1          302
        104  INSERT                 1          303
        104  INSERT                 1          304
        104  INSERT                 1          305
        104  INSERT                 1          306
        104  INSERT                 1          307
        104  INSERT                 1          308
        104  INSERT                 1          309
        104  INSERT                 1          310
        104  INSERT                 1          311
        104  INSERT                 1          312
        104  INSERT                 1          313
        104  INSERT                 1          314
        104  INSERT                 1          315
       -104  BEGIN-RANGE            0          316
       -104  END-RANGE              6          321

--- 17 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  21                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 21;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 104 and 104 
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>-- ==================================================================
>>	obey TESTMV630(CHECK_INDEX1);
>>-- ==================================================================
>>SELECT a,b FROM TABLE(INDEX_TABLE index1);

A            B          
-----------  -----------

          1           10
          2            9
          3            8
          4            7
          5            6
          6            5
          7            4
          8            3
          9            2
         10            1
         11           19
         12           18
         13           17
         14           16
         15           15
         16           14
         17           13
         18           12
         19           11
         20           10
         21           18
         22           17
         23           16
         24           15
         25           14
         26           13
         27           12
         28           11
         29           10
         30            9
         31           17
         32           16
         33           15
         34           14
         35           13
         36           12
         37           11
         38           10
         39            9
         40            8
         41           16
         42           15
         43           14
         44           13
         45           12
         46           11
         47           10
         48            9
         49            8
         50            7
         51           15
         52           14
         53           13
         54           12
         55           11
         56           10
         57            9
         58            8
         59            7
         60            6
         61           13
         62           12
         63           11
         64           10
         65            9
         66            8
         67            7
         68            6
         69            5
         70            4
         71           14
         72           13
         73           12
         74           11
         75           10
         76            9
         77            8
         78            7
         79            6
         80            5
         81           12
         82           11
         83           10
         84            9
         85            8
         86            7
         87            6
         88            5
         89            4
         90            3
        151           14
        152           13
        153           12
        154           11
        155           10
        156            9
        157            8
        158            7
        159            6
        160            5
        161           12
        162           11
        163           10
        164            9
        165            8
        166            7
        167            6
        168            5
        169            4
        170            3
        171           13
        172           12
        301            7
        302            6
        303            5
        304            4
        305            3
        306            2
        307            1
        308            0
        309           -1
        310           -2
        311           16
        312           15
        313           14
        314           13
        315           12
        316           11
        317           10
        318            9
        319            8
        320            7
        321           15

--- 133 row(s) selected.
>>
>>
>>-- ==================================================================
>>    obey TESTMV630(TEST4A);
>>-- ==================================================================
>>
>>-- 1. without EOF aftr range
>>
>>-- 17 rows -> buffers => end range falls on 1st row in following buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 504;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 508;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 512;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 523;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 501 and 522
+>       and a <> 504 and a <> 508 and a <> 512;

--- 19 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        105  INSERT                 1          501
        105  INSERT                 1          502
        105  INSERT                 1          503
        105  INSERT                 1          504
        105  INSERT                 1          505
        105  INSERT                 1          506
        105  INSERT                 1          507
        105  INSERT                 1          508
        105  INSERT                 1          509
        105  INSERT                 1          510
        105  INSERT                 1          511
        105  INSERT                 1          512
        105  INSERT                 1          513
        105  INSERT                 1          514
        105  INSERT                 1          515
        105  INSERT                 1          516
       -105  BEGIN-RANGE            0          517
       -105  END-RANGE              6          522
        105  INSERT                 1          523

--- 19 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  23                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 23;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 105 and 105 
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>
>>-- 2. with EOF after range
>>
>>-- 17 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 654;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 658;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 662;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 651 and 672
+>       and a <> 654 and a <> 658 and a <> 662;

--- 19 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        106  INSERT                 1          651
        106  INSERT                 1          652
        106  INSERT                 1          653
        106  INSERT                 1          654
        106  INSERT                 1          655
        106  INSERT                 1          656
        106  INSERT                 1          657
        106  INSERT                 1          658
        106  INSERT                 1          659
        106  INSERT                 1          660
        106  INSERT                 1          661
        106  INSERT                 1          662
        106  INSERT                 1          663
        106  INSERT                 1          664
        106  INSERT                 1          665
        106  INSERT                 1          666
       -106  BEGIN-RANGE            0          667
       -106  END-RANGE              6          672

--- 18 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  22                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 22;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 106 and 106 
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>-- ==================================================================
>>	obey TESTMV630(CHECK_INDEX1);
>>-- ==================================================================
>>SELECT a,b FROM TABLE(INDEX_TABLE index1);

A            B          
-----------  -----------

          1           10
          2            9
          3            8
          4            7
          5            6
          6            5
          7            4
          8            3
          9            2
         10            1
         11           19
         12           18
         13           17
         14           16
         15           15
         16           14
         17           13
         18           12
         19           11
         20           10
         21           18
         22           17
         23           16
         24           15
         25           14
         26           13
         27           12
         28           11
         29           10
         30            9
         31           17
         32           16
         33           15
         34           14
         35           13
         36           12
         37           11
         38           10
         39            9
         40            8
         41           16
         42           15
         43           14
         44           13
         45           12
         46           11
         47           10
         48            9
         49            8
         50            7
         51           15
         52           14
         53           13
         54           12
         55           11
         56           10
         57            9
         58            8
         59            7
         60            6
         61           13
         62           12
         63           11
         64           10
         65            9
         66            8
         67            7
         68            6
         69            5
         70            4
         71           14
         72           13
         73           12
         74           11
         75           10
         76            9
         77            8
         78            7
         79            6
         80            5
         81           12
         82           11
         83           10
         84            9
         85            8
         86            7
         87            6
         88            5
         89            4
         90            3
        151           14
        152           13
        153           12
        154           11
        155           10
        156            9
        157            8
        158            7
        159            6
        160            5
        161           12
        162           11
        163           10
        164            9
        165            8
        166            7
        167            6
        168            5
        169            4
        170            3
        171           13
        172           12
        301            7
        302            6
        303            5
        304            4
        305            3
        306            2
        307            1
        308            0
        309           -1
        310           -2
        311           16
        312           15
        313           14
        314           13
        315           12
        316           11
        317           10
        318            9
        319            8
        320            7
        321           15
        501            5
        502            4
        503            3
        504            2
        505            1
        506            0
        507           -1
        508           -2
        509           -3
        510           -4
        511           14
        512           13
        513           12
        514           11
        515           10
        516            9
        517            8
        518            7
        519            6
        520            5
        521           13
        522           12
        523           11
        651            9
        652            8
        653            7
        654            6
        655            5
        656            4
        657            3
        658            2
        659            1
        660            0
        661            7
        662            6
        663            5
        664            4
        665            3
        666            2
        667            1
        668            0
        669           -1
        670           -2
        671            8
        672            7

--- 178 row(s) selected.
>>
>>
>>-- ==================================================================
>>    obey TESTMV630(TEST5A);
>>-- ==================================================================
>>-- range size = 2 on buffer boundaries
>>
>>-- 1. without EOF after range
>>
>>-- 17 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 904;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 908;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 912;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 917;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 924;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 901 and 923 
+>       and a <> 904 and a <> 908 and a <> 912 and a <> 917;

--- 19 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        107  INSERT                 1          901
        107  INSERT                 1          902
        107  INSERT                 1          903
        107  INSERT                 1          904
        107  INSERT                 1          905
        107  INSERT                 1          906
        107  INSERT                 1          907
        107  INSERT                 1          908
        107  INSERT                 1          909
        107  INSERT                 1          910
        107  INSERT                 1          911
        107  INSERT                 1          912
        107  INSERT                 1          913
        107  INSERT                 1          914
        107  INSERT                 1          915
        107  INSERT                 1          916
        107  INSERT                 1          917
        107  INSERT                 1          918
        107  INSERT                 1          919
        107  INSERT                 1          920
        107  INSERT                 1          921
       -107  BEGIN-RANGE            0          922
       -107  END-RANGE              2          923
        107  INSERT                 1          924

--- 24 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  24                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 24;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 107 and 107 
+>	de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>
>>-- 2. with EOF after range
>>
>>-- 17 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 934;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 938;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 942;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 947;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 931 and 953 
+>       and a <> 934 and a <> 938 and a <> 942 and a <> 947;

--- 19 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        108  INSERT                 1          931
        108  INSERT                 1          932
        108  INSERT                 1          933
        108  INSERT                 1          934
        108  INSERT                 1          935
        108  INSERT                 1          936
        108  INSERT                 1          937
        108  INSERT                 1          938
        108  INSERT                 1          939
        108  INSERT                 1          940
        108  INSERT                 1          941
        108  INSERT                 1          942
        108  INSERT                 1          943
        108  INSERT                 1          944
        108  INSERT                 1          945
        108  INSERT                 1          946
        108  INSERT                 1          947
        108  INSERT                 1          948
        108  INSERT                 1          949
        108  INSERT                 1          950
        108  INSERT                 1          951
       -108  BEGIN-RANGE            0          952
       -108  END-RANGE              2          953

--- 23 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  23                     1                     1                     1

--- 1 row(s) selected.
>>set param ?size 23;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 108 and 108
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>-- ==================================================================
>>	obey TESTMV630(CHECK_INDEX1);
>>-- ==================================================================
>>SELECT a,b FROM TABLE(INDEX_TABLE index1);

A            B          
-----------  -----------

          1           10
          2            9
          3            8
          4            7
          5            6
          6            5
          7            4
          8            3
          9            2
         10            1
         11           19
         12           18
         13           17
         14           16
         15           15
         16           14
         17           13
         18           12
         19           11
         20           10
         21           18
         22           17
         23           16
         24           15
         25           14
         26           13
         27           12
         28           11
         29           10
         30            9
         31           17
         32           16
         33           15
         34           14
         35           13
         36           12
         37           11
         38           10
         39            9
         40            8
         41           16
         42           15
         43           14
         44           13
         45           12
         46           11
         47           10
         48            9
         49            8
         50            7
         51           15
         52           14
         53           13
         54           12
         55           11
         56           10
         57            9
         58            8
         59            7
         60            6
         61           13
         62           12
         63           11
         64           10
         65            9
         66            8
         67            7
         68            6
         69            5
         70            4
         71           14
         72           13
         73           12
         74           11
         75           10
         76            9
         77            8
         78            7
         79            6
         80            5
         81           12
         82           11
         83           10
         84            9
         85            8
         86            7
         87            6
         88            5
         89            4
         90            3
        151           14
        152           13
        153           12
        154           11
        155           10
        156            9
        157            8
        158            7
        159            6
        160            5
        161           12
        162           11
        163           10
        164            9
        165            8
        166            7
        167            6
        168            5
        169            4
        170            3
        171           13
        172           12
        301            7
        302            6
        303            5
        304            4
        305            3
        306            2
        307            1
        308            0
        309           -1
        310           -2
        311           16
        312           15
        313           14
        314           13
        315           12
        316           11
        317           10
        318            9
        319            8
        320            7
        321           15
        501            5
        502            4
        503            3
        504            2
        505            1
        506            0
        507           -1
        508           -2
        509           -3
        510           -4
        511           14
        512           13
        513           12
        514           11
        515           10
        516            9
        517            8
        518            7
        519            6
        520            5
        521           13
        522           12
        523           11
        651            9
        652            8
        653            7
        654            6
        655            5
        656            4
        657            3
        658            2
        659            1
        660            0
        661            7
        662            6
        663            5
        664            4
        665            3
        666            2
        667            1
        668            0
        669           -1
        670           -2
        671            8
        672            7
        901            1
        902            0
        903           -1
        904           -2
        905           -3
        906           -4
        907           -5
        908           -6
        909           -7
        910           -8
        911           10
        912            9
        913            8
        914            7
        915            6
        916            5
        917            4
        918            3
        919            2
        920            1
        921            9
        922            8
        923            7
        924            6
        931            8
        932            7
        933            6
        934            5
        935            4
        936            3
        937            2
        938            1
        939            0
        940           -1
        941            7
        942            6
        943            5
        944            4
        945            3
        946            2
        947            1
        948            0
        949           -1
        950           -2
        951            6
        952            5
        953            4

--- 225 row(s) selected.
>>
>>
>>-- ==================================================================
>>    obey TESTMV630(TEST6A);
>>-- ==================================================================
>>-- begin range on end of buffer
>>
>>-- 1. followed by Single insert
>>
>>-- 16 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1004;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1008;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1012;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1017;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1023;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 1001 and 1022
+>       and a <> 1004 and a <> 1008 and a <> 1012 and a <> 1017;

--- 18 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        109  INSERT                 1         1001
        109  INSERT                 1         1002
        109  INSERT                 1         1003
        109  INSERT                 1         1004
        109  INSERT                 1         1005
        109  INSERT                 1         1006
        109  INSERT                 1         1007
        109  INSERT                 1         1008
        109  INSERT                 1         1009
        109  INSERT                 1         1010
        109  INSERT                 1         1011
        109  INSERT                 1         1012
        109  INSERT                 1         1013
        109  INSERT                 1         1014
        109  INSERT                 1         1015
        109  INSERT                 1         1016
        109  INSERT                 1         1017
        109  INSERT                 1         1018
        109  INSERT                 1         1019
        109  INSERT                 1         1020
        109  INSERT                 1         1021
        109  INSERT                 1         1022
        109  INSERT                 1         1023

--- 23 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  23                     0                     0                     0

--- 1 row(s) selected.
>>set param ?size 23;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 109 and 109
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>
>>-- 2. followd by EOF
>>
>>-- 16 rows -> buffer
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1034;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1038;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1042;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a = 1047;

--- 1 row(s) inserted.
>>insert into T_630_T1 select a, b, c, d from T_630_T3 where a between 1031 and 1052
+>       and a <> 1034 and a <> 1038 and a <> 1042 and a <> 1047;

--- 18 row(s) inserted.
>>
>>execute select_iud_log;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        110  INSERT                 1         1031
        110  INSERT                 1         1032
        110  INSERT                 1         1033
        110  INSERT                 1         1034
        110  INSERT                 1         1035
        110  INSERT                 1         1036
        110  INSERT                 1         1037
        110  INSERT                 1         1038
        110  INSERT                 1         1039
        110  INSERT                 1         1040
        110  INSERT                 1         1041
        110  INSERT                 1         1042
        110  INSERT                 1         1043
        110  INSERT                 1         1044
        110  INSERT                 1         1045
        110  INSERT                 1         1046
        110  INSERT                 1         1047
        110  INSERT                 1         1048
        110  INSERT                 1         1049
        110  INSERT                 1         1050
        110  INSERT                 1         1051
        110  INSERT                 1         1052

--- 22 row(s) selected.
>>execute compare_BR_ER;

NUM_OF_ROWS           NUM_OF_BR             NUM_OF_ER             ER_AFTER_BR
--------------------  --------------------  --------------------  --------------------

                  22                     0                     0                     0

--- 1 row(s) selected.
>>set param ?size 22;
>>execute check_range_size;

(EXPR)              
--------------------

                   0

--- 1 row(s) selected.
>>
>>refresh T_630_MV1 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV1
+>    from singledelta T_630_T1 between 110 and 110
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>-- for compare
>>PREPARE stat1 FROM
+>    select b, 
+>           count(*) as cnt, 
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T1
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV1
+>    order by b;

--- SQL command prepared.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>-- ==================================================================
>>-- ==================================================================
>>-- ==================================================================
>>-- ==================================================================
>>-- ==================================================================
>>
>>-- ==================================================================
>>	obey TESTMV630(CHECK_INDEX1);
>>-- ==================================================================
>>SELECT a,b FROM TABLE(INDEX_TABLE index1);

A            B          
-----------  -----------

          1           10
          2            9
          3            8
          4            7
          5            6
          6            5
          7            4
          8            3
          9            2
         10            1
         11           19
         12           18
         13           17
         14           16
         15           15
         16           14
         17           13
         18           12
         19           11
         20           10
         21           18
         22           17
         23           16
         24           15
         25           14
         26           13
         27           12
         28           11
         29           10
         30            9
         31           17
         32           16
         33           15
         34           14
         35           13
         36           12
         37           11
         38           10
         39            9
         40            8
         41           16
         42           15
         43           14
         44           13
         45           12
         46           11
         47           10
         48            9
         49            8
         50            7
         51           15
         52           14
         53           13
         54           12
         55           11
         56           10
         57            9
         58            8
         59            7
         60            6
         61           13
         62           12
         63           11
         64           10
         65            9
         66            8
         67            7
         68            6
         69            5
         70            4
         71           14
         72           13
         73           12
         74           11
         75           10
         76            9
         77            8
         78            7
         79            6
         80            5
         81           12
         82           11
         83           10
         84            9
         85            8
         86            7
         87            6
         88            5
         89            4
         90            3
        151           14
        152           13
        153           12
        154           11
        155           10
        156            9
        157            8
        158            7
        159            6
        160            5
        161           12
        162           11
        163           10
        164            9
        165            8
        166            7
        167            6
        168            5
        169            4
        170            3
        171           13
        172           12
        301            7
        302            6
        303            5
        304            4
        305            3
        306            2
        307            1
        308            0
        309           -1
        310           -2
        311           16
        312           15
        313           14
        314           13
        315           12
        316           11
        317           10
        318            9
        319            8
        320            7
        321           15
        501            5
        502            4
        503            3
        504            2
        505            1
        506            0
        507           -1
        508           -2
        509           -3
        510           -4
        511           14
        512           13
        513           12
        514           11
        515           10
        516            9
        517            8
        518            7
        519            6
        520            5
        521           13
        522           12
        523           11
        651            9
        652            8
        653            7
        654            6
        655            5
        656            4
        657            3
        658            2
        659            1
        660            0
        661            7
        662            6
        663            5
        664            4
        665            3
        666            2
        667            1
        668            0
        669           -1
        670           -2
        671            8
        672            7
        901            1
        902            0
        903           -1
        904           -2
        905           -3
        906           -4
        907           -5
        908           -6
        909           -7
        910           -8
        911           10
        912            9
        913            8
        914            7
        915            6
        916            5
        917            4
        918            3
        919            2
        920            1
        921            9
        922            8
        923            7
        924            6
        931            8
        932            7
        933            6
        934            5
        935            4
        936            3
        937            2
        938            1
        939            0
        940           -1
        941            7
        942            6
        943            5
        944            4
        945            3
        946            2
        947            1
        948            0
        949           -1
        950           -2
        951            6
        952            5
        953            4
       1001           17
       1002           16
       1003           15
       1004           14
       1005           13
       1006           12
       1007           11
       1008           10
       1009            9
       1010            8
       1011           26
       1012           25
       1013           24
       1014           23
       1015           22
       1016           21
       1017           20
       1018           19
       1019           18
       1020           17
       1021           25
       1022           24
       1023           23
       1031           24
       1032           23
       1033           22
       1034           21
       1035           20
       1036           19
       1037           18
       1038           17
       1039           16
       1040           15
       1041           23
       1042           22
       1043           21
       1044           20
       1045           19
       1046           18
       1047           17
       1048           16
       1049           15
       1050           14
       1051           22
       1052           21

--- 270 row(s) selected.
>>
>>
>>-- ==================================================================
>>    obey TESTMV630(TEST7);
>>-- ==================================================================
>>-- for compare
>>PREPARE stat1 FROM 
+>    select b,
+>           count(*) as cnt,
+>           avg(c) as average,
+>           sum(a) as suma
+>    from T_630_T4
+>    group by b
+>    order by b;

--- SQL command prepared.
>>
>>PREPARE stat2 FROM
+>    select b, cnt, average, suma
+>    from T_630_MV7
+>    order by b;

--- SQL command prepared.
>>
>>
>>-- bulk insert
>>
>>insert into T_630_T4 select a, b, c, d from T_630_T3 where a <= 2000;

--- 2000 row(s) inserted.
>>
>>select "@EPOCH"
+>        , case "@OPERATION_TYPE" when 0 then 'INSERT' 
+>				 when 1 then 'DELETE' 
+>				 when 2 then 'I-UPDATE'
+>				 when 3 then 'D-UPDATE'
+>				 when 4 then 'END-RANGE'
+>				 when 12 then 'BEGIN-RANGE'
+>          end
+>	, "@RANGE_SIZE"
+>	, a
+> from table(iud_log_table T_630_T4)
+> order by a, syskey;

@EPOCH       (EXPR)       @RANGE_SIZE  A          
-----------  -----------  -----------  -----------

        101  INSERT                 1            1
        101  INSERT                 1            2
        101  INSERT                 1            3
        101  INSERT                 1            4
        101  INSERT                 1            5
       -101  BEGIN-RANGE            0            6
       -101  END-RANGE           1995         2000

--- 7 row(s) selected.
>>
>>select count("@OPERATION_TYPE") - 
+>            (select count("@OPERATION_TYPE")
+>             from table (iud_log_table T_630_T4)
+>             where "@OPERATION_TYPE" = 12)  as br_minus_er
+> from table (iud_log_table T_630_T4)
+> where "@OPERATION_TYPE" = 4;

BR_MINUS_ER         
--------------------

                   0

--- 1 row(s) selected.
>>
>>select sum("@RANGE_SIZE") - 2000 as range_size_minus_rows_inserted
+>    from table (iud_log_table T_630_T4);

RANGE_SIZE_MINUS_ROWS_INSERTED
------------------------------

                             0

--- 1 row(s) selected.
>>
>>
>>
>>refresh T_630_MV7 debug 130;

*** ERROR[20526] Refresh completed with errors. See REFRESH.LOG for description.

--- SQL operation failed with errors.
>>internal refresh T_630_MV7
+>    from singledelta T_630_T4 between 101 and 101
+>        de level 2 use rangelog 20 NUM_OF_RANGES
+>        use iudlog 10 rows_inserted 10 rows_deleted 10 rows_updated;

--- SQL operation complete.
>>
>>log;
1,2c1,2
< >>  log TEMP1;
< >>  execute stat1;
---
> >>  log TEMP2;
> >>  execute stat2;
>>
>>
>>
>>-- ==================================================================
>>
>>	obey TESTMV630(CHECK_INDEX4);
>>-- ==================================================================
>>SELECT a,b FROM TABLE(INDEX_TABLE index4);

A            B          
-----------  -----------

          1           10
          2            9
          3            8
          4            7
          5            6
          6            5
          7            4
          8            3
          9            2
         10            1
         11           19
         12           18
         13           17
         14           16
         15           15
         16           14
         17           13
         18           12
         19           11
         20           10
         21           18
         22           17
         23           16
         24           15
         25           14
         26           13
         27           12
         28           11
         29           10
         30            9
         31           17
         32           16
         33           15
         34           14
         35           13
         36           12
         37           11
         38           10
         39            9
         40            8
         41           16
         42           15
         43           14
         44           13
         45           12
         46           11
         47           10
         48            9
         49            8
         50            7
         51           15
         52           14
         53           13
         54           12
         55           11
         56           10
         57            9
         58            8
         59            7
         60            6
         61           13
         62           12
         63           11
         64           10
         65            9
         66            8
         67            7
         68            6
         69            5
         70            4
         71           14
         72           13
         73           12
         74           11
         75           10
         76            9
         77            8
         78            7
         79            6
         80            5
         81           12
         82           11
         83           10
         84            9
         85            8
         86            7
         87            6
         88            5
         89            4
         90            3
         91           11
         92           10
         93            9
         94            8
         95            7
         96            6
         97            5
         98            4
         99            3
        100            2
        101            9
        102            8
        103            7
        104            6
        105            5
        106            4
        107            3
        108            2
        109            1
        110            0
        111           18
        112           17
        113           16
        114           15
        115           14
        116           13
        117           12
        118           11
        119           10
        120            9
        121           17
        122           16
        123           15
        124           14
        125           13
        126           12
        127           11
        128           10
        129            9
        130            8
        131           16
        132           15
        133           14
        134           13
        135           12
        136           11
        137           10
        138            9
        139            8
        140            7
        141           15
        142           14
        143           13
        144           12
        145           11
        146           10
        147            9
        148            8
        149            7
        150            6
        151           14
        152           13
        153           12
        154           11
        155           10
        156            9
        157            8
        158            7
        159            6
        160            5
        161           12
        162           11
        163           10
        164            9
        165            8
        166            7
        167            6
        168            5
        169            4
        170            3
        171           13
        172           12
        173           11
        174           10
        175            9
        176            8
        177            7
        178            6
        179            5
        180            4
        181           11
        182           10
        183            9
        184            8
        185            7
        186            6
        187            5
        188            4
        189            3
        190            2
        191           10
        192            9
        193            8
        194            7
        195            6
        196            5
        197            4
        198            3
        199            2
        200            1
        201            8
        202            7
        203            6
        204            5
        205            4
        206            3
        207            2
        208            1
        209            0
        210           -1
        211           17
        212           16
        213           15
        214           14
        215           13
        216           12
        217           11
        218           10
        219            9
        220            8
        221           16
        222           15
        223           14
        224           13
        225           12
        226           11
        227           10
        228            9
        229            8
        230            7
        231           15
        232           14
        233           13
        234           12
        235           11
        236           10
        237            9
        238            8
        239            7
        240            6
        241           14
        242           13
        243           12
        244           11
        245           10
        246            9
        247            8
        248            7
        249            6
        250            5
        251           13
        252           12
        253           11
        254           10
        255            9
        256            8
        257            7
        258            6
        259            5
        260            4
        261           11
        262           10
        263            9
        264            8
        265            7
        266            6
        267            5
        268            4
        269            3
        270            2
        271           12
        272           11
        273           10
        274            9
        275            8
        276            7
        277            6
        278            5
        279            4
        280            3
        281           10
        282            9
        283            8
        284            7
        285            6
        286            5
        287            4
        288            3
        289            2
        290            1
        291            9
        292            8
        293            7
        294            6
        295            5
        296            4
        297            3
        298            2
        299            1
        300            0
        301            7
        302            6
        303            5
        304            4
        305            3
        306            2
        307            1
        308            0
        309           -1
        310           -2
        311           16
        312           15
        313           14
        314           13
        315           12
        316           11
        317           10
        318            9
        319            8
        320            7
        321           15
        322           14
        323           13
        324           12
        325           11
        326           10
        327            9
        328            8
        329            7
        330            6
        331           14
        332           13
        333           12
        334           11
        335           10
        336            9
        337            8
        338            7
        339            6
        340            5
        341           13
        342           12
        343           11
        344           10
        345            9
        346            8
        347            7
        348            6
        349            5
        350            4
        351           12
        352           11
        353           10
        354            9
        355            8
        356            7
        357            6
        358            5
        359            4
        360            3
        361           10
        362            9
        363            8
        364            7
        365            6
        366            5
        367            4
        368            3
        369            2
        370            1
        371           11
        372           10
        373            9
        374            8
        375            7
        376            6
        377            5
        378            4
        379            3
        380            2
        381            9
        382            8
        383            7
        384            6
        385            5
        386            4
        387            3
        388            2
        389            1
        390            0
        391            8
        392            7
        393            6
        394            5
        395            4
        396            3
        397            2
        398            1
        399            0
        400           -1
        401            6
        402            5
        403            4
        404            3
        405            2
        406            1
        407            0
        408           -1
        409           -2
        410           -3
        411           15
        412           14
        413           13
        414           12
        415           11
        416           10
        417            9
        418            8
        419            7
        420            6
        421           14
        422           13
        423           12
        424           11
        425           10
        426            9
        427            8
        428            7
        429            6
        430            5
        431           13
        432           12
        433           11
        434           10
        435            9
        436            8
        437            7
        438            6
        439            5
        440            4
        441           12
        442           11
        443           10
        444            9
        445            8
        446            7
        447            6
        448            5
        449            4
        450            3
        451           11
        452           10
        453            9
        454            8
        455            7
        456            6
        457            5
        458            4
        459            3
        460            2
        461            9
        462            8
        463            7
        464            6
        465            5
        466            4
        467            3
        468            2
        469            1
        470            0
        471           10
        472            9
        473            8
        474            7
        475            6
        476            5
        477            4
        478            3
        479            2
        480            1
        481            8
        482            7
        483            6
        484            5
        485            4
        486            3
        487            2
        488            1
        489            0
        490           -1
        491            7
        492            6
        493            5
        494            4
        495            3
        496            2
        497            1
        498            0
        499           -1
        500           -2
        501            5
        502            4
        503            3
        504            2
        505            1
        506            0
        507           -1
        508           -2
        509           -3
        510           -4
        511           14
        512           13
        513           12
        514           11
        515           10
        516            9
        517            8
        518            7
        519            6
        520            5
        521           13
        522           12
        523           11
        524           10
        525            9
        526            8
        527            7
        528            6
        529            5
        530            4
        531           12
        532           11
        533           10
        534            9
        535            8
        536            7
        537            6
        538            5
        539            4
        540            3
        541           11
        542           10
        543            9
        544            8
        545            7
        546            6
        547            5
        548            4
        549            3
        550            2
        551           10
        552            9
        553            8
        554            7
        555            6
        556            5
        557            4
        558            3
        559            2
        560            1
        561            8
        562            7
        563            6
        564            5
        565            4
        566            3
        567            2
        568            1
        569            0
        570           -1
        571            9
        572            8
        573            7
        574            6
        575            5
        576            4
        577            3
        578            2
        579            1
        580            0
        581            7
        582            6
        583            5
        584            4
        585            3
        586            2
        587            1
        588            0
        589           -1
        590           -2
        591            6
        592            5
        593            4
        594            3
        595            2
        596            1
        597            0
        598           -1
        599           -2
        600           -3
        601            4
        602            3
        603            2
        604            1
        605            0
        606           -1
        607           -2
        608           -3
        609           -4
        610           -5
        611           13
        612           12
        613           11
        614           10
        615            9
        616            8
        617            7
        618            6
        619            5
        620            4
        621           12
        622           11
        623           10
        624            9
        625            8
        626            7
        627            6
        628            5
        629            4
        630            3
        631           11
        632           10
        633            9
        634            8
        635            7
        636            6
        637            5
        638            4
        639            3
        640            2
        641           10
        642            9
        643            8
        644            7
        645            6
        646            5
        647            4
        648            3
        649            2
        650            1
        651            9
        652            8
        653            7
        654            6
        655            5
        656            4
        657            3
        658            2
        659            1
        660            0
        661            7
        662            6
        663            5
        664            4
        665            3
        666            2
        667            1
        668            0
        669           -1
        670           -2
        671            8
        672            7
        673            6
        674            5
        675            4
        676            3
        677            2
        678            1
        679            0
        680           -1
        681            6
        682            5
        683            4
        684            3
        685            2
        686            1
        687            0
        688           -1
        689           -2
        690           -3
        691            5
        692            4
        693            3
        694            2
        695            1
        696            0
        697           -1
        698           -2
        699           -3
        700           -4
        701            3
        702            2
        703            1
        704            0
        705           -1
        706           -2
        707           -3
        708           -4
        709           -5
        710           -6
        711           12
        712           11
        713           10
        714            9
        715            8
        716            7
        717            6
        718            5
        719            4
        720            3
        721           11
        722           10
        723            9
        724            8
        725            7
        726            6
        727            5
        728            4
        729            3
        730            2
        731           10
        732            9
        733            8
        734            7
        735            6
        736            5
        737            4
        738            3
        739            2
        740            1
        741            9
        742            8
        743            7
        744            6
        745            5
        746            4
        747            3
        748            2
        749            1
        750            0
        751            8
        752            7
        753            6
        754            5
        755            4
        756            3
        757            2
        758            1
        759            0
        760           -1
        761            6
        762            5
        763            4
        764            3
        765            2
        766            1
        767            0
        768           -1
        769           -2
        770           -3
        771            7
        772            6
        773            5
        774            4
        775            3
        776            2
        777            1
        778            0
        779           -1
        780           -2
        781            5
        782            4
        783            3
        784            2
        785            1
        786            0
        787           -1
        788           -2
        789           -3
        790           -4
        791            4
        792            3
        793            2
        794            1
        795            0
        796           -1
        797           -2
        798           -3
        799           -4
        800           -5
        801            2
        802            1
        803            0
        804           -1
        805           -2
        806           -3
        807           -4
        808           -5
        809           -6
        810           -7
        811           11
        812           10
        813            9
        814            8
        815            7
        816            6
        817            5
        818            4
        819            3
        820            2
        821           10
        822            9
        823            8
        824            7
        825            6
        826            5
        827            4
        828            3
        829            2
        830            1
        831            9
        832            8
        833            7
        834            6
        835            5
        836            4
        837            3
        838            2
        839            1
        840            0
        841            8
        842            7
        843            6
        844            5
        845            4
        846            3
        847            2
        848            1
        849            0
        850           -1
        851            7
        852            6
        853            5
        854            4
        855            3
        856            2
        857            1
        858            0
        859           -1
        860           -2
        861            5
        862            4
        863            3
        864            2
        865            1
        866            0
        867           -1
        868           -2
        869           -3
        870           -4
        871            6
        872            5
        873            4
        874            3
        875            2
        876            1
        877            0
        878           -1
        879           -2
        880           -3
        881            4
        882            3
        883            2
        884            1
        885            0
        886           -1
        887           -2
        888           -3
        889           -4
        890           -5
        891            3
        892            2
        893            1
        894            0
        895           -1
        896           -2
        897           -3
        898           -4
        899           -5
        900           -6
        901            1
        902            0
        903           -1
        904           -2
        905           -3
        906           -4
        907           -5
        908           -6
        909           -7
        910           -8
        911           10
        912            9
        913            8
        914            7
        915            6
        916            5
        917            4
        918            3
        919            2
        920            1
        921            9
        922            8
        923            7
        924            6
        925            5
        926            4
        927            3
        928            2
        929            1
        930            0
        931            8
        932            7
        933            6
        934            5
        935            4
        936            3
        937            2
        938            1
        939            0
        940           -1
        941            7
        942            6
        943            5
        944            4
        945            3
        946            2
        947            1
        948            0
        949           -1
        950           -2
        951            6
        952            5
        953            4
        954            3
        955            2
        956            1
        957            0
        958           -1
        959           -2
        960           -3
        961            4
        962            3
        963            2
        964            1
        965            0
        966           -1
        967           -2
        968           -3
        969           -4
        970           -5
        971            5
        972            4
        973            3
        974            2
        975            1
        976            0
        977           -1
        978           -2
        979           -3
        980           -4
        981            3
        982            2
        983            1
        984            0
        985           -1
        986           -2
        987           -3
        988           -4
        989           -5
        990           -6
        991            2
        992            1
        993            0
        994           -1
        995           -2
        996           -3
        997           -4
        998           -5
        999           -6
       1000           -7
       1001           17
       1002           16
       1003           15
       1004           14
       1005           13
       1006           12
       1007           11
       1008           10
       1009            9
       1010            8
       1011           26
       1012           25
       1013           24
       1014           23
       1015           22
       1016           21
       1017           20
       1018           19
       1019           18
       1020           17
       1021           25
       1022           24
       1023           23
       1024           22
       1025           21
       1026           20
       1027           19
       1028           18
       1029           17
       1030           16
       1031           24
       1032           23
       1033           22
       1034           21
       1035           20
       1036           19
       1037           18
       1038           17
       1039           16
       1040           15
       1041           23
       1042           22
       1043           21
       1044           20
       1045           19
       1046           18
       1047           17
       1048           16
       1049           15
       1050           14
       1051           22
       1052           21
       1053           20
       1054           19
       1055           18
       1056           17
       1057           16
       1058           15
       1059           14
       1060           13
       1061           20
       1062           19
       1063           18
       1064           17
       1065           16
       1066           15
       1067           14
       1068           13
       1069           12
       1070           11
       1071           21
       1072           20
       1073           19
       1074           18
       1075           17
       1076           16
       1077           15
       1078           14
       1079           13
       1080           12
       1081           19
       1082           18
       1083           17
       1084           16
       1085           15
       1086           14
       1087           13
       1088           12
       1089           11
       1090           10
       1091           18
       1092           17
       1093           16
       1094           15
       1095           14
       1096           13
       1097           12
       1098           11
       1099           10
       1100            9
       1101           16
       1102           15
       1103           14
       1104           13
       1105           12
       1106           11
       1107           10
       1108            9
       1109            8
       1110            7
       1111           25
       1112           24
       1113           23
       1114           22
       1115           21
       1116           20
       1117           19
       1118           18
       1119           17
       1120           16
       1121           24
       1122           23
       1123           22
       1124           21
       1125           20
       1126           19
       1127           18
       1128           17
       1129           16
       1130           15
       1131           23
       1132           22
       1133           21
       1134           20
       1135           19
       1136           18
       1137           17
       1138           16
       1139           15
       1140           14
       1141           22
       1142           21
       1143           20
       1144           19
       1145           18
       1146           17
       1147           16
       1148           15
       1149           14
       1150           13
       1151           21
       1152           20
       1153           19
       1154           18
       1155           17
       1156           16
       1157           15
       1158           14
       1159           13
       1160           12
       1161           19
       1162           18
       1163           17
       1164           16
       1165           15
       1166           14
       1167           13
       1168           12
       1169           11
       1170           10
       1171           20
       1172           19
       1173           18
       1174           17
       1175           16
       1176           15
       1177           14
       1178           13
       1179           12
       1180           11
       1181           18
       1182           17
       1183           16
       1184           15
       1185           14
       1186           13
       1187           12
       1188           11
       1189           10
       1190            9
       1191           17
       1192           16
       1193           15
       1194           14
       1195           13
       1196           12
       1197           11
       1198           10
       1199            9
       1200            8
       1201           15
       1202           14
       1203           13
       1204           12
       1205           11
       1206           10
       1207            9
       1208            8
       1209            7
       1210            6
       1211           24
       1212           23
       1213           22
       1214           21
       1215           20
       1216           19
       1217           18
       1218           17
       1219           16
       1220           15
       1221           23
       1222           22
       1223           21
       1224           20
       1225           19
       1226           18
       1227           17
       1228           16
       1229           15
       1230           14
       1231           22
       1232           21
       1233           20
       1234           19
       1235           18
       1236           17
       1237           16
       1238           15
       1239           14
       1240           13
       1241           21
       1242           20
       1243           19
       1244           18
       1245           17
       1246           16
       1247           15
       1248           14
       1249           13
       1250           12
       1251           20
       1252           19
       1253           18
       1254           17
       1255           16
       1256           15
       1257           14
       1258           13
       1259           12
       1260           11
       1261           18
       1262           17
       1263           16
       1264           15
       1265           14
       1266           13
       1267           12
       1268           11
       1269           10
       1270            9
       1271           19
       1272           18
       1273           17
       1274           16
       1275           15
       1276           14
       1277           13
       1278           12
       1279           11
       1280           10
       1281           17
       1282           16
       1283           15
       1284           14
       1285           13
       1286           12
       1287           11
       1288           10
       1289            9
       1290            8
       1291           16
       1292           15
       1293           14
       1294           13
       1295           12
       1296           11
       1297           10
       1298            9
       1299            8
       1300            7
       1301           14
       1302           13
       1303           12
       1304           11
       1305           10
       1306            9
       1307            8
       1308            7
       1309            6
       1310            5
       1311           23
       1312           22
       1313           21
       1314           20
       1315           19
       1316           18
       1317           17
       1318           16
       1319           15
       1320           14
       1321           22
       1322           21
       1323           20
       1324           19
       1325           18
       1326           17
       1327           16
       1328           15
       1329           14
       1330           13
       1331           21
       1332           20
       1333           19
       1334           18
       1335           17
       1336           16
       1337           15
       1338           14
       1339           13
       1340           12
       1341           20
       1342           19
       1343           18
       1344           17
       1345           16
       1346           15
       1347           14
       1348           13
       1349           12
       1350           11
       1351           19
       1352           18
       1353           17
       1354           16
       1355           15
       1356           14
       1357           13
       1358           12
       1359           11
       1360           10
       1361           17
       1362           16
       1363           15
       1364           14
       1365           13
       1366           12
       1367           11
       1368           10
       1369            9
       1370            8
       1371           18
       1372           17
       1373           16
       1374           15
       1375           14
       1376           13
       1377           12
       1378           11
       1379           10
       1380            9
       1381           16
       1382           15
       1383           14
       1384           13
       1385           12
       1386           11
       1387           10
       1388            9
       1389            8
       1390            7
       1391           15
       1392           14
       1393           13
       1394           12
       1395           11
       1396           10
       1397            9
       1398            8
       1399            7
       1400            6
       1401           13
       1402           12
       1403           11
       1404           10
       1405            9
       1406            8
       1407            7
       1408            6
       1409            5
       1410            4
       1411           22
       1412           21
       1413           20
       1414           19
       1415           18
       1416           17
       1417           16
       1418           15
       1419           14
       1420           13
       1421           21
       1422           20
       1423           19
       1424           18
       1425           17
       1426           16
       1427           15
       1428           14
       1429           13
       1430           12
       1431           20
       1432           19
       1433           18
       1434           17
       1435           16
       1436           15
       1437           14
       1438           13
       1439           12
       1440           11
       1441           19
       1442           18
       1443           17
       1444           16
       1445           15
       1446           14
       1447           13
       1448           12
       1449           11
       1450           10
       1451           18
       1452           17
       1453           16
       1454           15
       1455           14
       1456           13
       1457           12
       1458           11
       1459           10
       1460            9
       1461           16
       1462           15
       1463           14
       1464           13
       1465           12
       1466           11
       1467           10
       1468            9
       1469            8
       1470            7
       1471           17
       1472           16
       1473           15
       1474           14
       1475           13
       1476           12
       1477           11
       1478           10
       1479            9
       1480            8
       1481           15
       1482           14
       1483           13
       1484           12
       1485           11
       1486           10
       1487            9
       1488            8
       1489            7
       1490            6
       1491           14
       1492           13
       1493           12
       1494           11
       1495           10
       1496            9
       1497            8
       1498            7
       1499            6
       1500            5
       1501           12
       1502           11
       1503           10
       1504            9
       1505            8
       1506            7
       1507            6
       1508            5
       1509            4
       1510            3
       1511           21
       1512           20
       1513           19
       1514           18
       1515           17
       1516           16
       1517           15
       1518           14
       1519           13
       1520           12
       1521           20
       1522           19
       1523           18
       1524           17
       1525           16
       1526           15
       1527           14
       1528           13
       1529           12
       1530           11
       1531           19
       1532           18
       1533           17
       1534           16
       1535           15
       1536           14
       1537           13
       1538           12
       1539           11
       1540           10
       1541           18
       1542           17
       1543           16
       1544           15
       1545           14
       1546           13
       1547           12
       1548           11
       1549           10
       1550            9
       1551           17
       1552           16
       1553           15
       1554           14
       1555           13
       1556           12
       1557           11
       1558           10
       1559            9
       1560            8
       1561           15
       1562           14
       1563           13
       1564           12
       1565           11
       1566           10
       1567            9
       1568            8
       1569            7
       1570            6
       1571           16
       1572           15
       1573           14
       1574           13
       1575           12
       1576           11
       1577           10
       1578            9
       1579            8
       1580            7
       1581           14
       1582           13
       1583           12
       1584           11
       1585           10
       1586            9
       1587            8
       1588            7
       1589            6
       1590            5
       1591           13
       1592           12
       1593           11
       1594           10
       1595            9
       1596            8
       1597            7
       1598            6
       1599            5
       1600            4
       1601           11
       1602           10
       1603            9
       1604            8
       1605            7
       1606            6
       1607            5
       1608            4
       1609            3
       1610            2
       1611           20
       1612           19
       1613           18
       1614           17
       1615           16
       1616           15
       1617           14
       1618           13
       1619           12
       1620           11
       1621           19
       1622           18
       1623           17
       1624           16
       1625           15
       1626           14
       1627           13
       1628           12
       1629           11
       1630           10
       1631           18
       1632           17
       1633           16
       1634           15
       1635           14
       1636           13
       1637           12
       1638           11
       1639           10
       1640            9
       1641           17
       1642           16
       1643           15
       1644           14
       1645           13
       1646           12
       1647           11
       1648           10
       1649            9
       1650            8
       1651           16
       1652           15
       1653           14
       1654           13
       1655           12
       1656           11
       1657           10
       1658            9
       1659            8
       1660            7
       1661           14
       1662           13
       1663           12
       1664           11
       1665           10
       1666            9
       1667            8
       1668            7
       1669            6
       1670            5
       1671           15
       1672           14
       1673           13
       1674           12
       1675           11
       1676           10
       1677            9
       1678            8
       1679            7
       1680            6
       1681           13
       1682           12
       1683           11
       1684           10
       1685            9
       1686            8
       1687            7
       1688            6
       1689            5
       1690            4
       1691           12
       1692           11
       1693           10
       1694            9
       1695            8
       1696            7
       1697            6
       1698            5
       1699            4
       1700            3
       1701           10
       1702            9
       1703            8
       1704            7
       1705            6
       1706            5
       1707            4
       1708            3
       1709            2
       1710            1
       1711           19
       1712           18
       1713           17
       1714           16
       1715           15
       1716           14
       1717           13
       1718           12
       1719           11
       1720           10
       1721           18
       1722           17
       1723           16
       1724           15
       1725           14
       1726           13
       1727           12
       1728           11
       1729           10
       1730            9
       1731           17
       1732           16
       1733           15
       1734           14
       1735           13
       1736           12
       1737           11
       1738           10
       1739            9
       1740            8
       1741           16
       1742           15
       1743           14
       1744           13
       1745           12
       1746           11
       1747           10
       1748            9
       1749            8
       1750            7
       1751           15
       1752           14
       1753           13
       1754           12
       1755           11
       1756           10
       1757            9
       1758            8
       1759            7
       1760            6
       1761           13
       1762           12
       1763           11
       1764           10
       1765            9
       1766            8
       1767            7
       1768            6
       1769            5
       1770            4
       1771           14
       1772           13
       1773           12
       1774           11
       1775           10
       1776            9
       1777            8
       1778            7
       1779            6
       1780            5
       1781           12
       1782           11
       1783           10
       1784            9
       1785            8
       1786            7
       1787            6
       1788            5
       1789            4
       1790            3
       1791           11
       1792           10
       1793            9
       1794            8
       1795            7
       1796            6
       1797            5
       1798            4
       1799            3
       1800            2
       1801            9
       1802            8
       1803            7
       1804            6
       1805            5
       1806            4
       1807            3
       1808            2
       1809            1
       1810            0
       1811           18
       1812           17
       1813           16
       1814           15
       1815           14
       1816           13
       1817           12
       1818           11
       1819           10
       1820            9
       1821           17
       1822           16
       1823           15
       1824           14
       1825           13
       1826           12
       1827           11
       1828           10
       1829            9
       1830            8
       1831           16
       1832           15
       1833           14
       1834           13
       1835           12
       1836           11
       1837           10
       1838            9
       1839            8
       1840            7
       1841           15
       1842           14
       1843           13
       1844           12
       1845           11
       1846           10
       1847            9
       1848            8
       1849            7
       1850            6
       1851           14
       1852           13
       1853           12
       1854           11
       1855           10
       1856            9
       1857            8
       1858            7
       1859            6
       1860            5
       1861           12
       1862           11
       1863           10
       1864            9
       1865            8
       1866            7
       1867            6
       1868            5
       1869            4
       1870            3
       1871           13
       1872           12
       1873           11
       1874           10
       1875            9
       1876            8
       1877            7
       1878            6
       1879            5
       1880            4
       1881           11
       1882           10
       1883            9
       1884            8
       1885            7
       1886            6
       1887            5
       1888            4
       1889            3
       1890            2
       1891           10
       1892            9
       1893            8
       1894            7
       1895            6
       1896            5
       1897            4
       1898            3
       1899            2
       1900            1
       1901            8
       1902            7
       1903            6
       1904            5
       1905            4
       1906            3
       1907            2
       1908            1
       1909            0
       1910           -1
       1911           17
       1912           16
       1913           15
       1914           14
       1915           13
       1916           12
       1917           11
       1918           10
       1919            9
       1920            8
       1921           16
       1922           15
       1923           14
       1924           13
       1925           12
       1926           11
       1927           10
       1928            9
       1929            8
       1930            7
       1931           15
       1932           14
       1933           13
       1934           12
       1935           11
       1936           10
       1937            9
       1938            8
       1939            7
       1940            6
       1941           14
       1942           13
       1943           12
       1944           11
       1945           10
       1946            9
       1947            8
       1948            7
       1949            6
       1950            5
       1951           13
       1952           12
       1953           11
       1954           10
       1955            9
       1956            8
       1957            7
       1958            6
       1959            5
       1960            4
       1961           11
       1962           10
       1963            9
       1964            8
       1965            7
       1966            6
       1967            5
       1968            4
       1969            3
       1970            2
       1971           12
       1972           11
       1973           10
       1974            9
       1975            8
       1976            7
       1977            6
       1978            5
       1979            4
       1980            3
       1981           10
       1982            9
       1983            8
       1984            7
       1985            6
       1986            5
       1987            4
       1988            3
       1989            2
       1990            1
       1991            9
       1992            8
       1993            7
       1994            6
       1995            5
       1996            4
       1997            3
       1998            2
       1999            1
       2000            0

--- 2000 row(s) selected.
>>
>>
>>-- ==================================================================
>>--------------------------------
>>
>>-- In case the tests don't work properly try these ones.
>>-- They are the same tests, considering VSBB is doing a different number of simple inserts
>>-- before inserting the rabge itself.
>>
>>-- obey TESTMV630(TEST3B);
>>-- obey TESTMV630(TEST4B);
>>-- obey TESTMV630(TEST5B);
>>-- obey TESTMV630(TEST6B);
>>
>>-- obey TESTMV630(TEST3C);
>>-- obey TESTMV630(TEST4C);
>>-- obey TESTMV630(TEST5C);
>>-- obey TESTMV630(TEST6C);
>>
>>-- Clean and Exit
>>obey TESTMV630(CLEAN_UP);
>>-- ==================================================================
>>set schema catmvs.mvschm;

--- SQL operation complete.
>>
>>create MVGroup MVG1_630;

--- SQL operation complete.
>>ALTER MVGroup MVG1_630 ADD T_630_MV1 ,T_630_MV7;

--- SQL operation complete.
>>refresh MVGroup MVG1_630 cancel;

--- SQL operation complete.
>>
>>drop mv T_630_MV7;

--- SQL operation complete.
>>drop mv T_630_MV1;

--- SQL operation complete.
>>drop table T_630_T4;

--- SQL operation complete.
>>drop table T_630_T3;

--- SQL operation complete.
>>drop table T_630_T2;

--- SQL operation complete.
>>drop table T_630_T1;

--- SQL operation complete.
>>
>>drop mvgroup MVG1_630;

--- SQL operation complete.
>>
>>
>>set param ?schema_name 'MVSCHM';
>>
>>obey COMPARE_NUM_OF_OBJ;
>>-- expected 'EQUAL'
>>select 'EQUAL' as rel
+>from catmvs.mvschm.Num_Obj
+>where  SCHEMA_NAME = ?schema_name and 
+>       num_of_objects
+>	=
+>	(select count(objects.object_uid)  num_of_objcts
+>	from HP_DEFINITION_SCHEMA.objects objects,
+>    HP_SYSTEM_CATALOG.SYSTEM_SCHEMA.SCHEMATA SCHEMATA
+>    	where schemata.schema_uid = objects.schema_uid
+>   	and objects.OBJECT_NAME_SPACE <> 'CN'and ?schema_name =SCHEMA_NAME
+>	group by SCHEMA_NAME);

REL  
-----

EQUAL

--- 1 row(s) selected.
>>
>>drop table Num_Obj;

--- SQL operation complete.
>>
>>
>>
>>log;
