int mdb_test_sarg(MdbHandle *mdb, MdbColumn *col, MdbSargNode *node, MdbField *field) { char tmpbuf[256]; if (node->op == MDB_ISNULL) return field->is_null?1:0; else if (node->op == MDB_NOTNULL) return field->is_null?0:1; switch (col->col_type) { case MDB_BOOL: return mdb_test_int(node, !field->is_null); break; case MDB_BYTE: return mdb_test_int(node, (gint32)((char *)field->value)[0]); break; case MDB_INT: return mdb_test_int(node, (gint32)mdb_get_int16(field->value, 0)); break; case MDB_LONGINT: return mdb_test_int(node, (gint32)mdb_get_int32(field->value, 0)); break; case MDB_TEXT: mdb_unicode2ascii(mdb, field->value, field->siz, tmpbuf, 256); return mdb_test_string(node, tmpbuf); case MDB_DATETIME: return mdb_test_date(node, mdb_get_double(field->value, 0)); default: fprintf(stderr, "Calling mdb_test_sarg on unknown type. Add code to mdb_test_sarg() for type %d\n",col->col_type); break; } return 1; }
double mdb_pg_get_double(MdbHandle *mdb, int offset) { if (offset <0 || offset+8 > mdb->fmt->pg_size) return -1; mdb->cur_pos+=8; return mdb_get_double(mdb->pg_buf, offset); }