@@ -325,6 +325,7 @@ static int refresh_gbl_events_on_hndl(cdb2_hndl_tp *);
325325static int cdb2_get_dbhosts (cdb2_hndl_tp * );
326326static void hndl_set_comdb2buf (cdb2_hndl_tp * , COMDB2BUF * , int idx );
327327static int send_reset (COMDB2BUF * sb , int localcache );
328+ static void free_raw_response (cdb2_hndl_tp * hndl );
328329
329330static int check_hb_on_blocked_write = 0 ; // temporary switch - this will be default behavior
330331static int check_hb_on_blocked_write_set_from_env = 0 ;
@@ -1484,7 +1485,11 @@ void cdb2_set_sockpool(const char *sp_path)
14841485 SOCKPOOL_OTHER_NAME = strdup (sp_path );
14851486}
14861487
1487- static int is_valid_int (const char * str )
1488+ #ifndef CDB2API_SERVER
1489+ static
1490+ #endif
1491+ int
1492+ cdb2_is_valid_int (const char * str )
14881493{
14891494 while (* str ) {
14901495 if (!isdigit (* str ))
@@ -1582,7 +1587,7 @@ static void parse_dbhosts_from_env(int *dbnum, int *num_hosts, char hosts[][CDB2
15821587 if (tok == NULL ) {
15831588 return ;
15841589 }
1585- if (is_valid_int (tok )) {
1590+ if (cdb2_is_valid_int (tok )) {
15861591 * dbnum = atoi (tok );
15871592 tok = strtok_r (NULL , " :," , & last );
15881593 }
@@ -1758,7 +1763,7 @@ static void read_comdb2db_cfg(cdb2_hndl_tp *hndl, COMDB2BUF *s, const char *comd
17581763 }
17591764 if (comdb2db_name && strcasecmp (comdb2db_name , tok ) == 0 ) {
17601765 tok = strtok_r (NULL , " :," , & last );
1761- if (tok && is_valid_int (tok )) {
1766+ if (tok && cdb2_is_valid_int (tok )) {
17621767 * comdb2db_num = atoi (tok );
17631768 tok = strtok_r (NULL , " :," , & last );
17641769 }
@@ -1778,7 +1783,7 @@ static void read_comdb2db_cfg(cdb2_hndl_tp *hndl, COMDB2BUF *s, const char *comd
17781783 CDB2DBCONFIG_ADDL_PATH [sizeof (CDB2DBCONFIG_ADDL_PATH ) - 1 ] = '\0' ;
17791784 }
17801785 } else { /* host list */
1781- if (tok && is_valid_int (tok )) {
1786+ if (tok && cdb2_is_valid_int (tok )) {
17821787 * dbnum = atoi (tok );
17831788 tok = strtok_r (NULL , " :," , & last );
17841789 }
@@ -1854,7 +1859,7 @@ static void read_comdb2db_cfg(cdb2_hndl_tp *hndl, COMDB2BUF *s, const char *comd
18541859 for (ii = 0 ; ii <= current_size ; ii ++ )
18551860 cdb2_room_distance [ii ] = INT_MAX ;
18561861 while (tok != NULL ) {
1857- if (!is_valid_int (tok ))
1862+ if (!cdb2_is_valid_int (tok ))
18581863 break ;
18591864 ii = atoi (tok );
18601865 if (ii == 0 ) {
@@ -1870,7 +1875,7 @@ static void read_comdb2db_cfg(cdb2_hndl_tp *hndl, COMDB2BUF *s, const char *comd
18701875 }
18711876 tok = strtok_r (NULL , " ," , & last );
18721877
1873- if (tok && is_valid_int (tok ))
1878+ if (tok && cdb2_is_valid_int (tok ))
18741879 distance = atoi (tok );
18751880 else
18761881 continue ;
@@ -1897,7 +1902,7 @@ static void read_comdb2db_cfg(cdb2_hndl_tp *hndl, COMDB2BUF *s, const char *comd
18971902 cdb2_alarm_unread_socket_data = value_on_off (tok , & err );
18981903 } else if (!cdb2_max_discard_records_set_from_env && (strcasecmp ("max_discard_records" , tok ) == 0 )) {
18991904 tok = strtok_r (NULL , " =:," , & last );
1900- if (tok && is_valid_int (tok ))
1905+ if (tok && cdb2_is_valid_int (tok ))
19011906 cdb2_max_discard_records = atoi (tok );
19021907 } else if (!cdb2_flat_col_vals_set_from_env && strcasecmp ("flat_col_vals" , tok ) == 0 ) {
19031908 if ((tok = strtok_r (NULL , " =:," , & last )) != NULL )
@@ -4614,6 +4619,10 @@ static int cdb2_send_query(cdb2_hndl_tp *hndl, cdb2_hndl_tp *event_hndl, COMDB2B
46144619#if _LINUX_SOURCE
46154620 sqlquery .little_endian = 1 ;
46164621#endif
4622+ if (hndl && hndl -> is_tagged ) {
4623+ sqlquery .has_is_tagged = 1 ;
4624+ sqlquery .is_tagged = 1 ;
4625+ }
46174626
46184627 sqlquery .n_bindvars = n_bindvars ;
46194628 sqlquery .bindvars = bindvars ;
@@ -5191,7 +5200,9 @@ int cdb2_close(cdb2_hndl_tp *hndl)
51915200 newsql_disconnect (hndl , hndl -> sb , __LINE__ );
51925201
51935202 if (hndl -> firstresponse ) {
5194- cdb2__sqlresponse__free_unpacked (hndl -> firstresponse , NULL );
5203+ free_raw_response (hndl );
5204+ if (hndl -> firstresponse )
5205+ cdb2__sqlresponse__free_unpacked (hndl -> firstresponse , NULL );
51955206 hndl -> firstresponse = NULL ;
51965207 free ((void * )hndl -> first_buf );
51975208 hndl -> first_buf = NULL ;
@@ -6005,6 +6016,17 @@ static void attach_to_handle(cdb2_hndl_tp *child, cdb2_hndl_tp *parent)
60056016 }
60066017}
60076018
6019+ static void free_raw_response (cdb2_hndl_tp * hndl )
6020+ {
6021+ // Tagged requests receive a RESPONSE_HEADER__SQL_RESPONSE_RAW response that
6022+ // contains both the "header" and the row data. So the first response is
6023+ // also the last response and we only need to free one.
6024+ if (hndl -> is_tagged && hndl -> firstresponse && hndl -> firstresponse == hndl -> lastresponse ) {
6025+ cdb2__sqlresponse__free_unpacked (hndl -> firstresponse , NULL );
6026+ hndl -> firstresponse = hndl -> lastresponse = NULL ;
6027+ }
6028+ }
6029+
60086030static void pb_alloc_heuristic (cdb2_hndl_tp * hndl )
60096031{
60106032 if (!cdb2_protobuf_heuristic )
@@ -8273,6 +8295,11 @@ static int get_connection_int(cdb2_hndl_tp *hndl, int *err)
82738295 if (get_dbinfo || * err )
82748296 return -1 ;
82758297 before_discovery (hndl );
8298+ if (strcmp (hndl -> type , "configured" ) == 0 && hndl -> num_hosts > 0 ) {
8299+ // Special setting of "configured" means the proxy generated a list of hosts in its config and we should
8300+ // use that. Don't try discovery or sockpool - use what's in the proxy config.
8301+ return 0 ;
8302+ }
82768303 COMDB2BUF * sb = sockpool_get (hndl );
82778304 after_discovery (hndl );
82788305 if (sb == NULL )
@@ -8827,6 +8854,8 @@ int cdb2_open(cdb2_hndl_tp **handle, const char *dbname, const char *type,
88278854 hndl -> connected_host = -1 ;
88288855 hndl -> send_stack = 0 ;
88298856 hndl -> read_intrans_results = 1 ;
8857+ hndl -> is_admin = (flags & CDB2_ADMIN );
8858+ hndl -> is_tagged = (flags & CDB2_SET_TAGGED );
88308859
88318860 /* We don't do dbinfo if DIRECT_CPU. So we'd default peer SSL mode to
88328861 ALLOW. We will find it out later when we send SSL negotitaion packet
@@ -8836,8 +8865,6 @@ int cdb2_open(cdb2_hndl_tp **handle, const char *dbname, const char *type,
88368865 hndl -> max_retries = MAX_RETRIES ;
88378866 hndl -> min_retries = MIN_RETRIES ;
88388867
8839- hndl -> is_admin = (flags & CDB2_ADMIN );
8840-
88418868 if (cdb2_use_env_vars ) {
88428869 hndl -> db_default_type_override_env = 0 ;
88438870 hndl -> sockpool_enabled = 0 ;
0 commit comments