| 3180 | // |
| 3181 | |
| 3182 | static gpre_nod* par_udf( gpre_req* request) |
| 3183 | { |
| 3184 | if (!request) |
| 3185 | return NULL; |
| 3186 | |
| 3187 | assert_IS_REQ(request); |
| 3188 | |
| 3189 | // Check for user defined functions |
| 3190 | // resolve only if an identifier |
| 3191 | if ((isQuoted(gpreGlob.token_global.tok_type)) || gpreGlob.token_global.tok_type == tok_ident) |
| 3192 | SQL_resolve_identifier("<Udf Name>", NULL, NAME_SIZE); |
| 3193 | |
| 3194 | gpre_nod* node; |
| 3195 | USHORT local_count; |
| 3196 | |
| 3197 | udf* an_udf; |
| 3198 | if (request->req_database) |
| 3199 | an_udf = MET_get_udf(request->req_database, gpreGlob.token_global.tok_string); |
| 3200 | else |
| 3201 | { |
| 3202 | // no database was specified, check the metadata for all the databases |
| 3203 | // for the existence of the udf |
| 3204 | |
| 3205 | an_udf = NULL; |
| 3206 | for (gpre_dbb* db = gpreGlob.isc_databases; db; db = db->dbb_next) |
| 3207 | { |
| 3208 | udf* tmp_udf = MET_get_udf(db, gpreGlob.token_global.tok_string); |
| 3209 | if (tmp_udf) |
| 3210 | if (an_udf) |
| 3211 | { |
| 3212 | // udf was found in more than one database |
| 3213 | SCHAR s[ERROR_LENGTH]; |
| 3214 | fb_utils::snprintf(s, sizeof(s), "UDF %s is ambiguous", gpreGlob.token_global.tok_string); |
| 3215 | PAR_error(s); |
| 3216 | } |
| 3217 | else |
| 3218 | { |
| 3219 | an_udf = tmp_udf; |
| 3220 | request->req_database = db; |
| 3221 | } |
| 3222 | } |
| 3223 | } |
| 3224 | |
| 3225 | if (an_udf) |
| 3226 | { |
| 3227 | if ((SQL_DIALECT_V5 == gpreGlob.sw_sql_dialect) && |
| 3228 | (dtype_sql_date == an_udf->udf_dtype || |
| 3229 | dtype_sql_time == an_udf->udf_dtype || |
| 3230 | dtype_int64 == an_udf->udf_dtype)) |
| 3231 | { |
| 3232 | SQL_dialect1_bad_type(an_udf->udf_dtype); |
| 3233 | } |
| 3234 | |
| 3235 | node = MSC_node(nod_udf, 2); |
| 3236 | node->nod_count = 1; |
| 3237 | node->nod_arg[1] = (gpre_nod*) an_udf; |
| 3238 | PAR_get_token(); |
| 3239 | EXP_left_paren(0); |
no test coverage detected