Skip to content

Commit 918c1c1

Browse files
committed
Fully test the GUC, fix http empty strings
1 parent 03d5773 commit 918c1c1

File tree

12 files changed

+246
-15
lines changed

12 files changed

+246
-15
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ifneq ($(OS),Darwin)
7070
endif
7171

7272
# Clean up the clickhouse-cpp build directory and generated files.
73-
EXTRA_CLEAN = $(CH_CPP_BUILD_DIR) sql/$(EXTENSION)--$(EXTVERSION).sql src/fdw.c compile_commands.json
73+
EXTRA_CLEAN = sql/$(EXTENSION)--$(EXTVERSION).sql src/fdw.c compile_commands.json
7474

7575
# Import PGXS.
7676
PGXS := $(shell $(PG_CONFIG) --pgxs)

src/http.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,8 @@ ch_http_simple_query(ch_http_connection_t * conn, const ch_query * query)
209209
curl_easy_setopt(conn->curl, CURLOPT_NOPROGRESS, 1L);
210210
if (conn->dbname)
211211
{
212-
char *buf = palloc(strlen(conn->dbname) + strlen(DATABASE_HEADER) + 3);
213-
214-
sprintf(buf, "%s: %s", DATABASE_HEADER, conn->dbname);
215-
headers = curl_slist_append(headers, buf);
212+
headers = curl_slist_append(headers, psprintf("%s: %s", DATABASE_HEADER, conn->dbname));
216213
curl_easy_setopt(conn->curl, CURLOPT_HTTPHEADER, headers);
217-
pfree(buf);
218214
}
219215

220216
curl_error_happened = false;

src/pglink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ http_fetch_row(ch_cursor * cursor, List * attrs, TupleDesc tupdesc, Datum * v, b
303303
else if (state->val[0] != '\0')
304304
values[i] = pstrdup(state->val);
305305
else
306-
values[i] = NULL;
306+
values[i] = "";
307307
}
308308

309309
if (attcount > 0 && rc != CH_EOL && rc != CH_EOF)

test/expected/gucs.out

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
\unset ECHO
2+
ch_noop_bigint
3+
----------------
4+
5+
(1 row)
6+
27
NOTICE: OK ``
38
NOTICE: OK `join_use_nulls=1`
49
NOTICE: OK `join_use_nulls=1, xyz=true`
@@ -9,4 +14,98 @@ NOTICE: ERR 42601 - pg_clickhouse: missing "=" after "join_use_nulls" in option
914
NOTICE: ERR 42601 - pg_clickhouse: missing "=" after "join_use_nulls" in options string
1015
NOTICE: ERR 42601 - pg_clickhouse: unterminated quoted string in options string
1116
NOTICE: ERR 42601 - pg_clickhouse: missing comma after "join_use_nulls" value in options string
12-
NOTICE: drop cascades to foreign table remote_settings
17+
name | value
18+
----------------+-------
19+
join_use_nulls | 1
20+
(1 row)
21+
22+
name | value
23+
----------------+-------
24+
join_use_nulls | 1
25+
(1 row)
26+
27+
pg_clickhouse.session_settings
28+
----------------------------------------------
29+
+
30+
connect_timeout = 2, +
31+
count_distinct_implementation = uniq, +
32+
join_algorithm = 'prefer_partial_merge',+
33+
join_use_nulls = 0, +
34+
join_use_nulls = 1, +
35+
log_queries_min_type = QUERY_FINISH, +
36+
max_block_size = 32768, +
37+
max_execution_time = 45, +
38+
max_result_rows = 1024, +
39+
metrics_perf_events_list = 'this,that', +
40+
network_compression_method = ZSTD, +
41+
poll_interval = 5, +
42+
totals_mode = after_having_auto +
43+
44+
(1 row)
45+
46+
name | value
47+
-------------------------------+----------------------
48+
connect_timeout | 2
49+
count_distinct_implementation | uniq
50+
join_algorithm | prefer_partial_merge
51+
join_use_nulls | 1
52+
log_queries_min_type | QUERY_FINISH
53+
max_block_size | 32768
54+
max_execution_time | 45
55+
max_result_rows | 1024
56+
metrics_perf_events_list | this,that
57+
network_compression_method | ZSTD
58+
poll_interval | 5
59+
totals_mode | after_having_auto
60+
(12 rows)
61+
62+
name | value
63+
-------------------------------+----------------------
64+
connect_timeout | 2
65+
count_distinct_implementation | uniq
66+
join_algorithm | prefer_partial_merge
67+
join_use_nulls | 1
68+
log_queries_min_type | QUERY_FINISH
69+
max_block_size | 32768
70+
max_execution_time | 45
71+
max_result_rows | 1024
72+
metrics_perf_events_list | this,that
73+
network_compression_method | ZSTD
74+
poll_interval | 5
75+
totals_mode | after_having_auto
76+
(12 rows)
77+
78+
name | ?column?
79+
-------------------------------+----------
80+
connect_timeout | t
81+
count_distinct_implementation | t
82+
join_algorithm | t
83+
join_use_nulls | t
84+
log_queries_min_type | t
85+
max_block_size | t
86+
max_execution_time | t
87+
max_result_rows | t
88+
metrics_perf_events_list | t
89+
network_compression_method | t
90+
poll_interval | t
91+
totals_mode | t
92+
(12 rows)
93+
94+
name | ?column?
95+
-------------------------------+----------
96+
connect_timeout | t
97+
count_distinct_implementation | t
98+
join_algorithm | t
99+
join_use_nulls | t
100+
log_queries_min_type | t
101+
max_block_size | t
102+
max_execution_time | t
103+
max_result_rows | t
104+
metrics_perf_events_list | t
105+
network_compression_method | t
106+
poll_interval | t
107+
totals_mode | t
108+
(12 rows)
109+
110+
NOTICE: drop cascades to foreign table bin_remote_settings
111+
NOTICE: drop cascades to foreign table http_remote_settings

