Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit531737d

Browse files
author
Amit Kapila
committed
Refactor function parse_output_parameters.
Instead of using multiple parameters in parse_ouput_parameters functionsignature, use the struct PGOutputData that encapsulates all pgoutputoptions. It will be useful for future work where we need to add otheroptions in pgoutput.Author: Euler TaveiraReviewed-by: Amit KapilaDiscussion:https://postgr.es/m/CADK3HHJ-+9SO7KuRLH=9Wa1rAo60Yreq1GFNkH_kd0=CdaWM+A@mail.gmail.com
1 parent6d41dd0 commit531737d

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
staticvoid
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
boolprotocol_version_given= false;
165163
boolpublication_names_given= false;
166164
boolbinary_option_given= false;
167165
boolstreaming_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
elseif (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
elseif (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
boolis_init)
246245
{
247-
boolenable_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
elseif (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
boolbinary;
28+
boolstreaming;
2829
}PGOutputData;
2930

3031
#endif/* PGOUTPUT_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp