Skip to content

Commit

Permalink
PG-1245 Format sources
Browse files Browse the repository at this point in the history
  • Loading branch information
artemgavrilov committed Dec 20, 2024
1 parent a10e8c6 commit 0be0271
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion percona_pg_telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ write_pg_settings(void)
{
char *str = SPI_getvalue(tuptable->vals[row_count], tuptable->tupdesc, col_count);

char *value = (str == NULL || str[0] == '\0') ? null_value : str;
char *value = (str == NULL || str[0] == '\0') ? null_value : str;

flags = (col_count == tuptable->tupdesc->natts) ? (PT_JSON_KEY_VALUE | PT_JSON_LAST_ELEMENT) : PT_JSON_KEY_VALUE;

Expand Down
8 changes: 5 additions & 3 deletions pt_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ construct_json_block(char *buf, size_t buf_sz, char *key, char *raw_value, int f
char *value = NULL;
char str[2048] = {0};
char fmt_str[2048] = {0};
char comma = (flags & PT_JSON_LAST_ELEMENT) ? '\0' : ',';
char comma = (flags & PT_JSON_LAST_ELEMENT) ? '\0' : ',';

/* Make the string empty so that we can always concat. */
buf[0] = '\0';

Expand All @@ -92,7 +93,8 @@ construct_json_block(char *buf, size_t buf_sz, char *key, char *raw_value, int f

if (flags & PT_JSON_VALUE)
{
char v[2048] = {0};
char v[2048] = {0};

snprintf(v, sizeof(v), "\"%s\"%c", value, comma);

strlcat(str, v, sizeof(str));
Expand All @@ -102,7 +104,7 @@ construct_json_block(char *buf, size_t buf_sz, char *key, char *raw_value, int f

if (flags & PT_JSON_ARRAY_START)
{
strlcat(str, "[", sizeof(str));
strlcat(str, "[", sizeof(str));
PT_FORMAT_JSON(fmt_str, sizeof(fmt_str), str, (*json_file_indent));
strlcat(buf, fmt_str, buf_sz);

Expand Down

0 comments on commit 0be0271

Please sign in to comment.