@@ -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 ;
@@ -4614,6 +4615,10 @@ static int cdb2_send_query(cdb2_hndl_tp *hndl, cdb2_hndl_tp *event_hndl, COMDB2B
46144615#if _LINUX_SOURCE
46154616 sqlquery .little_endian = 1 ;
46164617#endif
4618+ if (hndl && hndl -> is_tagged ) {
4619+ sqlquery .has_is_tagged = 1 ;
4620+ sqlquery .is_tagged = 1 ;
4621+ }
46174622
46184623 sqlquery .n_bindvars = n_bindvars ;
46194624 sqlquery .bindvars = bindvars ;
@@ -5191,7 +5196,9 @@ int cdb2_close(cdb2_hndl_tp *hndl)
51915196 newsql_disconnect (hndl , hndl -> sb , __LINE__ );
51925197
51935198 if (hndl -> firstresponse ) {
5194- cdb2__sqlresponse__free_unpacked (hndl -> firstresponse , NULL );
5199+ free_raw_response (hndl );
5200+ if (hndl -> firstresponse )
5201+ cdb2__sqlresponse__free_unpacked (hndl -> firstresponse , NULL );
51955202 hndl -> firstresponse = NULL ;
51965203 free ((void * )hndl -> first_buf );
51975204 hndl -> first_buf = NULL ;
@@ -6005,6 +6012,17 @@ static void attach_to_handle(cdb2_hndl_tp *child, cdb2_hndl_tp *parent)
60056012 }
60066013}
60076014
6015+ static void free_raw_response (cdb2_hndl_tp * hndl )
6016+ {
6017+ // Tagged requests receive a RESPONSE_HEADER__SQL_RESPONSE_RAW response that
6018+ // contains both the "header" and the row data. So the first response is
6019+ // also the last response and we only need to free one.
6020+ if (hndl -> is_tagged && hndl -> firstresponse && hndl -> firstresponse == hndl -> lastresponse ) {
6021+ cdb2__sqlresponse__free_unpacked (hndl -> firstresponse , NULL );
6022+ hndl -> firstresponse = hndl -> lastresponse = NULL ;
6023+ }
6024+ }
6025+
60086026static void pb_alloc_heuristic (cdb2_hndl_tp * hndl )
60096027{
60106028 if (!cdb2_protobuf_heuristic )
@@ -8273,6 +8291,11 @@ static int get_connection_int(cdb2_hndl_tp *hndl, int *err)
82738291 if (get_dbinfo || * err )
82748292 return -1 ;
82758293 before_discovery (hndl );
8294+ if (strcmp (hndl -> type , "configured" ) == 0 && hndl -> num_hosts > 0 ) {
8295+ // Special setting of "configured" means the proxy generated a list of hosts in its config and we should
8296+ // use that. Don't try discovery or sockpool - use what's in the proxy config.
8297+ return 0 ;
8298+ }
82768299 COMDB2BUF * sb = sockpool_get (hndl );
82778300 after_discovery (hndl );
82788301 if (sb == NULL )
@@ -8827,6 +8850,8 @@ int cdb2_open(cdb2_hndl_tp **handle, const char *dbname, const char *type,
88278850 hndl -> connected_host = -1 ;
88288851 hndl -> send_stack = 0 ;
88298852 hndl -> read_intrans_results = 1 ;
8853+ hndl -> is_admin = (flags & CDB2_ADMIN );
8854+ hndl -> is_tagged = (flags & CDB2_SET_TAGGED );
88308855
88318856 /* We don't do dbinfo if DIRECT_CPU. So we'd default peer SSL mode to
88328857 ALLOW. We will find it out later when we send SSL negotitaion packet
@@ -8836,8 +8861,6 @@ int cdb2_open(cdb2_hndl_tp **handle, const char *dbname, const char *type,
88368861 hndl -> max_retries = MAX_RETRIES ;
88378862 hndl -> min_retries = MIN_RETRIES ;
88388863
8839- hndl -> is_admin = (flags & CDB2_ADMIN );
8840-
88418864 if (cdb2_use_env_vars ) {
88428865 hndl -> db_default_type_override_env = 0 ;
88438866 hndl -> sockpool_enabled = 0 ;
0 commit comments