| 3881 | } |
| 3882 | |
| 3883 | static int retry_query_list(cdb2_hndl_tp *hndl, int num_retry, int run_last) |
| 3884 | { |
| 3885 | debugprint("retry_all %d, intran %d\n", hndl->retry_all, hndl->in_trans); |
| 3886 | |
| 3887 | if (!hndl->retry_all || !hndl->in_trans) |
| 3888 | return 0; |
| 3889 | |
| 3890 | int rc = 0; |
| 3891 | if (!(hndl->snapshot_file || hndl->query_no <= 1)) { |
| 3892 | debugprint("in_trans=%d snapshot_file=%d query_no=%d\n", hndl->in_trans, |
| 3893 | hndl->snapshot_file, hndl->query_no); |
| 3894 | sprintf(hndl->errstr, "Database disconnected while in transaction."); |
| 3895 | return CDB2ERR_TRAN_IO_ERROR; /* Fail if disconnect happens in |
| 3896 | transaction which doesn't have snapshot |
| 3897 | info.*/ |
| 3898 | } |
| 3899 | |
| 3900 | /* Replay all the queries. */ |
| 3901 | char *host = "NOT-CONNECTED"; |
| 3902 | if (hndl->connected_host >= 0) |
| 3903 | host = hndl->hosts[hndl->connected_host]; |
| 3904 | |
| 3905 | /*Send Begin. */ |
| 3906 | hndl->is_retry = num_retry; |
| 3907 | |
| 3908 | clear_responses(hndl); |
| 3909 | hndl->read_intrans_results = 1; |
| 3910 | |
| 3911 | hndl->in_trans = 0; |
| 3912 | debugprint("sending 'begin' to %s\n", host); |
| 3913 | rc = cdb2_send_query(hndl, hndl, hndl->sb, hndl->dbname, "begin", |
| 3914 | hndl->num_set_commands, hndl->num_set_commands_sent, |
| 3915 | hndl->commands, 0, NULL, 0, NULL, 1, 0, num_retry, 0, |
| 3916 | __LINE__); |
| 3917 | hndl->in_trans = 1; |
| 3918 | debugprint("cdb2_send_query rc = %d, setting in_trans to 1\n", rc); |
| 3919 | |
| 3920 | if (rc != 0) { |
| 3921 | sbuf2close(hndl->sb); |
| 3922 | hndl->sb = NULL; |
| 3923 | debugprint("send_query host=%s rc=%d; returning 1\n", host, rc); |
| 3924 | return 1; |
| 3925 | } |
| 3926 | int len = 0; |
| 3927 | int type = 0; |
| 3928 | rc = cdb2_read_record(hndl, &hndl->first_buf, &len, &type); |
| 3929 | if (rc) { |
| 3930 | sbuf2close(hndl->sb); |
| 3931 | hndl->sb = NULL; |
| 3932 | debugprint("cdb2_read_record from %s rc=%d, returning 1\n", host, rc); |
| 3933 | return 1; |
| 3934 | } |
| 3935 | |
| 3936 | if (type == RESPONSE_HEADER__DBINFO_RESPONSE) { |
| 3937 | if (hndl->flags & CDB2_DIRECT_CPU) { |
| 3938 | debugprint("directcpu will ignore dbinfo\n"); |
| 3939 | return 1; |
| 3940 | } |
no test coverage detected