-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Truncate all STATEMENT/QUERY log lines (#123)
- Loading branch information
Showing
7 changed files
with
300 additions
and
84 deletions.
There are no files selected for viewing
28 changes: 0 additions & 28 deletions
28
edgedbpkg/postgresql/patches/postgresql-edgedb__gate_statement_log-14.patch
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
edgedbpkg/postgresql/patches/postgresql-edgedb__gate_statement_log-15.patch
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
edgedbpkg/postgresql/patches/postgresql-edgedb__gate_statement_log-16.patch
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
edgedbpkg/postgresql/patches/postgresql-edgedb__truncate_log-14.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
From 2c80b43e91b812fd7083801eca5b0b8f41d0c178 Mon Sep 17 00:00:00 2001 | ||
From: Fantix King <[email protected]> | ||
Date: Thu, 14 Nov 2024 19:44:01 -0500 | ||
Subject: [PATCH 6/6] Truncate long STATEMENT/QUERY log | ||
|
||
--- | ||
src/backend/utils/error/elog.c | 31 +++++++++++++++++++++++++++++-- | ||
1 file changed, 29 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c | ||
index 8d33686510a..ae186e79a29 100644 | ||
--- a/src/backend/utils/error/elog.c | ||
+++ b/src/backend/utils/error/elog.c | ||
@@ -185,6 +185,7 @@ static void write_pipe_chunks(char *data, int len, int dest); | ||
static void send_message_to_frontend(ErrorData *edata); | ||
static const char *error_severity(int elevel); | ||
static void append_with_tabs(StringInfo buf, const char *str); | ||
+static void append_n_with_tabs(StringInfo buf, const char *str, int n); | ||
|
||
|
||
/* | ||
@@ -3065,7 +3066,7 @@ send_message_to_server_log(ErrorData *edata) | ||
{ | ||
log_line_prefix(&buf, edata); | ||
appendStringInfoString(&buf, _("QUERY: ")); | ||
- append_with_tabs(&buf, edata->internalquery); | ||
+ append_n_with_tabs(&buf, edata->internalquery, 1024); | ||
appendStringInfoChar(&buf, '\n'); | ||
} | ||
if (edata->context && !edata->hide_ctx) | ||
@@ -3110,7 +3111,7 @@ send_message_to_server_log(ErrorData *edata) | ||
{ | ||
log_line_prefix(&buf, edata); | ||
appendStringInfoString(&buf, _("STATEMENT: ")); | ||
- append_with_tabs(&buf, debug_query_string); | ||
+ append_n_with_tabs(&buf, debug_query_string, 1024); | ||
appendStringInfoChar(&buf, '\n'); | ||
} | ||
|
||
@@ -3551,6 +3552,32 @@ append_with_tabs(StringInfo buf, const char *str) | ||
} | ||
|
||
|
||
+/* | ||
+ * append_n_with_tabs | ||
+ * | ||
+ * Append the string to the StringInfo buffer truncating at n characters, | ||
+ * inserting a tab after any newline, and `...` at the end if truncated. | ||
+ */ | ||
+static void | ||
+append_n_with_tabs(StringInfo buf, const char *str, int n) | ||
+{ | ||
+ char ch; | ||
+ | ||
+ while ((ch = *str++) != '\0' && n > 0) | ||
+ { | ||
+ appendStringInfoCharMacro(buf, ch); | ||
+ if (ch == '\n') | ||
+ appendStringInfoCharMacro(buf, '\t'); | ||
+ n--; | ||
+ } | ||
+ if (ch != '\0') { | ||
+ appendStringInfoCharMacro(buf, '.'); | ||
+ appendStringInfoCharMacro(buf, '.'); | ||
+ appendStringInfoCharMacro(buf, '.'); | ||
+ } | ||
+} | ||
+ | ||
+ | ||
/* | ||
* Write errors to stderr (or by equal means when stderr is | ||
* not available). Used before ereport/elog can be used | ||
-- | ||
2.47.0 | ||
|
75 changes: 75 additions & 0 deletions
75
edgedbpkg/postgresql/patches/postgresql-edgedb__truncate_log-15.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
From 38b74895b1dbbad3c6fa935cbb3f77f449b8d5ea Mon Sep 17 00:00:00 2001 | ||
From: Fantix King <[email protected]> | ||
Date: Thu, 14 Nov 2024 19:44:01 -0500 | ||
Subject: [PATCH 6/6] Truncate long STATEMENT/QUERY log | ||
|
||
--- | ||
src/backend/utils/error/elog.c | 31 +++++++++++++++++++++++++++++-- | ||
1 file changed, 29 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c | ||
index 01066832e18..4bad03460e4 100644 | ||
--- a/src/backend/utils/error/elog.c | ||
+++ b/src/backend/utils/error/elog.c | ||
@@ -180,6 +180,7 @@ static void log_line_prefix(StringInfo buf, ErrorData *edata); | ||
static void send_message_to_server_log(ErrorData *edata); | ||
static void send_message_to_frontend(ErrorData *edata); | ||
static void append_with_tabs(StringInfo buf, const char *str); | ||
+static void append_n_with_tabs(StringInfo buf, const char *str, int n); | ||
|
||
|
||
/* | ||
@@ -2876,7 +2877,7 @@ send_message_to_server_log(ErrorData *edata) | ||
{ | ||
log_line_prefix(&buf, edata); | ||
appendStringInfoString(&buf, _("QUERY: ")); | ||
- append_with_tabs(&buf, edata->internalquery); | ||
+ append_n_with_tabs(&buf, edata->internalquery, 1024); | ||
appendStringInfoChar(&buf, '\n'); | ||
} | ||
if (edata->context && !edata->hide_ctx) | ||
@@ -2919,7 +2920,7 @@ send_message_to_server_log(ErrorData *edata) | ||
{ | ||
log_line_prefix(&buf, edata); | ||
appendStringInfoString(&buf, _("STATEMENT: ")); | ||
- append_with_tabs(&buf, debug_query_string); | ||
+ append_n_with_tabs(&buf, debug_query_string, 1024); | ||
appendStringInfoChar(&buf, '\n'); | ||
} | ||
|
||
@@ -3365,6 +3366,32 @@ append_with_tabs(StringInfo buf, const char *str) | ||
} | ||
|
||
|
||
+/* | ||
+ * append_n_with_tabs | ||
+ * | ||
+ * Append the string to the StringInfo buffer truncating at n characters, | ||
+ * inserting a tab after any newline, and `...` at the end if truncated. | ||
+ */ | ||
+static void | ||
+append_n_with_tabs(StringInfo buf, const char *str, int n) | ||
+{ | ||
+ char ch; | ||
+ | ||
+ while ((ch = *str++) != '\0' && n > 0) | ||
+ { | ||
+ appendStringInfoCharMacro(buf, ch); | ||
+ if (ch == '\n') | ||
+ appendStringInfoCharMacro(buf, '\t'); | ||
+ n--; | ||
+ } | ||
+ if (ch != '\0') { | ||
+ appendStringInfoCharMacro(buf, '.'); | ||
+ appendStringInfoCharMacro(buf, '.'); | ||
+ appendStringInfoCharMacro(buf, '.'); | ||
+ } | ||
+} | ||
+ | ||
+ | ||
/* | ||
* Write errors to stderr (or by equal means when stderr is | ||
* not available). Used before ereport/elog can be used | ||
-- | ||
2.47.0 | ||
|
75 changes: 75 additions & 0 deletions
75
edgedbpkg/postgresql/patches/postgresql-edgedb__truncate_log-16.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
From 19e6ae523ab82adf8f256ed2dd892183c2d20593 Mon Sep 17 00:00:00 2001 | ||
From: Fantix King <[email protected]> | ||
Date: Thu, 14 Nov 2024 19:44:01 -0500 | ||
Subject: [PATCH 6/6] Truncate long STATEMENT/QUERY log | ||
|
||
--- | ||
src/backend/utils/error/elog.c | 31 +++++++++++++++++++++++++++++-- | ||
1 file changed, 29 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c | ||
index 7112fb00069..b0326ba3649 100644 | ||
--- a/src/backend/utils/error/elog.c | ||
+++ b/src/backend/utils/error/elog.c | ||
@@ -192,6 +192,7 @@ static void log_line_prefix(StringInfo buf, ErrorData *edata); | ||
static void send_message_to_server_log(ErrorData *edata); | ||
static void send_message_to_frontend(ErrorData *edata); | ||
static void append_with_tabs(StringInfo buf, const char *str); | ||
+static void append_n_with_tabs(StringInfo buf, const char *str, int n); | ||
|
||
|
||
/* | ||
@@ -3218,7 +3219,7 @@ send_message_to_server_log(ErrorData *edata) | ||
{ | ||
log_line_prefix(&buf, edata); | ||
appendStringInfoString(&buf, _("QUERY: ")); | ||
- append_with_tabs(&buf, edata->internalquery); | ||
+ append_n_with_tabs(&buf, edata->internalquery, 1024); | ||
appendStringInfoChar(&buf, '\n'); | ||
} | ||
if (edata->context && !edata->hide_ctx) | ||
@@ -3261,7 +3262,7 @@ send_message_to_server_log(ErrorData *edata) | ||
{ | ||
log_line_prefix(&buf, edata); | ||
appendStringInfoString(&buf, _("STATEMENT: ")); | ||
- append_with_tabs(&buf, debug_query_string); | ||
+ append_n_with_tabs(&buf, debug_query_string, 1024); | ||
appendStringInfoChar(&buf, '\n'); | ||
} | ||
|
||
@@ -3707,6 +3708,32 @@ append_with_tabs(StringInfo buf, const char *str) | ||
} | ||
|
||
|
||
+/* | ||
+ * append_n_with_tabs | ||
+ * | ||
+ * Append the string to the StringInfo buffer truncating at n characters, | ||
+ * inserting a tab after any newline, and `...` at the end if truncated. | ||
+ */ | ||
+static void | ||
+append_n_with_tabs(StringInfo buf, const char *str, int n) | ||
+{ | ||
+ char ch; | ||
+ | ||
+ while ((ch = *str++) != '\0' && n > 0) | ||
+ { | ||
+ appendStringInfoCharMacro(buf, ch); | ||
+ if (ch == '\n') | ||
+ appendStringInfoCharMacro(buf, '\t'); | ||
+ n--; | ||
+ } | ||
+ if (ch != '\0') { | ||
+ appendStringInfoCharMacro(buf, '.'); | ||
+ appendStringInfoCharMacro(buf, '.'); | ||
+ appendStringInfoCharMacro(buf, '.'); | ||
+ } | ||
+} | ||
+ | ||
+ | ||
/* | ||
* Write errors to stderr (or by equal means when stderr is | ||
* not available). Used before ereport/elog can be used | ||
-- | ||
2.47.0 | ||
|
75 changes: 75 additions & 0 deletions
75
edgedbpkg/postgresql/patches/postgresql-edgedb__truncate_log-17.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
From a5969a9f10e83a28154d1d8297babd2b31170dc0 Mon Sep 17 00:00:00 2001 | ||
From: Fantix King <[email protected]> | ||
Date: Thu, 14 Nov 2024 19:44:01 -0500 | ||
Subject: [PATCH 6/6] Truncate long STATEMENT/QUERY log | ||
|
||
--- | ||
src/backend/utils/error/elog.c | 31 +++++++++++++++++++++++++++++-- | ||
1 file changed, 29 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c | ||
index b924b524d0b..2246e8f6047 100644 | ||
--- a/src/backend/utils/error/elog.c | ||
+++ b/src/backend/utils/error/elog.c | ||
@@ -191,6 +191,7 @@ static void log_line_prefix(StringInfo buf, ErrorData *edata); | ||
static void send_message_to_server_log(ErrorData *edata); | ||
static void send_message_to_frontend(ErrorData *edata); | ||
static void append_with_tabs(StringInfo buf, const char *str); | ||
+static void append_n_with_tabs(StringInfo buf, const char *str, int n); | ||
|
||
|
||
/* | ||
@@ -3237,7 +3238,7 @@ send_message_to_server_log(ErrorData *edata) | ||
{ | ||
log_line_prefix(&buf, edata); | ||
appendStringInfoString(&buf, _("QUERY: ")); | ||
- append_with_tabs(&buf, edata->internalquery); | ||
+ append_n_with_tabs(&buf, edata->internalquery, 1024); | ||
appendStringInfoChar(&buf, '\n'); | ||
} | ||
if (edata->context && !edata->hide_ctx) | ||
@@ -3280,7 +3281,7 @@ send_message_to_server_log(ErrorData *edata) | ||
{ | ||
log_line_prefix(&buf, edata); | ||
appendStringInfoString(&buf, _("STATEMENT: ")); | ||
- append_with_tabs(&buf, debug_query_string); | ||
+ append_n_with_tabs(&buf, debug_query_string, 1024); | ||
appendStringInfoChar(&buf, '\n'); | ||
} | ||
|
||
@@ -3729,6 +3730,32 @@ append_with_tabs(StringInfo buf, const char *str) | ||
} | ||
|
||
|
||
+/* | ||
+ * append_n_with_tabs | ||
+ * | ||
+ * Append the string to the StringInfo buffer truncating at n characters, | ||
+ * inserting a tab after any newline, and `...` at the end if truncated. | ||
+ */ | ||
+static void | ||
+append_n_with_tabs(StringInfo buf, const char *str, int n) | ||
+{ | ||
+ char ch; | ||
+ | ||
+ while ((ch = *str++) != '\0' && n > 0) | ||
+ { | ||
+ appendStringInfoCharMacro(buf, ch); | ||
+ if (ch == '\n') | ||
+ appendStringInfoCharMacro(buf, '\t'); | ||
+ n--; | ||
+ } | ||
+ if (ch != '\0') { | ||
+ appendStringInfoCharMacro(buf, '.'); | ||
+ appendStringInfoCharMacro(buf, '.'); | ||
+ appendStringInfoCharMacro(buf, '.'); | ||
+ } | ||
+} | ||
+ | ||
+ | ||
/* | ||
* Write errors to stderr (or by equal means when stderr is | ||
* not available). Used before ereport/elog can be used | ||
-- | ||
2.47.0 | ||
|