8000 [PBCKP-236] final update after review · postgrespro/pg_probackup@6e67123 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6e67123

Browse files
author
Ivan Lazarev
committed
[PBCKP-236] final update after review
1 parent b3351b5 commit 6e67123

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/utils/remote.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,8 @@ static char* extract_pg_edition_str()
292292
#endif
293293
}
294294

295-
#define COMPATIBILITY_VAL_STR(macro) #macro, macro
296-
#define COMPATIBILITY_VAL_INT_HELPER(macro, helper_buf, buf_size) (snprintf(helper_buf, buf_size, "%d", macro), helper_buf)
297-
#define COMPATIBILITY_VAL_INT(macro, helper_buf, buf_size) #macro, COMPATIBILITY_VAL_INT_HELPER(macro, helper_buf, buf_size)
298-
299-
#define COMPATIBILITY_VAL_SEPARATOR "="
300-
#define COMPATIBILITY_LINE_SEPARATOR "\n"
295+
#define COMPATIBILITY_VAL_STR(macro) { #macro, macro, 0 }
296+
#define COMPATIBILITY_VAL_INT(macro) { #macro, NULL, macro }
301297

302298
/*
303299
* Compose compatibility string to be sent by pg_probackup agent
@@ -307,13 +303,10 @@ static char* extract_pg_edition_str()
307303
*/
308304
size_t prepare_compatibility_str(char* compatibility_buf, size_t compatibility_buf_size)
309305
{
310-
char compatibility_val_int_macro_helper_buf[32];
311-
char* compatibility_params[] = {
306+
struct { const char* name; const char* strval; int intval; } compatibility_params[] = {
312307
COMPATIBILITY_VAL_STR(PG_MAJORVERSION),
313-
"edition", extract_pg_edition_str(),
314-
/* 32/64 bits compatibility */
315-
COMPATIBILITY_VAL_INT(SIZEOF_VOID_P,
316-
compatibility_val_int_macro_helper_buf, sizeof compatibility_val_int_macro_helper_buf),
308+
{ "edition", extract_pg_edition_str(), 0 },
309+
COMPATIBILITY_VAL_INT(SIZEOF_VOID_P),
317310
};
318311

319312
size_t result_size = 0;
@@ -324,9 +317,16 @@ size_t prepare_compatibility_str(char* compatibility_buf, size_t compatibility_b
324317

325318
for (int i = 0; i < compatibility_params_array_size; i+=2)
326319
{
327-
result_size += snprintf(compatibility_buf + result_size, compatibility_buf_size - result_size,
328-
"%s" COMPATIBILITY_VAL_SEPARATOR "%s" COMPATIBILITY_LINE_SEPARATOR,
329-
compatibility_params[i], compatibility_params[i+1]);
320+
if (compatibility_params[i].strval != NULL)
321+
result_size += snprintf(compatibility_buf + result_size, compatibility_buf_size - result_size,
322+
"%s=%s/n",
323+
compatibility_params[i].name,
324+
compatibility_params[i].strval);
325+
else
326+
result_size += snprintf(compatibility_buf + result_size, compatibility_buf_size - result_size,
327+
"%s=%d/n",
328+
compatibility_params[i].name,
329+
compatibility_params[i].intval);
330330
Assert(result_size < compatibility_buf_size);
331331
}
332332
return result_size + 1;
@@ -349,7 +349,7 @@ void check_remote_agent_compatibility(int agent_version, char *compatibility_str
349349

350350
elog(ERROR, "Remote agent protocol version %s does not match local program protocol version %s, "
351351
"consider to upgrade pg_probackup binary",
352-
agent_version_str, AGENT_PROTOCOL_VERSION_STR);
352+
agent_version_str, AGENT_PROTOCOL_VERSION_STR);
353353
}
354354

355355
/* checking compatibility params */

0 commit comments

Comments
 (0)
0