| 3760 | // |
| 3761 | |
| 3762 | static act* act_open_blob( act_t act_op, gpre_sym* symbol) |
| 3763 | { |
| 3764 | if (!MSC_match(KW_BLOB)) |
| 3765 | CPR_s_error("BLOB"); |
| 3766 | |
| 3767 | // if the token isn't an identifier, complain |
| 3768 | |
| 3769 | tok* f_token = (tok*) MSC_alloc(TOK_LEN); |
| 3770 | f_token->tok_length = gpreGlob.token_global.tok_length; |
| 3771 | |
| 3772 | // Funny, as if we can have relation names up to MAX_SYM_SIZE. |
| 3773 | SQL_resolve_identifier("<column_name>", f_token->tok_string, f_token->tok_length + 1); |
| 3774 | if (gpreGlob.token_global.tok_length >= NAME_SIZE) |
| 3775 | PAR_error("Field name too long"); |
| 3776 | |
| 3777 | CPR_token(); |
| 3778 | |
| 3779 | if (act_op == ACT_blob_open) |
| 3780 | { |
| 3781 | if (!MSC_match(KW_FROM)) |
| 3782 | CPR_s_error("FROM"); |
| 3783 | } |
| 3784 | else if (!MSC_match(KW_INTO)) |
| 3785 | CPR_s_error("INTO"); |
| 3786 | |
| 3787 | gpre_req* request = MSC_request(REQ_cursor); |
| 3788 | request->req_flags = (act_op == ACT_blob_open) ? REQ_sql_blob_open : REQ_sql_blob_create; |
| 3789 | |
| 3790 | SCHAR r_name[NAME_SIZE], db_name[NAME_SIZE], owner_name[NAME_SIZE]; |
| 3791 | SQL_relation_name(r_name, db_name, owner_name); |
| 3792 | |
| 3793 | |
| 3794 | SCHAR s[ERROR_LENGTH]; |
| 3795 | gpre_rel* relation = SQL_relation(request, r_name, db_name, owner_name, true); |
| 3796 | gpre_fld* field = MET_field(relation, f_token->tok_string); |
| 3797 | if (!field) |
| 3798 | { |
| 3799 | fb_utils::snprintf(s, sizeof(s), "column \"%s\" not in context", f_token->tok_string); |
| 3800 | PAR_error(s); |
| 3801 | } |
| 3802 | |
| 3803 | if (!(field->fld_flags & FLD_blob)) |
| 3804 | { |
| 3805 | fb_utils::snprintf(s, sizeof(s), "column %s is not a BLOB", field->fld_symbol->sym_string); |
| 3806 | PAR_error(s); |
| 3807 | } |
| 3808 | |
| 3809 | if (field->fld_array_info) |
| 3810 | { |
| 3811 | fb_utils::snprintf(s, sizeof(s), "column %s is an array and can not be opened as a BLOB", |
| 3812 | field->fld_symbol->sym_string); |
| 3813 | PAR_error(s); |
| 3814 | } |
| 3815 | |
| 3816 | ref* reference = MSC_reference(0); |
| 3817 | reference->ref_field = field; |
| 3818 | |
| 3819 | gpre_ctx* context = MSC_context(request); |
no test coverage detected