Commit 7584649a authored by Tom Lane's avatar Tom Lane

Re-pgindent src/bin/pg_dump/*.

Seems to have gotten rather messy lately, as a consequence of a couple
of large recent commits.
parent 389573fd
......@@ -1331,7 +1331,8 @@ readMessageFromPipe(int fd)
static int
pgpipe(int handles[2])
{
pgsocket s, tmp_sock;
pgsocket s,
tmp_sock;
struct sockaddr_in serv_addr;
int len = sizeof(serv_addr);
......
......@@ -32,8 +32,8 @@ typedef enum
/* Arguments needed for a worker process */
typedef struct ParallelArgs
{
ArchiveHandle *AH;
TocEntry *te;
ArchiveHandle *AH;
TocEntry *te;
} ParallelArgs;
/* State for each parallel activity slot */
......
......@@ -4241,7 +4241,7 @@ identify_locking_dependencies(ArchiveHandle *AH, TocEntry *te)
if (depid <= AH->maxDumpId && AH->tocsByDumpId[depid] != NULL &&
((strcmp(AH->tocsByDumpId[depid]->desc, "TABLE DATA") == 0) ||
strcmp(AH->tocsByDumpId[depid]->desc, "TABLE") == 0))
strcmp(AH->tocsByDumpId[depid]->desc, "TABLE") == 0))
lockids[nlockids++] = depid;
}
......
......@@ -572,7 +572,7 @@ EndDBCopyMode(Archive *AHX, const char *tocEntryTag)
res = PQgetResult(AH->connection);
if (PQresultStatus(res) != PGRES_COMMAND_OK)
warn_or_exit_horribly(AH, modulename, "COPY failed for table \"%s\": %s",
tocEntryTag, PQerrorMessage(AH->connection));
tocEntryTag, PQerrorMessage(AH->connection));
PQclear(res);
AH->pgCopyIn = false;
......
......@@ -275,7 +275,7 @@ main(int argc, char **argv)
int compressLevel = -1;
int plainText = 0;
ArchiveFormat archiveFormat = archUnknown;
ArchiveMode archiveMode;
ArchiveMode archiveMode;
DumpOptions *dopt = NewDumpOptions();
......@@ -2156,7 +2156,8 @@ dumpDatabase(Archive *fout, DumpOptions *dopt)
*collate,
*ctype,
*tablespace;
uint32 frozenxid, minmxid;
uint32 frozenxid,
minmxid;
datname = PQdb(conn);
......@@ -2186,7 +2187,7 @@ dumpDatabase(Archive *fout, DumpOptions *dopt)
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
"(%s datdba) AS dba, "
"pg_encoding_to_char(encoding) AS encoding, "
"datcollate, datctype, datfrozenxid, 0 AS datminmxid, "
"datcollate, datctype, datfrozenxid, 0 AS datminmxid, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
"shobj_description(oid, 'pg_database') AS description "
......@@ -2200,7 +2201,7 @@ dumpDatabase(Archive *fout, DumpOptions *dopt)
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
"(%s datdba) AS dba, "
"pg_encoding_to_char(encoding) AS encoding, "
"NULL AS datcollate, NULL AS datctype, datfrozenxid, 0 AS datminmxid, "
"NULL AS datcollate, NULL AS datctype, datfrozenxid, 0 AS datminmxid, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
"shobj_description(oid, 'pg_database') AS description "
......@@ -2214,7 +2215,7 @@ dumpDatabase(Archive *fout, DumpOptions *dopt)
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
"(%s datdba) AS dba, "
"pg_encoding_to_char(encoding) AS encoding, "
"NULL AS datcollate, NULL AS datctype, datfrozenxid, 0 AS datminmxid, "
"NULL AS datcollate, NULL AS datctype, datfrozenxid, 0 AS datminmxid, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace "
"FROM pg_database "
"WHERE datname = ",
......@@ -2338,7 +2339,8 @@ dumpDatabase(Archive *fout, DumpOptions *dopt)
PGresult *lo_res;
PQExpBuffer loFrozenQry = createPQExpBuffer();
PQExpBuffer loOutQry = createPQExpBuffer();
int i_relfrozenxid, i_relminmxid;
int i_relfrozenxid,
i_relminmxid;
/*
* pg_largeobject
......@@ -2383,16 +2385,16 @@ dumpDatabase(Archive *fout, DumpOptions *dopt)
resetPQExpBuffer(loFrozenQry);
resetPQExpBuffer(loOutQry);
if (fout->remoteVersion >= 90300)
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid = %u;\n",
LargeObjectMetadataRelationId);
else
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid = %u;\n",
LargeObjectMetadataRelationId);
if (fout->remoteVersion >= 90300)
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid = %u;\n",
LargeObjectMetadataRelationId);
else
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid = %u;\n",
LargeObjectMetadataRelationId);
lo_res = ExecuteSqlQueryForSingleRow(fout, loFrozenQry->data);
......@@ -2747,22 +2749,24 @@ dumpBlobs(Archive *fout, DumpOptions *dopt, void *arg)
/*
* getRowSecurity
* get information about every row-security policy on a dumpable table.
* get information about every row-security policy on a dumpable table.
*/
void
getRowSecurity(Archive *fout, TableInfo tblinfo[], int numTables)
{
PQExpBuffer query;
PGresult *res;
PQExpBuffer query;
PGresult *res;
RowSecurityInfo *rsinfo;
int i_oid;
int i_tableoid;
int i_rsecpolname;
int i_rseccmd;
int i_rsecroles;
int i_rsecqual;
int i_rsecwithcheck;
int i, j, ntups;
int i_oid;
int i_tableoid;
int i_rsecpolname;
int i_rseccmd;
int i_rsecroles;
int i_rsecqual;
int i_rsecwithcheck;
int i,
j,
ntups;
if (fout->remoteVersion < 90500)
return;
......@@ -2771,7 +2775,7 @@ getRowSecurity(Archive *fout, TableInfo tblinfo[], int numTables)
for (i = 0; i < numTables; i++)
{
TableInfo *tbinfo = &tblinfo[i];
TableInfo *tbinfo = &tblinfo[i];
/* Ignore row-security on tables not to be dumped */
if (!tbinfo->dobj.dump)
......@@ -2783,9 +2787,9 @@ getRowSecurity(Archive *fout, TableInfo tblinfo[], int numTables)
tbinfo->dobj.name);
/*
* Get row-security enabled information for the table.
* We represent RLS enabled on a table by creating RowSecurityInfo
* object with an empty policy.
* Get row-security enabled information for the table. We represent
* RLS enabled on a table by creating RowSecurityInfo object with an
* empty policy.
*/
if (tbinfo->rowsec)
{
......@@ -2826,7 +2830,7 @@ getRowSecurity(Archive *fout, TableInfo tblinfo[], int numTables)
"CASE WHEN s.rsecroles = '{0}' THEN 'PUBLIC' ELSE "
" array_to_string(ARRAY(SELECT rolname from pg_roles WHERE oid = ANY(s.rsecroles)), ', ') END AS rsecroles, "
"pg_get_expr(s.rsecqual, s.rsecrelid) AS rsecqual, "
"pg_get_expr(s.rsecwithcheck, s.rsecrelid) AS rsecwithcheck "
"pg_get_expr(s.rsecwithcheck, s.rsecrelid) AS rsecwithcheck "
"FROM pg_catalog.pg_rowsecurity s "
"WHERE rsecrelid = '%u'",
tbinfo->dobj.catId.oid);
......@@ -2894,7 +2898,7 @@ getRowSecurity(Archive *fout, TableInfo tblinfo[], int numTables)
/*
* dumpRowSecurity
* dump the definition of the given row-security policy
* dump the definition of the given row-security policy
*/
static void
dumpRowSecurity(Archive *fout, DumpOptions *dopt, RowSecurityInfo *rsinfo)
......@@ -2909,8 +2913,8 @@ dumpRowSecurity(Archive *fout, DumpOptions *dopt, RowSecurityInfo *rsinfo)
/*
* If rsecpolname is NULL, then this record is just indicating that ROW
* LEVEL SECURITY is enabled for the table.
* Dump as ALTER TABLE <table> ENABLE ROW LEVEL SECURITY.
* LEVEL SECURITY is enabled for the table. Dump as ALTER TABLE <table>
* ENABLE ROW LEVEL SECURITY.
*/
if (rsinfo->rsecpolname == NULL)
{
......@@ -6622,8 +6626,8 @@ getTableAttrs(Archive *fout, DumpOptions *dopt, TableInfo *tblinfo, int numTable
*/
if (g_verbose)
write_msg(NULL, "finding the columns and types of table \"%s\".\"%s\"\n",
tbinfo->dobj.namespace->dobj.name,
tbinfo->dobj.name);
tbinfo->dobj.namespace->dobj.name,
tbinfo->dobj.name);
resetPQExpBuffer(q);
......@@ -6835,8 +6839,8 @@ getTableAttrs(Archive *fout, DumpOptions *dopt, TableInfo *tblinfo, int numTable
if (g_verbose)
write_msg(NULL, "finding default expressions of table \"%s\".\"%s\"\n",
tbinfo->dobj.namespace->dobj.name,
tbinfo->dobj.name);
tbinfo->dobj.namespace->dobj.name,
tbinfo->dobj.name);
resetPQExpBuffer(q);
if (fout->remoteVersion >= 70300)
......@@ -13772,7 +13776,7 @@ dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
* Analogously, we set up typed tables using ALTER TABLE / OF here.
*/
if (dopt->binary_upgrade && (tbinfo->relkind == RELKIND_RELATION ||
tbinfo->relkind == RELKIND_FOREIGN_TABLE))
tbinfo->relkind == RELKIND_FOREIGN_TABLE))
{
for (j = 0; j < tbinfo->numatts; j++)
{
......@@ -13874,7 +13878,7 @@ dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
/* We preserve the toast oids, so we can use it during restore */
appendPQExpBufferStr(q, "\n-- For binary upgrade, set toast's relfrozenxid and relminmxid\n");
appendPQExpBuffer(q, "UPDATE pg_catalog.pg_class\n"
"SET relfrozenxid = '%u', relminmxid = '%u'\n"
"SET relfrozenxid = '%u', relminmxid = '%u'\n"
"WHERE oid = '%u';\n",
tbinfo->toast_frozenxid,
tbinfo->toast_minmxid, tbinfo->toast_oid);
......
......@@ -460,13 +460,13 @@ typedef struct _blobInfo
*/
typedef struct _rowSecurityInfo
{
DumpableObject dobj;
TableInfo *rstable;
char *rsecpolname; /* null indicates RLS is enabled on rel */
char *rseccmd;
char *rsecroles;
char *rsecqual;
char *rsecwithcheck;
DumpableObject dobj;
TableInfo *rstable;
char *rsecpolname; /* null indicates RLS is enabled on rel */
char *rseccmd;
char *rsecroles;
char *rsecqual;
char *rsecwithcheck;
} RowSecurityInfo;
/* global decls */
......
......@@ -57,7 +57,7 @@ static void buildShSecLabels(PGconn *conn, const char *catalog_name,
uint32 objectId, PQExpBuffer buffer,
const char *target, const char *objname);
static PGconn *connectDatabase(const char *dbname, const char *connstr, const char *pghost, const char *pgport,
const char *pguser, trivalue prompt_password, bool fail_on_error);
const char *pguser, trivalue prompt_password, bool fail_on_error);
static char *constructConnStr(const char **keywords, const char **values);
static PGresult *executeQuery(PGconn *conn, const char *query);
static void executeCommand(PGconn *conn, const char *query);
......@@ -1277,7 +1277,7 @@ dumpCreateDB(PGconn *conn)
"SELECT datname, "
"coalesce(rolname, (select rolname from pg_authid where oid=(select datdba from pg_database where datname='template0'))), "
"pg_encoding_to_char(d.encoding), "
"datcollate, datctype, datfrozenxid, 0 AS datminmxid, "
"datcollate, datctype, datfrozenxid, 0 AS datminmxid, "
"datistemplate, datacl, datconnlimit, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
"FROM pg_database d LEFT JOIN pg_authid u ON (datdba = u.oid) "
......@@ -1287,7 +1287,7 @@ dumpCreateDB(PGconn *conn)
"SELECT datname, "
"coalesce(rolname, (select rolname from pg_authid where oid=(select datdba from pg_database where datname='template0'))), "
"pg_encoding_to_char(d.encoding), "
"null::text AS datcollate, null::text AS datctype, datfrozenxid, 0 AS datminmxid, "
"null::text AS datcollate, null::text AS datctype, datfrozenxid, 0 AS datminmxid, "
"datistemplate, datacl, datconnlimit, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
"FROM pg_database d LEFT JOIN pg_authid u ON (datdba = u.oid) "
......@@ -1297,7 +1297,7 @@ dumpCreateDB(PGconn *conn)
"SELECT datname, "
"coalesce(usename, (select usename from pg_shadow where usesysid=(select datdba from pg_database where datname='template0'))), "
"pg_encoding_to_char(d.encoding), "
"null::text AS datcollate, null::text AS datctype, datfrozenxid, 0 AS datminmxid, "
"null::text AS datcollate, null::text AS datctype, datfrozenxid, 0 AS datminmxid, "
"datistemplate, datacl, -1 as datconnlimit, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
"FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) "
......@@ -1307,7 +1307,7 @@ dumpCreateDB(PGconn *conn)
"SELECT datname, "
"coalesce(usename, (select usename from pg_shadow where usesysid=(select datdba from pg_database where datname='template0'))), "
"pg_encoding_to_char(d.encoding), "
"null::text AS datcollate, null::text AS datctype, datfrozenxid, 0 AS datminmxid, "
"null::text AS datcollate, null::text AS datctype, datfrozenxid, 0 AS datminmxid, "
"datistemplate, datacl, -1 as datconnlimit, "
"'pg_default' AS dattablespace "
"FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) "
......@@ -1419,7 +1419,7 @@ dumpCreateDB(PGconn *conn)
{
appendPQExpBufferStr(buf, "-- For binary upgrade, set datfrozenxid and datminmxid.\n");
appendPQExpBuffer(buf, "UPDATE pg_catalog.pg_database "
"SET datfrozenxid = '%u', datminmxid = '%u' "
"SET datfrozenxid = '%u', datminmxid = '%u' "
"WHERE datname = ",
dbfrozenxid, dbminmxid);
appendStringLiteralConn(buf, dbname, conn);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment