<|start_filename|>thirdparty/tpcds-kit/tools/w_store_sales.c<|end_filename|>
/* 
 * Legal Notice 
 * 
 * This document and associated source code (the "Work") is a part of a 
 * benchmark specification maintained by the TPC. 
 * 
 * The TPC reserves all right, title, and interest to the Work as provided 
 * under U.S. and international laws, including without limitation all patent 
 * and trademark rights therein. 
 * 
 * No Warranty 
 * 
 * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION 
 *     CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE 
 *     AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER 
 *     WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, 
 *     INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES, 
 *     DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR 
 *     PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF 
 *     WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE. 
 *     ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, 
 *     QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT 
 *     WITH REGARD TO THE WORK. 
 * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO 
 *     ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE 
 *     COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS 
 *     OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT, 
 *     INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
 *     OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT 
 *     RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD 
 *     ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. 
 * 
 * Contributors:
 * Gradient Systems
 */ 
#include "config.h"
#include "porting.h"
#include "decimal.h"
#include "w_store_sales.h"
#include "w_store_returns.h"
#include "genrand.h"
#include "columns.h"
#include "build_support.h"
#include "tables.h"
#include "constants.h"
#include "print.h"
#include "nulls.h"
#include "tdefs.h"
#include "scaling.h"
#include "permute.h"
#include "scd.h"
#include "parallel.h"
#ifdef JMS
extern rng_t Streams[];
#endif

struct W_STORE_SALES_TBL g_w_store_sales;
ds_key_t skipDays(int nTable, ds_key_t *pRemainder);
static int *pItemPermutation,
   nItemCount,
	nItemIndex;
static ds_key_t jDate,
   kNewDateIndex;

/*
* mk_store_sales
*/
static void
mk_master (void *row, ds_key_t index)
{
	struct W_STORE_SALES_TBL *r;
	static decimal_t dMin,
		dMax;
	static int bInit = 0,
		nMaxItemCount;
	static ds_key_t kNewDateIndex = 0;

	if (row == NULL)
		r = &g_w_store_sales;
	else
		r = row;

	if (!bInit)
	{
      strtodec (&dMin, "1.00");
      strtodec (&dMax, "100000.00");
		nMaxItemCount = 20;
		jDate = skipDays(STORE_SALES, &kNewDateIndex);
		pItemPermutation = makePermutation(NULL, nItemCount = (int)getIDCount(ITEM), SS_PERMUTATION);
		
		bInit = 1;
	}

	
   while (index > kNewDateIndex)	/* need to move to a new date */
   {
      jDate += 1;
      kNewDateIndex += dateScaling(STORE_SALES, jDate);
   }
		r->ss_sold_store_sk = mk_join (SS_SOLD_STORE_SK, STORE, 1);
		r->ss_sold_time_sk = mk_join (SS_SOLD_TIME_SK, TIME, 1);
		r->ss_sold_date_sk = mk_join (SS_SOLD_DATE_SK, DATE, 1);
		r->ss_sold_customer_sk = mk_join (SS_SOLD_CUSTOMER_SK, CUSTOMER, 1);
		r->ss_sold_cdemo_sk = mk_join (SS_SOLD_CDEMO_SK, CUSTOMER_DEMOGRAPHICS, 1);
		r->ss_sold_hdemo_sk = mk_join (SS_SOLD_HDEMO_SK, HOUSEHOLD_DEMOGRAPHICS, 1);
		r->ss_sold_addr_sk = mk_join (SS_SOLD_ADDR_SK, CUSTOMER_ADDRESS, 1);
		r->ss_ticket_number = index;
		genrand_integer(&nItemIndex, DIST_UNIFORM, 1, nItemCount, 0, SS_SOLD_ITEM_SK);

      return;
}


static void
mk_detail (void *row, int bPrint)
{
int nTemp;
struct W_STORE_RETURNS_TBL ReturnRow;
struct W_STORE_SALES_TBL *r;
tdef *pT = getSimpleTdefsByNumber(STORE_SALES);

	if (row == NULL)
		r = &g_w_store_sales;
	else
		r = row;

   nullSet(&pT->kNullBitMap, SS_NULLS);
	/* 
	 * items need to be unique within an order
	 * use a sequence within the permutation 
	 */
	if (++nItemIndex > nItemCount)
      nItemIndex = 1;
   r->ss_sold_item_sk = matchSCDSK(getPermutationEntry(pItemPermutation, nItemIndex), r->ss_sold_date_sk, ITEM);
	r->ss_sold_promo_sk = mk_join (SS_SOLD_PROMO_SK, PROMOTION, 1);
	set_pricing(SS_PRICING, &r->ss_pricing);

	/** 
	* having gone to the trouble to make the sale, now let's see if it gets returned
	*/
	
	/**
	 * hack to print to stdout when there is a sales/returns combo
	 * skip the returns since we can't send two tables to stdout at the same time
	 * TODO: add logic to generate the returns tables to stdout on their own
	 */	
	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 && (!is_set("FILTER") || !is_set("_CHILD_ONLY")))
      pr_w_store_sales(NULL);
	
	return;
}

/*
* Routine: 
* Purpose: 
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: None
*/
int
pr_w_store_sales(void *row)
{
	struct W_STORE_SALES_TBL *r;
	
	if (row == NULL)
		r = &g_w_store_sales;
	else
		r = row;

	print_start(STORE_SALES);
	print_key(SS_SOLD_DATE_SK, r->ss_sold_date_sk, 1);
	print_key(SS_SOLD_TIME_SK, r->ss_sold_time_sk, 1);
	print_key(SS_SOLD_ITEM_SK, r->ss_sold_item_sk, 1);
	print_key(SS_SOLD_CUSTOMER_SK, r->ss_sold_customer_sk, 1);
	print_key(SS_SOLD_CDEMO_SK, r->ss_sold_cdemo_sk, 1);
	print_key(SS_SOLD_HDEMO_SK, r->ss_sold_hdemo_sk, 1);
	print_key(SS_SOLD_ADDR_SK, r->ss_sold_addr_sk, 1);
	print_key(SS_SOLD_STORE_SK, r->ss_sold_store_sk, 1);
	print_key(SS_SOLD_PROMO_SK, r->ss_sold_promo_sk, 1);
	print_key(SS_TICKET_NUMBER, r->ss_ticket_number, 1);
	print_integer(SS_PRICING_QUANTITY, r->ss_pricing.quantity, 1);
	print_decimal(SS_PRICING_WHOLESALE_COST, &r->ss_pricing.wholesale_cost, 1);
	print_decimal(SS_PRICING_LIST_PRICE, &r->ss_pricing.list_price, 1);
	print_decimal(SS_PRICING_SALES_PRICE, &r->ss_pricing.sales_price, 1);
	print_decimal(SS_PRICING_COUPON_AMT, &r->ss_pricing.coupon_amt, 1);
	print_decimal(SS_PRICING_EXT_SALES_PRICE, &r->ss_pricing.ext_sales_price, 1);
	print_decimal(SS_PRICING_EXT_WHOLESALE_COST, &r->ss_pricing.ext_wholesale_cost, 1);
	print_decimal(SS_PRICING_EXT_LIST_PRICE, &r->ss_pricing.ext_list_price, 1);
	print_decimal(SS_PRICING_EXT_TAX, &r->ss_pricing.ext_tax, 1);
	print_decimal(SS_PRICING_COUPON_AMT, &r->ss_pricing.coupon_amt, 1);
	print_decimal(SS_PRICING_NET_PAID, &r->ss_pricing.net_paid, 1);
	print_decimal(SS_PRICING_NET_PAID_INC_TAX, &r->ss_pricing.net_paid_inc_tax, 1);
	print_decimal(SS_PRICING_NET_PROFIT, &r->ss_pricing.net_profit, 0);
	print_end(STORE_SALES);

	return(0);
}


/*
* Routine: 
* Purpose: 
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: None
*/
int 
ld_w_store_sales(void *pSrc)
{
	struct W_STORE_SALES_TBL *r;
		
	if (pSrc == NULL)
		r = &g_w_store_sales;
	else
		r = pSrc;
	
	return(0);
}

/*
* mk_store_sales
*/
int
mk_w_store_sales (void *row, ds_key_t index)
{
	int nLineitems,
		i;

   /* build the static portion of an order */
	mk_master(row, index);

   /* set the number of lineitems and build them */
	genrand_integer(&nLineitems, DIST_UNIFORM, 8, 16, 0, SS_TICKET_NUMBER);
   for (i = 1; i <= nLineitems; i++)
   {
	   mk_detail(NULL, 1);
   }

   /**
   * and finally return 1 since we have already printed the rows
   */	
   return (1);
}


/*
* Routine: 
* Purpose: 
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: None
*/
int
vld_w_store_sales(int nTable, ds_key_t kRow, int *Permutation)
{
	int nLineitem,
		nMaxLineitem,
		i;

	row_skip(nTable, kRow - 1);
	row_skip(STORE_RETURNS, kRow - 1);
	jDate = skipDays(STORE_SALES, &kNewDateIndex);		
	mk_master(NULL, kRow);
	genrand_integer(&nMaxLineitem, DIST_UNIFORM, 8, 16, 9, SS_TICKET_NUMBER);
	genrand_integer(&nLineitem, DIST_UNIFORM, 1, nMaxLineitem, 0, SS_PRICING_QUANTITY);
	for (i = 1; i < nLineitem; i++)
	{
		mk_detail(NULL, 0);
	}
	mk_detail(NULL, 1);

	return(0);
}



<|start_filename|>thirdparty/tpcds-kit/tools/config.h<|end_filename|>
/* 
 * Legal Notice 
 * 
 * This document and associated source code (the "Work") is a part of a 
 * benchmark specification maintained by the TPC. 
 * 
 * The TPC reserves all right, title, and interest to the Work as provided 
 * under U.S. and international laws, including without limitation all patent 
 * and trademark rights therein. 
 * 
 * No Warranty 
 * 
 * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION 
 *     CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE 
 *     AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER 
 *     WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, 
 *     INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES, 
 *     DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR 
 *     PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF 
 *     WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE. 
 *     ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, 
 *     QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT 
 *     WITH REGARD TO THE WORK. 
 * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO 
 *     ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE 
 *     COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS 
 *     OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT, 
 *     INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
 *     OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT 
 *     RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD 
 *     ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. 
 * 
 * Contributors:
 * Gradient Systems
 */ 

#ifndef CONFIG_H
#define CONFIG_H

#ifdef OSX
#define SUPPORT_64BITS
#define HUGE_TYPE	int64_t
#define HUGE_FORMAT	"%lld"
#define HUGE_COUNT	1
#define USE_STRING_H
#define USE_STDLIB_H
#define FLEX
#endif /* OSX */

#ifdef NCR
#define STDLIB_HAS_GETOPT
#define USE_STRING_H
#define USE_VALUES_H
#ifdef SQLSERVER
#define WIN32
#else
/* the 64 bit defines are for the Metaware compiler */
#define SUPPORT_64BITS
#define HUGE_TYPE long long
#define HUGE_COUNT	1
#define HUGE_FORMAT "%LLd"
#define int32_t int
#endif /* SQLSERVER or MP/RAS */
#endif /* NCR */

#ifdef AIX
#define _ALL_SOURCE
#define USE_STRING_H
#define USE_LIMITS_H
/*
 * if the C compiler is 3.1 or later, then uncomment the
 * lines for 64 bit seed generation
 */
#define SUPPORT_64BITS
#define HUGE_TYPE long long
#define HUGE_COUNT	1
#define HUGE_FORMAT	"%lld"
#define STDLIB_HAS_GETOPT
#define USE_STDLIB_H
#define FLEX
#endif /* AIX */

