MCPcopy Create free account
hub / github.com/apache/cloudberry / StreamLogicalLog

Function StreamLogicalLog

src/bin/pg_basebackup/pg_recvlogical.c:203–643  ·  view source on GitHub ↗

* Start the log streaming */

Source from the content-addressed store, hash-verified

201 * Start the log streaming
202 */
203static void
204StreamLogicalLog(void)
205{
206 PGresult *res;
207 char *copybuf = NULL;
208 TimestampTz last_status = -1;
209 int i;
210 PQExpBuffer query;
211
212 output_written_lsn = InvalidXLogRecPtr;
213 output_fsync_lsn = InvalidXLogRecPtr;
214
215 /*
216 * Connect in replication mode to the server
217 */
218 if (!conn)
219 conn = GetConnection();
220 if (!conn)
221 /* Error message already written in GetConnection() */
222 return;
223
224 /*
225 * Start the replication
226 */
227 if (verbose)
228 pg_log_info("starting log streaming at %X/%X (slot %s)",
229 LSN_FORMAT_ARGS(startpos),
230 replication_slot);
231
232 /* Initiate the replication stream at specified location */
233 query = createPQExpBuffer();
234 appendPQExpBuffer(query, "START_REPLICATION SLOT \"%s\" LOGICAL %X/%X",
235 replication_slot, LSN_FORMAT_ARGS(startpos));
236
237 /* print options if there are any */
238 if (noptions)
239 appendPQExpBufferStr(query, " (");
240
241 for (i = 0; i < noptions; i++)
242 {
243 /* separator */
244 if (i > 0)
245 appendPQExpBufferStr(query, ", ");
246
247 /* write option name */
248 appendPQExpBuffer(query, "\"%s\"", options[(i * 2)]);
249
250 /* write option value if specified */
251 if (options[(i * 2) + 1] != NULL)
252 appendPQExpBuffer(query, " '%s'", options[(i * 2) + 1]);
253 }
254
255 if (noptions)
256 appendPQExpBufferChar(query, ')');
257
258 res = PQexec(conn, query->data);
259 if (PQresultStatus(res) != PGRES_COPY_BOTH)
260 {

Callers 1

mainFunction · 0.85

Calls 15

createPQExpBufferFunction · 0.85
appendPQExpBufferFunction · 0.85
appendPQExpBufferStrFunction · 0.85
appendPQExpBufferCharFunction · 0.85
PQexecFunction · 0.85
PQresultStatusFunction · 0.85
PQresultErrorMessageFunction · 0.85
PQclearFunction · 0.85
resetPQExpBufferFunction · 0.85
PQfreememFunction · 0.85
feGetCurrentTimestampFunction · 0.85

Tested by

no test coverage detected