diff options
author | Jun Kuriyama <kuriyama@FreeBSD.org> | 2004-02-25 13:47:27 +0000 |
---|---|---|
committer | Jun Kuriyama <kuriyama@FreeBSD.org> | 2004-02-25 13:47:27 +0000 |
commit | f18b1ceaea3d1b56ad15395efce4064344557ae9 (patch) | |
tree | 9b55689b9e8cf1d39f88654efc4ccfcea1eb2e30 /databases/pgcluster/files/patch-libpq:replicate.c | |
parent | Update to 0.11 (diff) |
o Fix some bugs reported on ML.
o Fix more style bugs in debug message.
o Add internal function to postmaster which returns current replication
server.
o Add new packet handler to pgreplicate which returns cluster node
status information.
o Add check scripts for nagios. These scripts may be useful, but not
intended to officially supported by me. I'll make them as another
port when they become stable.
Notes
Notes:
svn path=/head/; revision=102097
Diffstat (limited to 'databases/pgcluster/files/patch-libpq:replicate.c')
-rw-r--r-- | databases/pgcluster/files/patch-libpq:replicate.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/databases/pgcluster/files/patch-libpq:replicate.c b/databases/pgcluster/files/patch-libpq:replicate.c new file mode 100644 index 000000000000..1c7d3fea1b43 --- /dev/null +++ b/databases/pgcluster/files/patch-libpq:replicate.c @@ -0,0 +1,69 @@ +--- src/backend/libpq/replicate.c.orig.1 Fri Feb 20 11:38:39 2004 ++++ src/backend/libpq/replicate.c Wed Feb 25 09:28:07 2004 +@@ -645,6 +645,7 @@ + return NULL; + } + sock = get_replicate_server_socket( sp , socket_type); ++ elog(DEBUG1, "get_replicate_server_socket() returns %d", sock); + if (sock == -1) + { + if (Debug_pretty_print) +@@ -668,7 +669,7 @@ + while (send_replicate_packet(sock,&header,query_string) != STATUS_OK) + { + if (Debug_pretty_print) +- elog(DEBUG1,"replication server: %s may be down",sp->hostName); ++ elog(DEBUG1,"replication server: %s may be down (cnt=%d, sock=%d)", sp->hostName, cnt, sock); + close_replicate_server_socket ( sp , socket_type); + sp->useFlag = DATA_ERR; + sock = search_new_replication_server( sp,socket_type,&header); +@@ -760,6 +761,11 @@ + fd_set wmask; + struct timeval timeout; + ++ /* check parameter */ ++ if ((sock <= 0) || (header == NULL) || (query_string == NULL)) ++ { ++ return STATUS_ERROR; ++ } + /*header->query_size +=1;*/ + header_size = sizeof(ReplicateHeader); + buf_size = header_size + header->query_size + 4; +@@ -776,6 +782,7 @@ + /* + * Wait for something to happen. + */ ++ elog(DEBUG1, "send_replicate_packet(%d, %p, %s)", sock, header, query_string); + FD_ZERO(&wmask); + FD_SET(sock,&wmask); + rtn = select(sock+1, (fd_set *)NULL, &wmask, (fd_set *)NULL, &timeout); +@@ -1767,4 +1774,29 @@ + return false; + } + } ++ ++extern Datum pgr_current_replicator(PG_FUNCTION_ARGS); ++PG_FUNCTION_INFO_V1(pgr_current_replicator); ++ ++Datum ++pgr_current_replicator(PG_FUNCTION_ARGS) ++{ ++ int len; ++ char buf[HOSTNAME_MAX_LENGTH + 6]; ++ text *result; ++ ReplicateServerInfo *sp; ++ ++ sp = PGR_get_replicate_server_info(); ++ if (sp == NULL) { ++ PG_RETURN_NULL(); ++ } ++ len = snprintf(buf, sizeof(buf), "%s:%d", ++ sp->hostName, sp->portNumber); ++ result = palloc(VARHDRSZ + len); ++ VARATT_SIZEP(result) = VARHDRSZ + len; ++ memcpy(VARDATA(result), buf, len); ++ ++ PG_RETURN_TEXT_P(result); ++} ++ + #endif /* USE_REPLICATION */ |