@@ -30,6 +30,11 @@ local dbdbgen = import 'dbdbgen.libsonnet';
30
30
help: 'Enable foreign keys in the generated schema.' ,
31
31
type: 'bool' ,
32
32
},
33
+ secondary_key: {
34
+ long: 'secondary-key' ,
35
+ help: 'Enable secondary keys in the generated schema (for MySQL only).' ,
36
+ type: 'bool' ,
37
+ },
33
38
34
39
// TPC-C output contains no special characters.
35
40
escape_backslash:: null ,
@@ -44,6 +49,7 @@ local dbdbgen = import 'dbdbgen.libsonnet';
44
49
prefix: m.table_prefix,
45
50
warehouses: m.warehouses,
46
51
fk: if m.foreign_key then '' else '-- ' ,
52
+ sk: if m.secondary_key then '' else '-- ' ,
47
53
};
48
54
[
49
55
/* 0_config
@@ -372,6 +378,7 @@ local dbdbgen = import 'dbdbgen.libsonnet';
372
378
c_data varchar(500),
373
379
/*{{ rand.regex('[0-9a-zA-Z]{300,500}') }}*/
374
380
%(fk)sforeign key (c_w_id, c_d_id) references %(prefix)sdistrict (d_w_id, d_id),
381
+ %(sk)skey (c_w_id, c_d_id, c_last, c_first),
375
382
primary key (c_w_id, c_d_id, c_id)
376
383
);
377
384
||| % format,
@@ -396,15 +403,15 @@ local dbdbgen = import 'dbdbgen.libsonnet';
396
403
rows_per_file: 3e6 ,
397
404
template_string: |||
398
405
create table %(prefix)shistory (
399
- h_c_id integer,
406
+ h_c_id integer not null ,
400
407
/*{{ mod(rownum-1, 3000)+1 }}*/
401
- h_c_d_id integer,
408
+ h_c_d_id integer not null ,
402
409
/*{{ @d_id := mod(div(rownum-1, 3000), 10)+1 }}*/
403
- h_c_w_id integer,
410
+ h_c_w_id integer not null ,
404
411
/*{{ @w_id := div(rownum-1, 30000)+1 }}*/
405
- h_d_id integer,
412
+ h_d_id integer not null ,
406
413
/*{{ @d_id }}*/
407
- h_w_id integer,
414
+ h_w_id integer not null ,
408
415
/*{{ @w_id }}*/
409
416
h_date timestamp,
410
417
/*{{ current_timestamp }}*/
@@ -414,6 +421,8 @@ local dbdbgen = import 'dbdbgen.libsonnet';
414
421
/*{{ rand.regex('[0-9a-zA-Z]{12,24}') }}*/
415
422
%(fk)s,foreign key (h_c_w_id, h_c_d_id, h_c_id) references %(prefix)scustomer (c_w_id, c_d_id, c_id)
416
423
%(fk)s,foreign key (h_w_id, h_d_id) references %(prefix)sdistrict (d_w_id, d_id)
424
+ %(sk)s,key (h_w_id)
425
+ %(sk)s,key (h_c_w_id)
417
426
);
418
427
||| % format,
419
428
},
@@ -478,6 +487,7 @@ local dbdbgen = import 'dbdbgen.libsonnet';
478
487
o_entry_d timestamp,
479
488
/*{{ @o_entry_d := current_timestamp }}*/
480
489
%(fk)sforeign key (o_w_id, o_d_id, o_c_id) references %(prefix)scustomer (c_w_id, c_d_id, c_id),
490
+ %(sk)skey (o_w_id, o_d_id, o_c_id, o_id),
481
491
primary key (o_w_id, o_d_id, o_id)
482
492
);
483
493
0 commit comments