Skip to content

Commit 2893476

Browse files
committed
Revert "postgres_binary_mode".
This is great feature, but the way it hooks into configuration must be rewritten (as discussed with Yichun on the IRC). This reverts commit 4187c57.
1 parent 41bca29 commit 2893476

File tree

5 files changed

+6
-40
lines changed

5 files changed

+6
-40
lines changed

README.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ postgres_pass
4646
-------------
4747
* **syntax**: `postgres_pass upstream`
4848
* **default**: `none`
49-
* **context**: `location`, `if location`
49+
* **context**: `location`
5050

5151
Set name of an upstream block that will be used for the database connections
5252
(it can include variables).
@@ -56,31 +56,19 @@ postgres_query
5656
--------------
5757
* **syntax**: `postgres_query [methods] query`
5858
* **default**: `none`
59-
* **context**: `http`, `server`, `location`, `if location`
59+
* **context**: `http`, `server`, `location`
6060

6161
Set query string (it can include variables). When methods are specified then
6262
query is used only for them, otherwise it's used for all methods.
6363

6464
This directive can be used more than once within same context.
6565

6666

67-
postgres_binary_mode
68-
-----------------------
69-
* **syntax**: `postgres_binary_mode on|off`
70-
* **default**: `off`
71-
* **context**: `http`, `server`, `location`, `if location`
72-
73-
Controls whether to use the binary mode for `all` the data fields
74-
in the result set on the PostgreSQL side. The big-endian format is usually followed,
75-
which is controled by PostgreSQL.
76-
77-
Default off.
78-
7967
postgres_rewrite
8068
----------------
8169
* **syntax**: `postgres_rewrite [methods] condition [=]status_code`
8270
* **default**: `none`
83-
* **context**: `http`, `server`, `location`, `location if`
71+
* **context**: `http`, `server`, `location`
8472

8573
Rewrite response `status_code` when given condition is met (first one wins!):
8674

@@ -102,7 +90,7 @@ postgres_output
10290
---------------
10391
* **syntax**: `postgres_output none|value|row|rds [row] [column]`
10492
* **default**: `rds`
105-
* **context**: `http`, `server`, `location`, `location if`
93+
* **context**: `http`, `server`, `location`
10694

10795
Set output format:
10896

src/ngx_postgres_module.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,6 @@ static ngx_command_t ngx_postgres_module_commands[] = {
117117
offsetof(ngx_postgres_loc_conf_t, upstream.read_timeout),
118118
NULL },
119119

120-
{ ngx_string("postgres_binary_mode"),
121-
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|
122-
NGX_HTTP_LIF_CONF|NGX_CONF_FLAG,
123-
ngx_conf_set_flag_slot,
124-
NGX_HTTP_LOC_CONF_OFFSET,
125-
offsetof(ngx_postgres_loc_conf_t, binary_mode),
126-
NULL },
127-
128120
ngx_null_command
129121
};
130122

@@ -317,7 +309,6 @@ ngx_postgres_create_loc_conf(ngx_conf_t *cf)
317309
* conf->query.methods = NULL
318310
* conf->query.def = NULL
319311
* conf->output_value = NULL
320-
* conf->binary_mode = 0
321312
*/
322313

323314
conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC;
@@ -326,7 +317,6 @@ ngx_postgres_create_loc_conf(ngx_conf_t *cf)
326317
conf->rewrites = NGX_CONF_UNSET_PTR;
327318
conf->output_handler = NGX_CONF_UNSET_PTR;
328319
conf->variables = NGX_CONF_UNSET_PTR;
329-
conf->binary_mode = NGX_CONF_UNSET;
330320

331321
/* the hardcoded values */
332322
conf->upstream.cyclic_temp_file = 0;
@@ -387,8 +377,6 @@ ngx_postgres_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
387377

388378
ngx_conf_merge_ptr_value(conf->variables, prev->variables, NULL);
389379

390-
ngx_conf_merge_value(conf->binary_mode, prev->binary_mode, 0);
391-
392380
dd("returning NGX_CONF_OK");
393381
return NGX_CONF_OK;
394382
}

src/ngx_postgres_module.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ typedef struct {
155155
ngx_postgres_value_t *output_value;
156156
/* custom variables */
157157
ngx_array_t *variables;
158-
159-
/* data field format */
160-
ngx_flag_t binary_mode;
161158
} ngx_postgres_loc_conf_t;
162159

163160
typedef struct {

src/ngx_postgres_processor.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,7 @@ ngx_postgres_upstream_send_query(ngx_http_request_t *r, ngx_connection_t *pgxc,
219219

220220
dd("sending query: %s", query);
221221

222-
if (pgdt->loc_conf->binary_mode) {
223-
pgrc = PQsendQueryParams(pgdt->pgconn, (const char *) query, 0,
224-
NULL, NULL, NULL, NULL, /* binary */ 1);
225-
226-
} else {
227-
pgrc = PQsendQuery(pgdt->pgconn, (const char *) query);
228-
}
229-
222+
pgrc = PQsendQuery(pgdt->pgconn, (const char *) query);
230223
if (pgrc == 0) {
231224
dd("sending query failed");
232225
ngx_log_error(NGX_LOG_ERR, pgxc->log, 0,

t/loc-if.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Content-Type: application/x-resty-dbd-stream
8080
8181
8282
83-
=== TEST 2: postgres_pass and postgres_query work in location if blocks
83+
=== TEST 1: postgres_pass and postgres_query work in location if blocks
8484
--- http_config
8585
upstream database {
8686
postgres_server 127.0.0.1:$TEST_NGINX_POSTGRESQL_PORT dbname=ngx_test

0 commit comments

Comments
 (0)