#ifdef CYGWIN
#define USE_STRING_H
#define PATH_SEP	'\\'
#define SUPPORT_64BITS
#define HUGE_TYPE __int64
#define HUGE_COUNT	1
#define HUGE_FORMAT "%I64d"
#endif /* WIN32 */

#ifdef HPUX
#define SUPPORT_64BITS
#define HUGE_TYPE	long long int
#define HUGE_FORMAT	"%lld"
#define HUGE_COUNT	1
#define USE_STRING_H
#define USE_VALUES_H
#define USE_STDLIB_H
#define FLEX
#endif /* HPUX */

#ifdef INTERIX
#define USE_LIMITS_H
#define SUPPORT_64BITS
#define HUGE_TYPE long long int
#define HUGE_FORMAT "%lld"
#define HUGE_COUNT 1
#endif /* INTERIX */

#ifdef LINUX
#define SUPPORT_64BITS
#define HUGE_TYPE	int64_t
#define HUGE_FORMAT	"%lld"
#define HUGE_COUNT	1
#define USE_STRING_H
#define USE_VALUES_H
#define USE_STDLIB_H
#define FLEX
#endif /* LINUX */

#ifdef SOLARIS
#define SUPPORT_64BITS
#define HUGE_TYPE	long long 
#define HUGE_FORMAT	"%lld"
#define HUGE_COUNT	1
#define USE_STRING_H
#define USE_VALUES_H
#define USE_STDLIB_H
#endif /* SOLARIS */

#ifdef SOL86
#define SUPPORT_64BITS
#define HUGE_TYPE	long long 
#define HUGE_FORMAT	"%lld"
#define HUGE_COUNT	1
#define USE_STRING_H
#define USE_VALUES_H
#define USE_STDLIB_H
#endif /* SOLARIS */

#ifdef WIN32
#define USE_STRING_H
#define USE_LIMITS_H
#define PATH_SEP	'\\'
#define SUPPORT_64BITS
#define HUGE_TYPE __int64
#define HUGE_COUNT	1
#define HUGE_FORMAT "%I64d"
#endif /* WIN32 */

/* preliminary defines for 64-bit windows compile */
#ifdef WIN64
#define USE_STRING_H
#define PATH_SEP	'\\'
#define SUPPORT_64BITS
#define HUGE_TYPE __int64
#define HUGE_COUNT	1
#define HUGE_FORMAT "%I64d"
#endif /* WIN32 */

#ifndef PATH_SEP
#define PATH_SEP '/'
#endif /* PATH_SEP */

#ifndef HUGE_TYPE
#error The code now requires 64b support
#endif

/***
 ** DATABASE DEFINES
 ***/
#ifdef _MYSQL
#define STR_QUOTES
#endif
#endif /* CONFIG_H */



<|start_filename|>thirdparty/tpcds-kit/tools/error_msg.c<|end_filename|>
/* 
 * Legal Notice 
 * 
 * This document and associated source code (the "Work") is a part of a 
 * benchmark specification maintained by the TPC. 
 * 
 * The TPC reserves all right, title, and interest to the Work as provided 
 * under U.S. and international laws, including without limitation all patent 
 * and trademark rights therein. 
 * 
 * No Warranty 
 * 
 * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION 
 *     CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE 
 *     AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER 
 *     WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, 
 *     INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES, 
 *     DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR 
 *     PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF 
 *     WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE. 
 *     ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, 
 *     QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT 
 *     WITH REGARD TO THE WORK. 
 * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO 
 *     ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE 
 *     COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS 
 *     OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT, 
 *     INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
 *     OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT 
 *     RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD 
 *     ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. 
 * 
 * Contributors:
 * Gradient Systems
 */ 
#include "config.h"
#include "porting.h"
#include <stdio.h>
#include "error_msg.h"
#include "grammar_support.h"
static int *LN;
static char *FN;

err_msg_t Errors[MAX_ERROR + 2] = {
	{EFLG_NO_ARG, "", },
	{EFLG_STR_ARG, "File '%s' not found"},
	{EFLG_NO_ARG, "Line exceeds maximum length"},
	{EFLG_STR_ARG, "Memory allocation failed %s"},
	{EFLG_STR_ARG, "Syntax Error: \n'%s'"},
	{EFLG_NO_ARG, "Invalid/Out-of-range Argument"},
	{EFLG_STR_ARG, "'%s' is not a unique name"},
	{EFLG_STR_ARG, "'%s' is not a valid name"},
	{EFLG_NO_ARG, "Command parse failed"},
	{EFLG_NO_ARG, "Invalid tag found"},
	{EFLG_STR_ARG, "Read failed on '%s'"},
	{EFLG_NO_ARG, "Too Many Templates!"},
	{EFLG_NO_ARG, "Each workload definition must be in its own file"},
	{EFLG_NO_ARG, "Query Class name must be unique within a workload definition"},
	{EFLG_NO_ARG, "Query Template must be unique within a query class"},
	{EFLG_STR_ARG|EFLG_SYSTEM, "Open failed on '%s'"},
	{EFLG_STR_ARG, "%s  not yet implemented"},										/* QERR_NOT_IMPLEMENTED */
	{EFLG_STR_ARG, "string trucated to '%s'"},
	{EFLG_NO_ARG, "Non-terminated string"},
	{EFLG_STR_ARG, "failed to write to '%s'"},
	{EFLG_NO_ARG, "No type vector defined for distribution"},
	{EFLG_NO_ARG, "No weight count defined for distribution"},
	{EFLG_NO_ARG, "No limits defined for pricing calculations"},
	{EFLG_STR_ARG, "Percentage is out of bounds in substitution '%s'"},
	{EFLG_STR_ARG, "Name is not a distribution or table name: '%s'"},
	{EFLG_NO_ARG, "Cannot evaluate expression"},
	{EFLG_STR_ARG, "Substitution'%s' is used before being initialized"}, /* QERR_NO_INIT */
	{EFLG_NO_ARG, "RANGE()/LIST()/ULIST() not supported for NORMAL distributions"},
	{EFLG_STR_ARG, "Bad Nesting; '%s' not found"},
	{EFLG_STR_ARG, "Include stack overflow when opening '%s'"},
	{EFLG_STR_ARG, "Bad function call: '%s'"},
	{EFLG_STR_ARG, "Bad Hierarchy Call: '%s'"},
	{EFLG_NO_ARG, "Must set types and weights before defining names"},
	{EFLG_NO_ARG, "More than 20 arguments in definition"},
	{EFLG_NO_ARG, "Argument type mismatch"},
	{EFLG_NO_ARG, "RANGE()/LIST()/ULIST() cannot be used in the same expression"},		/* QERR_RANGE_LIST */
	{EFLG_NO_ARG, "Selected volume is NOT valid for result publication"},
	{EFLG_STR_ARG, "Parameter setting failed for '%s'"},
	{EFLG_STR_ARG, "Table %s is being joined without an explicit rule"},
	{EFLG_STR_ARG, "Table %s is not yet fully defined"},
	{EFLG_STR_ARG, "Table %s is a child; it is populated during the build of its parent (e.g., catalog_sales builds catalog returns)"},
	{EFLG_NO_ARG, "Command line arguments for dbgen_version exceed 200 characters; truncated"},
	{EFLG_NO_ARG, "A query template list must be supplied using the INPUT option"},	/* QERR_NO_QUERYLIST */
	{EFLG_NO_ARG, "Invalid query number found in permutation!"},					/* QERR_QUERY_RANGE */
	{EFLG_NO_ARG, "RANGE/LIST/ULIST expressions not valid as function parameters"},		/* QERR_MODIFIED_PARAM */
	{EFLG_NO_ARG, "RANGE/LIST/ULIST truncated to available values"},						/* QERR_MODIFIED_PARAM */
	{EFLG_NO_ARG, "This scale factor is valid for QUALIFICATION ONLY"},				/* QERR_QUALIFICATION_SCALE */
	{EFLG_STR_ARG, "Generating %s requires the '-update' option"},		/* QERR_TABLE_UPDATE */
	{0, NULL}
};

/*
 * Routine: 
 * Purpose: 
 * Algorithm:
 * Data Structures:
 *
 * Params:
 * Returns:
 * Called By: 
 * Calls: 
 * Assumptions:
 * Side Effects:
 * TODO: None
 */
void
ProcessErrorCode (int nErrorCode, char *szRoutineName, char *szParam,
                  int nParam)
{
   switch (nErrorCode)
     {
     case QERR_NO_FILE:
        ReportError (QERR_NO_FILE, szParam, 1);
        break;
     case QERR_SYNTAX:
     case QERR_RANGE_ERROR:
     case QERR_NON_UNIQUE:
     case QERR_BAD_NAME:
     case QERR_DEFINE_OVERFLOW:
     case QERR_INVALID_TAG:
     case QERR_READ_FAILED:
     case QERR_NO_MEMORY:
     case QERR_LINE_TOO_LONG:
        ReportError (nErrorCode, szRoutineName, 1);
        break;
     }
   return;
}

/*
 * Routine: 
 * Purpose: 
 * Algorithm:
 * Data Structures:
 *
 * Params:
 * Returns:
 * Called By: 
 * Calls: 
 * Assumptions:
 * Side Effects:
 * TODO: None
 */
int
ReportError (int nError, char *msg, int bExit)
{
   char e_msg[128];

   if (nError < MAX_ERROR)
     {
        switch (Errors[-nError].flags & EFLG_ARG_MASK)
          {
          case EFLG_NO_ARG:
             fprintf (stderr, "ERROR: %s at line %d in %s\n",
                      Errors[-nError].prompt, pCurrentFile->line_number, pCurrentFile->name);
             break;
          case EFLG_STR_ARG:
             sprintf (e_msg, Errors[-nError].prompt, msg);
             fprintf (stderr, "ERROR: %s at line %d in %s\n",
                      e_msg, pCurrentFile->line_number, pCurrentFile->name);
             break;
          }

        if (Errors[-nError].flags & EFLG_SYSTEM)
           perror (msg);
     }

   if (bExit)
      exit (nError);
   else
      return (nError);
}

/*
 * Routine: 
 * Purpose: 
 * Algorithm:
 * Data Structures:
 *
 * Params:
 * Returns:
 * Called By: 
 * Calls: 
 * Assumptions:
 * Side Effects:
 * TODO: None
 */
int
ReportErrorNoLine (int nError, char *msg, int bExit)
{
   char e_msg[1024];

   if (nError < MAX_ERROR)
     {
        switch (Errors[-nError].flags & EFLG_ARG_MASK)
          {
          case EFLG_NO_ARG:
			  fprintf (stderr, "%s: %s\n", (bExit)?"ERROR":"Warning", Errors[-nError].prompt);
             break;
          case EFLG_STR_ARG:
             sprintf (e_msg, Errors[-nError].prompt, msg);
             fprintf (stderr, "%s: %s\n", (bExit)?"ERROR":"Warning", e_msg);
             break;
          }

        if (Errors[-nError].flags & EFLG_SYSTEM)
           perror (msg);
     }

   if (bExit)
      exit (nError);
   else
      return (nError);
}

/*
 * Routine: 
 * Purpose: 
 * Algorithm:
 * Data Structures:
 *
 * Params:
 * Returns:
 * Called By: 
 * Calls: 
 * Assumptions:
 * Side Effects:
 * TODO: None
 */
void
SetErrorGlobals (char *szFileName, int *nLineNumber)
{
	FN = szFileName;
	LN = nLineNumber;

	return;
}


<|start_filename|>thirdparty/tpcds-kit/tools/Makefile<|end_filename|>
#
#  Legal Notice
#
#  This document and associated source code (the "Work") is a part of a
#  benchmark specification maintained by the TPC.
# 
#  The TPC reserves all right, title, and interest to the Work as provided
#  under U.S. and international laws, including without limitation all patent
#  and trademark rights therein.
# 
#  No Warranty
# 
#  1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
#      CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
#      AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
#      WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
#      INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
#      DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
#      PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
#      WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
#      ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
#      QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
#      WITH REGARD TO THE WORK.
#  1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
#      ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
#      COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
#      OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
#      INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
#      OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
#      RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
#      ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
# 
#  Contributors:
#  Gradient Systems
# 
#
#
################
## TARGET OS HERE
################
# OS Values: AIX, LINUX, SOLARIS, NCR, HPUX, OSX
OS = LINUX
###########
# No changes should be necessary below this point
# Each compile variable is adjusted for the target platform using the OS setting above
###########
# CC
AIX_CC		= xlC
HPUX_CC		= gcc
LINUX_CC	= gcc
NCR_CC		= cc
OSX_CC		= gcc
SOLARIS_CC	= gcc
SOL86_CC	= cc
CC		= $($(OS)_CC)
# CFLAGS
AIX_CFLAGS		= -q64 -O3 -D_LARGE_FILES
HPUX_CFLAGS		= -O3 -Wall
LINUX_CFLAGS	= -g -Wall
NCR_CFLAGS		= -g 
OSX_CFLAGS		= -g -Wall
SOLARIS_CFLAGS	= -O3 -Wall
SOL86_CFLAGS	= -O3 
BASE_CFLAGS    	= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DYYDEBUG #-maix64 -DMEM_TEST 
CFLAGS			= $(BASE_CFLAGS) -D$(OS) $($(OS)_CFLAGS)
# EXE
AIX_EXE		= 
HPUX_EXE	= 
LINUX_EXE	= 
NCR_EXE		= 
OSX_EXE		= 
SOLARIS_EXE	= 
SOL86_EXE	= 
EXE			= $($(OS)_EXE)
# LEX
AIX_LEX		= flex
HPUX_LEX	= flex
LINUX_LEX	= lex
NCR_LEX		= lex
OSX_LEX		= lex
SOLARIS_LEX	= lex
SOL86_LEX	= lex
LEX			= $($(OS)_LEX)
# LIBS
AIX_LIBS	= -lm
HPUX_LIBS	= -lm -ll
LINUX_LIBS	= -lm
NCR_LIBS	= -lm -lc89
OSX_LIBS	= -lm
SOLARIS_LIBS	= -ly -ll -lm
SOL86_LIBS	= -ly -ll -lm
LIBS		= $($(OS)_LIBS)
# YACC
AIX_YACC	= yacc
HPUX_YACC	= bison -y
LINUX_YACC	= yacc
NCR_YACC	= yacc
OSX_YACC	= yacc
SOLARIS_YACC	= yacc
SOL86_YACC	= yacc
YACC		= $($(OS)_YACC)
# YFLAGS
AIX_YFLAGS	= -d -v
HPUX_YFLAGS	= -y -d -v
LINUX_YFLAGS	= -d -v
NCR_YFLAGS	= -d -v
OSX_YFLAGS	= -d -v
SOLARIS_YFLAGS	= -d -v
SOL86_YFLAGS	= -d -v
YFLAGS		= $($(OS)_YFLAGS)
###############
TREE_ROOT=/tmp/tree
#
PROG1 = dsdgen$(EXE)
PROG2 = dsqgen$(EXE)
PROG3 = distcomp$(EXE)
PROG4 = mkheader$(EXE)
PROG5 = checksum$(EXE)
PROGS = $(PROG1) $(PROG2) $(PROG3) $(PROG4) $(PROG5)
#
COMMON_HDR = address.h build_support.h config.h constants.h date.h \
	dcgram.h dcomp.h dcomp_params.h decimal.h dist.h driver.h \
	error_msg.h expr.h genrand.h grammar.h grammar_support.h \
	list.h load.h misc.h nulls.h parallel.h params.h \
	permute.h porting.h pricing.h print.h qgen_params.h query_handler.h \
	release.h r_params.h StringBuffer.h tdef_functions.h \
	tdefs.h template.h scd.h mathops.h scd.h sparse.h validate.h
DISTCOMP_HDR = dcgram.h dcomp.h dcomp_params.h grammar.h nulls.h 
QGEN_HDR = eval.h substitution.h  keywords.h permute.h qgen_params.h 
S_HDR = s_brand.h s_customer_address.h scaling.h s_call_center.h s_catalog.h \
	s_catalog_order.h s_catalog_order_lineitem.h s_catalog_page.h \
	s_catalog_promotional_item.h s_catalog_returns.h s_category.h \
	s_class.h s_company.h s_customer.h s_division.h s_inventory.h \
	s_item.h s_manager.h s_manufacturer.h s_market.h s_pline.h s_product.h \
	s_promotion.h s_purchase.h s_reason.h s_store.h \
	s_store_promotional_item.h s_store_returns.h s_subcategory.h \
	s_subclass.h s_warehouse.h s_web_order.h \
	s_web_order_lineitem.h s_web_page.h s_web_promotional_item.h \
	s_web_returns.h s_web_site.h s_tdefs.h s_zip_to_gmt.h
W_HDR = w_call_center.h w_catalog_page.h w_catalog_returns.h \
	w_catalog_sales.h w_customer_address.h w_customer_demographics.h \
	w_customer.h w_datetbl.h w_household_demographics.h w_income_band.h \
	w_inventory.h w_item.h \
	w_promotion.h w_reason.h w_ship_mode.h \
	w_store.h w_store_returns.h w_store_sales.h w_tdefs.h w_timetbl.h \
	w_warehouse.h w_web_page.h w_web_returns.h w_web_sales.h w_web_site.h \
	dbgen_version.h
HDR = $(COMMON_HDR) $(DISTCOMP_HDR) $(QGEN_HDR) $(S_HDR) $(W_HDR)
#
COMMON_SRC = address.c build_support.c date.c \
	decimal.c dist.c driver.c error_msg.c expr.c genrand.c \
	grammar_support.c join.c list.c load.c misc.c \
	nulls.c parallel.c permute.c pricing.c print.c r_params.c StringBuffer.c \
	tdef_functions.c tdefs.c text.c scd.c scaling.c release.c scd.c sparse.c \
	porting.c validate.c
DISTCOMP_SRC = dcgram.c dcomp.c grammar.c 
QGEN_SRC = tokenizer.l substitution.c QgenMain.c qgen.y query_handler.c \
	eval.c keywords.c
S_SRC = s_brand.c s_customer_address.c scaling.c s_call_center.c s_catalog.c \
	s_catalog_order.c s_catalog_order_lineitem.c s_catalog_page.c \
	s_catalog_promotional_item.c s_catalog_returns.c s_category.c \
	s_class.c s_company.c s_customer.c s_division.c s_inventory.c s_item.c \
	s_manager.c s_manufacturer.c s_market.c s_pline.c s_product.c \
	s_promotion.c s_purchase.c s_reason.c s_store.c \
	s_store_promotional_item.c s_store_returns.c s_subcategory.c \
	s_subclass.c s_warehouse.c s_web_order.c s_web_order_lineitem.c \
	s_web_page.c s_web_promotinal_item.c s_web_returns.c s_web_site.c \
	s_zip_to_gmt.c
W_SRC = w_call_center.c w_catalog_page.c w_catalog_returns.c w_catalog_sales.c \
	w_customer_address.c w_customer.c w_customer_demographics.c  \
	w_datetbl.c w_household_demographics.c w_income_band.c w_inventory.c \
	w_item.c \
	w_promotion.c w_reason.c w_ship_mode.c w_store.c w_store_returns.c \
	w_store_sales.c w_timetbl.c w_warehouse.c w_web_page.c w_web_returns.c \
	w_web_sales.c w_web_site.c dbgen_version.c
SRC = $(COMMON_SRC) $(DISTCOMP_SRC) $(S_SRC) $(W_SRC) $(QGEN_SRC) mkheader.c checksum.c
#
DBGEN_OBJ = address.o build_support.o date.o \
	decimal.o dist.o driver.o error_msg.o genrand.o \
	join.o list.o load.o misc.o \
	nulls.o parallel.o permute.o pricing.o print.o r_params.o StringBuffer.o \
	tdef_functions.o tdefs.o text.o scd.o scaling.o release.o sparse.o validate.o
DISTCOMP_OBJ = dcgram.o dcomp.o grammar.o error_msg.o StringBuffer.o r_params.o 
QGEN_OBJ = address.o date.o decimal.o dist.o error_msg.o expr.o \
	eval.o genrand.o grammar_support.o keywords.o list.o \
	nulls.o permute.o print.o QgenMain.o query_handler.o r_params.o \
	scaling.o StringBuffer.o substitution.o tdefs.o text.o tokenizer.o w_inventory.o y.tab.o \
	release.o scd.o build_support.o parallel.o 
S_OBJ = s_brand.o s_customer_address.o s_call_center.o s_catalog.o \
	s_catalog_order.o s_catalog_order_lineitem.o s_catalog_page.o \
	s_catalog_promotional_item.o s_catalog_returns.o s_category.o \
	s_class.o s_company.o s_customer.o s_division.o s_inventory.o s_item.o \
	s_manager.o s_manufacturer.o s_market.o s_pline.o s_product.o \
	s_promotion.o s_purchase.o s_reason.o s_store.o \
	s_store_promotional_item.o s_store_returns.o s_subcategory.o \
	s_subclass.o s_warehouse.o s_web_order.o s_web_order_lineitem.o \
	s_web_page.o s_web_promotinal_item.o s_web_returns.o s_web_site.o \
	s_zip_to_gmt.o
W_OBJ = w_call_center.o w_catalog_page.o w_catalog_returns.o w_catalog_sales.o \
	w_customer_address.o w_customer.o w_customer_demographics.o  \
	w_datetbl.o w_household_demographics.o w_income_band.o w_inventory.o \
	w_item.o \
	w_promotion.o w_reason.o w_ship_mode.o w_store.o w_store_returns.o \
	w_store_sales.o w_timetbl.o w_warehouse.o w_web_page.o w_web_returns.o \
	w_web_sales.o w_web_site.o dbgen_version.o
#
OBJ1 =	$(S_OBJ) $(W_OBJ) $(DBGEN_OBJ)
OBJ2 =	$(QGEN_OBJ)
OBJ3 =	$(DISTCOMP_OBJ)
OBJ4 =	mkheader.o
OBJ5 =	checksum.o
OBJ = $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) $(OBJ5)
#
IDX 	=	tpcds.idx 
IDXSRC =	calendar.dst cities.dst english.dst fips.dst names.dst \
			streets.dst tpcds.dst items.dst scaling.dst
#
DOC =	README HISTORY PORTING.NOTES QGEN.doc \
	ReleaseNotes.txt README_grammar.txt How_To_Guide.doc
DDL = 	tpcds.sql tpcds.wam source_schema.wam tpcds_source.sql
OTHER=	Makefile.suite column_list.txt parallel.sh specification.doc tpcds_ri.sql
WIN_MAKE=dbgen2.vcproj distcomp.vcproj qgen2.vcproj mkheader.vcproj \
	y.tab.c y.tab.h tokenizer.c grammar.vcproj dbgen2.sln Cygwin\ Tools.rules checksum.vcproj
