bdr: Add database oid to IDENTIFY_SYSTEM
authorAndres Freund <andres@anarazel.de>
Fri, 3 May 2013 14:53:58 +0000 (16:53 +0200)
committerAndres Freund <andres@anarazel.de>
Fri, 17 May 2013 16:40:36 +0000 (18:40 +0200)
Adjust all IDENTIFY_SYSTEM callers

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
src/backend/replication/walsender.c
src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_basebackup/pg_receivellog.c
src/bin/pg_basebackup/pg_receivexlog.c
src/bin/pg_basebackup/receivelog.c

index 8760539f8e234b09c99f4525f5902655728ac620..8f1937a2916f2f094933d48981b764395c924fc8 100644 (file)
@@ -130,7 +130,7 @@ libpqrcv_identify_system(TimeLineID *primary_tli)
                        "the primary server: %s",
                        PQerrorMessage(streamConn))));
    }
-   if (PQnfields(res) != 4 || PQntuples(res) != 1)
+   if (PQnfields(res) != 5 || PQntuples(res) != 1)
    {
        int         ntuples = PQntuples(res);
        int         nfields = PQnfields(res);
@@ -138,7 +138,7 @@ libpqrcv_identify_system(TimeLineID *primary_tli)
        PQclear(res);
        ereport(ERROR,
                (errmsg("invalid response from primary server"),
-                errdetail("Expected 1 tuple with 4 fields, got %d tuples with %d fields.",
+                errdetail("Expected 1 tuple with 5 fields, got %d tuples with %d fields.",
                           ntuples, nfields)));
    }
    primary_sysid = PQgetvalue(res, 0, 0);
index 526a4caf0be4eb3ee2f6f86026cc595d4adaae84..ae094e9dbf740ce4aa3802206a5dc497d4f84839 100644 (file)
@@ -262,7 +262,8 @@ IdentifySystem(void)
    char        tli[11];
    char        xpos[MAXFNAMELEN];
    XLogRecPtr  logptr;
-   char*        dbname = NULL;
+   char        *dbname = NULL;
+   char        dboid[10];
 
    /*
     * Reply with a result set with one row, four columns. First col is system
@@ -287,11 +288,14 @@ IdentifySystem(void)
    snprintf(xpos, sizeof(xpos), "%X/%X", (uint32) (logptr >> 32), (uint32) logptr);
 
    if (MyDatabaseId != InvalidOid)
+   {
        dbname = get_database_name(MyDatabaseId);
+       sprintf(dboid, "%u", MyDatabaseId);
+   }
 
    /* Send a RowDescription message */
    pq_beginmessage(&buf, 'T');
-   pq_sendint(&buf, 4, 2);     /* 4 fields */
+   pq_sendint(&buf, 5, 2);     /* 5 fields */
 
    /* first field */
    pq_sendstring(&buf, "systemid");    /* col name */
@@ -328,11 +332,21 @@ IdentifySystem(void)
    pq_sendint(&buf, -1, 2);        /* typlen */
    pq_sendint(&buf, 0, 4);     /* typmod */
    pq_sendint(&buf, 0, 2);     /* format code */
+
+   /* fifth field */
+   pq_sendstring(&buf, "dboid");   /* col name */
+   pq_sendint(&buf, 0, 4);     /* table oid */
+   pq_sendint(&buf, 0, 2);     /* attnum */
+   pq_sendint(&buf, INT4OID, 4);       /* type oid */
+   pq_sendint(&buf, 4, 2);     /* typlen */
+   pq_sendint(&buf, 0, 4);     /* typmod */
+   pq_sendint(&buf, 0, 2);     /* format code */
+
    pq_endmessage(&buf);
 
    /* Send a DataRow message */
    pq_beginmessage(&buf, 'D');
-   pq_sendint(&buf, 4, 2);     /* # of columns */
+   pq_sendint(&buf, 5, 2);     /* # of columns */
    pq_sendint(&buf, strlen(sysid), 4); /* col1 len */
    pq_sendbytes(&buf, (char *) &sysid, strlen(sysid));
    pq_sendint(&buf, strlen(tli), 4);   /* col2 len */
@@ -344,10 +358,14 @@ IdentifySystem(void)
    {
        pq_sendint(&buf, strlen(dbname), 4);    /* col4 len */
        pq_sendbytes(&buf, (char *) dbname, strlen(dbname));
+
+       pq_sendint(&buf, strlen(dboid), 4); /* col5 len */
+       pq_sendbytes(&buf, dboid, strlen(dboid));
    }
    else
    {
        pq_sendint(&buf, -1, 4);    /* col4 len */
+       pq_sendint(&buf, -1, 4);    /* col5 len */
    }
    pq_endmessage(&buf);
 }
index ca0b6c8cc25008fa5306f6dec83e60a49e25f188..2e29135f1e96fba1cff129bafa4a7f9029d9b0e8 100644 (file)
@@ -1283,11 +1283,11 @@ BaseBackup(void)
                progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
        disconnect_and_exit(1);
    }
-   if (PQntuples(res) != 1 || PQnfields(res) != 4)
+   if (PQntuples(res) != 1 || PQnfields(res) != 5)
    {
        fprintf(stderr,
                _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d fields\n"),
-               progname, PQntuples(res), PQnfields(res), 1, 4);
+               progname, PQntuples(res), PQnfields(res), 1, 5);
        disconnect_and_exit(1);
    }
    sysidentifier = pg_strdup(PQgetvalue(res, 0, 0));
index e98452d740492c0fb624d8e473defac0a072eed2..f28bb125e6475ef4e17aecc35e3171cd42e6958f 100644 (file)
@@ -754,11 +754,11 @@ main(int argc, char **argv)
            disconnect_and_exit(1);
        }
 
-       if (PQntuples(res) != 1 || PQnfields(res) != 4)
+       if (PQntuples(res) != 1 || PQnfields(res) != 5)
        {
            fprintf(stderr,
                    _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d fields\n"),
-                   progname, PQntuples(res), PQnfields(res), 1, 4);
+                   progname, PQntuples(res), PQnfields(res), 1, 5);
            disconnect_and_exit(1);
        }
        PQclear(res);
index acbb3b6fe80e0bb6950b199d6303487819a8f0cd..52d241266832116a971362141a4dea3ed1929eab 100644 (file)
@@ -252,11 +252,11 @@ StreamLog(void)
                progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
        disconnect_and_exit(1);
    }
-   if (PQntuples(res) != 1 || PQnfields(res) != 4)
+   if (PQntuples(res) != 1 || PQnfields(res) != 5)
    {
        fprintf(stderr,
                _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d fields\n"),
-               progname, PQntuples(res), PQnfields(res), 1, 4);
+               progname, PQntuples(res), PQnfields(res), 1, 5);
        disconnect_and_exit(1);
    }
    servertli = atoi(PQgetvalue(res, 0, 1));
index 5e6f62ff4651766e933e4fa85bd26181bcf9ff5b..a255efcb648b9e46775e4e3e1a28300a7e5d1483 100644 (file)
@@ -531,11 +531,11 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
            PQclear(res);
            return false;
        }
-       if (PQnfields(res) != 4 || PQntuples(res) != 1)
+       if (PQnfields(res) != 5 || PQntuples(res) != 1)
        {
            fprintf(stderr,
                    _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d fields\n"),
-                   progname, PQntuples(res), PQnfields(res), 1, 4);
+                   progname, PQntuples(res), PQnfields(res), 1, 5);
            PQclear(res);
            return false;
        }