| 2358 | // |
| 2359 | |
| 2360 | static act* par_open_blob( act_t act_op, gpre_sym* symbol) |
| 2361 | { |
| 2362 | // If somebody hasn't already parsed up a symbol for us, parse the |
| 2363 | // symbol and the mandatory IN now. |
| 2364 | |
| 2365 | if (!symbol) |
| 2366 | { |
| 2367 | symbol = PAR_symbol(SYM_dummy); |
| 2368 | if (!MSC_match(KW_IN)) |
| 2369 | CPR_s_error("IN"); |
| 2370 | } |
| 2371 | |
| 2372 | // The next thing we should find is a field reference. Get it. |
| 2373 | gpre_ctx* context; |
| 2374 | gpre_fld* field = EXP_field(&context); |
| 2375 | if (!field) |
| 2376 | return NULL; |
| 2377 | |
| 2378 | TEXT s[ERROR_LENGTH]; |
| 2379 | if (!(field->fld_flags & FLD_blob)) |
| 2380 | { |
| 2381 | fb_utils::snprintf(s, sizeof(s), "Field %s is not a blob", field->fld_symbol->sym_string); |
| 2382 | PAR_error(s); |
| 2383 | } |
| 2384 | |
| 2385 | if (field->fld_array_info) |
| 2386 | { |
| 2387 | fb_utils::snprintf(s, sizeof(s), "Field %s is an array and can not be opened as a blob", |
| 2388 | field->fld_symbol->sym_string); |
| 2389 | PAR_error(s); |
| 2390 | } |
| 2391 | |
| 2392 | gpre_req* request = context->ctx_request; |
| 2393 | ref* reference = EXP_post_field(field, context, false); |
| 2394 | |
| 2395 | blb* blob = (blb*) MSC_alloc(BLB_LEN); |
| 2396 | blob->blb_symbol = symbol; |
| 2397 | blob->blb_reference = reference; |
| 2398 | |
| 2399 | // See if we need a blob filter (do we have a subtype to subtype clause?) |
| 2400 | |
| 2401 | for (;;) |
| 2402 | { |
| 2403 | if (MSC_match(KW_FILTER)) |
| 2404 | { |
| 2405 | blob->blb_const_from_type = (MSC_match(KW_FROM)) ? |
| 2406 | PAR_blob_subtype(request->req_database) : field->fld_sub_type; |
| 2407 | if (!MSC_match(KW_TO)) |
| 2408 | CPR_s_error("TO"); |
| 2409 | blob->blb_const_to_type = PAR_blob_subtype(request->req_database); |
| 2410 | } |
| 2411 | else if (MSC_match(KW_STREAM)) |
| 2412 | blob->blb_type = isc_bpb_type_stream; |
| 2413 | else |
| 2414 | break; |
| 2415 | } |
| 2416 | |
| 2417 | if (!(blob->blb_seg_length = field->fld_seg_length)) |
no test coverage detected