Skip to content

Commit 531737d

Browse files
author
Amit Kapila
committed
Refactor function parse_output_parameters.
Instead of using multiple parameters in parse_ouput_parameters function signature, use the struct PGOutputData that encapsulates all pgoutput options. It will be useful for future work where we need to add other options in pgoutput. Author: Euler Taveira Reviewed-by: Amit Kapila Discussion: https://postgr.es/m/CADK3HHJ-+9SO7KuRLH=9Wa1rAo60Yreq1GFNkH_kd0=CdaWM+A@mail.gmail.com
1 parent 6d41dd0 commit 531737d

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/backend/replication/pgoutput/pgoutput.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,16 @@ _PG_output_plugin_init(OutputPluginCallbacks *cb)
156156
}
157157

158158
static void
159-
parse_output_parameters(List *options, uint32 *protocol_version,
160-
List **publication_names, bool *binary,
161-
bool *enable_streaming)
159+
parse_output_parameters(List *options, PGOutputData *data)
162160
{
163161
ListCell *lc;
164162
bool protocol_version_given = false;
165163
bool publication_names_given = false;
166164
bool binary_option_given = false;
167165
bool streaming_given = false;
168166

169-
*binary = false;
167+
data->binary = false;
168+
data->streaming = false;
170169

171170
foreach(lc, options)
172171
{
@@ -196,7 +195,7 @@ parse_output_parameters(List *options, uint32 *protocol_version,
196195
errmsg("proto_version \"%s\" out of range",
197196
strVal(defel->arg))));
198197

199-
*protocol_version = (uint32) parsed;
198+
data->protocol_version = (uint32) parsed;
200199
}
201200
else if (strcmp(defel->defname, "publication_names") == 0)
202201
{
@@ -207,7 +206,7 @@ parse_output_parameters(List *options, uint32 *protocol_version,
207206
publication_names_given = true;
208207

209208
if (!SplitIdentifierString(strVal(defel->arg), ',',
210-
publication_names))
209+
&data->publication_names))
211210
ereport(ERROR,
212211
(errcode(ERRCODE_INVALID_NAME),
213212
errmsg("invalid publication_names syntax")));
@@ -220,7 +219,7 @@ parse_output_parameters(List *options, uint32 *protocol_version,
220219
errmsg("conflicting or redundant options")));
221220
binary_option_given = true;
222221

223-
*binary = defGetBoolean(defel);
222+
data->binary = defGetBoolean(defel);
224223
}
225224
else if (strcmp(defel->defname, "streaming") == 0)
226225
{
@@ -230,7 +229,7 @@ parse_output_parameters(List *options, uint32 *protocol_version,
230229
errmsg("conflicting or redundant options")));
231230
streaming_given = true;
232231

233-
*enable_streaming = defGetBoolean(defel);
232+
data->streaming = defGetBoolean(defel);
234233
}
235234
else
236235
elog(ERROR, "unrecognized pgoutput option: %s", defel->defname);
@@ -244,7 +243,6 @@ static void
244243
pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
245244
bool is_init)
246245
{
247-
bool enable_streaming = false;
248246
PGOutputData *data = palloc0(sizeof(PGOutputData));
249247

250248
/* Create our memory context for private allocations. */
@@ -265,11 +263,7 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
265263
if (!is_init)
266264
{
267265
/* Parse the params and ERROR if we see any we don't recognize */
268-
parse_output_parameters(ctx->output_plugin_options,
269-
&data->protocol_version,
270-
&data->publication_names,
271-
&data->binary,
272-
&enable_streaming);
266+
parse_output_parameters(ctx->output_plugin_options, data);
273267

274268
/* Check if we support requested protocol */
275269
if (data->protocol_version > LOGICALREP_PROTO_MAX_VERSION_NUM)
@@ -295,7 +289,7 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
295289
* we only allow it with sufficient version of the protocol, and when
296290
* the output plugin supports it.
297291
*/
298-
if (!enable_streaming)
292+
if (!data->streaming)
299293
ctx->streaming = false;
300294
else if (data->protocol_version < LOGICALREP_PROTO_STREAM_VERSION_NUM)
301295
ereport(ERROR,

src/include/replication/pgoutput.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ typedef struct PGOutputData
2525
List *publication_names;
2626
List *publications;
2727
bool binary;
28+
bool streaming;
2829
} PGOutputData;
2930

3031
#endif /* PGOUTPUT_H */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy