Example #1
0
void Dynamic::stop(bool sendClear)
{
    if (isRemote()) {
        if (sendClear) {
            sendCommand(Control, QStringList() << "stop" << "1");
        } else {
            sendCommand(Control, QStringList() << "stop");
        }
        return;
    }

    #if !defined Q_OS_WIN
    int i=currentEntry.isEmpty() ? -1 : entryList.indexOf(currentEntry);
    QModelIndex idx=index(i, 0, QModelIndex());
    int pid=getPid();

    if (!pid) {
        if (sendClear) {
            emit clear();
        }
        currentEntry=QString();
        emit running(false);
        if (idx.isValid()) {
            emit dataChanged(idx, idx);
        }
        return;
    }

    if (0!=::kill(pid, 0)) {
        if (sendClear) {
            emit clear();
        }
        currentEntry=QString();
        emit running(false);
        if (idx.isValid()) {
            emit dataChanged(idx, idx);
        }
        return;
    }

    if (controlApp(false)) {
        if (sendClear) {
            emit clear();
        }
        currentEntry=QString();
        emit running(isRunning());
        if (idx.isValid()) {
            emit dataChanged(idx, idx);
        }
        return;
    }
    #endif
}
Example #2
0
QString Branch::getRefName()
{
    QString refName;
    if (isLocal())
    {
        refName = "refs/heads/" + branchName;
    }
    else if (isRemote())
    {
        refName = "refs/remotes/" + branchName;
    }
    return refName;
}
Example #3
0
static int 
has_remote_or_replica( sql_rel *rel ) 
{
	if (!rel)
		return 0;

	switch (rel->op) {
	case op_basetable: {
		sql_table *t = rel->l;

		if (isReplicaTable(t) || isRemote(t)) 
			return 1;
	} 	
	case op_table:
		break;
	case op_join: 
	case op_left: 
	case op_right: 
	case op_full: 

	case op_apply: 
	case op_semi: 
	case op_anti: 

	case op_union: 
	case op_inter: 
	case op_except: 
		if (has_remote_or_replica( rel->l ) ||
		    has_remote_or_replica( rel->r ))
			return 1;
		break;
	case op_project:
	case op_select: 
	case op_groupby: 
	case op_topn: 
	case op_sample: 
		if (has_remote_or_replica( rel->l )) 
			return 1;
		break;
	case op_ddl: 
		if (has_remote_or_replica( rel->l )) 
			return 1;
	case op_insert:
	case op_update:
	case op_delete:
		if (rel->r && has_remote_or_replica( rel->r )) 
			return 1;
		break;
	}
	return 0;
}
void Robot::setFront(const Vector& aVector, bool aNotifyObservers /*= true*/)
{
	front = aVector;

	if (!isRemote()) {
		std::ostringstream body;
		body << "robot-front " << front.x << " " << front.y << " " << name;
		queueMessage(body.str());
	}

	if (aNotifyObservers == true) {
		notifyObservers();
	}
}
void Robot::setPosition(const Point& aPosition, bool aNotifyObservers /*= true*/)
{
	if (position == aPosition) {
		return;
	}

	position = aPosition;

	if (!isRemote()) {
		std::ostringstream body;
		body << "robot-position " << position.x << " " << position.y << " " << name;
		queueMessage(body.str());
	}

	if (aNotifyObservers == true) {
		notifyObservers();
	}
}
Example #6
0
bool Dynamic::save(const Entry &e)
{
    if (e.name.isEmpty()) {
        return false;
    }

    QString string;
    QTextStream str(&string);
    if (e.ratingFrom!=0 || e.ratingTo!=0) {
        str << constRatingKey << constKeyValSep << e.ratingFrom << constRangeSep << e.ratingTo<< '\n';
    }
    foreach (const Rule &rule, e.rules) {
        if (!rule.isEmpty()) {
            str << constRuleKey << '\n';
            Rule::ConstIterator it(rule.constBegin());
            Rule::ConstIterator end(rule.constEnd());
            for (; it!=end; ++it) {
                str << it.key() << constKeyValSep << it.value() << '\n';
            }
        }
    }

    if (isRemote()) {
        if (sendCommand(Save, QStringList() << e.name << string)) {
            currentSave=e;
            return true;
        }
        return false;
    }

    QFile f(Utils::dataDir(constDir, true)+e.name+constExtension);
    if (f.open(QIODevice::WriteOnly|QIODevice::Text)) {
        QTextStream out(&f);
        out.setCodec("UTF-8");
        out << string;
        updateEntry(e);
        return true;
    }
    return false;
}
Example #7
0
bool Beam::charPoll( double dt ) {
    // Shifter tile bends beam
    Cell *c = g_fld->get(loc);
    if( c->gt == GT_SHIFTER && c->st == ST_NONE && c->bt == BT_AIR ) {
        Vec2 dv = dirToVec2(c->dir) * PPC* SHIFTER_ACCEL;
        v += dv * dt;
        if( v.len() > BEAM_NORMAL_VEL ) {
            v = v.normalize(BEAM_NORMAL_VEL);
        }
        setRot( atan2(v.y,v.x));
        //        print("v:%f %f  dv:%f %f d:%d",v.x,v.y, dv.x, dv.y, c->dir );
    }
    
    loc += v * dt;

    // Stronger is bigger
    float s = PPC;
    if( ene >= 64 ) s *= 3; else if( ene >= 16 ) s *= 2; else if( ene >= 4 ) s *= 1.5;
    setScl(s);
    
    // Shoot on blocks
    Vec2 rt,lt,rb,lb;
    Cell *rtc = g_fld->get( rt = loc + Vec2(hitsz,hitsz));
    Cell *ltc = g_fld->get( lt = loc + Vec2(-hitsz,hitsz));
    Cell *rbc = g_fld->get( rb = loc + Vec2(hitsz,-hitsz));
    Cell *lbc = g_fld->get( lb = loc + Vec2(-hitsz,-hitsz));
    Cell *tgtc = NULL;
    Vec2 tgtat;
    Vec2 candat[4];
    Cell *cands[4];
    int candi=0;
    // 
    if(rtc&&rtc->isBeamHit() && rtc->isImmutableAgainstBeam()==false ) { cands[candi] = rtc; candat[candi] = rt; candi++; }
    if(rbc&&rbc->isBeamHit() && rbc->isImmutableAgainstBeam()==false ) { cands[candi] = rbc; candat[candi] = rb; candi++; }
    if(ltc&&ltc->isBeamHit() && ltc->isImmutableAgainstBeam()==false ) { cands[candi] = ltc; candat[candi] = lt; candi++; }
    if(lbc&&lbc->isBeamHit() && lbc->isImmutableAgainstBeam()==false ) { cands[candi] = lbc; candat[candi] = lb; candi++; }
    if( candi > 0 ) {
        int ind = irange(0,candi);
        tgtc = cands[ind];
        tgtat = candat[ind];
    }

    // Out of the world
    if(!rtc)return false;

    if( rtc && rtc->gt == GT_JUNGLE && range(0,100) < 1 ) {
        createLeafEffect(loc);
    }

    updateIndex();

    if( isRemote() ) return true;

    if(tgtc) {
        int consumed;
        BLOCKTYPE orig_bt = tgtc->bt;
        if( g_fld->damage(tgtat,ene,&consumed,this) ) {
            createSparkEffect();
            if( orig_bt == BT_CELL || orig_bt == BT_FLYGEN ) {
                soundPlayAt(g_wormdamage_sound,loc,1);
            } else if( orig_bt != BT_SNOW && orig_bt != BT_IVY && orig_bt != BT_TREE && orig_bt != BT_BOMBFLOWER ) {
                soundPlayAt(g_beamhithard_sound,loc,1);
            }
            if( orig_bt == BT_BARRIER && tgtc->hyper_count > 0 ) {
                Vec2 tgt;
                if( g_fld->findEnemyAttackTarget(loc,&tgt, MACHINE_SHOOT_DISTANCE ) ) {
                    int n = irange(1,4);
                    for(int i=0;i<n;i++) Bullet::shootAt( BLT_SPARIO, loc, tgt );
                }
            }
            ene -= consumed;
            if( ene <= 0 ) return false; else return true;
        }
    } else {
        // Immutable cells
        Cell *cells[4];
        g_fld->getCorner4( loc, 1, &cells[0], &cells[1], &cells[2], &cells[3] );
        for(int i=0;i<4;i++) {
            if(cells[i] && cells[i]->isImmutableAgainstBeam()) {
                soundPlayAt(g_beamhithard_sound,loc,1);
                createSparkEffect();
                return false;
            }
        }
    }

    if( type == BEAMTYPE_BLASTER ) {
        float s = PPC;
        g_fld->meltSnow(loc + Vec2(-s,-s) );
        g_fld->meltSnow(loc + Vec2(-s,s) );
        g_fld->meltSnow(loc + Vec2(s,-s) );
        g_fld->meltSnow(loc + Vec2(s,s) );        
    } else {
        if( range(0,100) < (float)(ene)/2.0 ) {
            g_fld->meltSnow(loc);
        }
    }
        

    // Shoot on enemies
    Char *cur = (Char*) g_char_layer->prop_top;
    while(cur) {
        if( cur->isEnemyCategory() ) {
            Enemy *e = (Enemy*) cur;
            if( e->hitWithFlyHeight(this,PPC/2) && e->beam_hits ) {
                int dmg = ene;
                if( dmg > e->hp ) dmg = e->hp;
                e->notifyHitBeam(this, dmg);
                createSparkEffect();
                //
                ene -= dmg;
                if(ene<=0) to_clean = true;
                g_fld->meltSnow(loc);
            }
        } else if( cur->category == CAT_PC ) {
            // recharging other player characters
            PC *pc = (PC*) cur;
            if( pc->hit(this,PPC/2)) {
                //                print("pcid:%d shooter:%d ene:%d/%d", pc->id, shooter_id, pc->ene, pc->maxene );
                if( pc->id != shooter_id && shooter_id == g_pc->id ) {
                    //                    print("PC:E:%d id:%d max:%d", pc->ene, pc->id, pc->maxene );
                    int charged = pc->charge(ene);
                    if(charged>0) {
                        pc->energy_chain_heat_count ++;
                        //                        print("sending E-chain e:%d(%d>%d) to: %d-%d  heat:%d",
                        //                              ene, charged, pc->ene, pc->client_id, pc->internal_id ,pc->energy_chain_heat_count );
                        realtimeEnergyChainSend(pc,charged);
                        return false;
                    } 
                }
            }
        }
        
        cur = (Char*) cur->next;
    }




    return true;
}
Example #8
0
static sql_rel *
distribute(mvc *sql, sql_rel *rel) 
{
	sql_rel *l = NULL, *r = NULL;
	prop *p, *pl, *pr;

	if (!rel)
		return rel;

	if (rel_is_ref(rel)) {
		if (has_remote_or_replica(rel)) {
			sql_rel *nrel = rel_copy(sql->sa, rel);

			if (nrel && rel->p)
				nrel->p = prop_copy(sql->sa, rel->p);
			rel_destroy(rel);
			rel = nrel;
		} else {
			return rel;
		}
	}

	switch (rel->op) {
	case op_basetable: {
		sql_table *t = rel->l;

		/* set_remote() */
		if (isRemote(t)) {
			char *uri = t->query;

			p = rel->p = prop_create(sql->sa, PROP_REMOTE, rel->p); 
			p->value = uri;
		}
	}
	case op_table:
		break;
	case op_join: 
	case op_left: 
	case op_right: 
	case op_full: 

	case op_apply: 
	case op_semi: 
	case op_anti: 

	case op_union: 
	case op_inter: 
	case op_except: 
		l = rel->l = distribute(sql, rel->l);
		r = rel->r = distribute(sql, rel->r);

		if (l && (pl = find_prop(l->p, PROP_REMOTE)) != NULL &&
		    	   r && (pr = find_prop(r->p, PROP_REMOTE)) == NULL) {
			r = rel->r = distribute(sql, replica(sql, rel->r, pl->value));
		} else if (l && (pl = find_prop(l->p, PROP_REMOTE)) == NULL &&
		    	   r && (pr = find_prop(r->p, PROP_REMOTE)) != NULL) {
			l = rel->l = distribute(sql, replica(sql, rel->l, pr->value));
		}
		if (l && (pl = find_prop(l->p, PROP_REMOTE)) != NULL &&
		    r && (pr = find_prop(r->p, PROP_REMOTE)) != NULL && 
		    strcmp(pl->value, pr->value) == 0) {
			l->p = prop_remove(l->p, pl);
			r->p = prop_remove(r->p, pr);
			pl->p = rel->p;
			rel->p = pl;
		}
		break;
	case op_project:
	case op_select: 
	case op_groupby: 
	case op_topn: 
	case op_sample: 
		rel->l = distribute(sql, rel->l);
		l = rel->l;
		if (l && (p = find_prop(l->p, PROP_REMOTE)) != NULL) {
			l->p = prop_remove(l->p, p);
			p->p = rel->p;
			rel->p = p;
		}
		break;
	case op_ddl: 
		rel->l = distribute(sql, rel->l);
		if (rel->r)
			rel->r = distribute(sql, rel->r);
		break;
	case op_insert:
	case op_update:
	case op_delete:
		rel->r = distribute(sql, rel->r);
		break;
	}
	return rel;
}
Example #9
0
static sql_rel *
replica(mvc *sql, sql_rel *rel, char *uri) 
{
	if (!rel)
		return rel;

	if (rel_is_ref(rel)) {
		if (has_remote_or_replica(rel)) {
			sql_rel *nrel = rel_copy(sql->sa, rel);

			if (nrel && rel->p)
				nrel->p = prop_copy(sql->sa, rel->p);
			rel_destroy(rel);
			rel = nrel;
		} else {
			return rel;
		}
	}
	switch (rel->op) {
	case op_basetable: {
		sql_table *t = rel->l;

		if (isReplicaTable(t)) {
			node *n;

			if (uri) {
				/* replace by the replica which matches the uri */
				for (n = t->tables.set->h; n; n = n->next) {
					sql_table *p = n->data;
	
					if (isRemote(p) && strcmp(uri, p->query) == 0) {
						rel = rewrite_replica(sql, rel, t, p);
						break;
					}
				}
			} else { /* no match, use first */
				sql_table *p = NULL;

				if (t->tables.set) {
					p = t->tables.set->h->data;
					rel = rewrite_replica(sql, rel, t, p);
				} else {
					rel = NULL;
				}
			}
		}
	}
	case op_table:
		break;
	case op_join: 
	case op_left: 
	case op_right: 
	case op_full: 

	case op_apply: 
	case op_semi: 
	case op_anti: 

	case op_union: 
	case op_inter: 
	case op_except: 
		rel->l = replica(sql, rel->l, uri);
		rel->r = replica(sql, rel->r, uri);
		break;
	case op_project:
	case op_select: 
	case op_groupby: 
	case op_topn: 
	case op_sample: 
		rel->l = replica(sql, rel->l, uri);
		break;
	case op_ddl: 
		rel->l = replica(sql, rel->l, uri);
		if (rel->r)
			rel->r = replica(sql, rel->r, uri);
		break;
	case op_insert:
	case op_update:
	case op_delete:
		rel->r = replica(sql, rel->r, uri);
		break;
	}
	return rel;
}
Example #10
0
static lng
SQLgetSpace(mvc *m, MalBlkPtr mb, int prepare)
{
	sql_trans *tr = m->session->tr;
	lng size,space = 0, i;
	str lasttable = 0;

	for (i = 0; i < mb->stop; i++) {
		InstrPtr p = mb->stmt[i];

		/* now deal with the update binds, it is only necessary to identify that there are updats
		 * The actual size is not that important */
		if (getModuleId(p) == sqlRef && getFunctionId(p) == bindRef  && p->retc <= 2){
			char *sname = getVarConstant(mb, getArg(p, 1 + p->retc)).val.sval;
			char *tname = getVarConstant(mb, getArg(p, 2 + p->retc)).val.sval;
			char *cname = getVarConstant(mb, getArg(p, 3 + p->retc)).val.sval;
			int access = getVarConstant(mb, getArg(p, 4 + p->retc)).val.ival;
			sql_schema *s = mvc_bind_schema(m, sname);
			sql_table *t = 0;
			sql_column *c = 0;

			if (!s || strcmp(s->base.name, dt_schema) == 0)
				continue;
			t = mvc_bind_table(m, s, tname);
			if (!t)
				continue;
			c = mvc_bind_column(m, t, cname);
			if (!s)
				continue;

			/* we have to sum the cost of all three components of a BAT */
			if (c && (!isRemote(c->t) && !isMergeTable(c->t)) && (lasttable == 0 || strcmp(lasttable,tname)==0)) {
				size = SQLgetColumnSize(tr, c, access);
				space += size;	// accumulate once per table
				//lasttable = tname;	 invalidate this attempt
				if( !prepare && size == 0  && ! t->system){
					//mnstr_printf(GDKout,"found empty column %s.%s.%s prepare %d size "LLFMT"\n",sname,tname,cname,prepare,size);
					setFunctionId(p, emptybindRef);
				}
			}
		}
		if (getModuleId(p) == sqlRef && (getFunctionId(p) == bindidxRef)) {
			char *sname = getVarConstant(mb, getArg(p, 1 + p->retc)).val.sval;
			//char *tname = getVarConstant(mb, getArg(p, 2 + p->retc)).val.sval;
			char *idxname = getVarConstant(mb, getArg(p, 3 + p->retc)).val.sval;
			int access = getVarConstant(mb, getArg(p, 4 + p->retc)).val.ival;
			sql_schema *s = mvc_bind_schema(m, sname);
			BAT *b;

			if (getFunctionId(p) == bindidxRef) {
				sql_idx *i = mvc_bind_idx(m, s, idxname);

				if (i && (!isRemote(i->t) && !isMergeTable(i->t))) {
					b = store_funcs.bind_idx(tr, i, RDONLY);
					if (b) {
						space += (size =getBatSpace(b));
						if (!size) {
							sql_column *c = i->t->columns.set->h->data;
							size = SQLgetColumnSize(tr, c, access);
						}

						if( !prepare && size == 0 && ! i->t->system){
							setFunctionId(p, emptybindidxRef);
							//mnstr_printf(GDKout,"found empty column %s.%s.%s prepare %d size "LLFMT"\n",sname,tname,idxname,prepare,size);
						}
						BBPunfix(b->batCacheid);
					}
				}
			}
		}
	}
	return space;
}
Example #11
0
static void
SQLgetStatistics(Client cntxt, mvc *m, MalBlkPtr mb)
{
	InstrPtr *old = NULL;
	int oldtop, i, actions = 0, size = 0;
	lng clk = GDKusec();
	sql_trans *tr = m->session->tr;
	str msg;

	old = mb->stmt;
	oldtop = mb->stop;
	size = (mb->stop * 1.2 < mb->ssize) ? mb->ssize : (int) (mb->stop * 1.2);
	mb->stmt = (InstrPtr *) GDKzalloc(size * sizeof(InstrPtr));
	mb->ssize = size;
	mb->stop = 0;

	for (i = 0; i < oldtop; i++) {
		InstrPtr p = old[i];
		char *f = getFunctionId(p);
		ValRecord vr;

		if (getModuleId(p) == sqlRef && f == tidRef) {
			char *sname = getVarConstant(mb, getArg(p, 2)).val.sval;
			char *tname = getVarConstant(mb, getArg(p, 3)).val.sval;
			sql_schema *s = mvc_bind_schema(m, sname);
			sql_table *t;

			if (!s || strcmp(s->base.name, dt_schema) == 0) {
				pushInstruction(mb, p);
				continue;
			}

		       	t = mvc_bind_table(m, s, tname);

			if (t && (!isRemote(t) && !isMergeTable(t)) && t->p) {
				int k = getArg(p, 0), mt_member = t->p->base.id;

				varSetProp(mb, k, mtProp, op_eq, VALset(&vr, TYPE_int, &mt_member));
			}
		}
		if (getModuleId(p) == sqlRef && (f == bindRef || f == bindidxRef)) {
			int upd = (p->argc == 7 || p->argc == 9);
			char *sname = getVarConstant(mb, getArg(p, 2 + upd)).val.sval;
			char *tname = getVarConstant(mb, getArg(p, 3 + upd)).val.sval;
			char *cname = NULL;
			int not_null = 0, mt_member = 0;
			wrd rows = 1;	/* default to cope with delta bats */
			int mode = 0;
			int k = getArg(p, 0);
			sql_schema *s = mvc_bind_schema(m, sname);
			BAT *b;

			if (!s || strcmp(s->base.name, dt_schema) == 0) {
				pushInstruction(mb, p);
				continue;
			}
			cname = getVarConstant(mb, getArg(p, 4 + upd)).val.sval;
			mode = getVarConstant(mb, getArg(p, 5 + upd)).val.ival;

			if (s && f == bindidxRef && cname) {
				size_t cnt;
				sql_idx *i = mvc_bind_idx(m, s, cname);

				if (i && (!isRemote(i->t) && !isMergeTable(i->t))) {
					cnt = store_funcs.count_idx(tr, i, 1);
					assert(cnt <= (size_t) GDK_oid_max);
					b = store_funcs.bind_idx(m->session->tr, i, RDONLY);
					if (b) {
						str loc;
						if (b->batPersistence == PERSISTENT && BATlocation(&loc, &b->batCacheid) && loc)
							varSetProp(mb, k, fileProp, op_eq, VALset(&vr, TYPE_str, loc));
						cnt = BATcount(b);
						BBPunfix(b->batCacheid);
					}
					rows = (wrd) cnt;
					if (i->t->p) 
						mt_member = i->t->p->base.id;
				}
			} else if (s && f == bindRef && cname) {
				size_t cnt;
				sql_table *t = mvc_bind_table(m, s, tname);
				sql_column *c = mvc_bind_column(m, t, cname);

				if (c && (!isRemote(c->t) && !isMergeTable(c->t))) {
					not_null = !c->null;

					cnt = store_funcs.count_col(tr, c, 1);
					assert(cnt <= (size_t) GDK_oid_max);
					b = store_funcs.bind_col(m->session->tr, c, RDONLY);
					if (b) {
						str loc;
						if (b->batPersistence == PERSISTENT && BATlocation(&loc, &b->batCacheid) && loc)
							varSetProp(mb, k, fileProp, op_eq, VALset(&vr, TYPE_str, loc));
						cnt = BATcount(b);
						BBPunfix(b->batCacheid);
					}
					rows = (wrd) cnt;
					if (c->t->p) 
						mt_member = c->t->p->base.id;
				}
			}
			if (rows > 1 && mode != RD_INS)
				varSetProp(mb, k, rowsProp, op_eq, VALset(&vr, TYPE_wrd, &rows));
			if (not_null)
				varSetProp(mb, k, notnilProp, op_eq, NULL);
			if (mt_member && mode != RD_INS)
				varSetProp(mb, k, mtProp, op_eq, VALset(&vr, TYPE_int, &mt_member));

			{
				int lowprop = hlbProp, highprop = hubProp;
				/* rows == cnt has been checked above to be <= GDK_oid_max */
				oid low = 0, high = low + (oid) rows;
				pushInstruction(mb, p);

				if (mode == RD_INS) {
					low = high;
					high += 1024 * 1024;
				}
				varSetProp(mb, getArg(p, 0), lowprop, op_gte, VALset(&vr, TYPE_oid, &low));
				varSetProp(mb, getArg(p, 0), highprop, op_lt, VALset(&vr, TYPE_oid, &high));
			}

			if (not_null)
				actions++;
		} else {
			pushInstruction(mb, p);
		}
	}
	GDKfree(old);
	msg = optimizerCheck(cntxt, mb, "optimizer.SQLgetstatistics", actions, GDKusec() - clk);
	if (msg)		/* what to do with an error? */
		GDKfree(msg);
}
Example #12
0
static void SQLgetStatistics(Client cntxt, mvc *m, MalBlkPtr mb)
{
	InstrPtr *old = NULL;
	int oldtop, i, actions = 0, size = 0;
	lng clk = GDKusec();
	sql_trans *tr = m->session->tr;
	str msg;

	old = mb->stmt;
	oldtop = mb->stop;
	size = (mb->stop * 1.2 < mb->ssize) ? mb->ssize : (int) (mb->stop * 1.2);
	mb->stmt = (InstrPtr *) GDKzalloc(size * sizeof(InstrPtr));
	mb->ssize = size;
	mb->stop = 0;

	for (i = 0; i < oldtop; i++) {
		InstrPtr p = old[i];
		char *f = getFunctionId(p);

		if (getModuleId(p) == sqlRef && f == tidRef) {
			char *sname = getVarConstant(mb, getArg(p, 2)).val.sval;
			char *tname = getVarConstant(mb, getArg(p, 3)).val.sval;
			sql_schema *s = mvc_bind_schema(m, sname);
			sql_table *t;

			if (!s || strcmp(s->base.name, dt_schema) == 0) {
				pushInstruction(mb, p);
				continue;
			}

		       	t = mvc_bind_table(m, s, tname);

			if (t && (!isRemote(t) && !isMergeTable(t)) && t->p) {
				int mt_member = t->p->base.id;
				setMitosisPartition(p,mt_member);
			}
		}
		if (getModuleId(p) == sqlRef && (f == bindRef || f == bindidxRef)) {
			int upd = (p->argc == 7 || p->argc == 9);
			char *sname = getVarConstant(mb, getArg(p, 2 + upd)).val.sval;
			char *tname = getVarConstant(mb, getArg(p, 3 + upd)).val.sval;
			char *cname = NULL;
			int mt_member = 0;
			BUN rows = 1;	/* default to cope with delta bats */
			int mode = 0;
			int k = getArg(p, 0);
			sql_schema *s = mvc_bind_schema(m, sname);
			BAT *b;

			if (!s || strcmp(s->base.name, dt_schema) == 0) {
				pushInstruction(mb, p);
				continue;
			}
			cname = getVarConstant(mb, getArg(p, 4 + upd)).val.sval;
			mode = getVarConstant(mb, getArg(p, 5 + upd)).val.ival;

			if (s && f == bindidxRef && cname) {
				size_t cnt;
				sql_idx *i = mvc_bind_idx(m, s, cname);

				if (i && (!isRemote(i->t) && !isMergeTable(i->t))) {
					cnt = store_funcs.count_idx(tr, i, 1);
					assert(cnt <= (size_t) GDK_oid_max);
					b = store_funcs.bind_idx(m->session->tr, i, RDONLY);
					if (b) {
						cnt = BATcount(b);
						BBPunfix(b->batCacheid);
					}
					rows = (BUN) cnt;
					if (i->t->p) 
						mt_member = i->t->p->base.id;
				}
			} else if (s && f == bindRef && cname) {
				size_t cnt;
				sql_table *t = mvc_bind_table(m, s, tname);
				sql_column *c = mvc_bind_column(m, t, cname);

				if (c && (!isRemote(c->t) && !isMergeTable(c->t))) {
					cnt = store_funcs.count_col(tr, c, 1);
					assert(cnt <= (size_t) GDK_oid_max);
					b = store_funcs.bind_col(m->session->tr, c, RDONLY);
					if (b) {
						cnt = BATcount(b);
						BBPunfix(b->batCacheid);
					}
					rows = (BUN) cnt;
					if (c->t->p) 
						mt_member = c->t->p->base.id;
				}
			}
			if (rows > 1 && mode != RD_INS)
				setRowCnt(mb,k,rows);
			if (mt_member && mode != RD_INS)
				setMitosisPartition(p,mt_member);

			pushInstruction(mb, p);
		} else {
			pushInstruction(mb, p);
		}
	}
	GDKfree(old);
	msg = optimizerCheck(cntxt, mb, "optimizer.SQLgetstatistics", actions, GDKusec() - clk);
	if (msg)		/* what to do with an error? */
		GDKfree(msg);
}
Example #13
0
void SharedFilesDialog::copyLink()
{
    copyLink ( getSelected() , isRemote());
}