@@ -318,10 +318,10 @@ struct ch_binary_state
318318 bool (* check_cancel_fn ) (void );
319319
320320 /*
321- * Set when an unrecoverable protocol/IO error happened (eg server
322- * raised an exception mid-INSERT and closed the socket, or a write
323- * hit EPIPE). Callers must drop the cached connection rather than
324- * reuse it; the cache layer checks this via ch_binary_is_broken.
321+ * Set when an unrecoverable protocol/IO error happened (eg server raised
322+ * an exception mid-INSERT and closed the socket, or a write hit EPIPE).
323+ * Callers must drop the cached connection rather than reuse it; the cache
324+ * layer checks this via ch_binary_is_broken.
325325 */
326326 bool broken ;
327327};
@@ -495,8 +495,7 @@ ch_binary_connect(ch_connection_details * details, char *errbuf, size_t errbuf_s
495495
496496 if (rc != CHC_OK )
497497 {
498- set_errbuf (errbuf , errbuf_size ,
499- err .msg [0 ] ? err .msg : "chc_client_init failed" );
498+ set_errbuf (errbuf , errbuf_size , err .msg );
500499 goto fail ;
501500 }
502501 return conn ;
@@ -825,7 +824,7 @@ ch_binary_simple_query(ch_binary_connection_t * conn, const ch_query * query,
825824
826825 if (rc != CHC_OK )
827826 {
828- resp_set_error (resp , err .msg [ 0 ] ? err . msg : "send_query failed" );
827+ resp_set_error (resp , err .msg );
829828 s -> broken = true;
830829 goto done ;
831830 }
@@ -841,7 +840,7 @@ ch_binary_simple_query(ch_binary_connection_t * conn, const ch_query * query,
841840 rc = chc_client_recv_packet (s -> client , & pkt , & err );
842841 if (rc != CHC_OK )
843842 {
844- resp_set_error (resp , err .msg [ 0 ] ? err . msg : "recv_packet failed" );
843+ resp_set_error (resp , err .msg );
845844 s -> broken = true;
846845 break ;
847846 }
@@ -874,12 +873,13 @@ ch_binary_simple_query(ch_binary_connection_t * conn, const ch_query * query,
874873 case CHC_PKT_EXCEPTION :
875874 resp_set_exception (resp , pkt .exception );
876875 chc_packet_clear (s -> client , & pkt );
876+
877877 /*
878878 * Older servers (and some protocol states) close the socket
879879 * after raising an exception, so reusing this connection for
880880 * a follow-up query risks EPIPE. Match the legacy C++ driver
881- * (which always called Client::ResetConnection) and treat
882- * the connection as broken.
881+ * (which always called Client::ResetConnection) and treat the
882+ * connection as broken.
883883 */
884884 s -> broken = true;
885885 goto done ;
@@ -1053,8 +1053,8 @@ struct ch_binary_insert_handle
10531053{
10541054 chc_client * client ;
10551055 chc_alloc alloc ;
1056- struct ch_binary_state * state ; /* parent connection; used to flag
1057- * broken state on error */
1056+ struct ch_binary_state * state ; /* parent connection; used to flag broken
1057+ * state on error */
10581058 chc_block * initial_block ; /* schema source (server's empty Data) */
10591059 chc_query_opts opts ;
10601060 size_t ncols ;
@@ -1225,8 +1225,7 @@ recv_initial_block(struct ch_binary_state *s, ch_binary_insert_handle * h,
12251225
12261226 if (rc != CHC_OK )
12271227 {
1228- set_errbuf (errbuf , errbuf_size ,
1229- err .msg [0 ] ? err .msg : "recv_packet failed" );
1228+ set_errbuf (errbuf , errbuf_size , err .msg );
12301229 s -> broken = true;
12311230 return -1 ;
12321231 }
@@ -1316,7 +1315,7 @@ ch_binary_begin_insert(ch_binary_connection_t * conn, const ch_query * query,
13161315 free (sql );
13171316 if (rc != CHC_OK )
13181317 {
1319- set_errbuf (errbuf , errbuf_size , err .msg [ 0 ] ? err . msg : "send_query failed" );
1318+ set_errbuf (errbuf , errbuf_size , err .msg );
13201319 s -> broken = true;
13211320 ch_binary_end_insert (h , errbuf , errbuf_size );
13221321 return NULL ;
@@ -2127,7 +2126,7 @@ ch_binary_flush_block(ch_binary_insert_handle * h, char *errbuf, size_t errbuf_s
21272126
21282127 if (rc != CHC_OK )
21292128 {
2130- set_errbuf (errbuf , errbuf_size , err .msg [ 0 ] ? err . msg : "block_builder_init" );
2129+ set_errbuf (errbuf , errbuf_size , err .msg );
21312130 return -1 ;
21322131 }
21332132
@@ -2244,15 +2243,15 @@ ch_binary_flush_block(ch_binary_insert_handle * h, char *errbuf, size_t errbuf_s
22442243 }
22452244 if (rc != CHC_OK )
22462245 {
2247- set_errbuf (errbuf , errbuf_size , err .msg [ 0 ] ? err . msg : "block_builder_append" );
2246+ set_errbuf (errbuf , errbuf_size , err .msg );
22482247 goto cleanup ;
22492248 }
22502249 }
22512250
22522251 rc = chc_client_send_data (h -> client , bb , & err );
22532252 if (rc != CHC_OK )
22542253 {
2255- set_errbuf (errbuf , errbuf_size , err .msg [ 0 ] ? err . msg : "send_data" );
2254+ set_errbuf (errbuf , errbuf_size , err .msg );
22562255 if (h -> state )
22572256 h -> state -> broken = true;
22582257 goto cleanup ;
@@ -2305,8 +2304,7 @@ ch_binary_end_insert(ch_binary_insert_handle * h, char *errbuf, size_t errbuf_si
23052304 rc = chc_client_recv_packet (h -> client , & pkt , & err );
23062305 if (rc != CHC_OK )
23072306 {
2308- set_errbuf (errbuf , errbuf_size ,
2309- err .msg [0 ] ? err .msg : "recv_packet failed" );
2307+ set_errbuf (errbuf , errbuf_size , err .msg );
23102308 if (h -> state )
23112309 h -> state -> broken = true;
23122310 chc_packet_clear (h -> client , & pkt );
@@ -2321,6 +2319,7 @@ ch_binary_end_insert(ch_binary_insert_handle * h, char *errbuf, size_t errbuf_si
23212319 else if (pkt .exception && pkt .exception -> name )
23222320 msg = pkt .exception -> name ;
23232321 set_errbuf (errbuf , errbuf_size , msg );
2322+
23242323 /*
23252324 * Server raised an exception mid-INSERT and typically
23262325 * closes the socket; the next op on this conn would
@@ -2338,7 +2337,7 @@ ch_binary_end_insert(ch_binary_insert_handle * h, char *errbuf, size_t errbuf_si
23382337 }
23392338 else
23402339 {
2341- set_errbuf (errbuf , errbuf_size , err .msg [ 0 ] ? err . msg : "send_data terminator failed" );
2340+ set_errbuf (errbuf , errbuf_size , err .msg );
23422341 if (h -> state )
23432342 h -> state -> broken = true;
23442343 }
0 commit comments