Skip to content

Commit f61be78

Browse files
author
Ivan Lazarev
committed
[PBCKP-236] working solution cleaned up
1 parent 0604cce commit f61be78

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/utils/remote.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -249,26 +249,13 @@ bool launch_agent(void)
249249
return true;
250250
}
251251

252-
#define COMPATIBILITY_VAL(macro) #macro, macro
253-
#define COMPATIBILITY_STR(macro) #macro
254-
#define COMPATIBILITY_VAL_STR(macro) #macro, COMPATIBILITY_STR(macro)
252+
#define COMPATIBILITY_VAL_STR(macro) #macro, macro
253+
#define COMPATIBILITY_VAL_INT_HELPER(macro, helper_buf, buf_size) (snprintf(helper_buf, buf_size, "%d", macro), helper_buf)
254+
#define COMPATIBILITY_VAL_INT(macro, helper_buf, buf_size) #macro, COMPATIBILITY_VAL_INT_HELPER(macro, helper_buf, buf_size)
255255

256256
#define COMPATIBILITY_VAL_SEPARATOR "="
257257
#define COMPATIBILITY_LINE_SEPARATOR "\n"
258258

259-
static char* compatibility_params[] = {
260-
COMPATIBILITY_VAL(PG_MAJORVERSION),
261-
//TODO remove?
262-
//TODO doesn't work macro name check for ints!!!!
263-
COMPATIBILITY_VAL_STR(SIZEOF_VOID_P),
264-
//TODO REVIEW XXX can use edition.h/extract_pgpro_edition()
265-
#ifdef PGPRO_EDN
266-
//TODO add vanilla
267-
//TODO make "1c" -> "vanilla"
268-
COMPATIBILITY_VAL(PGPRO_EDN),
269-
#endif
270-
};
271-
272259
/*
273260
* Compose compatibility string to be sent by pg_probackup agent
274261
* through ssh and to be verified by pg_probackup peer.
@@ -277,6 +264,18 @@ static char* compatibility_params[] = {
277264
*/
278265
size_t prepare_compatibility_str(char* compatibility_buf, size_t compatibility_buf_size)
279266
{
267+
char compatibility_val_int_macro_helper_buf[32];
268+
char* compatibility_params[] = {
269+
COMPATIBILITY_VAL_STR(PG_MAJORVERSION),
270+
#ifdef PGPRO_EDN
271+
//TODO REVIEW can use edition.h/extract_pgpro_edition()
272+
COMPATIBILITY_VAL_STR(PGPRO_EDN),
273+
#endif
274+
//TODO REVIEW remove? no difference between 32/64 in global/pg_control.
275+
COMPATIBILITY_VAL_INT(SIZEOF_VOID_P,
276+
compatibility_val_int_macro_helper_buf, sizeof compatibility_val_int_macro_helper_buf),
277+
};
278+
280279
size_t result_size = 0;
281280
size_t compatibility_params_array_size = sizeof compatibility_params / sizeof compatibility_params[0];;
282281

0 commit comments

Comments
 (0)