#
FQD =		query_templates/*
VARIANTS =	query_variants/*
TESTS =		tests/*.sh tests/*.sql 
ANS = 		answer_sets/*.ans
QUERY_SRC = $(FQD) $(VARIANTS)
TREE_DOC =
JUNK	= tags *.idx tables.h streams.h columns.h y.tab.h y.tab.c tokenizer.c  \
	y.output .ctags_updated tpcds.idx.h
DBGENSRC	= $(SRC) $(HDR) $(OTHER) $(DOC) $(DDL) $(IDXSRC) $(WIN_MAKE) $(QUERY_SRC) $(TESTS) $(ANS)
GENERATED	= tables.h streams.h columns.h
DATE_STAMP	= `date '+%Y%m%d'`
#
all: .ctags_updated $(PROGS) $(IDX) 

$(PROG1): $(OBJ1) $(IDX)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $(PROG1) $(OBJ1) $(LIBS)
$(PROG2): $(OBJ2)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $(PROG2) $(OBJ2) $(LIBS)
$(PROG3): $(OBJ3)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $(PROG3) $(OBJ3) $(LIBS)
$(PROG4): $(OBJ4)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $(PROG4) $(OBJ4) $(LIBS)
$(PROG5): $(OBJ5)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $(PROG5) $(OBJ5) $(LIBS)
$(IDX): $(PROG3) $(IDXSRC)
	./$(PROG3) -i tpcds.dst -o $(IDX)

clean:
	-rm -f $(PROGS) $(OBJ) $(JUNK) $(IDX)
.ctags_updated: $(SRC)
	-ctags $(SRC) 2> /dev/null
	date > .ctags_updated
current_source:
	cvs update
depend: $(SRC) $(HDR)
	touch tables.h streams.h columns.h
	-makedepend -f Makefile.suite -Y -- $(CFLAGS) -- $(SRC) 2> /dev/null
	date > .depend_updated
	rm -f tables.h streams.h columns.h
lint:
	lint $(CFLAGS) -u -x -wO -p $(SRC1)
	lint $(CFLAGS) -u -x -wO -p $(SRC2)
release: current_source depend sum tar zip test_build
	rm -f tpcds_`date '+%Y%m%d'`.sum
	rm -rf test
tar: $(DBGENSRC)
	tar cvzf tpcds_`date '+%Y%m%d'`.tar.gz $(DBGENSRC) tpcds_`date '+%Y%m%d'`.sum
zip: $(DBGENSRC)
	zip tpcds_`date '+%Y%m%d'` $(DBGENSRC) tpcds_`date '+%Y%m%d'`.sum
data_set: /data/dbgen_version.dat
	touch data_set
/data/dbgen_version.dat: $(PROG1)
	rm -f /data/*.dat
	./$(PROG1) -f -sc 1 -dir /data
	./$(PROG1) -f -sc 1 -dir /data -update 1
sum: $(PROG1) data_set
	sum /data/*.dat > tpcds_`date '+%Y%m%d'`.sum
test_build: 
	(cd tests; sh -x test_list.sh `date '+%Y%m%d'` 1 1)
####
# Dependencies. Partially hand coded, partially generated by makedepend
####
$(GENERATED): $(PROG4) column_list.txt
	./$(PROG4) column_list.txt
tokenizer.c: tokenizer.l
y.tab.c: qgen.y
	$(YACC) $(YFLAGS) qgen.y
y.tab.o: y.tab.c
y.tab.h: qgen.y
	$(YACC) $(YFLAGS) qgen.y
tpcds.idx.h: $(IDXSRC) $(PROG3)
	./$(PROG3) -i tpcds.dst -o tpcds.idx
expr.o: y.tab.h
qgen_error.o: error_msg.c
	$(CC) $(CFLAGS) -DQGEN -c -o qgen_error.o error_msg.c
qgen:
	@make qgen2$(EXE)
join.o: tpcds.idx.h
driver.o: tpcds.idx.h
mkheader.o: mkheader.c 
$(OBJ1) $(OBJ2) $(OBJ3): $(GENERATED)
# DO NOT DELETE

address.o: config.h porting.h address.h constants.h dist.h r_params.h
address.o: genrand.h decimal.h mathops.h date.h columns.h tables.h tdefs.h
address.o: tdef_functions.h permute.h scaling.h
build_support.o: config.h porting.h decimal.h mathops.h constants.h dist.h
build_support.o: r_params.h genrand.h date.h address.h tdefs.h tables.h
build_support.o: columns.h tdef_functions.h build_support.h pricing.h
build_support.o: StringBuffer.h error_msg.h scaling.h
date.o: config.h porting.h date.h mathops.h dist.h
decimal.o: config.h porting.h decimal.h mathops.h
dist.o: config.h porting.h decimal.h mathops.h date.h dist.h genrand.h
dist.o: address.h constants.h error_msg.h r_params.h dcomp.h grammar.h
driver.o: config.h porting.h date.h mathops.h decimal.h genrand.h dist.h
driver.o: address.h constants.h tdefs.h tables.h columns.h tdef_functions.h
driver.o: build_support.h pricing.h params.h r_params.h release.h parallel.h
driver.o: scaling.h load.h error_msg.h print.h tpcds.idx.h grammar_support.h
driver.o: scd.h
error_msg.o: config.h porting.h error_msg.h grammar_support.h
expr.o: config.h porting.h error_msg.h StringBuffer.h expr.h list.h mathops.h
expr.o: y.tab.h substitution.h eval.h grammar_support.h date.h keywords.h
expr.o: dist.h genrand.h decimal.h address.h constants.h permute.h
genrand.o: config.h porting.h decimal.h mathops.h date.h genrand.h dist.h
genrand.o: address.h constants.h r_params.h params.h release.h columns.h
genrand.o: tables.h streams.h
grammar_support.o: config.h porting.h StringBuffer.h expr.h list.h mathops.h
grammar_support.o: grammar_support.h keywords.h error_msg.h qgen_params.h
grammar_support.o: r_params.h release.h substitution.h eval.h
join.o: config.h porting.h date.h mathops.h decimal.h dist.h constants.h
join.o: columns.h genrand.h address.h tdefs.h tables.h tdef_functions.h
join.o: build_support.h pricing.h tpcds.idx.h scaling.h w_web_sales.h
join.o: error_msg.h scd.h r_params.h sparse.h
list.o: config.h porting.h list.h error_msg.h
load.o: config.h porting.h tables.h
misc.o: config.h porting.h date.h mathops.h decimal.h dist.h misc.h tdefs.h
misc.o: tables.h columns.h tdef_functions.h r_params.h genrand.h address.h
misc.o: constants.h
nulls.o: config.h porting.h nulls.h genrand.h decimal.h mathops.h date.h
nulls.o: dist.h address.h constants.h tdefs.h tables.h columns.h
nulls.o: tdef_functions.h
parallel.o: config.h porting.h r_params.h scaling.h tdefs.h tables.h
parallel.o: columns.h tdef_functions.h genrand.h decimal.h mathops.h date.h
parallel.o: dist.h address.h constants.h
permute.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
permute.o: address.h constants.h
pricing.o: config.h porting.h decimal.h mathops.h pricing.h constants.h
pricing.o: columns.h error_msg.h dist.h driver.h genrand.h date.h address.h
pricing.o: w_web_sales.h s_pline.h
print.o: config.h porting.h tables.h print.h tdef_functions.h r_params.h
print.o: date.h mathops.h decimal.h tdefs.h columns.h nulls.h constants.h
print.o: build_support.h dist.h pricing.h
r_params.o: config.h porting.h r_params.h tdefs.h tables.h columns.h
r_params.o: tdef_functions.h release.h
StringBuffer.o: config.h porting.h StringBuffer.h
tdef_functions.o: w_call_center.h constants.h pricing.h decimal.h config.h
tdef_functions.o: porting.h mathops.h address.h date.h w_catalog_page.h
tdef_functions.o: w_catalog_returns.h w_catalog_sales.h w_customer.h
tdef_functions.o: w_customer_address.h w_customer_demographics.h w_datetbl.h
tdef_functions.o: w_household_demographics.h w_income_band.h w_inventory.h
tdef_functions.o: w_item.h w_promotion.h w_reason.h w_ship_mode.h w_store.h
tdef_functions.o: w_store_returns.h w_store_sales.h w_timetbl.h w_warehouse.h
tdef_functions.o: w_web_page.h w_web_returns.h w_web_sales.h w_web_site.h
tdef_functions.o: dbgen_version.h s_brand.h s_customer_address.h
tdef_functions.o: s_call_center.h s_catalog.h s_catalog_order.h
tdef_functions.o: s_catalog_order_lineitem.h s_catalog_page.h
tdef_functions.o: s_catalog_promotional_item.h s_catalog_returns.h
tdef_functions.o: s_category.h s_class.h s_company.h s_customer.h
tdef_functions.o: s_division.h s_inventory.h s_item.h s_manager.h
tdef_functions.o: s_manufacturer.h s_market.h s_pline.h s_product.h
tdef_functions.o: s_promotion.h s_purchase.h s_reason.h s_store.h
tdef_functions.o: s_store_promotional_item.h s_store_returns.h
tdef_functions.o: s_subcategory.h s_subclass.h s_warehouse.h s_web_order.h
tdef_functions.o: s_web_order_lineitem.h s_web_page.h
tdef_functions.o: s_web_promotional_item.h s_web_returns.h s_web_site.h
tdef_functions.o: s_zip_to_gmt.h tdef_functions.h tables.h validate.h
tdefs.o: config.h porting.h tables.h columns.h genrand.h decimal.h mathops.h
tdefs.o: date.h dist.h address.h constants.h tdefs.h tdef_functions.h
tdefs.o: scaling.h w_tdefs.h s_tdefs.h r_params.h
text.o: config.h porting.h decimal.h mathops.h date.h genrand.h dist.h
text.o: address.h constants.h
scd.o: config.h porting.h tdefs.h tables.h columns.h tdef_functions.h scd.h
scd.o: decimal.h mathops.h build_support.h date.h dist.h pricing.h scaling.h
scd.o: genrand.h address.h constants.h parallel.h params.h r_params.h
scd.o: release.h print.h permute.h
scaling.o: config.h porting.h dist.h constants.h genrand.h decimal.h
scaling.o: mathops.h date.h address.h columns.h tdefs.h tables.h
scaling.o: tdef_functions.h error_msg.h r_params.h w_inventory.h scaling.h
scaling.o: tpcds.idx.h print.h parallel.h scd.h
release.o: config.h porting.h release.h r_params.h
scd.o: config.h porting.h tdefs.h tables.h columns.h tdef_functions.h scd.h
scd.o: decimal.h mathops.h build_support.h date.h dist.h pricing.h scaling.h
scd.o: genrand.h address.h constants.h parallel.h params.h r_params.h
scd.o: release.h print.h permute.h
sparse.o: config.h porting.h scaling.h genrand.h decimal.h mathops.h date.h
sparse.o: dist.h address.h constants.h sparse.h tdefs.h tables.h columns.h
sparse.o: tdef_functions.h error_msg.h
porting.o: config.h porting.h
validate.o: config.h porting.h tdefs.h tables.h columns.h tdef_functions.h
validate.o: r_params.h parallel.h constants.h scd.h decimal.h mathops.h
validate.o: permute.h print.h
dcgram.o: config.h porting.h error_msg.h grammar.h dist.h dcomp.h r_params.h
dcgram.o: dcgram.h
dcomp.o: config.h porting.h r_params.h dcomp_params.h error_msg.h grammar.h
dcomp.o: dist.h dcgram.h dcomp.h substitution.h StringBuffer.h expr.h list.h
dcomp.o: mathops.h eval.h grammar_support.h
grammar.o: config.h porting.h grammar.h error_msg.h StringBuffer.h expr.h
grammar.o: list.h mathops.h decimal.h date.h
s_brand.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_brand.o: address.h constants.h s_brand.h print.h columns.h build_support.h
s_brand.o: pricing.h tables.h parallel.h
s_customer_address.o: config.h porting.h w_customer_address.h constants.h
s_customer_address.o: address.h s_customer_address.h date.h mathops.h
s_customer_address.o: decimal.h genrand.h dist.h columns.h build_support.h
s_customer_address.o: pricing.h print.h tables.h nulls.h tdefs.h
s_customer_address.o: tdef_functions.h
scaling.o: config.h porting.h dist.h constants.h genrand.h decimal.h
scaling.o: mathops.h date.h address.h columns.h tdefs.h tables.h
scaling.o: tdef_functions.h error_msg.h r_params.h w_inventory.h scaling.h
scaling.o: tpcds.idx.h print.h parallel.h scd.h
s_call_center.o: config.h porting.h s_call_center.h genrand.h decimal.h
s_call_center.o: mathops.h date.h dist.h address.h constants.h r_params.h
s_call_center.o: scaling.h tables.h build_support.h columns.h pricing.h
s_call_center.o: print.h w_call_center.h permute.h scd.h
s_catalog.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_catalog.o: address.h constants.h s_catalog.h print.h columns.h
s_catalog.o: build_support.h pricing.h misc.h tables.h
s_catalog_order.o: config.h porting.h genrand.h decimal.h mathops.h date.h
s_catalog_order.o: dist.h address.h constants.h s_catalog_order.h
s_catalog_order.o: s_catalog_order_lineitem.h pricing.h s_catalog_returns.h
s_catalog_order.o: print.h columns.h build_support.h tables.h misc.h
s_catalog_order.o: scaling.h params.h r_params.h release.h w_web_sales.h
s_catalog_order.o: parallel.h
s_catalog_order_lineitem.o: config.h porting.h genrand.h decimal.h mathops.h
s_catalog_order_lineitem.o: date.h dist.h address.h constants.h
s_catalog_order_lineitem.o: s_catalog_order_lineitem.h pricing.h
s_catalog_order_lineitem.o: s_catalog_order.h w_web_sales.h print.h columns.h
s_catalog_order_lineitem.o: build_support.h tables.h parallel.h permute.h
s_catalog_order_lineitem.o: scaling.h scd.h
s_catalog_page.o: config.h porting.h genrand.h decimal.h mathops.h date.h
s_catalog_page.o: dist.h address.h constants.h s_catalog_page.h
s_catalog_page.o: w_catalog_page.h print.h columns.h build_support.h
s_catalog_page.o: pricing.h tables.h scaling.h tdef_functions.h validate.h
s_catalog_page.o: parallel.h
s_catalog_promotional_item.o: config.h porting.h genrand.h decimal.h
s_catalog_promotional_item.o: mathops.h date.h dist.h address.h constants.h
s_catalog_promotional_item.o: s_catalog_promotional_item.h print.h columns.h
s_catalog_promotional_item.o: build_support.h pricing.h tables.h
s_catalog_returns.o: config.h porting.h genrand.h decimal.h mathops.h date.h
s_catalog_returns.o: dist.h address.h constants.h s_catalog_returns.h
s_catalog_returns.o: pricing.h s_catalog_order.h s_catalog_order_lineitem.h
s_catalog_returns.o: print.h columns.h build_support.h tables.h parallel.h
s_category.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_category.o: address.h constants.h s_category.h print.h columns.h
s_category.o: build_support.h pricing.h tables.h misc.h
s_class.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_class.o: address.h constants.h s_class.h print.h build_support.h columns.h
s_class.o: pricing.h tables.h misc.h parallel.h
s_company.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_company.o: address.h constants.h s_company.h print.h columns.h
s_company.o: build_support.h pricing.h tables.h parallel.h
s_customer.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_customer.o: address.h constants.h s_customer.h print.h columns.h
s_customer.o: build_support.h pricing.h tables.h scaling.h parallel.h
s_customer.o: w_customer_demographics.h w_customer_address.h permute.h
s_division.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_division.o: address.h constants.h s_division.h print.h columns.h
s_division.o: build_support.h pricing.h tables.h parallel.h
s_inventory.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_inventory.o: address.h constants.h s_inventory.h print.h columns.h
s_inventory.o: build_support.h pricing.h tables.h r_params.h parallel.h
s_inventory.o: scaling.h scd.h
s_item.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_item.o: address.h constants.h s_item.h w_item.h print.h columns.h
s_item.o: build_support.h pricing.h tables.h misc.h parallel.h permute.h
s_item.o: scaling.h scd.h tdef_functions.h r_params.h
s_manager.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_manager.o: address.h constants.h s_manager.h print.h columns.h
s_manager.o: build_support.h pricing.h tables.h parallel.h
s_manufacturer.o: config.h porting.h genrand.h decimal.h mathops.h date.h
s_manufacturer.o: dist.h address.h constants.h s_manufacturer.h print.h
s_manufacturer.o: columns.h build_support.h pricing.h tables.h parallel.h
s_market.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_market.o: address.h constants.h s_market.h print.h columns.h
s_market.o: build_support.h pricing.h tables.h misc.h parallel.h
s_pline.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_pline.o: address.h constants.h s_pline.h pricing.h s_purchase.h print.h
s_pline.o: columns.h build_support.h tables.h misc.h parallel.h scaling.h
s_pline.o: permute.h scd.h
s_product.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_product.o: address.h constants.h s_product.h print.h columns.h
s_product.o: build_support.h pricing.h tables.h parallel.h
s_promotion.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_promotion.o: address.h constants.h s_promotion.h w_promotion.h print.h
s_promotion.o: columns.h build_support.h pricing.h tables.h misc.h parallel.h
s_promotion.o: permute.h scaling.h tdef_functions.h scd.h r_params.h
s_purchase.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_purchase.o: address.h constants.h s_purchase.h s_pline.h pricing.h
s_purchase.o: s_store_returns.h print.h columns.h build_support.h tables.h
s_purchase.o: r_params.h misc.h scaling.h parallel.h
s_reason.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_reason.o: address.h constants.h s_reason.h print.h columns.h
s_reason.o: build_support.h pricing.h tables.h misc.h parallel.h
s_store.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_store.o: address.h constants.h s_store.h w_store.h print.h columns.h
s_store.o: build_support.h pricing.h tables.h parallel.h permute.h scaling.h
s_store.o: scd.h
s_store_promotional_item.o: config.h porting.h genrand.h decimal.h mathops.h
s_store_promotional_item.o: date.h dist.h address.h constants.h
s_store_promotional_item.o: s_store_promotional_item.h print.h columns.h
s_store_promotional_item.o: build_support.h pricing.h tables.h parallel.h
s_store_returns.o: config.h porting.h genrand.h decimal.h mathops.h date.h
s_store_returns.o: dist.h address.h constants.h s_store_returns.h pricing.h
s_store_returns.o: s_purchase.h s_pline.h print.h columns.h build_support.h
s_store_returns.o: tables.h parallel.h
s_subcategory.o: config.h porting.h genrand.h decimal.h mathops.h date.h
s_subcategory.o: dist.h address.h constants.h s_subcategory.h print.h
s_subcategory.o: columns.h build_support.h pricing.h tables.h misc.h
s_subcategory.o: parallel.h
s_subclass.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_subclass.o: address.h constants.h s_subclass.h print.h columns.h
s_subclass.o: build_support.h pricing.h tables.h misc.h parallel.h
s_warehouse.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_warehouse.o: address.h constants.h s_warehouse.h w_warehouse.h print.h
s_warehouse.o: columns.h build_support.h pricing.h tables.h misc.h parallel.h
s_warehouse.o: permute.h scaling.h
s_web_order.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_web_order.o: address.h constants.h s_web_order.h print.h columns.h
s_web_order.o: build_support.h pricing.h tables.h misc.h
s_web_order.o: s_web_order_lineitem.h params.h r_params.h release.h scaling.h
s_web_order.o: w_web_sales.h s_web_returns.h parallel.h
s_web_order_lineitem.o: config.h porting.h genrand.h decimal.h mathops.h
s_web_order_lineitem.o: date.h dist.h address.h constants.h
s_web_order_lineitem.o: s_web_order_lineitem.h pricing.h s_web_order.h
s_web_order_lineitem.o: print.h columns.h build_support.h tables.h
s_web_order_lineitem.o: w_web_sales.h parallel.h permute.h scaling.h scd.h
s_web_page.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_web_page.o: address.h constants.h s_web_page.h w_web_page.h print.h
s_web_page.o: columns.h build_support.h pricing.h tables.h scaling.h
s_web_page.o: parallel.h permute.h scd.h tdef_functions.h
s_web_promotinal_item.o: config.h porting.h genrand.h decimal.h mathops.h
s_web_promotinal_item.o: date.h dist.h address.h constants.h
s_web_promotinal_item.o: s_web_promotional_item.h print.h columns.h
s_web_promotinal_item.o: build_support.h pricing.h tables.h parallel.h
s_web_returns.o: config.h porting.h genrand.h decimal.h mathops.h date.h
s_web_returns.o: dist.h address.h constants.h s_web_returns.h pricing.h
s_web_returns.o: print.h columns.h build_support.h tables.h w_web_sales.h
s_web_returns.o: s_web_order.h s_web_order_lineitem.h parallel.h
s_web_site.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
s_web_site.o: address.h constants.h s_web_site.h w_web_site.h print.h
s_web_site.o: columns.h build_support.h pricing.h tables.h scaling.h
s_web_site.o: permute.h scd.h
s_zip_to_gmt.o: config.h porting.h genrand.h decimal.h mathops.h date.h
s_zip_to_gmt.o: dist.h address.h constants.h s_zip_to_gmt.h print.h columns.h
s_zip_to_gmt.o: build_support.h pricing.h tables.h tdef_functions.h
s_zip_to_gmt.o: r_params.h parallel.h tdefs.h
w_call_center.o: config.h porting.h w_call_center.h constants.h pricing.h
w_call_center.o: decimal.h mathops.h address.h date.h genrand.h dist.h
w_call_center.o: r_params.h scaling.h columns.h tables.h misc.h
w_call_center.o: build_support.h print.h tdefs.h tdef_functions.h nulls.h
w_call_center.o: scd.h
w_catalog_page.o: config.h porting.h constants.h w_catalog_page.h date.h
w_catalog_page.o: mathops.h decimal.h genrand.h dist.h address.h
w_catalog_page.o: build_support.h columns.h pricing.h misc.h print.h tables.h
w_catalog_page.o: scaling.h nulls.h tdefs.h tdef_functions.h
w_catalog_returns.o: config.h porting.h genrand.h decimal.h mathops.h date.h
w_catalog_returns.o: dist.h address.h constants.h w_catalog_returns.h
w_catalog_returns.o: pricing.h w_catalog_sales.h print.h columns.h
w_catalog_returns.o: build_support.h tables.h nulls.h tdefs.h
w_catalog_returns.o: tdef_functions.h parallel.h
w_catalog_sales.o: config.h porting.h w_catalog_sales.h pricing.h decimal.h
w_catalog_sales.o: mathops.h w_catalog_returns.h date.h genrand.h dist.h
w_catalog_sales.o: address.h constants.h columns.h tables.h build_support.h
w_catalog_sales.o: print.h nulls.h tdefs.h tdef_functions.h scaling.h
w_catalog_sales.o: permute.h params.h r_params.h release.h parallel.h scd.h
w_customer_address.o: config.h porting.h w_customer_address.h constants.h
w_customer_address.o: address.h date.h mathops.h decimal.h genrand.h dist.h
w_customer_address.o: columns.h build_support.h pricing.h print.h tables.h
w_customer_address.o: nulls.h tdefs.h tdef_functions.h
w_customer.o: config.h porting.h constants.h columns.h w_customer.h genrand.h
w_customer.o: decimal.h mathops.h date.h dist.h address.h build_support.h
w_customer.o: pricing.h tables.h print.h nulls.h tdefs.h tdef_functions.h
w_customer_demographics.o: config.h porting.h w_customer_demographics.h
w_customer_demographics.o: genrand.h decimal.h mathops.h date.h dist.h
w_customer_demographics.o: address.h constants.h columns.h build_support.h
w_customer_demographics.o: pricing.h tables.h print.h nulls.h tdefs.h
w_customer_demographics.o: tdef_functions.h sparse.h
w_datetbl.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
w_datetbl.o: address.h constants.h w_datetbl.h print.h columns.h
w_datetbl.o: build_support.h pricing.h tables.h nulls.h tdefs.h
w_datetbl.o: tdef_functions.h
w_household_demographics.o: config.h porting.h genrand.h decimal.h mathops.h
w_household_demographics.o: date.h dist.h address.h constants.h
w_household_demographics.o: w_household_demographics.h print.h columns.h
w_household_demographics.o: build_support.h pricing.h tables.h nulls.h
w_household_demographics.o: tdefs.h tdef_functions.h sparse.h
w_income_band.o: config.h porting.h genrand.h decimal.h mathops.h date.h
w_income_band.o: dist.h address.h constants.h w_income_band.h print.h
w_income_band.o: columns.h build_support.h pricing.h tables.h nulls.h tdefs.h
w_income_band.o: tdef_functions.h
w_inventory.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
w_inventory.o: address.h constants.h w_inventory.h print.h columns.h
w_inventory.o: build_support.h pricing.h tables.h scaling.h nulls.h tdefs.h
w_inventory.o: tdef_functions.h scd.h
w_item.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
w_item.o: address.h constants.h w_item.h print.h columns.h build_support.h
w_item.o: pricing.h tables.h misc.h nulls.h tdefs.h tdef_functions.h scd.h
w_promotion.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
w_promotion.o: address.h constants.h w_promotion.h print.h columns.h
w_promotion.o: build_support.h pricing.h tables.h misc.h nulls.h tdefs.h
w_promotion.o: tdef_functions.h
w_reason.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
w_reason.o: address.h constants.h w_reason.h print.h columns.h
w_reason.o: build_support.h pricing.h tables.h nulls.h tdefs.h
w_reason.o: tdef_functions.h
w_ship_mode.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
w_ship_mode.o: address.h constants.h w_ship_mode.h print.h columns.h
w_ship_mode.o: build_support.h pricing.h tables.h nulls.h tdefs.h
w_ship_mode.o: tdef_functions.h
w_store.o: config.h porting.h constants.h w_store.h address.h decimal.h
w_store.o: mathops.h date.h genrand.h dist.h build_support.h columns.h
w_store.o: pricing.h misc.h print.h tables.h scaling.h nulls.h tdefs.h
w_store.o: tdef_functions.h scd.h
w_store_returns.o: config.h porting.h w_store_returns.h pricing.h decimal.h
w_store_returns.o: mathops.h w_store_sales.h constants.h tables.h print.h
w_store_returns.o: columns.h genrand.h date.h dist.h address.h
w_store_returns.o: build_support.h nulls.h tdefs.h tdef_functions.h
w_store_sales.o: config.h porting.h decimal.h mathops.h w_store_sales.h
w_store_sales.o: constants.h pricing.h w_store_returns.h genrand.h date.h
w_store_sales.o: dist.h address.h columns.h build_support.h tables.h print.h
w_store_sales.o: nulls.h tdefs.h tdef_functions.h scaling.h permute.h scd.h
w_store_sales.o: parallel.h
w_timetbl.o: config.h porting.h constants.h w_timetbl.h date.h mathops.h
w_timetbl.o: decimal.h genrand.h dist.h address.h build_support.h columns.h
w_timetbl.o: pricing.h misc.h print.h tables.h nulls.h tdefs.h
w_timetbl.o: tdef_functions.h
w_warehouse.o: config.h porting.h constants.h w_warehouse.h address.h date.h
w_warehouse.o: mathops.h decimal.h genrand.h dist.h build_support.h columns.h
w_warehouse.o: pricing.h misc.h print.h tables.h nulls.h tdefs.h
w_warehouse.o: tdef_functions.h
w_web_page.o: config.h porting.h constants.h w_web_page.h date.h mathops.h
w_web_page.o: decimal.h genrand.h dist.h address.h build_support.h columns.h
w_web_page.o: pricing.h misc.h print.h scaling.h tables.h nulls.h tdefs.h
w_web_page.o: tdef_functions.h scd.h
w_web_returns.o: config.h porting.h pricing.h decimal.h mathops.h
w_web_returns.o: w_web_returns.h w_web_sales.h date.h genrand.h dist.h
w_web_returns.o: address.h constants.h build_support.h columns.h misc.h
w_web_returns.o: print.h error_msg.h tables.h nulls.h tdefs.h
w_web_returns.o: tdef_functions.h
w_web_sales.o: config.h porting.h pricing.h decimal.h mathops.h w_web_sales.h
w_web_sales.o: w_web_returns.h date.h genrand.h dist.h address.h constants.h
w_web_sales.o: build_support.h columns.h misc.h print.h tables.h nulls.h
w_web_sales.o: tdefs.h tdef_functions.h scaling.h permute.h scd.h parallel.h
w_web_site.o: config.h porting.h constants.h address.h w_web_site.h decimal.h
w_web_site.o: mathops.h genrand.h date.h dist.h tables.h columns.h print.h
w_web_site.o: scaling.h build_support.h pricing.h misc.h nulls.h tdefs.h
w_web_site.o: tdef_functions.h scd.h
dbgen_version.o: config.h porting.h dbgen_version.h print.h columns.h
dbgen_version.o: build_support.h decimal.h mathops.h date.h dist.h pricing.h
dbgen_version.o: tables.h misc.h release.h
tokenizer.o: config.h porting.h keywords.h expr.h StringBuffer.h list.h
tokenizer.o: mathops.h y.tab.h qgen_params.h r_params.h release.h
tokenizer.o: substitution.h eval.h grammar_support.h
substitution.o: config.h porting.h error_msg.h dist.h date.h mathops.h
substitution.o: decimal.h misc.h genrand.h address.h constants.h
substitution.o: substitution.h StringBuffer.h expr.h list.h eval.h
QgenMain.o: config.h porting.h StringBuffer.h expr.h list.h mathops.h
QgenMain.o: grammar_support.h keywords.h substitution.h eval.h error_msg.h
QgenMain.o: qgen_params.h r_params.h release.h genrand.h decimal.h date.h
QgenMain.o: dist.h address.h constants.h query_handler.h permute.h
QgenMain.o: tdef_functions.h tables.h
qgen.o: config.h porting.h StringBuffer.h expr.h list.h mathops.h
qgen.o: grammar_support.h keywords.h substitution.h eval.h error_msg.h
qgen.o: tables.h qgen_params.h r_params.h release.h tdefs.h columns.h
qgen.o: tdef_functions.h query_handler.h dist.h scaling.h
query_handler.o: config.h porting.h StringBuffer.h eval.h substitution.h
query_handler.o: expr.h list.h mathops.h error_msg.h qgen_params.h r_params.h
query_handler.o: release.h genrand.h decimal.h date.h dist.h address.h
query_handler.o: constants.h
eval.o: config.h porting.h genrand.h decimal.h mathops.h date.h dist.h
eval.o: address.h constants.h eval.h expr.h StringBuffer.h list.h
eval.o: substitution.h error_msg.h tdefs.h tables.h columns.h
eval.o: tdef_functions.h build_support.h pricing.h scaling.h y.tab.h
eval.o: permute.h keywords.h dcomp.h grammar.h
keywords.o: config.h porting.h keywords.h expr.h StringBuffer.h list.h
keywords.o: mathops.h y.tab.h substitution.h eval.h error_msg.h
keywords.o: query_handler.h
mkheader.o: config.h porting.h


<|start_filename|>thirdparty/tpcds-kit/tools/w_web_sales.c<|end_filename|>
/* 
 * Legal Notice 
 * 
 * This document and associated source code (the "Work") is a part of a 
 * benchmark specification maintained by the TPC. 
 * 
 * The TPC reserves all right, title, and interest to the Work as provided 
 * under U.S. and international laws, including without limitation all patent 
 * and trademark rights therein. 
 * 
 * No Warranty 
 * 
 * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION 
 *     CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE 
 *     AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER 
 *     WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, 
 *     INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES, 
 *     DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR 
 *     PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF 
 *     WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE. 
 *     ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, 
 *     QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT 
 *     WITH REGARD TO THE WORK. 
 * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO 
 *     ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE 
 *     COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS 
 *     OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT, 
 *     INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
 *     OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT 
 *     RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD 
 *     ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. 
 * 
 * Contributors:
 * Gradient Systems
 */ 
