Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
ca43f71c
Commit
ca43f71c
authored
Sep 04, 2003
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid consuming unreasonable amounts of memory when GRANT has many
grantees.
parent
fe055e92
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
src/backend/catalog/aclchk.c
src/backend/catalog/aclchk.c
+14
-12
No files found.
src/backend/catalog/aclchk.c
View file @
ca43f71c
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.8
7 2003/08/04 02:39:58 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.8
8 2003/09/04 15:53:04 tgl
Exp $
*
*
* NOTES
* NOTES
* See acl.h.
* See acl.h.
...
@@ -72,6 +72,8 @@ dumpacl(Acl *acl)
...
@@ -72,6 +72,8 @@ dumpacl(Acl *acl)
* If is_grant is true, adds the given privileges for the list of
* If is_grant is true, adds the given privileges for the list of
* grantees to the existing old_acl. If is_grant is false, the
* grantees to the existing old_acl. If is_grant is false, the
* privileges for the given grantees are removed from old_acl.
* privileges for the given grantees are removed from old_acl.
*
* NB: the original old_acl is pfree'd.
*/
*/
static
Acl
*
static
Acl
*
merge_acl_with_grant
(
Acl
*
old_acl
,
bool
is_grant
,
merge_acl_with_grant
(
Acl
*
old_acl
,
bool
is_grant
,
...
@@ -94,22 +96,23 @@ merge_acl_with_grant(Acl *old_acl, bool is_grant,
...
@@ -94,22 +96,23 @@ merge_acl_with_grant(Acl *old_acl, bool is_grant,
PrivGrantee
*
grantee
=
(
PrivGrantee
*
)
lfirst
(
j
);
PrivGrantee
*
grantee
=
(
PrivGrantee
*
)
lfirst
(
j
);
AclItem
aclitem
;
AclItem
aclitem
;
uint32
idtype
;
uint32
idtype
;
Acl
*
newer_acl
;
if
(
grantee
->
username
)
if
(
grantee
->
username
)
{
{
aclitem
.
ai_grantee
=
get_usesysid
(
grantee
->
username
);
aclitem
.
ai_grantee
=
get_usesysid
(
grantee
->
username
);
idtype
=
ACL_IDTYPE_UID
;
idtype
=
ACL_IDTYPE_UID
;
}
}
else
if
(
grantee
->
groupname
)
else
if
(
grantee
->
groupname
)
{
{
aclitem
.
ai_grantee
=
get_grosysid
(
grantee
->
groupname
);
aclitem
.
ai_grantee
=
get_grosysid
(
grantee
->
groupname
);
idtype
=
ACL_IDTYPE_GID
;
idtype
=
ACL_IDTYPE_GID
;
}
}
else
else
{
{
aclitem
.
ai_grantee
=
ACL_ID_WORLD
;
aclitem
.
ai_grantee
=
ACL_ID_WORLD
;
idtype
=
ACL_IDTYPE_WORLD
;
idtype
=
ACL_IDTYPE_WORLD
;
}
}
...
@@ -126,14 +129,18 @@ merge_acl_with_grant(Acl *old_acl, bool is_grant,
...
@@ -126,14 +129,18 @@ merge_acl_with_grant(Acl *old_acl, bool is_grant,
(
errcode
(
ERRCODE_INVALID_GRANT_OPERATION
),
(
errcode
(
ERRCODE_INVALID_GRANT_OPERATION
),
errmsg
(
"grant options can only be granted to individual users"
)));
errmsg
(
"grant options can only be granted to individual users"
)));
aclitem
.
ai_grantor
=
GetUserId
();
aclitem
.
ai_grantor
=
GetUserId
();
ACLITEM_SET_PRIVS_IDTYPE
(
aclitem
,
ACLITEM_SET_PRIVS_IDTYPE
(
aclitem
,
(
is_grant
||
!
grant_option
)
?
privileges
:
ACL_NO_RIGHTS
,
(
is_grant
||
!
grant_option
)
?
privileges
:
ACL_NO_RIGHTS
,
(
grant_option
||
!
is_grant
)
?
privileges
:
ACL_NO_RIGHTS
,
(
grant_option
||
!
is_grant
)
?
privileges
:
ACL_NO_RIGHTS
,
idtype
);
idtype
);
new_acl
=
aclinsert3
(
new_acl
,
&
aclitem
,
modechg
,
behavior
);
newer_acl
=
aclinsert3
(
new_acl
,
&
aclitem
,
modechg
,
behavior
);
/* avoid memory leak when there are many grantees */
pfree
(
new_acl
);
new_acl
=
newer_acl
;
#ifdef ACLDEBUG
#ifdef ACLDEBUG
dumpacl
(
new_acl
);
dumpacl
(
new_acl
);
...
@@ -269,7 +276,6 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt)
...
@@ -269,7 +276,6 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt)
/* keep the catalog indexes up to date */
/* keep the catalog indexes up to date */
CatalogUpdateIndexes
(
relation
,
newtuple
);
CatalogUpdateIndexes
(
relation
,
newtuple
);
pfree
(
old_acl
);
pfree
(
new_acl
);
pfree
(
new_acl
);
heap_close
(
relation
,
RowExclusiveLock
);
heap_close
(
relation
,
RowExclusiveLock
);
...
@@ -366,7 +372,6 @@ ExecuteGrantStmt_Database(GrantStmt *stmt)
...
@@ -366,7 +372,6 @@ ExecuteGrantStmt_Database(GrantStmt *stmt)
/* keep the catalog indexes up to date */
/* keep the catalog indexes up to date */
CatalogUpdateIndexes
(
relation
,
newtuple
);
CatalogUpdateIndexes
(
relation
,
newtuple
);
pfree
(
old_acl
);
pfree
(
new_acl
);
pfree
(
new_acl
);
heap_endscan
(
scan
);
heap_endscan
(
scan
);
...
@@ -465,7 +470,6 @@ ExecuteGrantStmt_Function(GrantStmt *stmt)
...
@@ -465,7 +470,6 @@ ExecuteGrantStmt_Function(GrantStmt *stmt)
/* keep the catalog indexes up to date */
/* keep the catalog indexes up to date */
CatalogUpdateIndexes
(
relation
,
newtuple
);
CatalogUpdateIndexes
(
relation
,
newtuple
);
pfree
(
old_acl
);
pfree
(
new_acl
);
pfree
(
new_acl
);
heap_close
(
relation
,
RowExclusiveLock
);
heap_close
(
relation
,
RowExclusiveLock
);
...
@@ -565,7 +569,6 @@ ExecuteGrantStmt_Language(GrantStmt *stmt)
...
@@ -565,7 +569,6 @@ ExecuteGrantStmt_Language(GrantStmt *stmt)
/* keep the catalog indexes up to date */
/* keep the catalog indexes up to date */
CatalogUpdateIndexes
(
relation
,
newtuple
);
CatalogUpdateIndexes
(
relation
,
newtuple
);
pfree
(
old_acl
);
pfree
(
new_acl
);
pfree
(
new_acl
);
heap_close
(
relation
,
RowExclusiveLock
);
heap_close
(
relation
,
RowExclusiveLock
);
...
@@ -662,7 +665,6 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt)
...
@@ -662,7 +665,6 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt)
/* keep the catalog indexes up to date */
/* keep the catalog indexes up to date */
CatalogUpdateIndexes
(
relation
,
newtuple
);
CatalogUpdateIndexes
(
relation
,
newtuple
);
pfree
(
old_acl
);
pfree
(
new_acl
);
pfree
(
new_acl
);
heap_close
(
relation
,
RowExclusiveLock
);
heap_close
(
relation
,
RowExclusiveLock
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment