* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.416 2005/08/12 01:36:00 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.417 2005/08/15 02:36:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
bool dataOnly;
bool aclsSkip;
+/* subquery used to convert user ID (eg, datdba) to user name */
+static const char *username_subquery;
+
/* obsolete as of 7.3: */
static Oid g_last_builtin_oid; /* value of the last builtin oid */
free(cmd);
}
+ /* Select the appropriate subquery to convert user IDs to names */
+ if (g_fout->remoteVersion >= 80100)
+ username_subquery = "SELECT rolname FROM pg_catalog.pg_roles WHERE oid =";
+ else if (g_fout->remoteVersion >= 70300)
+ username_subquery = "SELECT usename FROM pg_catalog.pg_user WHERE usesysid =";
+ else
+ username_subquery = "SELECT usename FROM pg_user WHERE usesysid =";
+
/*
* If supported, set extra_float_digits so that we can dump float data
* exactly (given correctly implemented float I/O code, anyway)
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
NULL,
- tbinfo->usename, false,
+ tbinfo->rolname, false,
"TABLE DATA", "", "", copyStmt,
tdinfo->dobj.dependencies, tdinfo->dobj.nDeps,
dumpFn, tdinfo);
if (g_fout->remoteVersion >= 80000)
{
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
- "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
+ "(%s datdba) as dba, "
"pg_encoding_to_char(encoding) as encoding, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) as tablespace "
"FROM pg_database "
- "WHERE datname = ");
+ "WHERE datname = ",
+ username_subquery);
appendStringLiteral(dbQry, datname, true);
}
else if (g_fout->remoteVersion >= 70100)
{
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
- "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
+ "(%s datdba) as dba, "
"pg_encoding_to_char(encoding) as encoding, "
"NULL as tablespace "
"FROM pg_database "
- "WHERE datname = ");
+ "WHERE datname = ",
+ username_subquery);
appendStringLiteral(dbQry, datname, true);
}
else
appendPQExpBuffer(dbQry, "SELECT "
"(SELECT oid FROM pg_class WHERE relname = 'pg_database') AS tableoid, "
"oid, "
- "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
+ "(%s datdba) as dba, "
"pg_encoding_to_char(encoding) as encoding, "
"NULL as tablespace "
"FROM pg_database "
- "WHERE datname = ");
+ "WHERE datname = ",
+ username_subquery);
appendStringLiteral(dbQry, datname, true);
}
int i_tableoid;
int i_oid;
int i_nspname;
- int i_usename;
+ int i_rolname;
int i_nspacl;
/*
nsinfo[0].dobj.catId.oid = 0;
AssignDumpId(&nsinfo[0].dobj);
nsinfo[0].dobj.name = strdup("public");
- nsinfo[0].usename = strdup("");
+ nsinfo[0].rolname = strdup("");
nsinfo[0].nspacl = strdup("");
selectDumpableNamespace(&nsinfo[0]);
nsinfo[1].dobj.catId.oid = 1;
AssignDumpId(&nsinfo[1].dobj);
nsinfo[1].dobj.name = strdup("pg_catalog");
- nsinfo[1].usename = strdup("");
+ nsinfo[1].rolname = strdup("");
nsinfo[1].nspacl = strdup("");
selectDumpableNamespace(&nsinfo[1]);
* we read in can be linked to a containing namespace.
*/
appendPQExpBuffer(query, "SELECT tableoid, oid, nspname, "
- "(select usename from pg_user where nspowner = usesysid) as usename, "
- "nspacl FROM pg_namespace");
+ "(%s nspowner) as rolname, "
+ "nspacl FROM pg_namespace",
+ username_subquery);
res = PQexec(g_conn, query->data);
check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
i_tableoid = PQfnumber(res, "tableoid");
i_oid = PQfnumber(res, "oid");
i_nspname = PQfnumber(res, "nspname");
- i_usename = PQfnumber(res, "usename");
+ i_rolname = PQfnumber(res, "rolname");
i_nspacl = PQfnumber(res, "nspacl");
for (i = 0; i < ntups; i++)
nsinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&nsinfo[i].dobj);
nsinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_nspname));
- nsinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
+ nsinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname));
nsinfo[i].nspacl = strdup(PQgetvalue(res, i, i_nspacl));
/* Decide whether to dump this namespace */
selectDumpableNamespace(&nsinfo[i]);
- if (strlen(nsinfo[i].usename) == 0)
+ if (strlen(nsinfo[i].rolname) == 0)
write_msg(NULL, "WARNING: owner of schema \"%s\" appears to be invalid\n",
nsinfo[i].dobj.name);
}
int i_oid;
int i_typname;
int i_typnamespace;
- int i_usename;
+ int i_rolname;
int i_typinput;
int i_typoutput;
int i_typelem;
{
appendPQExpBuffer(query, "SELECT tableoid, oid, typname, "
"typnamespace, "
- "(select usename from pg_user where typowner = usesysid) as usename, "
+ "(%s typowner) as rolname, "
"typinput::oid as typinput, "
"typoutput::oid as typoutput, typelem, typrelid, "
"CASE WHEN typrelid = 0 THEN ' '::\"char\" "
"ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, "
"typtype, typisdefined "
- "FROM pg_type");
+ "FROM pg_type",
+ username_subquery);
}
else if (g_fout->remoteVersion >= 70100)
{
appendPQExpBuffer(query, "SELECT tableoid, oid, typname, "
"0::oid as typnamespace, "
- "(select usename from pg_user where typowner = usesysid) as usename, "
+ "(%s typowner) as rolname, "
"typinput::oid as typinput, "
"typoutput::oid as typoutput, typelem, typrelid, "
"CASE WHEN typrelid = 0 THEN ' '::\"char\" "
"ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, "
"typtype, typisdefined "
- "FROM pg_type");
+ "FROM pg_type",
+ username_subquery);
}
else
{
"(SELECT oid FROM pg_class WHERE relname = 'pg_type') AS tableoid, "
"oid, typname, "
"0::oid as typnamespace, "
- "(select usename from pg_user where typowner = usesysid) as usename, "
+ "(%s typowner) as rolname, "
"typinput::oid as typinput, "
"typoutput::oid as typoutput, typelem, typrelid, "
"CASE WHEN typrelid = 0 THEN ' '::\"char\" "
"ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, "
"typtype, typisdefined "
- "FROM pg_type");
+ "FROM pg_type",
+ username_subquery);
}
res = PQexec(g_conn, query->data);
i_oid = PQfnumber(res, "oid");
i_typname = PQfnumber(res, "typname");
i_typnamespace = PQfnumber(res, "typnamespace");
- i_usename = PQfnumber(res, "usename");
+ i_rolname = PQfnumber(res, "rolname");
i_typinput = PQfnumber(res, "typinput");
i_typoutput = PQfnumber(res, "typoutput");
i_typelem = PQfnumber(res, "typelem");
tinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_typname));
tinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_typnamespace)),
tinfo[i].dobj.catId.oid);
- tinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
+ tinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname));
tinfo[i].typinput = atooid(PQgetvalue(res, i, i_typinput));
typoutput = atooid(PQgetvalue(res, i, i_typoutput));
tinfo[i].typelem = atooid(PQgetvalue(res, i, i_typelem));
addObjectDependency(&tinfo[i].dobj,
funcInfo->dobj.dumpId);
- if (strlen(tinfo[i].usename) == 0 && tinfo[i].isDefined)
+ if (strlen(tinfo[i].rolname) == 0 && tinfo[i].isDefined)
write_msg(NULL, "WARNING: owner of data type \"%s\" appears to be invalid\n",
tinfo[i].dobj.name);
}
int i_oid;
int i_oprname;
int i_oprnamespace;
- int i_usename;
+ int i_rolname;
int i_oprcode;
/*
{
appendPQExpBuffer(query, "SELECT tableoid, oid, oprname, "
"oprnamespace, "
- "(select usename from pg_user where oprowner = usesysid) as usename, "
+ "(%s oprowner) as rolname, "
"oprcode::oid as oprcode "
- "FROM pg_operator");
+ "FROM pg_operator",
+ username_subquery);
}
else if (g_fout->remoteVersion >= 70100)
{
appendPQExpBuffer(query, "SELECT tableoid, oid, oprname, "
"0::oid as oprnamespace, "
- "(select usename from pg_user where oprowner = usesysid) as usename, "
+ "(%s oprowner) as rolname, "
"oprcode::oid as oprcode "
- "FROM pg_operator");
+ "FROM pg_operator",
+ username_subquery);
}
else
{
"(SELECT oid FROM pg_class WHERE relname = 'pg_operator') AS tableoid, "
"oid, oprname, "
"0::oid as oprnamespace, "
- "(select usename from pg_user where oprowner = usesysid) as usename, "
+ "(%s oprowner) as rolname, "
"oprcode::oid as oprcode "
- "FROM pg_operator");
+ "FROM pg_operator",
+ username_subquery);
}
res = PQexec(g_conn, query->data);
i_oid = PQfnumber(res, "oid");
i_oprname = PQfnumber(res, "oprname");
i_oprnamespace = PQfnumber(res, "oprnamespace");
- i_usename = PQfnumber(res, "usename");
+ i_rolname = PQfnumber(res, "rolname");
i_oprcode = PQfnumber(res, "oprcode");
for (i = 0; i < ntups; i++)
oprinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_oprname));
oprinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_oprnamespace)),
oprinfo[i].dobj.catId.oid);
- oprinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
+ oprinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname));
oprinfo[i].oprcode = atooid(PQgetvalue(res, i, i_oprcode));
- if (strlen(oprinfo[i].usename) == 0)
+ if (strlen(oprinfo[i].rolname) == 0)
write_msg(NULL, "WARNING: owner of operator \"%s\" appears to be invalid\n",
oprinfo[i].dobj.name);
}
int i_oid;
int i_conname;
int i_connamespace;
- int i_usename;
+ int i_rolname;
/* Conversions didn't exist pre-7.3 */
if (g_fout->remoteVersion < 70300)
appendPQExpBuffer(query, "SELECT tableoid, oid, conname, "
"connamespace, "
- "(select usename from pg_user where conowner = usesysid) as usename "
- "FROM pg_conversion");
+ "(%s conowner) as rolname "
+ "FROM pg_conversion",
+ username_subquery);
res = PQexec(g_conn, query->data);
check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
i_oid = PQfnumber(res, "oid");
i_conname = PQfnumber(res, "conname");
i_connamespace = PQfnumber(res, "connamespace");
- i_usename = PQfnumber(res, "usename");
+ i_rolname = PQfnumber(res, "rolname");
for (i = 0; i < ntups; i++)
{
convinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_conname));
convinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_connamespace)),
convinfo[i].dobj.catId.oid);
- convinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
+ convinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname));
}
PQclear(res);
int i_oid;
int i_opcname;
int i_opcnamespace;
- int i_usename;
+ int i_rolname;
/*
* find all opclasses, including builtin opclasses; we filter out
{
appendPQExpBuffer(query, "SELECT tableoid, oid, opcname, "
"opcnamespace, "
- "(select usename from pg_user where opcowner = usesysid) as usename "
- "FROM pg_opclass");
+ "(%s opcowner) as rolname "
+ "FROM pg_opclass",
+ username_subquery);
}
else if (g_fout->remoteVersion >= 70100)
{
appendPQExpBuffer(query, "SELECT tableoid, oid, opcname, "
"0::oid as opcnamespace, "
- "''::name as usename "
+ "''::name as rolname "
"FROM pg_opclass");
}
else
"(SELECT oid FROM pg_class WHERE relname = 'pg_opclass') AS tableoid, "
"oid, opcname, "
"0::oid as opcnamespace, "
- "''::name as usename "
+ "''::name as rolname "
"FROM pg_opclass");
}
i_oid = PQfnumber(res, "oid");
i_opcname = PQfnumber(res, "opcname");
i_opcnamespace = PQfnumber(res, "opcnamespace");
- i_usename = PQfnumber(res, "usename");
+ i_rolname = PQfnumber(res, "rolname");
for (i = 0; i < ntups; i++)
{
opcinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_opcname));
opcinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_opcnamespace)),
opcinfo[i].dobj.catId.oid);
- opcinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
+ opcinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname));
if (g_fout->remoteVersion >= 70300)
{
- if (strlen(opcinfo[i].usename) == 0)
+ if (strlen(opcinfo[i].rolname) == 0)
write_msg(NULL, "WARNING: owner of operator class \"%s\" appears to be invalid\n",
opcinfo[i].dobj.name);
}
int i_aggname;
int i_aggnamespace;
int i_aggbasetype;
- int i_usename;
+ int i_rolname;
int i_aggacl;
/* Make sure we are in proper schema */
appendPQExpBuffer(query, "SELECT tableoid, oid, proname as aggname, "
"pronamespace as aggnamespace, "
"proargtypes[0] as aggbasetype, "
- "(select usename from pg_user where proowner = usesysid) as usename, "
+ "(%s proowner) as rolname, "
"proacl as aggacl "
"FROM pg_proc "
"WHERE proisagg "
"AND pronamespace != "
- "(select oid from pg_namespace where nspname = 'pg_catalog')");
+ "(select oid from pg_namespace where nspname = 'pg_catalog')",
+ username_subquery);
}
else if (g_fout->remoteVersion >= 70100)
{
appendPQExpBuffer(query, "SELECT tableoid, oid, aggname, "
"0::oid as aggnamespace, "
"aggbasetype, "
- "(select usename from pg_user where aggowner = usesysid) as usename, "
+ "(%s aggowner) as rolname, "
"'{=X}' as aggacl "
"FROM pg_aggregate "
"where oid > '%u'::oid",
+ username_subquery,
g_last_builtin_oid);
}
else
"oid, aggname, "
"0::oid as aggnamespace, "
"aggbasetype, "
- "(select usename from pg_user where aggowner = usesysid) as usename, "
+ "(%s aggowner) as rolname, "
"'{=X}' as aggacl "
"FROM pg_aggregate "
"where oid > '%u'::oid",
+ username_subquery,
g_last_builtin_oid);
}
i_aggname = PQfnumber(res, "aggname");
i_aggnamespace = PQfnumber(res, "aggnamespace");
i_aggbasetype = PQfnumber(res, "aggbasetype");
- i_usename = PQfnumber(res, "usename");
+ i_rolname = PQfnumber(res, "rolname");
i_aggacl = PQfnumber(res, "aggacl");
for (i = 0; i < ntups; i++)
agginfo[i].aggfn.dobj.name = strdup(PQgetvalue(res, i, i_aggname));
agginfo[i].aggfn.dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_aggnamespace)),
agginfo[i].aggfn.dobj.catId.oid);
- agginfo[i].aggfn.usename = strdup(PQgetvalue(res, i, i_usename));
- if (strlen(agginfo[i].aggfn.usename) == 0)
+ agginfo[i].aggfn.rolname = strdup(PQgetvalue(res, i, i_rolname));
+ if (strlen(agginfo[i].aggfn.rolname) == 0)
write_msg(NULL, "WARNING: owner of aggregate function \"%s\" appears to be invalid\n",
agginfo[i].aggfn.dobj.name);
agginfo[i].aggfn.lang = InvalidOid; /* not currently
int i_oid;
int i_proname;
int i_pronamespace;
- int i_usename;
+ int i_rolname;
int i_prolang;
int i_pronargs;
int i_proargtypes;
"SELECT tableoid, oid, proname, prolang, "
"pronargs, proargtypes, prorettype, proacl, "
"pronamespace, "
- "(select usename from pg_user "
- " where proowner = usesysid) as usename, "
+ "(%s proowner) as rolname, "
"CASE WHEN oid IN "
" (select lanplcallfoid from pg_language "
" where lanplcallfoid != 0) THEN true "
" where lanplcallfoid != 0) "
" OR oid IN "
" (select lanvalidator from pg_language "
- " where lanplcallfoid != 0))"
- );
+ " where lanplcallfoid != 0))",
+ username_subquery);
}
else if (g_fout->remoteVersion >= 70100)
{
"pronargs, proargtypes, prorettype, "
"'{=X}' as proacl, "
"0::oid as pronamespace, "
- "(select usename from pg_user "
- " where proowner = usesysid) as usename, "
+ "(%s proowner) as rolname, "
"false AS is_pl_handler "
"FROM pg_proc "
"where pg_proc.oid > '%u'::oid",
+ username_subquery,
g_last_builtin_oid);
}
else
"pronargs, proargtypes, prorettype, "
"'{=X}' as proacl, "
"0::oid as pronamespace, "
- "(select usename from pg_user "
- " where proowner = usesysid) as usename, "
+ "(%s proowner) as rolname, "
"false AS is_pl_handler "
"FROM pg_proc "
"where pg_proc.oid > '%u'::oid",
+ username_subquery,
g_last_builtin_oid);
}
i_oid = PQfnumber(res, "oid");
i_proname = PQfnumber(res, "proname");
i_pronamespace = PQfnumber(res, "pronamespace");
- i_usename = PQfnumber(res, "usename");
+ i_rolname = PQfnumber(res, "rolname");
i_prolang = PQfnumber(res, "prolang");
i_pronargs = PQfnumber(res, "pronargs");
i_proargtypes = PQfnumber(res, "proargtypes");
finfo[i].dobj.namespace =
findNamespace(atooid(PQgetvalue(res, i, i_pronamespace)),
finfo[i].dobj.catId.oid);
- finfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
+ finfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname));
finfo[i].lang = atooid(PQgetvalue(res, i, i_prolang));
finfo[i].prorettype = atooid(PQgetvalue(res, i, i_prorettype));
finfo[i].proacl = strdup(PQgetvalue(res, i, i_proacl));
finfo[i].argtypes, finfo[i].nargs);
}
- if (strlen(finfo[i].usename) == 0)
+ if (strlen(finfo[i].rolname) == 0)
write_msg(NULL,
"WARNING: owner of function \"%s\" appears to be invalid\n",
finfo[i].dobj.name);
int i_relnamespace;
int i_relkind;
int i_relacl;
- int i_usename;
+ int i_rolname;
int i_relchecks;
int i_reltriggers;
int i_relhasindex;
appendPQExpBuffer(query,
"SELECT c.tableoid, c.oid, relname, "
"relacl, relkind, relnamespace, "
- "(select usename from pg_user where relowner = usesysid) as usename, "
+ "(%s relowner) as rolname, "
"relchecks, reltriggers, "
"relhasindex, relhasrules, relhasoids, "
"d.refobjid as owning_tab, "
"d.refclassid = c.tableoid and d.deptype = 'i') "
"where relkind in ('%c', '%c', '%c', '%c') "
"order by c.oid",
+ username_subquery,
RELKIND_SEQUENCE,
RELKIND_RELATION, RELKIND_SEQUENCE,
RELKIND_VIEW, RELKIND_COMPOSITE_TYPE);
appendPQExpBuffer(query,
"SELECT c.tableoid, c.oid, relname, "
"relacl, relkind, relnamespace, "
- "(select usename from pg_user where relowner = usesysid) as usename, "
+ "(%s relowner) as rolname, "
"relchecks, reltriggers, "
"relhasindex, relhasrules, relhasoids, "
"d.refobjid as owning_tab, "
"d.refclassid = c.tableoid and d.deptype = 'i') "
"where relkind in ('%c', '%c', '%c', '%c') "
"order by c.oid",
+ username_subquery,
RELKIND_SEQUENCE,
RELKIND_RELATION, RELKIND_SEQUENCE,
RELKIND_VIEW, RELKIND_COMPOSITE_TYPE);
appendPQExpBuffer(query,
"SELECT tableoid, oid, relname, relacl, relkind, "
"0::oid as relnamespace, "
- "(select usename from pg_user where relowner = usesysid) as usename, "
+ "(%s relowner) as rolname, "
"relchecks, reltriggers, "
"relhasindex, relhasrules, relhasoids, "
"NULL::oid as owning_tab, "
"from pg_class "
"where relkind in ('%c', '%c', '%c') "
"order by oid",
- RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
+ username_subquery,
+ RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
}
else if (g_fout->remoteVersion >= 70100)
{
appendPQExpBuffer(query,
"SELECT tableoid, oid, relname, relacl, relkind, "
"0::oid as relnamespace, "
- "(select usename from pg_user where relowner = usesysid) as usename, "
+ "(%s relowner) as rolname, "
"relchecks, reltriggers, "
"relhasindex, relhasrules, "
"'t'::bool as relhasoids, "
"from pg_class "
"where relkind in ('%c', '%c', '%c') "
"order by oid",
- RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
+ username_subquery,
+ RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
}
else
{
"THEN '%c'::\"char\" "
"ELSE relkind END AS relkind,"
"0::oid as relnamespace, "
- "(select usename from pg_user where relowner = usesysid) as usename, "
+ "(%s relowner) as rolname, "
"relchecks, reltriggers, "
"relhasindex, relhasrules, "
"'t'::bool as relhasoids, "
"where relkind in ('%c', '%c') "
"order by oid",
RELKIND_VIEW,
+ username_subquery,
RELKIND_RELATION, RELKIND_SEQUENCE);
}
i_relnamespace = PQfnumber(res, "relnamespace");
i_relacl = PQfnumber(res, "relacl");
i_relkind = PQfnumber(res, "relkind");
- i_usename = PQfnumber(res, "usename");
+ i_rolname = PQfnumber(res, "rolname");
i_relchecks = PQfnumber(res, "relchecks");
i_reltriggers = PQfnumber(res, "reltriggers");
i_relhasindex = PQfnumber(res, "relhasindex");
tblinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_relname));
tblinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_relnamespace)),
tblinfo[i].dobj.catId.oid);
- tblinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
+ tblinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname));
tblinfo[i].relacl = strdup(PQgetvalue(res, i, i_relacl));
tblinfo[i].relkind = *(PQgetvalue(res, i, i_relkind));
tblinfo[i].hasindex = (strcmp(PQgetvalue(res, i, i_relhasindex), "t") == 0);
}
/* Emit notice if join for owner failed */
- if (strlen(tblinfo[i].usename) == 0)
+ if (strlen(tblinfo[i].rolname) == 0)
write_msg(NULL, "WARNING: owner of table \"%s\" appears to be invalid\n",
tblinfo[i].dobj.name);
}
target->data,
tbinfo->dobj.namespace->dobj.name,
NULL,
- tbinfo->usename,
+ tbinfo->rolname,
false, "COMMENT", query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
target->data,
tbinfo->dobj.namespace->dobj.name,
NULL,
- tbinfo->usename,
+ tbinfo->rolname,
false, "COMMENT", query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId,
nspinfo->dobj.name,
NULL, NULL,
- nspinfo->usename,
+ nspinfo->rolname,
false, "SCHEMA", q->data, delq->data, NULL,
nspinfo->dobj.dependencies, nspinfo->dobj.nDeps,
NULL, NULL);
resetPQExpBuffer(q);
appendPQExpBuffer(q, "SCHEMA %s", qnspname);
dumpComment(fout, q->data,
- NULL, nspinfo->usename,
+ NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
dumpACL(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA",
qnspname, nspinfo->dobj.name, NULL,
- nspinfo->usename, nspinfo->nspacl);
+ nspinfo->rolname, nspinfo->nspacl);
free(qnspname);
tinfo->dobj.name,
tinfo->dobj.namespace->dobj.name,
NULL,
- tinfo->usename, false,
+ tinfo->rolname, false,
"TYPE", q->data, delq->data, NULL,
tinfo->dobj.dependencies, tinfo->dobj.nDeps,
NULL, NULL);
appendPQExpBuffer(q, "TYPE %s", fmtId(tinfo->dobj.name));
dumpComment(fout, q->data,
- tinfo->dobj.namespace->dobj.name, tinfo->usename,
+ tinfo->dobj.namespace->dobj.name, tinfo->rolname,
tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
PQclear(res);
tinfo->dobj.name,
tinfo->dobj.namespace->dobj.name,
NULL,
- tinfo->usename, false,
+ tinfo->rolname, false,
"DOMAIN", q->data, delq->data, NULL,
tinfo->dobj.dependencies, tinfo->dobj.nDeps,
NULL, NULL);
appendPQExpBuffer(q, "DOMAIN %s", fmtId(tinfo->dobj.name));
dumpComment(fout, q->data,
- tinfo->dobj.namespace->dobj.name, tinfo->usename,
+ tinfo->dobj.namespace->dobj.name, tinfo->rolname,
tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
destroyPQExpBuffer(q);
tinfo->dobj.name,
tinfo->dobj.namespace->dobj.name,
NULL,
- tinfo->usename, false,
+ tinfo->rolname, false,
"TYPE", q->data, delq->data, NULL,
tinfo->dobj.dependencies, tinfo->dobj.nDeps,
NULL, NULL);
appendPQExpBuffer(q, "TYPE %s", fmtId(tinfo->dobj.name));
dumpComment(fout, q->data,
- tinfo->dobj.namespace->dobj.name, tinfo->usename,
+ tinfo->dobj.namespace->dobj.name, tinfo->rolname,
tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
PQclear(res);
funcsig_tag,
finfo->dobj.namespace->dobj.name,
NULL,
- finfo->usename, false,
+ finfo->rolname, false,
"FUNCTION", q->data, delqry->data, NULL,
finfo->dobj.dependencies, finfo->dobj.nDeps,
NULL, NULL);
resetPQExpBuffer(q);
appendPQExpBuffer(q, "FUNCTION %s", funcsig);
dumpComment(fout, q->data,
- finfo->dobj.namespace->dobj.name, finfo->usename,
+ finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
dumpACL(fout, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION",
funcsig, funcsig_tag,
finfo->dobj.namespace->dobj.name,
- finfo->usename, finfo->proacl);
+ finfo->rolname, finfo->proacl);
PQclear(res);
oprinfo->dobj.name,
oprinfo->dobj.namespace->dobj.name,
NULL,
- oprinfo->usename,
+ oprinfo->rolname,
false, "OPERATOR", q->data, delq->data, NULL,
oprinfo->dobj.dependencies, oprinfo->dobj.nDeps,
NULL, NULL);
resetPQExpBuffer(q);
appendPQExpBuffer(q, "OPERATOR %s", oprid->data);
dumpComment(fout, q->data,
- oprinfo->dobj.namespace->dobj.name, oprinfo->usename,
+ oprinfo->dobj.namespace->dobj.name, oprinfo->rolname,
oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId);
PQclear(res);
opcinfo->dobj.name,
opcinfo->dobj.namespace->dobj.name,
NULL,
- opcinfo->usename,
+ opcinfo->rolname,
false, "OPERATOR CLASS", q->data, delq->data, NULL,
opcinfo->dobj.dependencies, opcinfo->dobj.nDeps,
NULL, NULL);
appendPQExpBuffer(q, " USING %s",
fmtId(amname));
dumpComment(fout, q->data,
- NULL, opcinfo->usename,
+ NULL, opcinfo->rolname,
opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId);
free(amname);
convinfo->dobj.name,
convinfo->dobj.namespace->dobj.name,
NULL,
- convinfo->usename,
+ convinfo->rolname,
false, "CONVERSION", q->data, delq->data, NULL,
convinfo->dobj.dependencies, convinfo->dobj.nDeps,
NULL, NULL);
resetPQExpBuffer(q);
appendPQExpBuffer(q, "CONVERSION %s", fmtId(convinfo->dobj.name));
dumpComment(fout, q->data,
- convinfo->dobj.namespace->dobj.name, convinfo->usename,
+ convinfo->dobj.namespace->dobj.name, convinfo->rolname,
convinfo->dobj.catId, 0, convinfo->dobj.dumpId);
PQclear(res);
aggsig_tag,
agginfo->aggfn.dobj.namespace->dobj.name,
NULL,
- agginfo->aggfn.usename,
+ agginfo->aggfn.rolname,
false, "AGGREGATE", q->data, delq->data, NULL,
agginfo->aggfn.dobj.dependencies, agginfo->aggfn.dobj.nDeps,
NULL, NULL);
resetPQExpBuffer(q);
appendPQExpBuffer(q, "AGGREGATE %s", aggsig);
dumpComment(fout, q->data,
- agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
+ agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
/*
"FUNCTION",
aggsig, aggsig_tag,
agginfo->aggfn.dobj.namespace->dobj.name,
- agginfo->aggfn.usename, agginfo->aggfn.proacl);
+ agginfo->aggfn.rolname, agginfo->aggfn.proacl);
free(aggsig);
free(aggsig_tag);
namecopy = strdup(fmtId(tbinfo->dobj.name));
dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE",
namecopy, tbinfo->dobj.name,
- tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->relacl);
free(namecopy);
}
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
(tbinfo->relkind == RELKIND_VIEW) ? NULL : tbinfo->reltablespace,
- tbinfo->usename,
+ tbinfo->rolname,
(strcmp(reltypename, "TABLE") == 0) ? tbinfo->hasoids : false,
reltypename, q->data, delq->data, NULL,
tbinfo->dobj.dependencies, tbinfo->dobj.nDeps,
tbinfo->attnames[adnum - 1],
tbinfo->dobj.namespace->dobj.name,
NULL,
- tbinfo->usename,
+ tbinfo->rolname,
false, "DEFAULT", q->data, delq->data, NULL,
adinfo->dobj.dependencies, adinfo->dobj.nDeps,
NULL, NULL);
indxinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
indxinfo->tablespace,
- tbinfo->usename, false,
+ tbinfo->rolname, false,
"INDEX", q->data, delq->data, NULL,
indxinfo->dobj.dependencies, indxinfo->dobj.nDeps,
NULL, NULL);
fmtId(indxinfo->dobj.name));
dumpComment(fout, q->data,
tbinfo->dobj.namespace->dobj.name,
- tbinfo->usename,
+ tbinfo->rolname,
indxinfo->dobj.catId, 0, indxinfo->dobj.dumpId);
destroyPQExpBuffer(q);
coninfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
indxinfo->tablespace,
- tbinfo->usename, false,
+ tbinfo->rolname, false,
"CONSTRAINT", q->data, delq->data, NULL,
coninfo->dobj.dependencies, coninfo->dobj.nDeps,
NULL, NULL);
coninfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
NULL,
- tbinfo->usename, false,
+ tbinfo->rolname, false,
"FK CONSTRAINT", q->data, delq->data, NULL,
coninfo->dobj.dependencies, coninfo->dobj.nDeps,
NULL, NULL);
coninfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
NULL,
- tbinfo->usename, false,
+ tbinfo->rolname, false,
"CHECK CONSTRAINT", q->data, delq->data, NULL,
coninfo->dobj.dependencies, coninfo->dobj.nDeps,
NULL, NULL);
coninfo->dobj.name,
tinfo->dobj.namespace->dobj.name,
NULL,
- tinfo->usename, false,
+ tinfo->rolname, false,
"CHECK CONSTRAINT", q->data, delq->data, NULL,
coninfo->dobj.dependencies, coninfo->dobj.nDeps,
NULL, NULL);
fmtId(tbinfo->dobj.name));
dumpComment(fout, q->data,
tbinfo->dobj.namespace->dobj.name,
- tbinfo->usename,
+ tbinfo->rolname,
coninfo->dobj.catId, 0,
coninfo->separate ? coninfo->dobj.dumpId : tbinfo->dobj.dumpId);
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
NULL,
- tbinfo->usename,
+ tbinfo->rolname,
false, "SEQUENCE", query->data, delqry->data, NULL,
tbinfo->dobj.dependencies, tbinfo->dobj.nDeps,
NULL, NULL);
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
NULL,
- tbinfo->usename,
+ tbinfo->rolname,
false, "SEQUENCE SET", query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
resetPQExpBuffer(query);
appendPQExpBuffer(query, "SEQUENCE %s", fmtId(tbinfo->dobj.name));
dumpComment(fout, query->data,
- tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
}
tginfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
NULL,
- tbinfo->usename, false,
+ tbinfo->rolname, false,
"TRIGGER", query->data, delqry->data, NULL,
tginfo->dobj.dependencies, tginfo->dobj.nDeps,
NULL, NULL);
fmtId(tbinfo->dobj.name));
dumpComment(fout, query->data,
- tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
+ tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tginfo->dobj.catId, 0, tginfo->dobj.dumpId);
destroyPQExpBuffer(query);
rinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
NULL,
- tbinfo->usename, false,
+ tbinfo->rolname, false,
"RULE", cmd->data, delcmd->data, NULL,
rinfo->dobj.dependencies, rinfo->dobj.nDeps,
NULL, NULL);
fmtId(tbinfo->dobj.name));
dumpComment(fout, query->data,
tbinfo->dobj.namespace->dobj.name,
- tbinfo->usename,
+ tbinfo->rolname,
rinfo->dobj.catId, 0, rinfo->dobj.dumpId);
PQclear(res);