From 42d108289b174c3ab5f419e815e3d0f254592fff Mon Sep 17 00:00:00 2001 From: Kaitmazian Maksim <m.kaitmazian@picodata.io> Date: Fri, 11 Aug 2023 13:42:46 +0300 Subject: [PATCH] remove pg_info, pg_debug, pg_warning --- pgproto/src/postgres/attributes.c | 2 +- pgproto/src/postgres/auth.c | 8 ++++---- pgproto/src/postgres/postgres.c | 9 ++++----- pgproto/src/postgres/report.h | 12 ------------ pgproto/src/postgres/startup.c | 2 +- 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/pgproto/src/postgres/attributes.c b/pgproto/src/postgres/attributes.c index b982cdb30e..503c593343 100644 --- a/pgproto/src/postgres/attributes.c +++ b/pgproto/src/postgres/attributes.c @@ -209,7 +209,7 @@ parse_metadata(const char **data, { uint32_t natts = mp_decode_array(data); if (natts >= (uint16_t)-1) { - pg_debug("too many attributes: %"PRIu32, natts); + say_error("too many attributes: %"PRIu32, natts); return -1; } row_desc->natts = (uint16_t)natts; diff --git a/pgproto/src/postgres/auth.c b/pgproto/src/postgres/auth.c index d9564757fc..09cfef4a4b 100644 --- a/pgproto/src/postgres/auth.c +++ b/pgproto/src/postgres/auth.c @@ -71,7 +71,7 @@ pg_send_auth_request(struct pg_port *port, enum PG_AUTH_REQUEST_CODE code, if (code != AUTH_REQ_OK) pg_flush(port); - pg_debug("sent auth request(%d) to user \'%s\'", code, port->user); + say_debug("sent auth request(%d) to user \'%s\'", code, port->user); } /** AuthResponse packet format. */ @@ -122,7 +122,7 @@ pg_recv_auth_response(struct pg_port *port, struct auth_response *packet) if (packet->data == NULL) return -1; - pg_debug("received auth response from user \'%s\'", port->user); + say_debug("received auth response from user \'%s\'", port->user); pg_read_gc(port); return 0; } @@ -206,14 +206,14 @@ pg_authenticate(struct pg_port *port) if (strcmp(auth_method, "md5") == 0) { rc = pg_authenticate_md5(port); } else { - pg_debug("unknown auth method %s", auth_method); + say_debug("unknown auth method %s", auth_method); goto auth_failed; } if (rc != 0) goto auth_failed; pg_send_auth_ok(port); - pg_info("authenticated"); + say_info("authenticated"); return 0; auth_failed: diff --git a/pgproto/src/postgres/postgres.c b/pgproto/src/postgres/postgres.c index f6614e4851..220c87fff4 100644 --- a/pgproto/src/postgres/postgres.c +++ b/pgproto/src/postgres/postgres.c @@ -163,7 +163,7 @@ process_simple_query_impl(struct pg_port *port) return -1; } - pg_debug("processing query \'%s\'", query); + say_debug("processing query \'%s\'", query); const char *response = dispatch_query_wrapped(query, query_len); if (response == NULL) { @@ -204,8 +204,7 @@ start_query_cycle(struct pg_port *port) uint8_t msg_type; pg_read_uint8(port, &msg_type); if (port->status == PG_EOF) { - pg_error(NULL, ERRCODE_CONNECTION_DOES_NOT_EXIST, - "unexpected EOF on client connection"); + say_error("unexpected EOF on client connection"); return -1; } else if (port->status == PG_ERR) { /* Error has already been logged. */ @@ -218,7 +217,7 @@ start_query_cycle(struct pg_port *port) return -1; break; case 'X': /* Terminate */ - pg_debug("got Terminate message"); + say_debug("got Terminate message"); return 0; default: pg_error(port, ERRCODE_FEATURE_NOT_SUPPORTED, @@ -268,7 +267,7 @@ cleanup: if (fiber_is_cancelled()) pg_notice(&port, "shutting down"); - pg_info("disconnected"); + say_info("disconnected"); pg_port_close(&port); return ret; } diff --git a/pgproto/src/postgres/report.h b/pgproto/src/postgres/report.h index d8f8a0bce6..97d8d540b4 100644 --- a/pgproto/src/postgres/report.h +++ b/pgproto/src/postgres/report.h @@ -25,18 +25,6 @@ void send_message_to_frontend(int level, struct pg_port *port, const char *sql_error_code, const char *fmt, ...); -/** Log a debug message. Message is not sent to the client. */ -#define pg_debug(...) \ - say_debug(__VA_ARGS__) - -/** Log an info message. Message is not sent to the client. */ -#define pg_info(...) \ - say_info(__VA_ARGS__) - -/** Log a warning message. Message is not sent to the client. */ -#define pg_warning(format, ...) \ - say_warning(format, __VA_ARGS__) - /** Log an error message. Message is sent to the client if port != NULL. */ #define pg_error(port, sql_code, ...) do { \ say_error(__VA_ARGS__); \ diff --git a/pgproto/src/postgres/startup.c b/pgproto/src/postgres/startup.c index a50e2e1bb7..3e9eaf81ae 100644 --- a/pgproto/src/postgres/startup.c +++ b/pgproto/src/postgres/startup.c @@ -244,6 +244,6 @@ pg_process_startup_message(struct pg_port *port) return -1; } - pg_debug("processed startup message for user \"%s\"", port->user); + say_debug("processed startup message for user \"%s\"", port->user); return 0; } -- GitLab