| 208 | } |
| 209 | |
| 210 | funcall::funcall(prod *p, sqltype *type_constraint, bool agg) |
| 211 | : value_expr(p), is_aggregate(agg) |
| 212 | { |
| 213 | if (type_constraint == scope->schema->internaltype) |
| 214 | fail("cannot call functions involving internal type"); |
| 215 | |
| 216 | auto &idx = agg ? p->scope->schema->aggregates_returning_type |
| 217 | : (4 < d6()) ? |
| 218 | p->scope->schema->routines_returning_type |
| 219 | : p->scope->schema->parameterless_routines_returning_type; |
| 220 | |
| 221 | retry: |
| 222 | |
| 223 | if (!type_constraint) { |
| 224 | proc = random_pick(random_pick(idx.begin(), idx.end())->second); |
| 225 | } else { |
| 226 | auto iters = idx.equal_range(type_constraint); |
| 227 | proc = random_pick(random_pick(iters)->second); |
| 228 | if (proc && !type_constraint->consistent(proc->restype)) { |
| 229 | retry(); |
| 230 | goto retry; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | if (!proc) { |
| 235 | retry(); |
| 236 | goto retry; |
| 237 | } |
| 238 | |
| 239 | if (type_constraint) |
| 240 | type = type_constraint; |
| 241 | else |
| 242 | type = proc->restype; |
| 243 | |
| 244 | if (type == scope->schema->internaltype) { |
| 245 | retry(); |
| 246 | goto retry; |
| 247 | } |
| 248 | |
| 249 | for (auto type : proc->argtypes) |
| 250 | if (type == scope->schema->internaltype |
| 251 | || type == scope->schema->arraytype) { |
| 252 | retry(); |
| 253 | goto retry; |
| 254 | } |
| 255 | |
| 256 | for (auto argtype : proc->argtypes) { |
| 257 | assert(argtype); |
| 258 | auto expr = value_expr::factory(this, argtype); |
| 259 | parms.push_back(expr); |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | void funcall::out(std::ostream &out) |
| 264 | { |
nothing calls this directly
no test coverage detected