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);
}
|