#include "config.h"
#include "porting.h"
#include <stdio.h>
#include "pricing.h"
#include "w_web_sales.h"
#include "w_web_returns.h"
#include "date.h"
#include "decimal.h"
#include "genrand.h"
#include "build_support.h"
#include "misc.h"
#include "print.h"
#include "tables.h"
#include "constants.h"
#include "nulls.h"
#include "tdefs.h"
#include "scaling.h"
#include "permute.h"
#include "scd.h"
#include "parallel.h"

struct W_WEB_SALES_TBL g_w_web_sales;
ds_key_t skipDays(int nTable, ds_key_t *pRemainder);

static ds_key_t kNewDateIndex = 0;
static ds_key_t jDate;
static int nItemIndex = 0;


/*
 * the validation process requires generating a single lineitem
 * so the main mk_xxx routine has been split into a master record portion
 * and a detail/lineitem portion.
 */
static void
mk_master (void *row, ds_key_t index)
{
   static decimal_t dMin,
      dMax;
   int nGiftPct;
   struct W_WEB_SALES_TBL *r;
   static int bInit = 0,
	   nItemCount;
	
	if (row == NULL)
		r = &g_w_web_sales;
	else
		r = row;

	if (!bInit)
	{
		strtodec (&dMin, "1.00");
		strtodec (&dMax, "100000.00");
		jDate = skipDays(WEB_SALES, &kNewDateIndex);	
		nItemCount = (int)getIDCount(ITEM);
		bInit = 1;
	}
		
	
	/***
	* some attributes reamin the same for each lineitem in an order; others are different
	* for each lineitem. Since the number of lineitems per order is static, we can use a 
	* modulo to determine when to change the semi-static values 
	*/
   while (index > kNewDateIndex)	/* need to move to a new date */
   {
      jDate += 1;
      kNewDateIndex += dateScaling(WEB_SALES, jDate);
   }

   r->ws_sold_date_sk = mk_join (WS_SOLD_DATE_SK, DATE, 1);
   r->ws_sold_time_sk = mk_join(WS_SOLD_TIME_SK, TIME, 1);
   r->ws_bill_customer_sk = mk_join (WS_BILL_CUSTOMER_SK, CUSTOMER, 1);
   r->ws_bill_cdemo_sk = mk_join (WS_BILL_CDEMO_SK, CUSTOMER_DEMOGRAPHICS, 1);
   r->ws_bill_hdemo_sk = mk_join (WS_BILL_HDEMO_SK, HOUSEHOLD_DEMOGRAPHICS, 1);
   r->ws_bill_addr_sk = mk_join (WS_BILL_ADDR_SK, CUSTOMER_ADDRESS, 1);
		
   /* most orders are for the ordering customers, some are not */
   genrand_integer(&nGiftPct, DIST_UNIFORM, 0, 99, 0, WS_SHIP_CUSTOMER_SK);
   if (nGiftPct > WS_GIFT_PCT)
   {
      r->ws_ship_customer_sk =
         mk_join (WS_SHIP_CUSTOMER_SK, CUSTOMER, 2);
      r->ws_ship_cdemo_sk =
         mk_join (WS_SHIP_CDEMO_SK, CUSTOMER_DEMOGRAPHICS, 2);
      r->ws_ship_hdemo_sk =
         mk_join (WS_SHIP_HDEMO_SK, HOUSEHOLD_DEMOGRAPHICS, 2);
      r->ws_ship_addr_sk =
         mk_join (WS_SHIP_ADDR_SK, CUSTOMER_ADDRESS, 2);
   }
   else
   {
      r->ws_ship_customer_sk =	r->ws_bill_customer_sk;
      r->ws_ship_cdemo_sk =	r->ws_bill_cdemo_sk;
      r->ws_ship_hdemo_sk =	r->ws_bill_hdemo_sk;
      r->ws_ship_addr_sk =	r->ws_bill_addr_sk;
   }

   r->ws_order_number = index;
   genrand_integer(&nItemIndex, DIST_UNIFORM, 1, nItemCount, 0, WS_ITEM_SK);

return;
}

