SQLsmith  v1.2.1-5-gfacd7a8
A random SQL query generator
schema.cc
1 #include <typeinfo>
2 #include "config.h"
3 #include "schema.hh"
4 #include "relmodel.hh"
5 #include <pqxx/pqxx>
6 #include "gitrev.h"
7 
8 using namespace std;
9 using namespace pqxx;
10 
11 void schema::generate_indexes() {
12 
13  cerr << "Generating indexes...";
14 
15  for (auto &type: types) {
16  assert(type);
17  for(auto &r: aggregates) {
18  if (type->consistent(r.restype))
19  aggregates_returning_type.insert(pair<sqltype*, routine*>(type, &r));
20  }
21 
22  for(auto &r: routines) {
23  if (!type->consistent(r.restype))
24  continue;
25  routines_returning_type.insert(pair<sqltype*, routine*>(type, &r));
26  if(!r.argtypes.size())
27  parameterless_routines_returning_type.insert(pair<sqltype*, routine*>(type, &r));
28  }
29 
30  for (auto &t: tables) {
31  for (auto &c: t.columns()) {
32  if (type->consistent(c.type)) {
33  tables_with_columns_of_type.insert(pair<sqltype*, table*>(type, &t));
34  break;
35  }
36  }
37  }
38 
39  for (auto &concrete: types) {
40  if (type->consistent(concrete))
41  concrete_type.insert(pair<sqltype*, sqltype*>(type, concrete));
42  }
43 
44  for (auto &o: operators) {
45  if (type->consistent(o.result))
46  operators_returning_type.insert(pair<sqltype*, op*>(type, &o));
47  }
48  }
49 
50  for (auto &t: tables) {
51  if (t.is_base_table)
52  base_tables.push_back(&t);
53  }
54 
55  cerr << "done." << endl;
56 
57  assert(booltype);
58  assert(inttype);
59  assert(internaltype);
60  assert(arraytype);
61 
62 }
supporting classes for the grammar
Base class providing schema information to grammar.