diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3997548 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,57 @@ +name: CI + +on: + pull_request: + push: + branches: + - master + +jobs: + build: + name: ${{matrix.name}} + runs-on: ${{matrix.os}} + env: + CC: ${{matrix.cc}} + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + include: + - name: Ubuntu-GCC + cc: gcc + os: ubuntu-latest + + - name: Ubuntu-Clang + cc: clang + os: ubuntu-latest + + - name: macOS-AppleClang + cc: clang + os: macos-latest + + steps: + - uses: actions/checkout@v4 + + - name: System Information + run: | + awk -v a=$(uname) 'BEGIN { a == "Linux" ? system("cat /etc/issue") : system("sw_vers") }' + ${CC} --version + + - name: Make + run: | + make + + - name: Generate SF 0.01 Data + run: | + mkdir generated_data && cd generated_data + ../dbgen -f -s 0.01 -k -b ../dists.dss + + - name: Generate Queries + run: | + mkdir generated_queries && cd generated_queries && ln -s ../queries/*.sql . + # With skew and seed 123. + ../qgen -k -s 0.01 -b ../dists.dss -r 123 -l params > /dev/null + # Without skew and seed 1234. + ../qgen -s 0.01 -b ../dists.dss -r 1234 -l params > /dev/null diff --git a/Makefile b/Makefile index 0cdc1c0..3cf2f70 100755 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ ################ ## CHANGE NAME OF ANSI COMPILER HERE ################ -CC = gcc +CC ?= gcc # Current values for DATABASE are: INFORMIX, DB2, TDAT (Teradata) # SQLSERVER, SYBASE, ORACLE, VECTORWISE # Current values for MACHINE are: ATT, DOS, HP, IBM, ICL, MVS, @@ -10,8 +10,8 @@ CC = gcc DATABASE= VECTORWISE MACHINE = LINUX WORKLOAD = TPCH -# -CFLAGS = -g -O3 -DDBNAME=\"dss\" -D$(MACHINE) -D$(DATABASE) -D$(WORKLOAD) -DRNG_TEST -D_FILE_OFFSET_BITS=64 -DJCCH_SKEW=1 +# HYRISE: Add -O3, remove -g. Add -Wno-dangling-else. +CFLAGS = -O3 -DDBNAME=\"dss\" -D$(MACHINE) -D$(DATABASE) -D$(WORKLOAD) -DRNG_TEST -D_FILE_OFFSET_BITS=64 -DJCCH_SKEW=1 -Wno-dangling-else LDFLAGS = -O3 # The OBJ,EXE and LIB macros will need to be changed for compilation under # Windows NT diff --git a/README b/README.md similarity index 98% rename from README rename to README.md index 03c38ef..8eca1db 100755 --- a/README +++ b/README.md @@ -1,3 +1,6 @@ +![Build Status](https://github.com/hyrise/jcch-dbgen/actions/workflows/ci.yml/badge.svg?branch=master) +### Note: This fork is adapted for compilation using recent versions of Clang and GCC, which we ensure with a [GitHub action](https://github.com/hyrise/jcch-dbgen/actions). + # @(#)README 2.4.0-JCCH ========================== JCC-H specific info ========================= diff --git a/build.c b/build.c index 45cff5f..86b0cda 100755 --- a/build.c +++ b/build.c @@ -110,7 +110,8 @@ mk_cust(DSS_HUGE n_cust, customer_t * c) if (!bInit) { - sprintf(szFormat, C_NAME_FMT, 9, HUGE_FORMAT + 1); + // HYRISE: Adapt string indexing. + sprintf(szFormat, C_NAME_FMT, 9, &HUGE_FORMAT[1]); bInit = 1; } c->custkey = n_cust; @@ -294,7 +295,8 @@ mk_order(DSS_HUGE index, order_t * o, long upd_num) if (!bInit) { - sprintf(szFormat, O_CLRK_FMT, 9, HUGE_FORMAT + 1); + // HYRISE: Adapt string indexing. + sprintf(szFormat, O_CLRK_FMT, 9, &HUGE_FORMAT[1]); bInit = 1; } if (asc_date == NULL) @@ -471,8 +473,9 @@ mk_part(DSS_HUGE index, part_t * p) if (!bInit) { - sprintf(szFormat, P_MFG_FMT, 1, HUGE_FORMAT + 1); - sprintf(szBrandFormat, P_BRND_FMT, 2, HUGE_FORMAT + 1); + // HYRISE: Adapt string indexing. + sprintf(szFormat, P_MFG_FMT, 1, &HUGE_FORMAT[1]); + sprintf(szBrandFormat, P_BRND_FMT, 2, &HUGE_FORMAT[1]); bInit = 1; } p->partkey = index; @@ -560,7 +563,7 @@ mk_supp(DSS_HUGE index, supplier_t * s) if (!bInit) { - sprintf(szFormat, S_NAME_FMT, 9, HUGE_FORMAT + 1); + sprintf(szFormat, S_NAME_FMT, 9, &HUGE_FORMAT[1]); bInit = 1; } s->suppkey = index; diff --git a/driver.c b/driver.c index ce2850c..28ebd9b 100755 --- a/driver.c +++ b/driver.c @@ -158,16 +158,18 @@ static int bTableSet = 0; /* * flat file print functions; used with -F(lat) option */ -int pr_cust (customer_t * c, int mode); -int pr_line (order_t * o, int mode); -int pr_order (order_t * o, int mode); -int pr_part (part_t * p, int mode); -int pr_psupp (part_t * p, int mode); -int pr_supp (supplier_t * s, int mode); -int pr_order_line (order_t * o, int mode); -int pr_part_psupp (part_t * p, int mode); -int pr_nation (code_t * c, int mode); -int pr_region (code_t * c, int mode); +// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype +// (C2x compatibility). +int pr_cust (void * c, int mode); +int pr_line (void * o, int mode); +int pr_order (void * o, int mode); +int pr_part (void * p, int mode); +int pr_psupp (void * p, int mode); +int pr_supp (void * s, int mode); +int pr_order_line (void * o, int mode); +int pr_part_psupp (void * p, int mode); +int pr_nation (void * c, int mode); +int pr_region (void * c, int mode); /* * seed generation functions; used with '-O s' option @@ -370,7 +372,8 @@ gen_tbl (int tnum, DSS_HUGE start, DSS_HUGE count, long upd_num) row_stop(tnum); if (set_seeds && (i % tdefs[tnum].base) < 2) { - printf("\nSeeds for %s at rowcount %ld\n", tdefs[tnum].comment, i); + // HYRISE: Change format specifier. + printf("\nSeeds for %s at rowcount %lld\n", tdefs[tnum].comment, i); dump_seeds(tnum); } } @@ -445,7 +448,8 @@ partial (int tbl, int s) if (verbose > 0) { - fprintf (stderr, "\tStarting to load stage %d of %d for %s...", + // HYRISE: Change format specifier. + fprintf (stderr, "\tStarting to load stage %d of %ld for %s...", s, children, tdefs[tbl].comment); } @@ -622,7 +626,8 @@ process_options (int count, char **vector) } part.s = (partsupp_t*) malloc(SUPP_PER_PART * sizeof(partsupp_t)); if (part.s == NULL) { - fprintf(stderr, "ERROR Allocating memory for %lld suppliers.\n", SUPP_PER_PART); + // HYRISE: Change format specifier. + fprintf(stderr, "ERROR Allocating memory for %d suppliers.\n", SUPP_PER_PART); exit(-1); } @@ -785,8 +790,9 @@ main (int ac, char **av) while (upd_num < updates) { if (verbose > 0) + // HYRISE: Change format specifier. fprintf (stderr, - "Generating update pair #%d for %s", + "Generating update pair #%ld for %s", upd_num + 1, tdefs[ORDER_LINE].comment); insert_orders_segment=0; insert_lineitem_segment=0; diff --git a/dss.h b/dss.h index 3a9f6d3..2db0051 100755 --- a/dss.h +++ b/dss.h @@ -177,8 +177,9 @@ typedef struct char *name; char *comment; DSS_HUGE base; - int (*loader) (); - long (*gen_seed)(); + int (*loader) (void * t, int); + // HYRISE: add function prototypes (C2x compatibility). + long (*gen_seed)(int, DSS_HUGE); int child; DSS_HUGE vtotal; } tdef; @@ -489,8 +490,9 @@ int dbg_print(int dt, FILE *tgt, void *data, int len, int eol); #define PR_DATE(tgt, yr, mn, dy) \ sprintf(tgt, "%02d-%02d-19%02d", mn, dy, yr) #else +// HYRISE: Change format specifier. #define PR_DATE(tgt, yr, mn, dy) \ -sprintf(tgt, "19%02d-%02d-%02d", yr, mn, dy) +sprintf(tgt, "19%02ld-%02ld-%02ld", yr, mn, dy) #endif /* DATE_FORMAT */ /* diff --git a/dsstypes.h b/dsstypes.h index 4c4baae..ef1e218 100755 --- a/dsstypes.h +++ b/dsstypes.h @@ -53,7 +53,9 @@ typedef struct } customer_t; /* customers.c */ long mk_cust PROTO((DSS_HUGE n_cust, customer_t * c)); -int pr_cust PROTO((customer_t * c, int mode)); +// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype +// (C2x compatibility). +int pr_cust PROTO((void * c, int mode)); int ld_cust PROTO((customer_t * c, int mode)); typedef struct @@ -95,7 +97,9 @@ typedef struct /* order.c */ long mk_order PROTO((DSS_HUGE index, order_t * o, long upd_num)); -int pr_order PROTO((order_t * o, int mode)); +// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype +// (C2x compatibility). +int pr_order PROTO((void * o, int mode)); int ld_order PROTO((order_t * o, int mode)); void mk_sparse PROTO((DSS_HUGE index, DSS_HUGE *ok, long seq)); @@ -131,7 +135,9 @@ typedef struct /* parts.c */ long mk_part PROTO((DSS_HUGE index, part_t * p)); -int pr_part PROTO((part_t * part, int mode)); +// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype +// (C2x compatibility). +int pr_part PROTO((void * part, int mode)); int ld_part PROTO((part_t * part, int mode)); typedef struct @@ -148,7 +154,9 @@ typedef struct } supplier_t; /* supplier.c */ long mk_supp PROTO((DSS_HUGE index, supplier_t * s)); -int pr_supp PROTO((supplier_t * supp, int mode)); +// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype +// (C2x compatibility). +int pr_supp PROTO((void * supp, int mode)); int ld_supp PROTO((supplier_t * supp, int mode)); typedef struct @@ -178,9 +186,13 @@ typedef struct /* code table */ int mk_nation PROTO((DSS_HUGE i, code_t * c)); -int pr_nation PROTO((code_t * c, int mode)); +// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype +// (C2x compatibility). +int pr_nation PROTO((void * c, int mode)); int ld_nation PROTO((code_t * c, int mode)); int mk_region PROTO((DSS_HUGE i, code_t * c)); -int pr_region PROTO((code_t * c, int mode)); +// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype +// (C2x compatibility). +int pr_region PROTO((void * c, int mode)); int ld_region PROTO((code_t * c, int mode)); diff --git a/print.c b/print.c index 96bfa40..4ef8ec2 100755 --- a/print.c +++ b/print.c @@ -135,7 +135,8 @@ dbg_print(int format, FILE *target, void *data, int len, int sep) } dollars = cents / 100; cents %= 100; - fprintf(target, "%ld.%02ld", dollars, cents); + // HYRISE: Change format specifier. + fprintf(target, "%d.%02d", dollars, cents); break; case DT_CHR: fprintf(target, "%c", *(char *)data); @@ -151,9 +152,10 @@ dbg_print(int format, FILE *target, void *data, int len, int sep) } int -pr_cust(customer_t *c, int mode) +pr_cust(void *t, int mode) { -static FILE *fp = NULL; + static FILE *fp = NULL; + customer_t *c = (customer_t *) t; if (fp == NULL) fp = print_prep(CUST, 0); @@ -179,10 +181,11 @@ static FILE *fp = NULL; * print the numbered order */ int -pr_order(order_t *o, int mode) +pr_order(void *t, int mode) { static FILE *fp_o = NULL; static int last_mode = 0; + order_t *o = (order_t *) t; if (fp_o == NULL || mode != last_mode) { @@ -266,9 +269,10 @@ pr_order_line(order_t *o, int mode) * print the given part */ int -pr_part(part_t *part, int mode) +pr_part(void *t, int mode) { -static FILE *p_fp = NULL; + static FILE *p_fp = NULL; + part_t *part = (part_t *) t; if (p_fp == NULL) p_fp = print_prep(PART, 0); @@ -331,9 +335,10 @@ pr_part_psupp(part_t *part, int mode) } int -pr_supp(supplier_t *supp, int mode) +pr_supp(void *t, int mode) { -static FILE *fp = NULL; + static FILE *fp = NULL; + supplier_t *supp = (supplier_t *) t; if (fp == NULL) fp = print_prep(SUPP, mode); @@ -352,9 +357,10 @@ static FILE *fp = NULL; } int -pr_nation(code_t *c, int mode) +pr_nation(void *t, int mode) { -static FILE *fp = NULL; + static FILE *fp = NULL; + code_t *c = (code_t *) t; if (fp == NULL) fp = print_prep(NATION, mode); @@ -370,9 +376,10 @@ static FILE *fp = NULL; } int -pr_region(code_t *c, int mode) +pr_region(void *t, int mode) { -static FILE *fp = NULL; + static FILE *fp = NULL; + code_t *c = (code_t *) t; if (fp == NULL) fp = print_prep(REGION, mode); diff --git a/qgen.c b/qgen.c index 1b32f8a..df0ede6 100755 --- a/qgen.c +++ b/qgen.c @@ -476,14 +476,16 @@ int main(int ac, char **av) for (i=optind; i < ac; i++) { char qname[10]; - sprintf(qname, "%d", SEQUENCE(snum, atoi(av[i]))); + // HYRISE: Change format specifier. + sprintf(qname, "%ld", SEQUENCE(snum, atoi(av[i]))); qsub(qname, flags); } else for (i=1; i <= QUERIES_PER_SET; i++) { char qname[10]; - sprintf(qname, "%d", SEQUENCE(snum, i)); + // HYRISE: Change format specifier. + sprintf(qname, "%ld", SEQUENCE(snum, i)); qsub(qname, flags); } else diff --git a/rnd.c b/rnd.c index 4655f4c..5b17dee 100755 --- a/rnd.c +++ b/rnd.c @@ -128,7 +128,8 @@ row_stop(int t) \ { if (set_seeds && (Seed[i].usage > Seed[i].boundary)) { - fprintf(stderr, "\nSEED CHANGE: seed[%d].usage = %d\n", + // HYRISE: Change format specifier. + fprintf(stderr, "\nSEED CHANGE: seed[%d].usage = %lld\n", i, Seed[i].usage); Seed[i].boundary = Seed[i].usage; } @@ -151,7 +152,8 @@ dump_seeds(int tbl) for (i=0; i <= MAX_STREAM; i++) if (Seed[i].table == tbl) #ifdef RNG_TEST - printf("%d(%ld):\t%ld\n", i, Seed[i].nCalls, Seed[i].value); + // HYRISE: Change format specifier. + printf("%d(%lld):\t%lld\n", i, Seed[i].nCalls, Seed[i].value); #else printf("%d:\t%ld\n", i, Seed[i].value); #endif diff --git a/skew/phash.c b/skew/phash.c index 429db94..fcfd943 100644 --- a/skew/phash.c +++ b/skew/phash.c @@ -41,7 +41,8 @@ void init_phash(phash_t *phash, unsigned long maxval) { return; } } - fprintf(stderr, "init_skew_failed: could not find inverse for %lld ring of %lld\n", maxval, PRIME); + // HYRISE: Change format specifier. + fprintf(stderr, "init_skew_failed: could not find inverse for %lu ring of %d\n", maxval, PRIME); exit(-1); } diff --git a/tpcd.h b/tpcd.h index 99bdae9..b52ef48 100755 --- a/tpcd.h +++ b/tpcd.h @@ -55,7 +55,8 @@ #define END_TRAN "COMMIT;" #define SET_OUTPUT "" #define SET_ROWCOUNT "first %d\n" -#define SET_DBASE "" +// HYRISE: Change format specifier. +#define SET_DBASE "%s" #endif /* VECTORWISE */ #ifdef DB2 diff --git a/varsub.c b/varsub.c index 6dd5ad8..e5f8aed 100755 --- a/varsub.c +++ b/varsub.c @@ -166,7 +166,8 @@ varsub(int qnum, int vnum, int flags) #ifdef JCCH_SKEW if (JCCH_skew) { strcpy(param[1], "1"); - strcpy(param[2], "SHINY MINED GOLD" + UnifInt(0, 10, qnum)); + // HYRISE: Adapt string indexing. + strcpy(param[2], &"SHINY MINED GOLD"[UnifInt(0, 10, qnum)]); } #endif param[4][0] = '\0'; @@ -300,7 +301,8 @@ varsub(int qnum, int vnum, int flags) pick_str(&colors, qnum, param[1]); #ifdef JCCH_SKEW if (JCCH_skew) { - strcpy(param[1], "shiny mined gold" + UnifInt(0, 10, qnum)); + // HYRISE: Adapt string indexing. + strcpy(param[1], &"shiny mined gold"[UnifInt(0, 10, qnum)]); } #endif param[2][0] = '\0';