MCPcopy Create free account
hub / github.com/anse1/sqlsmith / funcall

Method funcall

expr.cc:210–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208}
209
210funcall::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
263void funcall::out(std::ostream &out)
264{

Callers

nothing calls this directly

Calls 5

d6Function · 0.85
random_pickFunction · 0.85
failFunction · 0.70
retryFunction · 0.70
consistentMethod · 0.45

Tested by

no test coverage detected