8000 [PBCKP-236] 1c+certified editions check · postgrespro/pg_probackup@35df506 · GitHub
[go: up one dir, main page]

Skip to content

Commit 35df506

Browse files
author
Ivan Lazarev
committed
[PBCKP-236] 1c+certified editions check
1 parent 5659884 commit 35df506

File tree

2 files changed

+53
-6
lines changed

2 files changed

+53
-6
lines changed

src/utils/file.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ fio_get_agent_version(int* protocol, char* payload_buf, size_t payload_buf_size)
280280
IO_CHECK(fio_read_all(fio_stdin, &hdr, sizeof(hdr)), sizeof(hdr));
281281
if (hdr.size > payload_buf_size)
282282
{
283-
//TODO REVIEW XXX %zu is C99 but not ANSI S compatible, should we use ints, %zu is also applied at data.c:501 data.c:1638??
284283
elog(ERROR, "Corrupted remote compatibility protocol: insufficient payload_buf_size=%zu", payload_buf_size);
285284
}
286285

src/utils/remote.c

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,57 @@ bool launch_agent(void)
249249
return true;
250250
}
251251

252+
/* PGPRO 10-13 check to be "(certified)", with exceptional case PGPRO_11 conforming to "(standard certified)" */
253+
static bool check_certified()
254+
{
255+
#ifdef PGPRO_VERSION_STR
256+
return strstr(PGPRO_VERSION_STR, "(certified)") ||
257+
strstr(PGPRO_VERSION_STR, ("(standard certified)"));
258+
#endif
259+
return false;
260+
}
261+
262+
//TODO REVIEW review coding standard https://jira.postgrespro.ru/browse/PBCKP-251 with @funny_falcon, newlines, braces etc
263+
static char* extract_pg_edition_str()
264+
{
265+
static char *vanilla = "vanilla";
266+
static char *std = "standard";
267+
static char *ent = "enterprise";
268+
static char *std_cert = "standard-certified";
269+
static char *ent_cert = "enterprise-certified";
270+
271+
#ifdef PGPRO_EDITION
272+
if (strcasecmp(PGPRO_EDITION, "1C") == 0)
273+
return vanilla;
274+
275+
/* these "certified" checks are applicable to PGPRO from 9.6 up to 12 versions.
276+
* 13+ certified versions are compatible to non-certified ones */
277+
if (PG_VERSION_NUM < 100000)
278+
{
279+
if (strcmp(PGPRO_EDITION, "standard-certified") == 0)
280+
return std_cert;
281+
else if (strcmp(PGPRO_EDITION, "enterprise-certified"))
282+
return ent_cert;
283+
else
284+
Assert("Bad #define PGPRO_EDITION value" == 0);
285+
}
286+
287+
if (check_certified())
288+
{
289+
if (strcmp(PGPRO_EDITION, "standard"))
290+
return std_cert;
291+
else if (strcmp(PGPRO_EDITION, "enterprise") == 0)
292+
return ent_cert;
293+
else
294+
Assert("Bad #define PGPRO_EDITION value" == 0);
295+
}
296+
297+
return PGPRO_EDITION;
298+
#else
299+
return vanilla;
300+
#endif
301+
}
302+
252303
#define COMPATIBILITY_VAL_STR(macro) #macro, macro
253304
#define COMPATIBILITY_VAL_INT_HELPER(macro, helper_buf, buf_size) (snprintf(helper_buf, buf_size, "%d", macro), helper_buf)
254305
#define COMPATIBILITY_VAL_INT(macro, helper_buf, buf_size) #macro, COMPATIBILITY_VAL_INT_HELPER(macro, helper_buf, buf_size)
@@ -267,11 +318,8 @@ size_t prepare_compatibility_str(char* compatibility_buf, size_t compatibility_b
267318
char compatibility_val_int_macro_helper_buf[32];
268319
char* compatibility_params[] = {
269320
COMPATIBILITY_VAL_STR(PG_MAJORVERSION),
270-
#ifdef PGPRO_EDN
271-
//TODO REVIEW can use edition.h/extract_pgpro_edition() or similar
272-
COMPATIBILITY_VAL_STR(PGPRO_EDN),
273-
#endif
274-
//TODO REVIEW remove? no difference between 32/64 in global/pg_control.
321+
"edition", extract_pg_edition_str(),
322+
/* 32/64 bits compatibility */
275323
COMPATIBILITY_VAL_INT(SIZEOF_VOID_P,
276324
compatibility_val_int_macro_helper_buf, sizeof compatibility_val_int_macro_helper_buf),
277325
};

0 commit comments

Comments
 (0)
0