| 1477 | // |
| 1478 | |
| 1479 | static act* act_connect() |
| 1480 | { |
| 1481 | act* action = MSC_action(0, ACT_ready); |
| 1482 | action->act_whenever = gen_whenever(); |
| 1483 | bool need_handle = false; |
| 1484 | const USHORT default_buffers = 0; // useless? |
| 1485 | |
| 1486 | MSC_match(KW_TO); |
| 1487 | |
| 1488 | if (!MSC_match(KW_ALL) && !MSC_match(KW_DEFAULT)) |
| 1489 | { |
| 1490 | while (true) |
| 1491 | { |
| 1492 | rdy* ready = (rdy*) MSC_alloc(RDY_LEN); |
| 1493 | ready->rdy_next = (rdy*) action->act_object; |
| 1494 | action->act_object = (ref*) ready; |
| 1495 | |
| 1496 | gpre_sym* symbol = gpreGlob.token_global.tok_symbol; |
| 1497 | if (!symbol || symbol->sym_type != SYM_database) |
| 1498 | { |
| 1499 | ready->rdy_filename = SQL_var_or_string(false); |
| 1500 | if (MSC_match(KW_AS)) |
| 1501 | need_handle = true; |
| 1502 | } |
| 1503 | |
| 1504 | symbol = gpreGlob.token_global.tok_symbol; |
| 1505 | if (!symbol || symbol->sym_type != SYM_database) |
| 1506 | { |
| 1507 | if (!gpreGlob.isc_databases || gpreGlob.isc_databases->dbb_next || need_handle) |
| 1508 | { |
| 1509 | need_handle = false; |
| 1510 | CPR_s_error("<database handle>"); |
| 1511 | } |
| 1512 | ready->rdy_database = dup_dbb(gpreGlob.isc_databases); |
| 1513 | } |
| 1514 | |
| 1515 | need_handle = false; |
| 1516 | if (!ready->rdy_database) |
| 1517 | { |
| 1518 | ready->rdy_database = dup_dbb((gpre_dbb*) symbol->sym_object); |
| 1519 | PAR_get_token(); |
| 1520 | } |
| 1521 | |
| 1522 | // pick up the possible parameters, in any order |
| 1523 | |
| 1524 | USHORT buffers = 0; |
| 1525 | gpre_dbb* db = ready->rdy_database; |
| 1526 | connect_opts(&db->dbb_r_user, &db->dbb_r_password, |
| 1527 | &db->dbb_r_sql_role, &db->dbb_r_lc_messages, &buffers); |
| 1528 | |
| 1529 | gpre_req* request = NULL; |
| 1530 | if (buffers) |
| 1531 | request = PAR_set_up_dpb_info(ready, action, buffers); |
| 1532 | |
| 1533 | // if there are any options that take host variables as arguments, |
| 1534 | // make sure that we generate variables for the request so that the |
| 1535 | // dpb can be extended at runtime |
| 1536 |
no test coverage detected