static void
mk_detail (void *row, int bPrint)
{
	static int *pItemPermutation,
		nItemCount,
		bInit = 0;
	struct W_WEB_SALES_TBL *r;
	int nShipLag,
		nTemp;
   struct W_WEB_RETURNS_TBL w_web_returns;
   tdef *pT = getSimpleTdefsByNumber(WEB_SALES);


	if (!bInit)
	{
		jDate = skipDays(WEB_SALES, &kNewDateIndex);
		pItemPermutation = makePermutation(NULL, nItemCount = (int)getIDCount(ITEM), WS_PERMUTATION);
		
		bInit = 1;
	}

	if (row == NULL)
		r = &g_w_web_sales;
	else
		r = row;

	nullSet(&pT->kNullBitMap, WS_NULLS);


      /* orders are shipped some number of days after they are ordered,
      * and not all lineitems ship at the same time
      */
      genrand_integer (&nShipLag, DIST_UNIFORM, 
         WS_MIN_SHIP_DELAY, WS_MAX_SHIP_DELAY, 0, WS_SHIP_DATE_SK);
      r->ws_ship_date_sk = r->ws_sold_date_sk + nShipLag;

      if (++nItemIndex > nItemCount)
         nItemIndex = 1;
      r->ws_item_sk = matchSCDSK(getPermutationEntry(pItemPermutation, nItemIndex), r->ws_sold_date_sk, ITEM);

      /* the web page needs to be valid for the sale date */
      r->ws_web_page_sk = mk_join (WS_WEB_PAGE_SK, WEB_PAGE, r->ws_sold_date_sk);
      r->ws_web_site_sk = mk_join (WS_WEB_SITE_SK, WEB_SITE, r->ws_sold_date_sk);

      r->ws_ship_mode_sk = mk_join (WS_SHIP_MODE_SK, SHIP_MODE, 1);
      r->ws_warehouse_sk = mk_join (WS_WAREHOUSE_SK, WAREHOUSE, 1);
      r->ws_promo_sk = mk_join (WS_PROMO_SK, PROMOTION, 1);
      set_pricing(WS_PRICING, &r->ws_pricing);

      /** 
      * having gone to the trouble to make the sale, now let's see if it gets returned
      */
      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 && (!is_set("FILTER") || !is_set("_CHILD_ONLY")))
		  pr_w_web_sales(NULL);

	  return;
}

