File: schema.cc

package info (click to toggle)
sqlsmith 1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 540 kB
  • sloc: cpp: 3,221; sql: 175; makefile: 33; sh: 1
file content (62 lines) | stat: -rw-r--r-- 1,404 bytes parent folder | download | duplicates (2)
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
#include <typeinfo>
#include "config.h"
#include "schema.hh"
#include "relmodel.hh"
#include <pqxx/pqxx>
#include "gitrev.h"

using namespace std;
using namespace pqxx;

void schema::generate_indexes() {

  cerr << "Generating indexes...";

  for (auto &type: types) {
    assert(type);
    for(auto &r: aggregates) {
      if (type->consistent(r.restype))
	aggregates_returning_type.insert(pair<sqltype*, routine*>(type, &r));
    }

    for(auto &r: routines) {
      if (!type->consistent(r.restype))
	continue;
      routines_returning_type.insert(pair<sqltype*, routine*>(type, &r));
      if(!r.argtypes.size())
	parameterless_routines_returning_type.insert(pair<sqltype*, routine*>(type, &r));
    }
    
    for (auto &t: tables) {
      for (auto &c: t.columns()) {
	if (type->consistent(c.type)) {
	  tables_with_columns_of_type.insert(pair<sqltype*, table*>(type, &t));
	  break;
	}
      }
    }

    for (auto &concrete: types) {
      if (type->consistent(concrete))
	concrete_type.insert(pair<sqltype*, sqltype*>(type, concrete));
    }

    for (auto &o: operators) {
      if (type->consistent(o.result))
	operators_returning_type.insert(pair<sqltype*, op*>(type, &o));
    }
  }

  for (auto &t: tables) {
    if (t.is_base_table)
      base_tables.push_back(&t);
  }
  
  cerr << "done." << endl;

  assert(booltype);
  assert(inttype);
  assert(internaltype);
  assert(arraytype);

}