Skip to content

Commit efbeb49

Browse files
committed
fix timeout error
1 parent d3bb53c commit efbeb49

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/Statement.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,17 @@ public function error()
157157

158158
$body = $this->response()->body();
159159
$error_no = $this->response()->error_no();
160+
$error=$this->response()->error();
160161

161-
if (!$error_no) {
162+
if (!$error_no && !$error) {
162163
$parse = $this->parseErrorClickHouse($body);
163164

164165
if ($parse) {
165166
throw new DatabaseException($parse['message'] . "\nIN:" . $this->sql(), $parse['code']);
166167
}
167168
else {
168169
$code = $this->response()->http_code();
169-
$message = "HttpCode:" . $this->response()->http_code() . " ; " . $body;
170+
$message = "HttpCode:" . $this->response()->http_code() . " ; ".$this->response()->error()." ;" . $body;
170171
}
171172
}
172173
else {

tests/ClientTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,32 @@ public function testInsertArrayTable()
650650
$this->assertArraySubset([['s_key' => 'HASH1', 's_arr' => 11]], $state->rows());
651651
}
652652

653+
/**
654+
* @expectedException \ClickHouseDB\QueryException
655+
*/
656+
public function testInsertTableTimeout()
657+
{
658+
$this->create_table_summing_url_views();
659+
660+
$file_data_names = [
661+
$this->tmp_path . '_testInsertCSV_clickHouseDB_test.1.data',
662+
];
663+
664+
foreach ($file_data_names as $file_name) {
665+
$this->create_fake_csv_file($file_name, 5);
666+
}
667+
668+
$this->create_table_summing_url_views();
669+
670+
671+
$this->db->setTimeout(0.01);
672+
673+
674+
$stat = $this->db->insertBatchFiles('summing_url_views', $file_data_names, [
675+
'event_time', 'url_hash', 'site_id', 'views', 'v_00', 'v_55'
676+
]);
677+
$this->db->ping();
678+
}
653679
/**
654680
*
655681
*/

0 commit comments

Comments
 (0)