1 | /* |
2 | * Legal Notice |
3 | * |
4 | * This document and associated source code (the "Work") is a part of a |
5 | * benchmark specification maintained by the TPC. |
6 | * |
7 | * The TPC reserves all right, title, and interest to the Work as provided |
8 | * under U.S. and international laws, including without limitation all patent |
9 | * and trademark rights therein. |
10 | * |
11 | * No Warranty |
12 | * |
13 | * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION |
14 | * CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE |
15 | * AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER |
16 | * WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, |
17 | * INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES, |
18 | * DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR |
19 | * PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF |
20 | * WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE. |
21 | * ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, |
22 | * QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT |
23 | * WITH REGARD TO THE WORK. |
24 | * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO |
25 | * ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE |
26 | * COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS |
27 | * OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT, |
28 | * INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY, |
29 | * OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT |
30 | * RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD |
31 | * ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. |
32 | * |
33 | * Contributors: |
34 | * Gradient Systems |
35 | */ |
36 | #include "config.h" |
37 | #include "porting.h" |
38 | #include <stdio.h> |
39 | #include "constants.h" |
40 | #include "w_warehouse.h" |
41 | #include "date.h" |
42 | #include "decimal.h" |
43 | #include "genrand.h" |
44 | #include "build_support.h" |
45 | #include "misc.h" |
46 | #include "address.h" |
47 | #include "constants.h" |
48 | #include "tables.h" |
49 | #include "nulls.h" |
50 | #include "tdefs.h" |
51 | |
52 | #include "append_info.h" |
53 | |
54 | struct W_WAREHOUSE_TBL g_w_warehouse; |
55 | |
56 | /* |
57 | * mk_warehouse |
58 | */ |
59 | int mk_w_warehouse(void *info_arr, ds_key_t index) { |
60 | |
61 | /* begin locals declarations */ |
62 | struct W_WAREHOUSE_TBL *r; |
63 | tdef *pT = getSimpleTdefsByNumber(WAREHOUSE); |
64 | |
65 | r = &g_w_warehouse; |
66 | |
67 | nullSet(&pT->kNullBitMap, W_NULLS); |
68 | r->w_warehouse_sk = index; |
69 | mk_bkey(&r->w_warehouse_id[0], index, W_WAREHOUSE_ID); |
70 | gen_text(&r->w_warehouse_name[0], W_NAME_MIN, RS_W_WAREHOUSE_NAME, W_WAREHOUSE_NAME); |
71 | r->w_warehouse_sq_ft = genrand_integer(NULL, DIST_UNIFORM, W_SQFT_MIN, W_SQFT_MAX, 0, W_WAREHOUSE_SQ_FT); |
72 | |
73 | mk_address(&r->w_address, W_WAREHOUSE_ADDRESS); |
74 | |
75 | char szTemp[128]; |
76 | |
77 | void *info = append_info_get(info_arr, WAREHOUSE); |
78 | append_row_start(info); |
79 | |
80 | append_key(info, r->w_warehouse_sk); |
81 | append_varchar(info, r->w_warehouse_id); |
82 | append_varchar(info, &r->w_warehouse_name[0]); |
83 | append_integer(info, r->w_warehouse_sq_ft); |
84 | append_integer(info, r->w_address.street_num); |
85 | if (r->w_address.street_name2 != NULL) { |
86 | sprintf(szTemp, "%s %s" , r->w_address.street_name1, r->w_address.street_name2); |
87 | append_varchar(info, szTemp); |
88 | } else |
89 | append_varchar(info, r->w_address.street_name1); |
90 | append_varchar(info, r->w_address.street_type); |
91 | append_varchar(info, r->w_address.suite_num); |
92 | append_varchar(info, r->w_address.city); |
93 | append_varchar(info, r->w_address.county); |
94 | append_varchar(info, r->w_address.state); |
95 | sprintf(szTemp, "%05d" , r->w_address.zip); |
96 | append_varchar(info, szTemp); |
97 | append_varchar(info, r->w_address.country); |
98 | append_integer(info, r->w_address.gmt_offset); |
99 | |
100 | append_row_end(info); |
101 | |
102 | return 0; |
103 | } |
104 | |