This file is indexed.

/usr/lib/Wt/test/private/DboImplTest.C is in witty-examples 3.1.10-1ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * Copyright (C) 2009 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#include <boost/test/unit_test.hpp>

#include <Wt/Dbo/Dbo>

namespace dbo = Wt::Dbo;

#define SQL(...) #__VA_ARGS__

namespace {

void parseSql(const std::string& sql,  int listsCount,
	      int fieldsCount,
	      bool simpleSelect)
{
  dbo::Impl::SelectFieldLists result;
  bool simpleSelectCount;

  dbo::Impl::parseSql(sql, result, simpleSelectCount);

  BOOST_REQUIRE(result.size() == (unsigned)listsCount);

  int fields = 0;
  for (unsigned i = 0; i < result.size(); ++i) {
    fields += static_cast<int>(result[i].size());
    for (unsigned j = 0; j < result[i].size(); ++j) {
      dbo::Impl::SelectField& f = result[i][j];
      std::cerr << "Field: '" << sql.substr(f.begin, f.end - f.begin)
		<< "'" << std::endl;
    }
  }

  BOOST_REQUIRE(fields == fieldsCount);
  BOOST_REQUIRE(simpleSelect == simpleSelectCount);
}

}

BOOST_AUTO_TEST_CASE( DboImplTest_test1 )
{
  parseSql("select 1", 1, 1, true);
  parseSql("select a, b from foo", 1, 2, true);
  parseSql("select distinct a, b from foo", 1, 2, false);
  parseSql("select '1'", 1, 1, true);
  parseSql("select distinct '1'", 1, 1, false);
  parseSql("select 'Barts'' car'", 1, 1, true);

#if BOOST_VERSION >= 104100
  // These ones only work correctly with our new spirit-based parser

  parseSql("select 'Barts'', car', bike from depot", 1, 2, true);

  parseSql
    (SQL
     (WITH
      regional_sales AS 
      (
       SELECT region, SUM(amount) AS total_sales 
       FROM orders 
       GROUP BY region 
       ),
      top_regions AS
      ( 
       SELECT region 
       FROM regional_sales 
       WHERE total_sales > (SELECT SUM(total_sales)/10 FROM 
			    regional_sales)
      )
      SELECT region,
             product,
             SUM(quantity) AS product_units,
             SUM(amount) AS product_sales 
      FROM orders 
      WHERE region IN (SELECT region FROM top_regions)
      GROUP BY region, product, result, simpleSelectCount
      ),
     1, 4, false
     );

  parseSql
    (SQL
     (select a from foo
      intersect
      select b, c from bar),
     2, 3, false);
#endif // BOOST_VERSION
}