Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf3cc978

Browse files
committed
Add AUTHOID portability
1 parent28dc32c commitf3cc978

File tree

5 files changed

+57
-3
lines changed

5 files changed

+57
-3
lines changed

‎contrib/postgres_fdw/connection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ configure_remote_session(PGconn *conn)
323323
* Temporarily switch off this option. Not all regression tests passes
324324
* correctly without including 'public' value in default search path.
325325
*/
326-
do_sql_command(conn,"SET search_path = pg_catalog");
326+
/*do_sql_command(conn, "SET search_path = pg_catalog"); */
327327

328328
/*
329329
* Set remote timezone; this is basically just cosmetic, since all

‎src/backend/commands/user.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,41 @@ DropRole(DropRoleStmt *stmt)
11301130
heap_close(pg_authid_rel,NoLock);
11311131
}
11321132

1133+
char*
1134+
get_rolename(Oidroleid)
1135+
{
1136+
HeapTupletuple;
1137+
char*rolename;
1138+
1139+
tuple=SearchSysCache1(AUTHOID,ObjectIdGetDatum(roleid));
1140+
1141+
if (!HeapTupleIsValid(tuple))
1142+
ereport(ERROR,
1143+
(errcode(ERRCODE_UNDEFINED_OBJECT),
1144+
errmsg("role with oid\"%d\" does not exist",roleid)));
1145+
1146+
rolename=strdup(NameStr(((Form_pg_authid)GETSTRUCT(tuple))->rolname));
1147+
ReleaseSysCache(tuple);
1148+
returnrolename;
1149+
}
1150+
1151+
Oid
1152+
get_roleid(constchar*rolename)
1153+
{
1154+
HeapTupletuple;
1155+
Oidroleid;
1156+
1157+
tuple=SearchSysCache1(AUTHNAME,CStringGetDatum(rolename));
1158+
1159+
if (!HeapTupleIsValid(tuple))
1160+
ereport(ERROR,
1161+
(errcode(ERRCODE_UNDEFINED_OBJECT),
1162+
errmsg("role \"%s\" does not exist",rolename)));
1163+
1164+
roleid=HeapTupleGetOid(tuple);
1165+
ReleaseSysCache(tuple);
1166+
returnroleid;
1167+
}
11331168
/*
11341169
* Rename role
11351170
*/

‎src/backend/nodes/outfuncs.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include<ctype.h>
2727

28+
#include"commands/user.h"
2829
#include"lib/stringinfo.h"
2930
#include"nodes/extensible.h"
3031
#include"nodes/plannodes.h"
@@ -35,8 +36,9 @@
3536
#include"utils/syscache.h"
3637

3738
#defineNSP_NAME(nspoid) (get_namespace_name(nspoid))
38-
#defineOID_TYPES_NUM(5)
39-
staticconstOidoid_types[OID_TYPES_NUM]= {RELOID,TYPEOID,PROCOID,COLLOID,OPEROID};
39+
#defineOID_TYPES_NUM(6)
40+
staticconstOidoid_types[OID_TYPES_NUM]= {RELOID,TYPEOID,PROCOID,COLLOID,
41+
OPEROID,AUTHOID};
4042

4143
staticboolportable_output= false;
4244
void
@@ -141,6 +143,10 @@ write_oid_field(StringInfo str, Oid oid)
141143
}
142144
break;
143145

146+
caseAUTHOID:
147+
appendStringInfo(str,"%u %s",AUTHOID,get_rolename(oid));
148+
break;
149+
144150
default:
145151
Assert(0);
146152
break;

‎src/backend/nodes/readfuncs.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
/* Portable-related dependencies */
3838
#include"catalog/namespace.h"
39+
#include"commands/user.h"
3940
#include"utils/builtins.h"
4041
#include"utils/lsyscache.h"
4142
#include"utils/syscache.h"
@@ -2896,6 +2897,16 @@ read_oid_field(char **token, int *length)
28962897
}
28972898
break;
28982899

2900+
caseAUTHOID:
2901+
{
2902+
char*rolename;
2903+
2904+
*token=pg_strtok(length);/* get nspname */
2905+
rolename=nullable_string(*token,*length);
2906+
oid=get_roleid(rolename);
2907+
}
2908+
break;
2909+
28992910
default:
29002911
Assert(0);
29012912
break;

‎src/include/commands/user.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,7 @@ extern ObjectAddress RenameRole(const char *oldname, const char *newname);
4242
externvoidDropOwnedObjects(DropOwnedStmt*stmt);
4343
externvoidReassignOwnedObjects(ReassignOwnedStmt*stmt);
4444
externList*roleSpecsToIds(List*memberNames);
45+
externchar*get_rolename(Oidroid);
46+
externOidget_roleid(constchar*rolename);
4547

4648
#endif/* USER_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp