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
315a9ca3
Commit
315a9ca3
authored
Aug 18, 2002
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make CREATE CONSTRAINT TRIGGER check for REFERENCES privilege on both
master and slave tables.
parent
c828ec88
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
10 deletions
+29
-10
src/backend/commands/trigger.c
src/backend/commands/trigger.c
+29
-10
No files found.
src/backend/commands/trigger.c
View file @
315a9ca3
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.12
6 2002/08/17 12:15:48 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.12
7 2002/08/18 11:20:05 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -86,6 +86,11 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
rel
=
heap_openrv
(
stmt
->
relation
,
AccessExclusiveLock
);
if
(
stmt
->
constrrel
!=
NULL
)
constrrelid
=
RangeVarGetRelid
(
stmt
->
constrrel
,
false
);
else
constrrelid
=
InvalidOid
;
if
(
rel
->
rd_rel
->
relkind
!=
RELKIND_RELATION
)
elog
(
ERROR
,
"CreateTrigger: relation
\"
%s
\"
is not a table"
,
stmt
->
relation
->
relname
);
...
...
@@ -94,10 +99,29 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
elog
(
ERROR
,
"CreateTrigger: can't create trigger for system relation %s"
,
stmt
->
relation
->
relname
);
aclresult
=
pg_class_aclcheck
(
RelationGetRelid
(
rel
),
GetUserId
(),
stmt
->
isconstraint
?
ACL_REFERENCES
:
ACL_TRIGGER
);
if
(
aclresult
!=
ACLCHECK_OK
)
aclcheck_error
(
aclresult
,
RelationGetRelationName
(
rel
));
/* permission checks */
if
(
stmt
->
isconstraint
)
{
/* foreign key constraint trigger */
aclresult
=
pg_class_aclcheck
(
RelationGetRelid
(
rel
),
GetUserId
(),
ACL_REFERENCES
);
if
(
aclresult
!=
ACLCHECK_OK
)
aclcheck_error
(
aclresult
,
RelationGetRelationName
(
rel
));
if
(
constrrelid
!=
InvalidOid
)
{
aclresult
=
pg_class_aclcheck
(
constrrelid
,
GetUserId
(),
ACL_REFERENCES
);
if
(
aclresult
!=
ACLCHECK_OK
)
aclcheck_error
(
aclresult
,
get_rel_name
(
constrrelid
));
}
}
else
{
/* real trigger */
aclresult
=
pg_class_aclcheck
(
RelationGetRelid
(
rel
),
GetUserId
(),
ACL_TRIGGER
);
if
(
aclresult
!=
ACLCHECK_OK
)
aclcheck_error
(
aclresult
,
RelationGetRelationName
(
rel
));
}
/*
* Generate the trigger's OID now, so that we can use it in the name
...
...
@@ -124,11 +148,6 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
constrname
=
""
;
}
if
(
stmt
->
constrrel
!=
NULL
)
constrrelid
=
RangeVarGetRelid
(
stmt
->
constrrel
,
false
);
else
constrrelid
=
InvalidOid
;
TRIGGER_CLEAR_TYPE
(
tgtype
);
if
(
stmt
->
before
)
TRIGGER_SETT_BEFORE
(
tgtype
);
...
...
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