| 4826 | // |
| 4827 | |
| 4828 | static act* act_upsert(void) |
| 4829 | { |
| 4830 | const TEXT* transaction = NULL; |
| 4831 | |
| 4832 | par_options(&transaction); |
| 4833 | |
| 4834 | if (!MSC_match(KW_INTO)) |
| 4835 | CPR_s_error("INTO"); |
| 4836 | |
| 4837 | gpre_req* request = MSC_request(REQ_mass_update); |
| 4838 | request->req_trans = transaction; |
| 4839 | gpre_ctx* const context = SQE_context(request); |
| 4840 | gpre_rel* relation = context->ctx_relation; |
| 4841 | |
| 4842 | int count = 0; |
| 4843 | gpre_lls* fields = NULL; |
| 4844 | |
| 4845 | // Pick up a field list |
| 4846 | |
| 4847 | if (!MSC_match(KW_LEFT_PAREN)) |
| 4848 | { |
| 4849 | gpre_nod* list = MET_fields(context); |
| 4850 | count = list->nod_count; |
| 4851 | for (int i = 0; i < count; i++) |
| 4852 | MSC_push(list->nod_arg[i], &fields); |
| 4853 | } |
| 4854 | else |
| 4855 | { |
| 4856 | do |
| 4857 | { |
| 4858 | gpre_nod* node = SQE_field(request, false); |
| 4859 | |
| 4860 | if (node->nod_type == nod_array) |
| 4861 | { |
| 4862 | node->nod_type = nod_field; |
| 4863 | |
| 4864 | // Make sure no subscripts are specified |
| 4865 | |
| 4866 | if (node->nod_arg[1]) { |
| 4867 | PAR_error("Partial insert of arrays not permitted"); |
| 4868 | } |
| 4869 | } |
| 4870 | |
| 4871 | // Dialect 1 program may not insert new datatypes |
| 4872 | if ((SQL_DIALECT_V5 == gpreGlob.sw_sql_dialect) && |
| 4873 | (nod_field == node->nod_type)) |
| 4874 | { |
| 4875 | const USHORT field_dtype = |
| 4876 | ((ref*) (node->nod_arg[0]))->ref_field->fld_dtype; |
| 4877 | |
| 4878 | if ((dtype_sql_date == field_dtype) |
| 4879 | || (dtype_sql_time == field_dtype) |
| 4880 | || (dtype_int64 == field_dtype)) |
| 4881 | { |
| 4882 | SQL_dialect1_bad_type(field_dtype); |
| 4883 | } |
| 4884 | } |
| 4885 |
no test coverage detected