i_rolpassword,
i_rolvaliduntil,
i_rolreplication,
- i_rolcomment;
+ i_rolcomment,
+ i_is_current_user;
int i;
/* note: rolconfig is dumped later */
"rolcreaterole, rolcreatedb, "
"rolcanlogin, rolconnlimit, rolpassword, "
"rolvaliduntil, rolreplication, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment "
+ "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
+ "rolname = current_user AS is_current_user "
"FROM pg_authid "
"ORDER BY 2");
else if (server_version >= 80200)
"rolcreaterole, rolcreatedb, "
"rolcanlogin, rolconnlimit, rolpassword, "
"rolvaliduntil, false as rolreplication, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment "
+ "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
+ "rolname = current_user AS is_current_user "
"FROM pg_authid "
"ORDER BY 2");
else if (server_version >= 80100)
"rolcreaterole, rolcreatedb, "
"rolcanlogin, rolconnlimit, rolpassword, "
"rolvaliduntil, false as rolreplication, "
- "null as rolcomment "
+ "null as rolcomment, "
+ "rolname = current_user AS is_current_user "
"FROM pg_authid "
"ORDER BY 2");
else
"passwd as rolpassword, "
"valuntil as rolvaliduntil, "
"false as rolreplication, "
- "null as rolcomment "
+ "null as rolcomment, "
+ "rolname = current_user AS is_current_user "
"FROM pg_shadow "
"UNION ALL "
"SELECT 0, groname as rolname, "
"null::text as rolpassword, "
"null::abstime as rolvaliduntil, "
"false as rolreplication, "
- "null as rolcomment "
+ "null as rolcomment, false "
"FROM pg_group "
"WHERE NOT EXISTS (SELECT 1 FROM pg_shadow "
" WHERE usename = groname) "
i_rolvaliduntil = PQfnumber(res, "rolvaliduntil");
i_rolreplication = PQfnumber(res, "rolreplication");
i_rolcomment = PQfnumber(res, "rolcomment");
+ i_is_current_user = PQfnumber(res, "is_current_user");
if (PQntuples(res) > 0)
fprintf(OPF, "--\n-- Roles\n--\n\n");
* won't hurt for the CREATE to fail). This is particularly important
* for the role we are connected as, since even with --clean we will
* have failed to drop it. binary_upgrade cannot generate any errors,
- * so we assume the role is already created.
+ * so we assume the current role is already created.
*/
- if (!binary_upgrade)
+ if (!binary_upgrade ||
+ strcmp(PQgetvalue(res, i, i_is_current_user), "f") == 0)
appendPQExpBuffer(buf, "CREATE ROLE %s;\n", fmtId(rolename));
appendPQExpBuffer(buf, "ALTER ROLE %s WITH", fmtId(rolename));