| 14 | #include "random.hh" |
| 15 | |
| 16 | struct schema { |
| 17 | sqltype *booltype; |
| 18 | sqltype *inttype; |
| 19 | sqltype *internaltype; |
| 20 | sqltype *arraytype; |
| 21 | |
| 22 | std::vector<sqltype *> types; |
| 23 | |
| 24 | std::vector<table> tables; |
| 25 | std::vector<op> operators; |
| 26 | std::vector<routine> routines; |
| 27 | std::vector<routine> aggregates; |
| 28 | |
| 29 | typedef std::tuple<sqltype *,sqltype *,sqltype *> typekey; |
| 30 | std::multimap<typekey, op> index; |
| 31 | typedef std::multimap<typekey, op>::iterator op_iterator; |
| 32 | |
| 33 | std::map<sqltype*, std::vector<routine*>> routines_returning_type; |
| 34 | std::map<sqltype*, std::vector<routine*>> aggregates_returning_type; |
| 35 | std::map<sqltype*, std::vector<routine*>> parameterless_routines_returning_type; |
| 36 | std::map<sqltype*, std::vector<table*>> tables_with_columns_of_type; |
| 37 | std::map<sqltype*, std::vector<op*>> operators_returning_type; |
| 38 | std::map<sqltype*, std::vector<sqltype*>> concrete_type; |
| 39 | std::vector<table*> base_tables; |
| 40 | |
| 41 | string version; |
| 42 | int version_num; // comparable version number |
| 43 | |
| 44 | const char *true_literal = "true"; |
| 45 | const char *false_literal = "false"; |
| 46 | |
| 47 | virtual std::string quote_name(const std::string &id) = 0; |
| 48 | |
| 49 | void summary() { |
| 50 | std::cout << "Found " << tables.size() << |
| 51 | " user table(s) in information schema." << std::endl; |
| 52 | } |
| 53 | void fill_scope(struct scope &s) { |
| 54 | for (auto &t : tables) |
| 55 | s.tables.push_back(&t); |
| 56 | s.schema = this; |
| 57 | } |
| 58 | virtual void register_operator(op& o) { |
| 59 | operators.push_back(o); |
| 60 | typekey t(o.left, o.right, o.result); |
| 61 | index.insert(std::pair<typekey,op>(t,o)); |
| 62 | } |
| 63 | virtual void register_routine(routine& r) { |
| 64 | routines.push_back(r); |
| 65 | } |
| 66 | virtual void register_aggregate(routine& r) { |
| 67 | aggregates.push_back(r); |
| 68 | } |
| 69 | virtual op_iterator find_operator(sqltype *left, sqltype *right, sqltype *res) { |
| 70 | typekey t(left, right, res); |
| 71 | auto cons = index.equal_range(t); |
| 72 | if (cons.first == cons.second) |
| 73 | return index.end(); |
nothing calls this directly
no outgoing calls
no test coverage detected