static bool containsRecord(stKVDatabase *database, int64_t key) {
    MySqlDb *dbImpl = database->dbImpl;
    MYSQL_RES *rs = queryStart(dbImpl, "select id from %s where id=%lld", dbImpl->table,  (long long)key);
    char **row = queryNext(dbImpl, rs);
    bool found = (row != NULL);
    queryEnd(dbImpl, rs);
    return found;
}
static int64_t numberOfRecords(stKVDatabase *database) {
    MySqlDb *dbImpl = database->dbImpl;
    MYSQL_RES *rs = queryStart(dbImpl, "select count(*) from %s", dbImpl->table);
    char **row = queryNextRequired(dbImpl, rs);
    int64_t numRecords = stSafeStrToInt64(row[0]);
    queryEnd(dbImpl, rs);
    return numRecords;
}
// collect warnings into an array
static int getWarnings(MySqlDb *dbImpl, int maxToReport, char **warnings) {
    int numReturned = 0;
    MYSQL_RES *rs = queryStart(dbImpl, "show warnings limit %d", maxToReport);
    char **row;
    while ((row = queryNext(dbImpl, rs)) != NULL) {
        if (numReturned < maxToReport) {
            warnings[numReturned++] = stSafeCDynFmt("%s: %s (%s)", row[0], row[2], row[1]);
        }
    }
    mysql_free_result(rs);
    return numReturned;
}
static void *getPartialRecord(stKVDatabase *database, int64_t key, int64_t zeroBasedByteOffset, int64_t sizeInBytes, int64_t recordSize) {
    MySqlDb *dbImpl = database->dbImpl;
    MYSQL_RES *rs = queryStart(dbImpl, "select substring(data, %lld, %lld) from %s where id=%lld", (long long)zeroBasedByteOffset+1, (long long)sizeInBytes, dbImpl->table, (long long)key);
    char **row = queryNext(dbImpl, rs);
    void *data = NULL;
    int64_t readLen = 0;
    if (row != NULL) {
        readLen = queryLength(dbImpl, rs);
        data = stSafeCCopyMem(row[0], readLen);
    }
    queryEnd(dbImpl, rs);
    if (readLen != sizeInBytes) {
        stThrowNew(ST_KV_DATABASE_EXCEPTION_ID, "partial read of key %lld, expected %lld bytes got %lld bytes", (long long)key, (long long)sizeInBytes, (long long)readLen);
    }
    return data;
}
static void *getRecord2(stKVDatabase *database, int64_t key, int64_t *sizeOfRecord) {
    MySqlDb *dbImpl = database->dbImpl;
    MYSQL_RES *rs = queryStart(dbImpl, "select data from %s where id=%lld", dbImpl->table,  (long long)key);
    char **row = queryNext(dbImpl, rs);
    void *data = NULL;
    int64_t readLen = 0;
    if (row != NULL) {
        readLen = queryLength(dbImpl, rs);
        data = stSafeCCopyMem(row[0], readLen);
    }
    queryEnd(dbImpl, rs);
    if (sizeOfRecord != NULL) {
        *sizeOfRecord = readLen;
    }
    return data;
}
Beispiel #6
0
void ZealSearchEdit::selectQuery()
{
    setSelection(queryStart(), text().size());
}
Beispiel #7
0
// Clear input with consideration to docset filters
void ZealSearchEdit::clearQuery()
{
    QString query = text();
    query.chop(query.size() - queryStart());
    setText(query);
}
Beispiel #8
0
// Clear input with consideration to docset filters
void SearchEdit::clearQuery()
{
    setText(text().left(queryStart()));
}