Example #1
0
str
MDBtoggle(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
	int b = 0;

	(void) mb;		/* still unused */
	if (p->argc == 1) {
		/* Toggle */
		stk->cmd = stk->cmd ? 0 : 's';
		cntxt->itrace = cntxt->itrace ? 0 : 's';
		if (stk->cmd)
			MDBdelay = 1;	/* wait for real command */
		if (stk->up)
			stk->up->cmd = 0;
		return MAL_SUCCEED;
	}
	if (p->argc > 1) {
		b = *getArgReference_int(stk, p, 1);
	} else
		b = stk->cmd;
	if (b)
		MDBdelay = 1;	/* wait for real command */
	MDBstatus(b);
	stk->cmd = b ? 'n' : 0;
	if (stk->up)
		stk->up->cmd = b ? 'n' : 0;
	cntxt->itrace = b ? 'n' : 0;
	return MAL_SUCCEED;
}
Example #2
0
str
MDBgetStackFrameN(Client cntxt, MalBlkPtr m, MalStkPtr s, InstrPtr p)
{
	int n;
	bat *ret = getArgReference_bat(s, p, 0);
	bat *ret2 = getArgReference_bat(s, p, 1);
	BAT *b = BATnew(TYPE_void, TYPE_str, 256, TRANSIENT);
	BAT *bn = BATnew(TYPE_void, TYPE_str, 256, TRANSIENT);
	
	if (b == 0 || bn == 0) {
		BBPreclaim(b);
		BBPreclaim(bn);
		throw(MAL, "mdb.getStackFrame", MAL_MALLOC_FAIL);
	}
	BATseqbase(b,0);
	BATseqbase(bn,0);

	n = *getArgReference_int(s, p, 2);
	if (n < 0 || n >= getStkDepth(s)){
		BBPunfix(b->batCacheid);
		throw(MAL, "mdb.getStackFrame", ILLEGAL_ARGUMENT " Illegal depth.");
	}
	pseudo(ret,b,"view","stk","frame");
	pseudo(ret2,bn,"view","stk","frameB");
	return MDBgetFrame(b, bn, cntxt, m, s, n);
}
Example #3
0
str
CMDsetProfilerStream (Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
	str *host = getArgReference_str(stk,pci,1);
	int *port = getArgReference_int(stk,pci,2);
	(void) mb;		/* fool compiler */
	return setLogStream(cntxt->nspace, *host, *port);
}
Example #4
0
str
CMDopenProfilerStream(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pc)
{
	(void) cntxt;
	(void) mb;
	(void) stk;
	(void) pc;
	return openProfilerStream(cntxt->fdout, *getArgReference_int(stk,pc,1));
}
Example #5
0
str
CMDtomograph(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pc)
{
	int beat = *getArgReference_int(stk,pc,1);
	(void) mb;
	if( beat < 0)
		throw(MAL,"profiler.tomograph","negative heart beat not allowed");
	startProfiler(cntxt->user, -1, beat);
	return MAL_SUCCEED;
}
Example #6
0
str
MDBStkDepth(Client cntxt, MalBlkPtr mb, MalStkPtr s, InstrPtr p)
{
	int *ret = getArgReference_int(s, p, 0);

	(void) cntxt;
	(void) mb;		/* fool compiler */
	*ret = getStkDepth(s);
	return MAL_SUCCEED;
}
Example #7
0
str
MDBstart(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
	Client c;
	int pid;

	if( p->argc == 2){
		/* debug running process */
		pid = *getArgReference_int(stk, p, 1);
		if( pid< 0 || pid >= MAL_MAXCLIENTS || mal_clients[pid].mode <= FINISHCLIENT)
			throw(MAL, "mdb.start", ILLEGAL_ARGUMENT " Illegal process id");
		c= mal_clients+pid;
		/* make client aware of being debugged */
		cntxt= c;
	} else
	if ( stk->cmd == 0)
		stk->cmd = 'n';
	cntxt->itrace = stk->cmd;
	cntxt->debugOptimizer= TRUE;
	(void) mb;
	(void) p;
	return MAL_SUCCEED;
}
Example #8
0
str
SQLwindow_bound(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
	str msg = MAL_SUCCEED;
	bool preceding;
	lng first_half;
	int unit, bound, excl, part_offset = (pci->argc > 6);

	if ((pci->argc != 6 && pci->argc != 7) || getArgType(mb, pci, part_offset + 2) != TYPE_int ||
		getArgType(mb, pci, part_offset + 3) != TYPE_int || getArgType(mb, pci, part_offset + 4) != TYPE_int) {
		throw(SQL, "sql.window_bound", SQLSTATE(42000) "Invalid arguments");
	}

	unit = *getArgReference_int(stk, pci, part_offset + 2);
	bound = *getArgReference_int(stk, pci, part_offset + 3);
	excl = *getArgReference_int(stk, pci, part_offset + 4);

	assert(unit >= 0 && unit <= 3);
	assert(bound >= 0 && bound <= 5);
	assert(excl >= 0 && excl <= 2);
	preceding = (bound % 2 == 0);
	first_half = (bound < 2 || bound == 4);

	(void)cntxt;
	if (isaBatType(getArgType(mb, pci, 1))) {
		bat *res = getArgReference_bat(stk, pci, 0);
		BAT *b = BATdescriptor(*getArgReference_bat(stk, pci, part_offset + 1)), *p = NULL, *r, *l = NULL;
		int tp1 = getBatType(getArgType(mb, pci, part_offset + 1)), tp2 = getArgType(mb, pci, part_offset + 5);
		void* limit = NULL;
		bool is_negative = false, is_null = false, is_a_bat;
		gdk_return gdk_code;

		if (!b)
			throw(SQL, "sql.window_bound", SQLSTATE(HY005) "Cannot access column descriptor");

		if (excl != 0) {
			BBPunfix(b->batCacheid);
			throw(SQL, "sql.window_bound", SQLSTATE(42000) "Only EXCLUDE NO OTHERS exclusion is currently implemented");
		}

		is_a_bat = isaBatType(tp2);
		if(is_a_bat)
			tp2 = getBatType(tp2);

		voidresultBAT(r, TYPE_lng, BATcount(b), b, "sql.window_bound");
		if(is_a_bat) { //SQL_CURRENT_ROW shall never fall in limit validation
			l = BATdescriptor(*getArgReference_bat(stk, pci, part_offset + 5));
			if (!l) {
				BBPunfix(b->batCacheid);
				throw(SQL, "sql.window_bound", SQLSTATE(HY005) "Cannot access column descriptor");
			}
			switch (tp2) {
				case TYPE_bte:
					CHECK_NULLS_AND_NEGATIVES_COLUMN(bte)
					break;
				case TYPE_sht:
					CHECK_NULLS_AND_NEGATIVES_COLUMN(sht)
					break;
				case TYPE_int:
					CHECK_NULLS_AND_NEGATIVES_COLUMN(int)
					break;
				case TYPE_lng:
					CHECK_NULLS_AND_NEGATIVES_COLUMN(lng)
					break;
				case TYPE_flt:
					CHECK_NULLS_AND_NEGATIVES_COLUMN(flt)
					break;
				case TYPE_dbl:
					CHECK_NULLS_AND_NEGATIVES_COLUMN(dbl)
					break;
#ifdef HAVE_HGE
				case TYPE_hge:
					CHECK_NULLS_AND_NEGATIVES_COLUMN(hge)
					break;
#endif
				default: {
					BBPunfix(b->batCacheid);
					BBPunfix(l->batCacheid);
					throw(SQL, "sql.window_bound", SQLSTATE(42000) "%s limit not available for %s", "sql.window_bound", ATOMname(tp2));
				}
			}
			if(is_null || is_negative) {
				BBPunfix(b->batCacheid);
				BBPunfix(l->batCacheid);
				if(is_null)
					throw(SQL, "sql.window_bound", SQLSTATE(HY005) "All values on %s boundary must be non-null", preceding ? "PRECEDING" : "FOLLOWING");
				throw(SQL, "sql.window_bound", SQLSTATE(HY005) "All values on %s boundary must be non-negative", preceding ? "PRECEDING" : "FOLLOWING");
			}
		} else {
Example #9
0
/*
 * THe choice operator first searches the next one to identify
 * the fragment to be optimized and to gain access to the variables
 * without the need to declare them upfront.
 */
str
RUNchoice(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
	int target;
	lng cost, mincost;
	int i, j, pc;
	char *nme;
	InstrPtr q;

	pc = getPC(mb, p);
	for (i = pc + 1; i < mb->stop; i++) {
		q = getInstrPtr(mb, i);
		if (getModuleId(p) == getModuleId(q) &&
			getFunctionId(p) == getFunctionId(q)) {
			p = q;
			break;
		}
	}
	if (i == mb->stop)
		return MAL_SUCCEED;
	target = getArg(p, 2);
	if (getArgType(mb, p, 1) == TYPE_int && p->argc >= 3 && (p->argc - 1) % 2 == 0) {
		/* choice pairs */
		mincost = *getArgReference_int(stk, p, 1);
		for (i = 3; i < p->argc; i += 2) {
			cost = *getArgReference_int(stk, p, i);
			if (cost < mincost && !isVarDisabled(mb, getArg(p, i + 1))) {
				mincost = cost;
				target = getArg(p, i + 1);
			}
		}
	} else if (getArgType(mb, p, 1) == TYPE_str) {
		nme = *getArgReference_str(stk, p, 1);
		/* should be generalized to allow an arbitrary user defined function */
		if (strcmp(nme, "getVolume") != 0)
			throw(MAL, "scheduler.choice", ILLEGAL_ARGUMENT "Illegal cost function");

		mincost = -1;
		for (j = 2; j < p->argc; j++) {
			if (!isVarDisabled(mb, getArg(p, j)))
				for (i = pc + 1; i < mb->stop; i++) {
					InstrPtr q = getInstrPtr(mb, i);
					if (p->token >= 0 && getArg(q, 0) == getArg(p, j)) {
						cost = getVolume(stk, q, 1);
						if (cost > 0 && (cost < mincost || mincost == -1)) {
							mincost = cost;
							target = getArg(p, j);
						}
						break;
					}
				}

		}
	}
#ifdef DEBUG_RUN_MEMORUN
	mnstr_printf(cntxt->fdout, "#function target %s cost %d\n", getVarName(mb, target), mincost);
#else
	(void) cntxt;
#endif
	/* remove non-qualifying variables */
	for (i = 2; i < p->argc; i += 2)
		if (getArg(p, i) != target) {
			setVarDisabled(mb, getArg(p, i - 1));
			setVarDisabled(mb, getArg(p, i));
		}

	propagateNonTarget(mb, pc + 1);
#ifdef DEBUG_RUN_MEMORUN
	mnstr_printf(cntxt->fdout, "#cost choice selected %s %d\n",
			getVarName(mb, target), mincost);
	printFunction(cntxt->fdout, mb, 1);
#endif
	return MAL_SUCCEED;
}