summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup_archiver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_dump/pg_backup_archiver.c')
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c60
1 files changed, 20 insertions, 40 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 77fe51a3a53..233198afc0c 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -640,8 +640,7 @@ RestoreArchive(Archive *AHX)
* If we treated users as pg_dump'able objects then we'd need to reset
* currUser here too.
*/
- if (AH->currSchema)
- free(AH->currSchema);
+ free(AH->currSchema);
AH->currSchema = NULL;
}
@@ -2067,8 +2066,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
pg_log_debug("attempting to ascertain archive format");
- if (AH->lookahead)
- free(AH->lookahead);
+ free(AH->lookahead);
AH->readHeader = 0;
AH->lookaheadSize = 512;
@@ -3178,21 +3176,17 @@ _reconnectToDB(ArchiveHandle *AH, const char *dbname)
* NOTE: currUser keeps track of what the imaginary session user in our
* script is. It's now effectively reset to the original userID.
*/
- if (AH->currUser)
- free(AH->currUser);
+ free(AH->currUser);
AH->currUser = NULL;
/* don't assume we still know the output schema, tablespace, etc either */
- if (AH->currSchema)
- free(AH->currSchema);
+ free(AH->currSchema);
AH->currSchema = NULL;
- if (AH->currTableAm)
- free(AH->currTableAm);
+ free(AH->currTableAm);
AH->currTableAm = NULL;
- if (AH->currTablespace)
- free(AH->currTablespace);
+ free(AH->currTablespace);
AH->currTablespace = NULL;
/* re-establish fixed state */
@@ -3219,8 +3213,7 @@ _becomeUser(ArchiveHandle *AH, const char *user)
* NOTE: currUser keeps track of what the imaginary session user in our
* script is
*/
- if (AH->currUser)
- free(AH->currUser);
+ free(AH->currUser);
AH->currUser = pg_strdup(user);
}
@@ -3285,8 +3278,7 @@ _selectOutputSchema(ArchiveHandle *AH, const char *schemaName)
else
ahprintf(AH, "%s;\n\n", qry->data);
- if (AH->currSchema)
- free(AH->currSchema);
+ free(AH->currSchema);
AH->currSchema = pg_strdup(schemaName);
destroyPQExpBuffer(qry);
@@ -3347,8 +3339,7 @@ _selectTablespace(ArchiveHandle *AH, const char *tablespace)
else
ahprintf(AH, "%s;\n\n", qry->data);
- if (AH->currTablespace)
- free(AH->currTablespace);
+ free(AH->currTablespace);
AH->currTablespace = pg_strdup(want);
destroyPQExpBuffer(qry);
@@ -3399,8 +3390,7 @@ _selectTableAccessMethod(ArchiveHandle *AH, const char *tableam)
destroyPQExpBuffer(cmd);
- if (AH->currTableAm)
- free(AH->currTableAm);
+ free(AH->currTableAm);
AH->currTableAm = pg_strdup(want);
}
@@ -3659,8 +3649,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData)
*/
if (_tocEntryIsACL(te))
{
- if (AH->currUser)
- free(AH->currUser);
+ free(AH->currUser);
AH->currUser = NULL;
}
}
@@ -3991,17 +3980,13 @@ restore_toc_entries_prefork(ArchiveHandle *AH, TocEntry *pending_list)
DisconnectDatabase(&AH->public);
/* blow away any transient state from the old connection */
- if (AH->currUser)
- free(AH->currUser);
+ free(AH->currUser);
AH->currUser = NULL;
- if (AH->currSchema)
- free(AH->currSchema);
+ free(AH->currSchema);
AH->currSchema = NULL;
- if (AH->currTablespace)
- free(AH->currTablespace);
+ free(AH->currTablespace);
AH->currTablespace = NULL;
- if (AH->currTableAm)
- free(AH->currTableAm);
+ free(AH->currTableAm);
AH->currTableAm = NULL;
}
@@ -4842,16 +4827,11 @@ DeCloneArchive(ArchiveHandle *AH)
destroyPQExpBuffer(AH->sqlparse.curCmd);
/* Clear any connection-local state */
- if (AH->currUser)
- free(AH->currUser);
- if (AH->currSchema)
- free(AH->currSchema);
- if (AH->currTablespace)
- free(AH->currTablespace);
- if (AH->currTableAm)
- free(AH->currTableAm);
- if (AH->savedPassword)
- free(AH->savedPassword);
+ free(AH->currUser);
+ free(AH->currSchema);
+ free(AH->currTablespace);
+ free(AH->currTableAm);
+ free(AH->savedPassword);
free(AH);
}