~zeitgeist/zeitgeist/saucy-packaging-0-9-14

« back to all changes in this revision

Viewing changes to extensions/fts++/db-reader.vala

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2012-09-04 15:42:08 UTC
  • mfrom: (1.3.3)
  • Revision ID: package-import@ubuntu.com-20120904154208-pry3ywmp1ytqenov
Tags: 0.9.5-0ubuntu1
* New upstream bugfix release (LP: #1045587)
* debian/control:
  - Use standard version 3.9.3
  - Bump build-depends on valac-0.16
* debian/watch:
  - Fix download location

Show diffs side-by-side

added added

removed removed

Lines of Context:
281
281
        bool time_asc = ResultType.is_sort_order_asc ((ResultType) result_type);
282
282
        sql += " timestamp %s".printf ((time_asc) ? "ASC" : "DESC");
283
283
 
 
284
        if (where.get_is_simple ())
 
285
            sql = sql.replace ("FROM event_view", "FROM event");
 
286
 
284
287
        int rc;
285
288
        Sqlite.Statement stmt;
286
289
 
347
350
    {
348
351
        WhereClause where = new WhereClause (WhereClause.Type.AND);
349
352
 
350
 
        /**
351
 
         * We are using the unary operator here to tell SQLite to not use
352
 
         * the index on the timestamp column at the first place. This is a
353
 
         * "fix" for (LP: #672965) based on some benchmarks, which suggest
354
 
         * a performance win, but we might not oversee all implications.
355
 
         * (See http://www.sqlite.org/optoverview.html, section 6.0).
356
 
         *    -- Markus Korn, 29/11/2010
357
 
         */
358
353
        if (time_range.start != 0)
359
 
            where.add (("+timestamp >= %" + int64.FORMAT).printf(
 
354
            where.add (("timestamp >= %" + int64.FORMAT).printf(
360
355
                time_range.start));
361
356
        if (time_range.end != 0)
362
 
            where.add (("+timestamp <= %" + int64.FORMAT).printf(
 
357
            where.add (("timestamp <= %" + int64.FORMAT).printf(
363
358
                time_range.end));
364
359
 
365
360
        if (storage_state == StorageState.AVAILABLE ||
367
362
        {
368
363
            where.add ("(subj_storage_state=? OR subj_storage_state IS NULL)",
369
364
                storage_state.to_string ());
 
365
            where.set_is_simple (false);
370
366
        }
371
367
        else if (storage_state != StorageState.ANY)
372
368
        {
871
867
        }
872
868
        else
873
869
        {
874
 
            var sb = new StringBuilder ();
 
870
            string sql = "(%s)";
 
871
            string sub_sql = "";
 
872
            bool first = true;
875
873
            foreach (unowned string uri in symbols)
876
874
            {
877
 
                sb.append_printf ("%d,", lookup_table.id_try_string (uri));
 
875
                if (!first)
 
876
                    sub_sql = sub_sql + " OR ";
 
877
                sub_sql = sub_sql + "%s = %i ".printf (table_name, lookup_table.id_try_string (uri));
 
878
                first = false;
878
879
            }
879
 
            sb.truncate (sb.len - 1);
880
 
 
881
 
            string sql = "%s IN (%s)".printf(table_name, sb.str);
 
880
            sql = sql.printf (sub_sql);
882
881
            subwhere.add(sql);
883
882
        }
884
883