File: concurrent_pk_mix_updates_inserts.test_slow

package info (click to toggle)
duckdb 1.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 299,196 kB
  • sloc: cpp: 865,414; ansic: 57,292; python: 18,871; sql: 12,663; lisp: 11,751; yacc: 7,412; lex: 1,682; sh: 747; makefile: 564
file content (48 lines) | stat: -rw-r--r-- 952 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# name: test/sql/parallelism/interquery/concurrent_pk_mix_updates_inserts.test_slow
# description: Test concurrent inserts into primary key table
# group: [interquery]

statement ok
CREATE TABLE integers (i INTEGER PRIMARY KEY);

statement ok
INSERT INTO integers FROM range(100);

# table starts with values 0..100
# threads 0-5 insert values 100..200
# threads 5-10 update random values from within the table to other random values from within the table
# this can randomly leave some batches
concurrentloop threadid 0 10

loop x 0 100

onlyif threadid<5
statement maybe
INSERT INTO integers VALUES (100 + ${x})
----
violat


onlyif threadid>=5
statement maybe
UPDATE integers SET i = (random() * 199)::INTEGER WHERE i = (random() * 99)::INTEGER
----

endloop

endloop


# insert any missing values
loop x 0 200

statement maybe
INSERT INTO integers VALUES (${x})
----

endloop

query II
SELECT COUNT(*), COUNT(DISTINCT i) FROM integers
----
200	200