/*
* mk_web_sales
*/
int
mk_w_web_sales (void *row, ds_key_t index)
{
	int nLineitems,
		i;

   /* build the static portion of an order */
	mk_master(row, index);

   /* set the number of lineitems and build them */
	genrand_integer(&nLineitems, DIST_UNIFORM, 8, 16, 9, WS_ORDER_NUMBER);
   for (i = 1; i <= nLineitems; i++)
   {
	   mk_detail(NULL, 1);
   }

   /**
   * and finally return 1 since we have already printed the rows
   */	
   return (1);
}

/*
* Routine: 
* Purpose: 
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: None
*/
int
pr_w_web_sales(void *row)
{
	struct W_WEB_SALES_TBL *r;
	
	if (row == NULL)
		r = &g_w_web_sales;
	else
		r = row;
	
	print_start(WEB_SALES);
	print_key(WS_SOLD_DATE_SK, r->ws_sold_date_sk, 1);
	print_key(WS_SOLD_TIME_SK, r->ws_sold_time_sk, 1);
	print_key(WS_SHIP_DATE_SK, r->ws_ship_date_sk, 1);
	print_key(WS_ITEM_SK, r->ws_item_sk, 1);
	print_key(WS_BILL_CUSTOMER_SK, r->ws_bill_customer_sk, 1);
	print_key(WS_BILL_CDEMO_SK, r->ws_bill_cdemo_sk, 1);
	print_key(WS_BILL_HDEMO_SK, r->ws_bill_hdemo_sk, 1);
	print_key(WS_BILL_ADDR_SK, r->ws_bill_addr_sk, 1);
	print_key(WS_SHIP_CUSTOMER_SK, r->ws_ship_customer_sk, 1);
	print_key(WS_SHIP_CDEMO_SK, r->ws_ship_cdemo_sk, 1);
	print_key(WS_SHIP_HDEMO_SK, r->ws_ship_hdemo_sk, 1);
	print_key(WS_SHIP_ADDR_SK, r->ws_ship_addr_sk, 1);
	print_key(WS_WEB_PAGE_SK, r->ws_web_page_sk, 1);
	print_key(WS_WEB_SITE_SK, r->ws_web_site_sk, 1);
	print_key(WS_SHIP_MODE_SK, r->ws_ship_mode_sk, 1);
	print_key(WS_WAREHOUSE_SK, r->ws_warehouse_sk, 1);
	print_key(WS_PROMO_SK, r->ws_promo_sk, 1);
	print_key(WS_ORDER_NUMBER, r->ws_order_number, 1);
	print_integer(WS_PRICING_QUANTITY, r->ws_pricing.quantity, 1);
	print_decimal(WS_PRICING_WHOLESALE_COST, &r->ws_pricing.wholesale_cost, 1);
	print_decimal(WS_PRICING_LIST_PRICE, &r->ws_pricing.list_price, 1);
	print_decimal(WS_PRICING_SALES_PRICE, &r->ws_pricing.sales_price, 1);
	print_decimal(WS_PRICING_EXT_DISCOUNT_AMT, &r->ws_pricing.ext_discount_amt, 1);
	print_decimal(WS_PRICING_EXT_SALES_PRICE, &r->ws_pricing.ext_sales_price, 1);
	print_decimal(WS_PRICING_EXT_WHOLESALE_COST, &r->ws_pricing.ext_wholesale_cost, 1);
	print_decimal(WS_PRICING_EXT_LIST_PRICE, &r->ws_pricing.ext_list_price, 1);
	print_decimal(WS_PRICING_EXT_TAX, &r->ws_pricing.ext_tax, 1);
	print_decimal(WS_PRICING_COUPON_AMT, &r->ws_pricing.coupon_amt, 1);
	print_decimal(WS_PRICING_EXT_SHIP_COST, &r->ws_pricing.ext_ship_cost, 1);
	print_decimal(WS_PRICING_NET_PAID, &r->ws_pricing.net_paid, 1);
	print_decimal(WS_PRICING_NET_PAID_INC_TAX, &r->ws_pricing.net_paid_inc_tax, 1);
	print_decimal(WS_PRICING_NET_PAID_INC_SHIP, &r->ws_pricing.net_paid_inc_ship, 1);
	print_decimal(WS_PRICING_NET_PAID_INC_SHIP_TAX, &r->ws_pricing.net_paid_inc_ship_tax, 1);
	print_decimal(WS_PRICING_NET_PROFIT, &r->ws_pricing.net_profit, 0);
	print_end(WEB_SALES);

	return(0);
}

/*
* Routine: 
* Purpose: 
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: None
*/
int 
ld_w_web_sales(void *pSrc)
{
	struct W_WEB_SALES_TBL *r;
		
	if (pSrc == NULL)
		r = &g_w_web_sales;
	else
		r = pSrc;
	
	return(0);
}

/*
* Routine: 
* Purpose: 
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: None
*/
int
vld_web_sales(int nTable, ds_key_t kRow, int *Permutation)
{
	int nLineitem,
		nMaxLineitem,
		i;

	row_skip(nTable, kRow - 1);
	row_skip(WEB_RETURNS, (kRow - 1) );
	jDate = skipDays(WEB_SALES, &kNewDateIndex);		
	mk_master(NULL, kRow);
	genrand_integer(&nMaxLineitem, DIST_UNIFORM, 8, 16, 9, WS_ORDER_NUMBER);
	genrand_integer(&nLineitem, DIST_UNIFORM, 1, nMaxLineitem, 0, WS_PRICING_QUANTITY);
	for (i = 1; i < nLineitem; i++)
	{
		mk_detail(NULL, 0);
	}
   mk_detail(NULL, 1);

	return(0);
}



<|start_filename|>thirdparty/tpcds-kit/tools/print.c<|end_filename|>
/* 
 * Legal Notice 
 * 
 * This document and associated source code (the "Work") is a part of a 
 * benchmark specification maintained by the TPC. 
 * 
 * The TPC reserves all right, title, and interest to the Work as provided 
 * under U.S. and international laws, including without limitation all patent 
 * and trademark rights therein. 
 * 
 * No Warranty 
 * 
 * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION 
 *     CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE 
 *     AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER 
 *     WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, 
 *     INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES, 
 *     DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR 
 *     PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF 
 *     WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE. 
 *     ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, 
 *     QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT 
 *     WITH REGARD TO THE WORK. 
 * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO 
 *     ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE 
 *     COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS 
 *     OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT, 
 *     INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
 *     OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT 
 *     RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD 
 *     ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. 
 * 
 * Contributors:
 * Gradient Systems
 */ 
#include "config.h"
#include "porting.h"
#include <stdio.h>
#ifdef WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#include "tables.h"
#include "print.h"
#include "tdef_functions.h"
#include "r_params.h"
#include "date.h"
#include "decimal.h"
#include "tdefs.h"
#include "nulls.h"
#include "constants.h"
#include "build_support.h"

static FILE *fpOutfile = NULL;
static FILE *fpDeleteFile;
static char *arDeleteFiles[3] = {"", "delete_", "inventory_delete_"};

static int current_table = -1;

int print_jdate (FILE *pFile, ds_key_t kValue);

void 
print_close(int tbl)
{
   tdef *pTdef = getSimpleTdefsByNumber(tbl);

	fpOutfile = NULL;
	if (pTdef->outfile)
	{
		fclose(pTdef->outfile);
		pTdef->outfile = NULL;
	}

	if (pTdef->flags & FL_PARENT)
      print_close(pTdef->nParam);

	return;
}

int
print_separator (int sep)
{
	int res = 0;
	static char *pDelimiter;
	static int init = 0;
	
	if (!init)
	{
        pDelimiter = get_str ("DELIMITER");
        init = 1;
	}
	
	if (sep)
	{
		if (fwrite(pDelimiter, 1, 1, fpOutfile) != 1)
		{
			fprintf(stderr, "ERROR: Failed to write delimiter\n");
			exit(-1);
		}
	}
	   
	return (res);
}

/*
* Routine: 
* Purpose: 
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: None
*/
FILE *
print_prep (int table, int update)
{
   return (NULL);
}

/*
* Routine: dbg_print()
* Purpose: genralized data print routine
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: 20000113 need better separator handling
*		20020125 cast to/from 64b is messy, assumes int/pointer are same size
*/
void
print_integer (int nColumn, int val, int sep)
{
	if (!nullCheck(nColumn))
	{
		if (fprintf (fpOutfile, "%d", val) < 0)
		{
			fprintf(stderr, "ERROR: Failed to write output for column %d\n", nColumn);
			exit(-1);
		}
	}
#ifdef _MYSQL
		else fwrite("NULL", 1, 4, fpOutfile);
#endif
	print_separator (sep);
	
	return;
}

void
print_varchar (int nColumn, char *val, int sep)
{
	size_t nLength;

	if (!nullCheck(nColumn) && (val != NULL))
	{
      nLength = strlen(val);
		
#ifdef STR_QUOTES
		if ((fwrite ("\"", 1, 1, fpOutfile) != 1) ||
			(fwrite (val, 1, nLength, fpOutfile) != nLength) ||
			(fwrite ("\"", 1, 1, fpOutfile)) != 1)
#else
		if (fwrite (val, 1, nLength, fpOutfile) != nLength)
#endif
			{
				fprintf(stderr, "ERROR: Failed to write output for column %d\n", nColumn);
				exit(-1);
			}
	}
#ifdef _MYSQL
		else fwrite("NULL", 1, 4, fpOutfile);
#endif
	print_separator (sep);
	
   return;
}