test/expected/http.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ SELECT c3, (c3 = 'lf\ntab\t\b\f\r') AS true FROM ft3 WHERE c1 = 2;
132132
lf\ntab\t\b\f\r | t
133133
(1 row)
134134

135+
INSERT INTO ft3 VALUES (3, '');
136+
SELECT c3, (c3 = '') AS true FROM ft3 WHERE c1 = 3;
137+
c3 | true
138+
----+------
139+
| t
140+
(1 row)
141+
135142
INSERT INTO ft4
136143
SELECT id,
137144
id + 1,

test/expected/http_1.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ SELECT c3, (c3 = 'lf\ntab\t\b\f\r') AS true FROM ft3 WHERE c1 = 2;
132132
lf\ntab\t\b\f\r | t
133133
(1 row)
134134

135+
INSERT INTO ft3 VALUES (3, '');
136+
SELECT c3, (c3 = '') AS true FROM ft3 WHERE c1 = 3;
137+
c3 | true
138+
----+------
139+
| t
140+
(1 row)
141+
135142
INSERT INTO ft4
136143
SELECT id,
137144
id + 1,

test/expected/http_2.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ SELECT c3, (c3 = 'lf\ntab\t\b\f\r') AS true FROM ft3 WHERE c1 = 2;
132132
lf\ntab\t\b\f\r | t
133133
(1 row)
134134

135+
INSERT INTO ft3 VALUES (3, '');
136+
SELECT c3, (c3 = '') AS true FROM ft3 WHERE c1 = 3;
137+
c3 | true
138+
----+------
139+
| t
140+
(1 row)
141+
135142
INSERT INTO ft4
136143
SELECT id,
137144
id + 1,

test/expected/http_3.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ SELECT c3, (c3 = 'lf\ntab\t\b\f\r') AS true FROM ft3 WHERE c1 = 2;
132132
lf\ntab\t\b\f\r | t
133133
(1 row)
134134

135+
INSERT INTO ft3 VALUES (3, '');
136+
SELECT c3, (c3 = '') AS true FROM ft3 WHERE c1 = 3;
137+
c3 | true
138+
----+------
139+
| t
140+
(1 row)
141+
135142
INSERT INTO ft4
136143
SELECT id,
137144
id + 1,

test/expected/http_4.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ SELECT c3, (c3 = 'lf\ntab\t\b\f\r') AS true FROM ft3 WHERE c1 = 2;
132132
lf\ntab\t\b\f\r | t
133133
(1 row)
134134

135+
INSERT INTO ft3 VALUES (3, '');
136+
SELECT c3, (c3 = '') AS true FROM ft3 WHERE c1 = 3;
137+
c3 | true
138+
----+------
139+
| t
140+
(1 row)
141+
135142
INSERT INTO ft4
136143
SELECT id,
137144
id + 1,

test/expected/http_5.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ SELECT c3, (c3 = 'lf\ntab\t\b\f\r') AS true FROM ft3 WHERE c1 = 2;
132132
lf\ntab\t\b\f\r | t
133133
(1 row)
134134

135+
INSERT INTO ft3 VALUES (3, '');
136+
SELECT c3, (c3 = '') AS true FROM ft3 WHERE c1 = 3;
137+
c3 | true
138+
----+------
139+
| t
140+
(1 row)
141+
135142
INSERT INTO ft4
136143
SELECT id,
137144
id + 1,

0 commit comments

Comments
 (0)