@@ -114,6 +114,13 @@ bool isGPbackend;
114114
115115/* END MPP ADDITION */
116116
117+ /* subquery used to convert user ID (eg, datdba) to user name */
118+ static const char *username_subquery;
119+
120+ /*
121+ * For 8.0 and earlier servers, pulled from pg_database, for 8.1+ we use
122+ * FirstNormalObjectId - 1.
123+ */
117124static Oid g_last_builtin_oid; /* value of the last builtin oid */
118125
119126/* The specified names/patterns should to match at least one entity */
@@ -1000,6 +1007,8 @@ main(int argc, char **argv)
10001007 if (fout->isStandby)
10011008 dopt.no_unlogged_table_data = true;
10021009
1010+ username_subquery = "SELECT rolname FROM pg_catalog.pg_roles WHERE oid =";
1011+
10031012 /*
10041013 * Remember whether or not this GP database supports partitioning.
10051014 */
@@ -6434,11 +6443,11 @@ getTypeStorageOptions(Archive *fout, int *numTypes)
64346443 "t.tableoid as tableoid, "
64356444 "t.oid AS oid, "
64366445 "t.typnamespace AS typnamespace, "
6437- "typowner, "
6446+ "(%s typowner) as rolname , "
64386447 "array_to_string(a.typoptions, ', ') AS typoptions "
64396448 "FROM pg_type t "
64406449 "JOIN pg_catalog.pg_type_encoding a ON a.typid = t.oid "
6441- "WHERE t.typisdefined = 't'");
6450+ "WHERE t.typisdefined = 't'", username_subquery );
64426451
64436452 res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
64446453
@@ -7059,9 +7068,7 @@ getExtProtocols(Archive *fout, int *numExtProtocols)
70597068 int i_ptcname;
70607069 int i_rolname;
70617070 int i_ptcacl;
7062- int i_ptcracl;
7063- int i_ptcinitacl;
7064- int i_ptcinitracl;
7071+ int i_acldefault;
70657072 int i_ptctrusted;
70667073 int i_ptcreadid;
70677074 int i_ptcwriteid;
@@ -7079,7 +7086,9 @@ getExtProtocols(Archive *fout, int *numExtProtocols)
70797086 " ptcwritefn as ptcwriteoid, "
70807087 " ptcvalidatorfn as ptcvaloid, "
70817088 " ptcowner, "
7082- " ptc.ptctrusted as ptctrusted "
7089+ " ptc.ptctrusted as ptctrusted, "
7090+ " ptc.ptcacl as ptcacl, "
7091+ "acldefault('T', ptcowner) AS acldefault "
70837092 "FROM pg_extprotocol ptc "
70847093 "LEFT JOIN pg_init_privs pip ON "
70857094 " (ptc.oid = pip.objoid "
@@ -7113,11 +7122,9 @@ getExtProtocols(Archive *fout, int *numExtProtocols)
71137122 i_tableoid = PQfnumber(res, "tableoid");
71147123 i_oid = PQfnumber(res, "oid");
71157124 i_ptcname = PQfnumber(res, "ptcname");
7116- i_rolname = PQfnumber(res, "rolname ");
7125+ i_rolname = PQfnumber(res, "ptcowner ");
71177126 i_ptcacl = PQfnumber(res, "ptcacl");
7118- i_ptcracl = PQfnumber(res, "ptcracl");
7119- i_ptcinitacl = PQfnumber(res, "ptcinitacl");
7120- i_ptcinitracl = PQfnumber(res, "ptcinitracl");
7127+ i_acldefault = PQfnumber(res, "acldefault");
71217128 i_ptctrusted = PQfnumber(res, "ptctrusted");
71227129 i_ptcreadid = PQfnumber(res, "ptcreadoid");
71237130 i_ptcwriteid = PQfnumber(res, "ptcwriteoid");
@@ -7151,10 +7158,8 @@ getExtProtocols(Archive *fout, int *numExtProtocols)
71517158 else
71527159 ptcinfo[i].ptcvalidid = atooid(PQgetvalue(res, i, i_ptcvalidid));
71537160
7154- ptcinfo[i].ptcacl = pg_strdup(PQgetvalue(res, i, i_ptcacl));
7155- ptcinfo[i].rproacl = pg_strdup(PQgetvalue(res, i, i_ptcracl));
7156- ptcinfo[i].initproacl = pg_strdup(PQgetvalue(res, i, i_ptcinitacl));
7157- ptcinfo[i].initrproacl = pg_strdup(PQgetvalue(res, i, i_ptcinitracl));
7161+ ptcinfo[i].pacl.acl = pg_strdup(PQgetvalue(res, i, i_ptcacl));
7162+ ptcinfo[i].pacl.acldefault = pg_strdup(PQgetvalue(res, i, i_acldefault));
71587163 ptcinfo[i].ptctrusted = *(PQgetvalue(res, i, i_ptctrusted)) == 't';
71597164
71607165 /* Decide whether we want to dump it */
@@ -15422,7 +15427,6 @@ dumpExtProtocol(Archive *fout, const ExtProtInfo *ptcinfo)
1542215427 char *namecopy;
1542315428 int i;
1542415429 bool has_internal = false;
15425- DumpableAcl dbdacl;
1542615430
1542715431 /* Skip if not to be dumped */
1542815432 if (!ptcinfo->dobj.dump || fout->dopt->dataOnly)
@@ -15558,15 +15562,11 @@ dumpExtProtocol(Archive *fout, const ExtProtInfo *ptcinfo)
1555815562
1555915563 /* Handle the ACL */
1556015564 namecopy = pg_strdup(fmtId(ptcinfo->dobj.name));
15561- dbdacl.acl = ptcinfo->ptcacl;
15562- dbdacl.acldefault = ptcinfo->rproacl;
15563- dbdacl.privtype = 0;
15564- dbdacl.initprivs = NULL;
1556515565 dumpACL(fout, ptcinfo->dobj.dumpId, InvalidDumpId,
1556615566 "PROTOCOL",
1556715567 namecopy, NULL,
1556815568 NULL, ptcinfo->ptcowner,
15569- &dbdacl );
15569+ &ptcinfo->pacl );
1557015570 free(namecopy);
1557115571
1557215572 destroyPQExpBuffer(q);
0 commit comments