| 4508 | // |
| 4509 | |
| 4510 | static act* act_update() |
| 4511 | { |
| 4512 | if (MSC_match(KW_OR) && MSC_match(KW_INSERT)) |
| 4513 | return act_upsert(); |
| 4514 | |
| 4515 | const TEXT* transaction = NULL; |
| 4516 | |
| 4517 | par_options(&transaction); |
| 4518 | |
| 4519 | // First comes the relation. Unfortunately, there is no way to identify |
| 4520 | // its database until the cursor is known. Sigh. Save the token. |
| 4521 | |
| 4522 | SCHAR r_name[NAME_SIZE], db_name[NAME_SIZE], owner_name[NAME_SIZE]; |
| 4523 | SQL_relation_name(r_name, db_name, owner_name); |
| 4524 | |
| 4525 | // Parse the optional alias (context variable) |
| 4526 | |
| 4527 | gpre_sym* alias = gpreGlob.token_global.tok_symbol ? NULL : PAR_symbol(SYM_dummy); |
| 4528 | |
| 4529 | // Now we need the SET list list. Do this thru a linked list stack |
| 4530 | |
| 4531 | if (!MSC_match(KW_SET)) |
| 4532 | CPR_s_error("SET"); |
| 4533 | |
| 4534 | gpre_req* request = MSC_request(REQ_mass_update); |
| 4535 | gpre_rel* relation = SQL_relation(request, r_name, db_name, owner_name, true); |
| 4536 | gpre_ctx* input_context = MSC_context(request); |
| 4537 | input_context->ctx_relation = relation; |
| 4538 | |
| 4539 | if (alias) |
| 4540 | { |
| 4541 | alias->sym_type = SYM_context; |
| 4542 | alias->sym_object = input_context; |
| 4543 | HSH_insert(alias); |
| 4544 | gpreGlob.token_global.tok_symbol = HSH_lookup(gpreGlob.token_global.tok_string); |
| 4545 | } |
| 4546 | |
| 4547 | gpre_lls* stack = NULL; |
| 4548 | SSHORT count = 0; |
| 4549 | |
| 4550 | do { |
| 4551 | gpre_nod* set_item = MSC_node(nod_assignment, 2); |
| 4552 | set_item->nod_arg[1] = SQE_field(NULL, false); |
| 4553 | if (!MSC_match(KW_EQUALS)) |
| 4554 | CPR_s_error("assignment operator"); |
| 4555 | set_item->nod_arg[0] = SQE_value_or_null(request, false, NULL, NULL); |
| 4556 | MSC_push(set_item, &stack); |
| 4557 | count++; |
| 4558 | } while (MSC_match(KW_COMMA)); |
| 4559 | |
| 4560 | gpre_nod* set_list = MSC_node(nod_list, count); |
| 4561 | gpre_nod** const end_list = set_list->nod_arg + count; |
| 4562 | gpre_nod** ptr = end_list; |
| 4563 | |
| 4564 | while (stack) |
| 4565 | *--ptr = (gpre_nod*) MSC_pop(&stack); |
| 4566 | |
| 4567 | // Now the moment of truth. If the next few tokens are WHERE CURRENT OF |
no test coverage detected