Skip to content

Commit

Permalink
generate child table in filter mode
Browse files Browse the repository at this point in the history
  • Loading branch information
davies authored and juliuszsompolski committed Jun 6, 2017
1 parent 101d772 commit 90b8e13
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 26 deletions.
6 changes: 4 additions & 2 deletions tools/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,10 @@ main (int ac, char **av)
}
if (pT->flags & FL_CHILD)
{
if (tabid == i)
ReportErrorNoLine(QERR_TABLE_CHILD, pT->name, 1);
if (tabid == i) {
tabid ++;
set_flg("_CHILD_ONLY");
}
continue; /* children are generated by the parent call */
}
if ((tabid != -1) && (i != tabid))
Expand Down
3 changes: 2 additions & 1 deletion tools/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ option_t options[] =
{"VCOUNT", OPT_INT|OPT_ADV, 22, "set number of validation rows to be produced", NULL, "50"},
{"VSUFFIX", OPT_STR|OPT_ADV, 23, "set file suffix for data validation", NULL, ".vld"},
{"RNGSEED", OPT_INT|OPT_ADV, 24, "set RNG seed", NULL, "19620718"},
{"_CHILD_ONLY", OPT_FLG, 25, "output the child table only", NULL, "N"},
{NULL}
};

char *params[23 + 2];
char *params[24 + 2];
#else
extern option_t options[];
extern char *params[];
Expand Down
1 change: 1 addition & 0 deletions tools/r_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ char *get_str(char *var);
void set_str(char *param, char *value);
int get_int(char *var);
void set_int(char *var, char *val);
void set_flg(char *var);
int is_set(char *flag);
void clr_flg(char *flag);
int find_table(char *szParamName, char *tname);
Expand Down
18 changes: 10 additions & 8 deletions tools/w_catalog_sales.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,20 @@ mk_detail(void *row, int bPrint)
/**
* having gone to the trouble to make the sale, now let's see if it gets returned
*/
genrand_integer(&nTemp, DIST_UNIFORM, 0, 99, 0, CR_IS_RETURNED);
if (nTemp < CR_RETURN_PCT)
{
mk_w_catalog_returns(NULL, 1);
if (bPrint)
pr_w_catalog_returns(NULL);
}
if (!is_set("FILTER") || is_set("_CHILD_ONLY")) {
genrand_integer(&nTemp, DIST_UNIFORM, 0, 99, 0, CR_IS_RETURNED);
if (nTemp < CR_RETURN_PCT)
{
mk_w_catalog_returns(NULL, 1);
if (bPrint)
pr_w_catalog_returns(NULL);
}
}

/**
* now we print out the order and lineitem together as a single row
*/
if (bPrint)
if (bPrint && (!is_set("FILTER") || !is_set("_CHILD_ONLY")))
pr_w_catalog_sales(NULL);

return;
Expand Down
18 changes: 10 additions & 8 deletions tools/w_store_sales.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,17 @@ tdef *pT = getSimpleTdefsByNumber(STORE_SALES);
/**
* having gone to the trouble to make the sale, now let's see if it gets returned
*/
genrand_integer(&nTemp, DIST_UNIFORM, 0, 99, 0, SR_IS_RETURNED);
if (nTemp < SR_RETURN_PCT)
{
mk_w_store_returns(&ReturnRow, 1);
if (bPrint)
pr_w_store_returns(&ReturnRow);
}
if (!is_set("FILTER") || is_set("_CHILD_ONLY")) {
genrand_integer(&nTemp, DIST_UNIFORM, 0, 99, 0, SR_IS_RETURNED);
if (nTemp < SR_RETURN_PCT)
{
mk_w_store_returns(&ReturnRow, 1);
if (bPrint)
pr_w_store_returns(&ReturnRow);
}
}

if (bPrint)
if (bPrint && (!is_set("FILTER") || !is_set("_CHILD_ONLY")))
pr_w_store_sales(NULL);

return;
Expand Down
16 changes: 9 additions & 7 deletions tools/w_web_sales.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,20 @@ mk_detail (void *row, int bPrint)
/**
* having gone to the trouble to make the sale, now let's see if it gets returned
*/
genrand_integer(&nTemp, DIST_UNIFORM, 0, 99, 0, WR_IS_RETURNED);
if (nTemp < WR_RETURN_PCT)
{
mk_w_web_returns(&w_web_returns, 1);
if (bPrint)
pr_w_web_returns(&w_web_returns);
if (!is_set("FILTER") || is_set("_CHILD_ONLY")) {
genrand_integer(&nTemp, DIST_UNIFORM, 0, 99, 0, WR_IS_RETURNED);
if (nTemp < WR_RETURN_PCT)
{
mk_w_web_returns(&w_web_returns, 1);
if (bPrint)
pr_w_web_returns(&w_web_returns);
}
}

/**
* now we print out the order and lineitem together as a single row
*/
if (bPrint)
if (bPrint && (!is_set("FILTER") || !is_set("_CHILD_ONLY")))
pr_w_web_sales(NULL);

return;
Expand Down

0 comments on commit 90b8e13

Please sign in to comment.