Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3cf6e94

Browse files
committed
Use new datlastsysoid field in pg_database + some cleanups & fixes
1 parent 4ac1742 commit 3cf6e94

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ void RestoreArchive(Archive* AHX, RestoreOptions *ropt)
220220
*/
221221
if (!AH->CustomOutPtr)
222222
fprintf(stderr, "%s: WARNING - skipping BLOB restoration\n", progname);
223+
223224
} else {
224225

225226
_disableTriggers(AH, te, ropt);
@@ -951,6 +952,10 @@ int ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle* AH)
951952
{
952953
res = lo_write(AH->connection, AH->loFd, (void*)ptr, size * nmemb);
953954
ahlog(AH, 5, "Wrote %d bytes of BLOB data (result = %d)\n", size * nmemb, res);
955+
if (res < size * nmemb)
956+
die_horribly(AH, "%s: could not write to large object (result = %d, expected %d)\n",
957+
progname, res, size * nmemb);
958+
954959
return res;
955960
}
956961
else if (AH->gzOut)

src/bin/pg_dump/pg_backup_archiver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ typedef z_stream *z_streamp;
6262

6363
#define K_VERS_MAJOR 1
6464
#define K_VERS_MINOR 4
65-
#define K_VERS_REV 17
65+
#define K_VERS_REV 19
6666

6767
/* Data block types */
6868
#define BLK_DATA 1

src/bin/pg_dump/pg_dump.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
*
2424
* IDENTIFICATION
25-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.172 2000/10/22 05:27:18 momjian Exp $
25+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.173 2000/10/22 18:13:09 pjw Exp $
2626
*
2727
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
2828
*
@@ -140,7 +140,7 @@ static char *checkForQuote(const char *s);
140140
static void clearTableInfo(TableInfo *, int);
141141
static void dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
142142
TypeInfo *tinfo, int numTypes);
143-
static int findLastBuiltinOid(void);
143+
static int findLastBuiltinOid(const char*);
144144
static void setMaxOid(Archive *fout);
145145

146146
static void AddAcl(char *aclbuf, const char *keyword);
@@ -954,7 +954,7 @@ main(int argc, char **argv)
954954
PQclear(res);
955955
}
956956

957-
g_last_builtin_oid = findLastBuiltinOid();
957+
g_last_builtin_oid = findLastBuiltinOid(dbname);
958958

959959
/* Dump the database definition */
960960
if (!dataOnly)
@@ -3888,14 +3888,17 @@ setMaxOid(Archive *fout)
38883888
*/
38893889

38903890
static int
3891-
findLastBuiltinOid(void)
3891+
findLastBuiltinOid(const char* dbname)
38923892
{
38933893
PGresult *res;
38943894
int ntups;
38953895
int last_oid;
3896+
PQExpBuffer query = createPQExpBuffer();
3897+
3898+
resetPQExpBuffer(query);
3899+
appendPQExpBuffer(query, "SELECT datlastsysoid from pg_database where datname = '%s'", dbname);
38963900

3897-
res = PQexec(g_conn,
3898-
"SELECT oid from pg_database where datname = 'template1'");
3901+
res = PQexec(g_conn, query->data);
38993902
if (res == NULL ||
39003903
PQresultStatus(res) != PGRES_TUPLES_OK)
39013904
{
@@ -3916,7 +3919,7 @@ findLastBuiltinOid(void)
39163919
fprintf(stderr, "There is more than one 'template1' entry in the 'pg_database' table\n");
39173920
exit_nicely(g_conn);
39183921
}
3919-
last_oid = atoi(PQgetvalue(res, 0, PQfnumber(res, "oid")));
3922+
last_oid = atoi(PQgetvalue(res, 0, PQfnumber(res, "datlastsysoid")));
39203923
PQclear(res);
39213924
return last_oid;
39223925
}

0 commit comments

Comments
 (0)