void
print_delete (int * val)
{
   if (print_jdate(fpDeleteFile, *val))
	{
      fprintf(stderr, "ERROR: Failed to write delete key\n");
      exit(-1);
	}
   fprintf(fpDeleteFile, "%s", get_str("DELIMITER"));
   if (print_jdate(fpDeleteFile, *(val + 1)))
	{
      fprintf(stderr, "ERROR: Failed to write delete key\n");
      exit(-1);
	}
   if (is_set("TERMINATE"))
	   fprintf(fpDeleteFile, get_str("DELIMITER"));
   fprintf(fpDeleteFile, "\n");
   
   return;
}

/*
void
print_cp_delete (int nCatalog, int nPage)
{
   static int bInit = 0;
   static char *cp;
   
   if (!bInit)
   {
      cp = strdup(get_str("DELIMITER"));
      bInit = 1;
   }
   
   if (fprintf (fpDeleteFile, "%d%s%d\n", nCatalog, cp, nPage) < 0)
	{
      fprintf(stderr, "ERROR: Failed to write delete key\n");
      exit(-1);
	}
   
   return;
}
*/
void
print_char (int nColumn, char val, int sep)
{
	if (!nullCheck(nColumn))
	{
		if (fwrite (&val, 1, 1, fpOutfile) != 1)
		{
			fprintf(stderr, "ERROR: Failed to write output for column %d\n", nColumn);
			exit(-1);
		}
	}
#ifdef _MYSQL
		else fwrite("NULL", 1, 4, fpOutfile);
#endif
	print_separator (sep);

   return;
}

void
print_date (int nColumn, ds_key_t val, int sep)
{
	if (!nullCheck(nColumn))
	{
		if (val > 0)
		{
			if (print_jdate(fpOutfile, val))
			{
				fprintf(stderr, "ERROR: Failed to write output for column %d\n", nColumn);
				exit(-1);
			}
			
		}
#ifdef _MYSQL
		else fwrite("NULL", 1, 4, fpOutfile);
#endif
	}
	
#ifdef _MYSQL
		else fwrite("NULL", 1, 4, fpOutfile);
#endif
	print_separator (sep);
	   
	return;
}

void
print_time (int nColumn, ds_key_t val, int sep)
{
	int nHours, nMinutes, nSeconds;

	nHours = (int)(val / 3600);
	val -= 3600 * nHours;
	nMinutes = (int)(val / 60);
	val -= 60 * nMinutes;
	nSeconds = (int)(val % 60);
	
	if (!nullCheck(nColumn))
	{
		if (val != -1)
		{
			fprintf(fpOutfile, "%02d:%02d:%02d", nHours, nMinutes, nSeconds);
		}
#ifdef _MYSQL
		else fwrite("NULL", 1, 4, fpOutfile);
#endif
	}
#ifdef _MYSQL
		else fwrite("NULL", 1, 4, fpOutfile);
#endif
	
	print_separator (sep);
	   
	return;
}

void
print_decimal (int nColumn, decimal_t * val, int sep)
{
	int i;
	double dTemp;

	if (!nullCheck(nColumn))
	{
#ifdef WIN32
#pragma warning(disable: 4244)
#endif
	dTemp = val->number;
#ifdef WIN32
#pragma warning(default: 4244)
#endif
		for (i=0; i < val->precision; i++)
			dTemp /= 10.0;

		if (fprintf(fpOutfile, "%.*f", val->precision, dTemp) < 0)
		{
			fprintf(stderr, "ERROR: Failed to write output for column %d\n", nColumn);
			exit(-1);
		}
	}
#ifdef _MYSQL
		else fwrite("NULL", 1, 4, fpOutfile);
#endif
	print_separator (sep);
	
	return;
}

void
print_key (int nColumn, ds_key_t val, int sep)
{
	if (!nullCheck(nColumn))
	{
		if (val != (ds_key_t) -1) /* -1 is a special value, indicating NULL */
		{
			if (fprintf (fpOutfile, HUGE_FORMAT, val) < 0)
			{
				fprintf(stderr, "ERROR: Failed to write output for column %d\n", nColumn);
				exit(-1);
			}
		}
#ifdef _MYSQL
		else fwrite("NULL", 1, 4, fpOutfile);
#endif
	}
#ifdef _MYSQL
		else fwrite("NULL", 1, 4, fpOutfile);
#endif
	print_separator (sep);
	
	return;
}

void
print_id (int nColumn, ds_key_t val, int sep)
{
   char szID[RS_BKEY + 1];
   
   if (!nullCheck(nColumn))
   {
      if (val != (ds_key_t) -1) /* -1 is a special value, indicating NULL */
      {
         mk_bkey(szID, val, 0);
#ifdef STR_QUOTES
         if ((fwrite ("\"", 1, 1, fpOutfile) < 1) ||
            (fwrite (szID, 1, RS_BKEY, fpOutfile) < RS_BKEY) ||
			(fwrite ("\"", 1, 1, fpOutfile) < 1))
#else
            if (fwrite (szID, 1, RS_BKEY, fpOutfile) < RS_BKEY)
#endif
            {
               fprintf(stderr, "ERROR: Failed to write output for column %d\n", nColumn);
               exit(-1);
            }
      }
#ifdef _MYSQL
		else fwrite("NULL", 1, 4, fpOutfile);
#endif
   }
 #ifdef _MYSQL
		else fwrite("NULL", 1, 4, fpOutfile);
#endif
  print_separator (sep);
   
   return;
}

void
print_boolean (int nColumn, int val, int sep)
{
	if (!nullCheck(nColumn))
	{

#ifdef STR_QUOTES
		if (fwrite ((val?"\"Y\"":"\"N\""), 1, 3, fpOutfile) != 3)
#else
		if (fwrite ( ((val)?"Y":"N"), 1, 1, fpOutfile) != 1)
#endif
		{
			fprintf(stderr, "ERROR: Failed to write output for column %d\n", nColumn);
			exit(-1);
		}
	}
#ifdef _MYSQL
		else fwrite("NULL", 1, 4, fpOutfile);
#endif

	print_separator (sep);

	return;
}

/*
* Routine: print_start(tbl)
* Purpose: open the output file for a given table
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: None
*/
int
print_start (int tbl)
{
   int res = 0;
   char path[256];
   tdef *pTdef = getSimpleTdefsByNumber(tbl);


   current_table = tbl;

   if (is_set ("FILTER"))
	   fpOutfile = stdout;
   else
   {
	   if (pTdef->outfile == NULL)
	   {
		   if (is_set("PARALLEL"))
			   sprintf (path, "%s%c%s_%d_%d%s",
			   get_str ("DIR"),
			   PATH_SEP, getTableNameByID (tbl), 
			   get_int("CHILD"), get_int("PARALLEL"), (is_set("VALIDATE"))?get_str ("VSUFFIX"):get_str ("SUFFIX"));
		   else 
		   {
			   if (is_set("UPDATE"))
				   sprintf (path, "%s%c%s_%d%s",
				   get_str ("DIR"),
				   PATH_SEP, getTableNameByID (tbl), get_int("UPDATE"), (is_set("VALIDATE"))?get_str ("VSUFFIX"):get_str ("SUFFIX"));
			   else
				   sprintf (path, "%s%c%s%s",
				   get_str ("DIR"),
				   PATH_SEP, getTableNameByID (tbl), (is_set("VALIDATE"))?get_str ("VSUFFIX"):get_str ("SUFFIX"));
		   }
		   if ((access (path, F_OK) != -1) && !is_set ("FORCE"))
		   {
			   fprintf (stderr,
				   "ERROR: %s exists. Either remove it or use the FORCE option to overwrite it.\n",
				   path);
			   exit (-1);
		   }
#ifdef WIN32
		   pTdef->outfile = fopen (path, "wt");
#else
		   pTdef->outfile = fopen (path, "w");
#endif
	   }
     fpOutfile = pTdef->outfile;
   }
   
   res = (fpOutfile != NULL);

   if (!res)                    /* open failed! */
     {
        INTERNAL ("Failed to open output file!");
     }
#ifdef WIN32
   else if (setvbuf (fpOutfile, NULL, _IOFBF, 32767))
     {
        INTERNAL ("setvbuf() FAILED");
     }
#endif

   pTdef->flags |= FL_OPEN;

   return (0);
}

/*
* Routine: 
* Purpose: 
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: None
*/
int
print_end (int tbl)
{
   int res = 0;
   static int init = 0;
   static int add_term = 0;
   static char term[10];

   if (!init)
     {
        if (is_set ("TERMINATE"))
          {
             strncpy (term, get_str ("DELIMITER"), 9);
             add_term = strlen(term);
          }
        init = 1;
     }

   if (add_term)
      fwrite(term, 1, add_term, fpOutfile);
   fprintf (fpOutfile, "\n");
   fflush(fpOutfile);

   return (res);
}

/*
* Routine: openDeleteFile(void)
* Purpose: open the output file for the delete keys for a given table
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: None
*/
int
openDeleteFile(int bOpen)
{
   int res = 0;
   char path[256];
   
   if (!bOpen)
      fclose(fpDeleteFile);
   else
   {
      sprintf (path, "%s%c%s%d%s",
         get_str ("DIR"),
         PATH_SEP, arDeleteFiles[bOpen], get_int("UPDATE"), get_str("SUFFIX"));
      if ((access (path, F_OK) != -1) && !is_set ("FORCE"))
      {
         fprintf (stderr,
            "ERROR: %s exists. Either remove it or use the FORCE option to overwrite it.\n",
            path);
         exit (-1);
      }
#ifdef WIN32
      fpDeleteFile = fopen (path, "wt");
#else
      fpDeleteFile = fopen (path, "w");
#endif
      
      res = (fpDeleteFile != NULL);
      
      if (!res)                    /* open failed! */
      {
         INTERNAL ("Failed to open output file!");
      }
#ifdef WIN32
      else if (setvbuf (fpDeleteFile, NULL, _IOFBF, 32767))
      {
         INTERNAL ("setvbuf() FAILED");
      }
#endif
   }
   
   return (0);
}

/*
* Routine: print_string()
* Purpose: genralized data print routine
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
*/
void
print_string (char *szMessage, ds_key_t val)
{
	if (fprintf (fpOutfile, szMessage, val) < 0)
	{
		fprintf(stderr, "ERROR: Failed to write string\n");
		exit(-1);
	}

	return;
}

/*
* Routine: print_jdate()
* Purpose: genralized data print routine
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
*/
int
print_jdate (FILE *pFile, ds_key_t kValue)
{

	date_t dTemp;

	jtodt (&dTemp, (int) kValue);
#if (defined(STR_QUOTES) && !defined(_MYSQL))
	if ((fwrite ("\"", 1, 1, pFile) != 1) ||
		(fwrite(dttostr(&dTemp), 1, 10, pFile) != 10) ||
		(fwrite ("\"", 1, 1, pFile)) != 1)
#else
	if (fwrite(dttostr(&dTemp), 1, 10, pFile) != 10)
#endif
		return(-1);
	return(0);
}

/*
* Routine: 
* Purpose: 
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: None
*/
void
print_validation(ds_key_t kRowNumber)
{
	static int bInit = 0;
	static char szValidateFormat[20];

	if (!bInit)
	{
		sprintf(szValidateFormat, "Row #%s: ", HUGE_FORMAT);
		bInit = 1;
	}
	
	if (is_set("VALIDATE"))
	{
		print_string(szValidateFormat, kRowNumber);
	}

	return;
}
