MCPcopy Create free account
hub / github.com/apache/cloudberry / evalStandardFunc

Function evalStandardFunc

src/bin/pgbench/pgbench.c:2068–2635  ·  view source on GitHub ↗

* Recursive evaluation of standard functions, * which do not require lazy evaluation. */

Source from the content-addressed store, hash-verified

2066 * which do not require lazy evaluation.
2067 */
2068static bool
2069evalStandardFunc(CState *st,
2070 PgBenchFunction func, PgBenchExprLink *args,
2071 PgBenchValue *retval)
2072{
2073 /* evaluate all function arguments */
2074 int nargs = 0;
2075 PgBenchValue vargs[MAX_FARGS];
2076 PgBenchExprLink *l = args;
2077 bool has_null = false;
2078
2079 /* Some compiler (gcc-12) may raise warning about uninitialized variable */
2080 memset(vargs, 0, sizeof(vargs));
2081
2082 for (nargs = 0; nargs < MAX_FARGS && l != NULL; nargs++, l = l->next)
2083 {
2084 if (!evaluateExpr(st, l->expr, &vargs[nargs]))
2085 return false;
2086 has_null |= vargs[nargs].type == PGBT_NULL;
2087 }
2088
2089 if (l != NULL)
2090 {
2091 pg_log_error("too many function arguments, maximum is %d", MAX_FARGS);
2092 return false;
2093 }
2094
2095 /* NULL arguments */
2096 if (has_null && func != PGBENCH_IS && func != PGBENCH_DEBUG)
2097 {
2098 setNullValue(retval);
2099 return true;
2100 }
2101
2102 /* then evaluate function */
2103 switch (func)
2104 {
2105 /* overloaded operators */
2106 case PGBENCH_ADD:
2107 case PGBENCH_SUB:
2108 case PGBENCH_MUL:
2109 case PGBENCH_DIV:
2110 case PGBENCH_MOD:
2111 case PGBENCH_EQ:
2112 case PGBENCH_NE:
2113 case PGBENCH_LE:
2114 case PGBENCH_LT:
2115 {
2116 PgBenchValue *lval = &vargs[0],
2117 *rval = &vargs[1];
2118
2119 Assert(nargs == 2);
2120
2121 /* overloaded type management, double if some double */
2122 if ((lval->type == PGBT_DOUBLE ||
2123 rval->type == PGBT_DOUBLE) && func != PGBENCH_MOD)
2124 {
2125 double ld,

Callers 1

evalFuncFunction · 0.85

Calls 15

evaluateExprFunction · 0.85
setNullValueFunction · 0.85
coerceToDoubleFunction · 0.85
setDoubleValueFunction · 0.85
setBoolValueFunction · 0.85
coerceToIntFunction · 0.85
pg_add_s64_overflowFunction · 0.85
setIntValueFunction · 0.85
pg_sub_s64_overflowFunction · 0.85
pg_mul_s64_overflowFunction · 0.85
coerceToBoolFunction · 0.85
getrandFunction · 0.85

Tested by

no test coverage detected