int compressLevel = -1;
int plainText = 0;
ArchiveFormat archiveFormat = archUnknown;
- ArchiveMode archiveMode;
+ ArchiveMode archiveMode;
DumpOptions *dopt = NewDumpOptions();
*collate,
*ctype,
*tablespace;
- uint32 frozenxid, minmxid;
+ uint32 frozenxid,
+ minmxid;
datname = PQdb(conn);
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 "
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 "
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 = ",
PGresult *lo_res;
PQExpBuffer loFrozenQry = createPQExpBuffer();
PQExpBuffer loOutQry = createPQExpBuffer();
- int i_relfrozenxid, i_relminmxid;
+ int i_relfrozenxid,
+ i_relminmxid;
/*
* pg_largeobject
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);
/*
* 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;
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)
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)
{
"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);
/*
* 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)
/*
* 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)
{
*/
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);
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)
* 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++)
{
/* 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);
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);
"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) "
"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) "
"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) "
"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) "
{
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);