Skip to content

Commit a4b5f7d

Browse files
committed
Make sure there is no ORA-00001 risk
1 parent 58b9091 commit a4b5f7d

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

oltp/mtit_declarations.rwl

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# Licensed under the Universal Permissive License v 1.0
33
# as shown at https://oss.oracle.com/licenses/upl/
44

5-
# bengsig 17-jun-2023 - add mtit_partitions parameter
5+
# bengsig 18-jun-2024 - prevent ORA-1 risk
6+
# bengsig 17-jun-2024 - add mtit_partitions parameter
67
# bengsig 10-jun-2024 - Add hcc table
78
# bengsig 30-may-2024 - loadfactor used to mute threads
89
# bengsig 17-apr-2024 - no stats when idling
@@ -28,17 +29,24 @@
2829
# mtit_type / 100
2930
#
3031
# 0 - The sequence is part of the insert itself
31-
# and put into seq, rno is then always 0
32+
# and put into seq, rno is then always 1
3233
# as the seq column itself is unique
3334
#
3435
# 1 - Primary keys come from a separate query
3536
# from dual that gets one sequence number
3637
# that goes into the seq column, and rno is
37-
# then a number in the range 1..rowsperins
38-
# so uniqueness is from both columns
38+
# then based on a number in the range
39+
# 1..rowsperins but with the last two
40+
# digits in the range 02 .. 99 so
41+
# uniqueness is from both columns
3942
#
4043
# 2 - The primary key is in principle external
41-
# we do however generate it. See below.
44+
# we do however generate it. Note that for
45+
# these, the last two digits of rno is always
46+
# 00.
47+
#
48+
# Effectively the three different mtit_type/100 values
49+
# are guaranteed to not overlap, preventing ORA-00001
4250
#
4351
# mtit_type%100 describes the index used for the
4452
# primary key plus the type of sequence when relevant
@@ -163,10 +171,10 @@ procedure mtit_ins_rows()
163171
values (:seq, :rno, :val, :payload)";
164172
else
165173
# include seq in values clause
166-
# and set rno to 0
174+
# and set rno to 1
167175
modify sql mtit_ins_sql for
168176
"insert into " mtit_tab " (seq, rno, val, payload)
169-
values (" mtit_seq ".nextval, 0, :val, :payload)";
177+
values (" mtit_seq ".nextval, 1, :val, :payload)";
170178
end if;
171179

172180
modify sql mtit_ins_sql array mtit_array_size;
@@ -183,13 +191,16 @@ $endif
183191
nostatistics;
184192
wait 1;
185193
else
186-
for rno := 1 .. mtit_rows_per_exec loop
194+
integer rno2;
195+
for rno2 := 1 .. mtit_rows_per_exec loop
187196
if mtit_type%100 != 7 then
188197
val := uniform(0.0,1000.0);
189198
else
190199
val := round(uniform(0,1000));
191200
end if;
192201
sprintf payload, "%05d-%s-%05d", uniform(0,99999), ovid2load, uniform(0,99999);
202+
# make rno unique and have last digits in the range 02 .. 99
203+
rno := 2 + rno2%98 + 100 * (rno2/98);
193204
mtit_ins_sql;
194205
mtit_count_ins_rows();
195206
end loop;

0 commit comments

Comments
 (0)