void dump_ai_obj(FILE *fp, ai_obj *a)
{
	char dumpbuf[1024];

	if (C_IS_S(a->type) || C_IS_O(a->type)) {
		if (a->empty) {
			fprintf(fp, "\tSTRING ai_obj: EMPTY\n");
			return;
		}
		memcpy_ai_objStoDumpBuf(dumpbuf, a);
		fprintf(fp, "\tSTRING ai_obj: mt: %d len: %d -> (%s) type: %d\n", a->empty, a->len, dumpbuf, a->type);
	} else if (C_IS_C(a->type)) {
		if (a->empty) {
			fprintf(fp, "\tCNAME ai_obj: EMPTY\n");
			return;
		}
		memcpy_ai_objStoDumpBuf(dumpbuf, a);
		fprintf(fp, "\tCNAME ai_obj: mt: %d -> (%s) cmatch: %d", a->empty, dumpbuf, a->i);
		if (a->ic) {
			fprintf(fp, " ic: ");
			dumpIC(fp, a->ic);
		} else {
			fprintf(fp, "\n");
		}
	} else if (C_IS_I(a->type) || C_IS_P(a->type)) {
		char *name = C_IS_I(a->type) ? "INT" : "FUNC";
		if (a->enc == COL_TYPE_INT || a->enc == COL_TYPE_FUNC) {
			fprintf(fp, "\t%s ai_obj: mt: %d val: %u\n", name, a->empty, a->i);
		} else {
			memcpy_ai_objStoDumpBuf(dumpbuf, a);
			fprintf(fp, "\t%s(S) ai_obj: mt: %d val: %s\n", name, a->empty, dumpbuf);
		}
	} else if (C_IS_L(a->type)) {
		if (a->enc == COL_TYPE_LONG) {
			fprintf(fp, "\tLONG ai_obj: mt: %d val: %lu\n", a->empty, a->l);
		} else {
			memcpy_ai_objStoDumpBuf(dumpbuf, a);
			fprintf(fp, "\tLONG(S) ai_obj: mt: %d val: %s\n", a->empty, dumpbuf);
		}
	} else if (C_IS_X(a->type)) {
		fprintf(fp, "\tU128 ai_obj: mt: %d val: ", a->empty);
		DEBUG_U128(fp, a->x);
		fprintf(fp, "\n");
	} else if (C_IS_Y(a->type)) {
		fprintf(fp, "\tU160 ai_obj: mt: %d val: ", a->empty);
		DEBUG_U160(fp, a->y);
		fprintf(fp, "\n");
	} else if (C_IS_F(a->type)) {
		if (a->enc == COL_TYPE_INT) {
			fprintf(fp, "\tFLOAT ai_obj: mt: %d val: %f\n", a->empty, a->f);
		} else {
			memcpy_ai_objStoDumpBuf(dumpbuf, a);
			fprintf(fp, "\tFLOAT(S) ai_obj: mt: %d val: %s\n", a->empty, dumpbuf);
		}
	} else {
		fprintf(fp, "\tUNINITIALISED ai_obj mt: %d\n", a->empty);
	}
}
static int ai_objCmp(ai_obj *a, ai_obj *b)
{
	if (C_IS_S(a->type)) {
		return strncmp(a->s, b->s, a->len);
	} else if (C_IS_F(a->type)) {
		float f = a->f - b->f;
		return (f == 0.0)     ? 0 : ((f > 0.0)     ? 1 : -1);
	} else if (C_IS_L(a->type)) {
		return (a->l == b->l) ? 0 : ((a->l > b->l) ? 1 : -1);
	} else if (C_IS_X(a->type)) {
		return (a->x == b->x) ? 0 : ((a->x > b->x) ? 1 : -1);
	} else if (C_IS_Y(a->type)) {
		return u160Cmp_string20(&a->y, &b->y);
	} else if (C_IS_I(a->type) || C_IS_P(a->type)) {
		return (long) (a->i - b->i);
	} else {
		assert(!"ai_objCmp ERROR");
	}
}
static void setHigh(btSIter *siter, ai_obj *high, uchar ktype) {
	if        (C_IS_S(ktype)) {
		siter->x.highs            = cf_malloc(high->len + 1);    /* FREE ME 058 */
		memcpy(siter->x.highs, high->s, high->len);
		siter->x.highs[high->len] = '\0';
	} else if (C_IS_I(ktype)) {
		siter->x.high  = high->i;
	}
	else if (C_IS_L(ktype) || C_IS_G(ktype)) {
		siter->x.high  = high->l;
	}
	else if (C_IS_X(ktype)) {
		siter->x.highx = high->x;
	}
	else if (C_IS_Y(ktype)) {
		siter->x.highy = high->y;
	}
	else if (C_IS_F(ktype)) {
		siter->x.highf = high->f;
	}
}
Example #4
0
// SQL_AOF SQL_AOF SQL_AOF SQL_AOF SQL_AOF SQL_AOF SQL_AOF SQL_AOF SQL_AOF
sds DXDB_SQL_feedAppendOnlyFile(rcommand *cmd, robj **argv, int argc) {
    if (cmd->proc == insertCommand || cmd->proc == updateCommand  ||
        cmd->proc == deleteCommand || cmd->proc == replaceCommand ||
        cmd->proc == createCommand || cmd->proc == dropCommand    ||
        cmd->proc == alterCommand) {
        if (cmd->proc == createCommand) {
            if ((!strcasecmp(argv[1]->ptr, "LRUINDEX"))   ||
                (!strcasecmp(argv[1]->ptr, "LUATRIGGER"))) return sdsempty();
            int arg = 1, targ = 4, coln = 5;
            if (!strcasecmp(argv[1]->ptr,   "UNIQUE")) {
                arg = 2; targ = 5; coln = 6;
            }
            if (!strcasecmp(argv[arg]->ptr, "INDEX")) { // index on TEXT
                int      tmatch = find_table(argv[targ]->ptr);
                r_tbl_t *rt     = &Tbl[tmatch];
                char    *token  = argv[coln]->ptr;
                char    *end    = strchr(token, ')');
                STACK_STRDUP(cname, (token + 1), (end - token - 1))
                icol_t   ic     = find_column(tmatch, cname);
                uchar    ctype  = rt->col[ic.cmatch].type;
                if (C_IS_S(ctype)) {
                    int      imatch = find_index(tmatch, ic);
                    r_ind_t *ri     = &Index[imatch];
                    return createAlterTableFullText(rt, ri, ic.cmatch, 1);
                }
            }
        }
        sds buf = sdsempty();
        for (int j = 0; j < argc; j++) {
            robj *o = getDecodedObject(argv[j]);
            buf = sdscatlen(buf, o->ptr, sdslen(o->ptr));
            if (j != (argc - 1)) buf = sdscatlen(buf," ", 1);
            decrRefCount(o);
        }
        buf = sdscatlen(buf, ";\n", 2);
        return buf;
    }
    return sdsempty();
}