MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / act_update

Function act_update

src/gpre/sql.cpp:4510–4820  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4508//
4509
4510static 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

Callers 1

SQL_actionFunction · 0.85

Calls 15

MSC_matchFunction · 0.85
act_upsertFunction · 0.85
SQL_relation_nameFunction · 0.85
PAR_symbolFunction · 0.85
CPR_s_errorFunction · 0.85
MSC_requestFunction · 0.85
SQL_relationFunction · 0.85
MSC_contextFunction · 0.85
HSH_insertFunction · 0.85
HSH_lookupFunction · 0.85
MSC_nodeFunction · 0.85
SQE_fieldFunction · 0.85

Tested by

no test coverage detected