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
7c6baade
Commit
7c6baade
authored
May 07, 2004
by
Neil Conway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor CheckDropPermissions() to move some initialization code for
printing the proper error message out of the common path.
parent
d9050578
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
12 deletions
+30
-12
src/backend/tcop/utility.c
src/backend/tcop/utility.c
+30
-12
No files found.
src/backend/tcop/utility.c
View file @
7c6baade
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.21
4 2004/05/05 04:48:46 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.21
5 2004/05/07 19:12:26 neilc
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -99,8 +99,12 @@ static const struct msgstrings msgstringarray[] = {
};
/*
* Emit the right error message for a "DROP" command issued on a
* relation of the wrong type
*/
static
void
DropErrorMsg
(
char
*
relname
,
char
wrongkind
,
char
rightkind
)
DropErrorMsg
WrongType
(
char
*
relname
,
char
wrongkind
,
char
rightkind
)
{
const
struct
msgstrings
*
rentry
;
const
struct
msgstrings
*
wentry
;
...
...
@@ -121,24 +125,37 @@ DropErrorMsg(char *relname, char wrongkind, char rightkind)
(
wentry
->
kind
!=
'\0'
)
?
errhint
(
wentry
->
drophint_msg
)
:
0
));
}
/*
* Emit the right error message for a "DROP" command issued on a
* non-existent relation
*/
static
void
CheckDropPermissions
(
RangeVar
*
rel
,
char
rightkind
)
DropErrorMsgNonExistent
(
RangeVar
*
rel
,
char
rightkind
)
{
const
struct
msgstrings
*
rentry
;
Oid
relOid
;
HeapTuple
tuple
;
Form_pg_class
classform
;
for
(
rentry
=
msgstringarray
;
rentry
->
kind
!=
'\0'
;
rentry
++
)
{
if
(
rentry
->
kind
==
rightkind
)
break
;
Assert
(
rentry
->
kind
!=
'\0'
);
ereport
(
ERROR
,
(
errcode
(
rentry
->
nonexistent_code
),
errmsg
(
rentry
->
nonexistent_msg
,
rel
->
relname
)));
}
Assert
(
false
);
/* Should be impossible */
}
static
void
CheckDropPermissions
(
RangeVar
*
rel
,
char
rightkind
)
{
Oid
relOid
;
HeapTuple
tuple
;
Form_pg_class
classform
;
relOid
=
RangeVarGetRelid
(
rel
,
true
);
if
(
!
OidIsValid
(
relOid
))
ereport
(
ERROR
,
(
errcode
(
rentry
->
nonexistent_code
),
errmsg
(
rentry
->
nonexistent_msg
,
rel
->
relname
)));
DropErrorMsgNonExistent
(
rel
,
rightkind
);
tuple
=
SearchSysCache
(
RELOID
,
ObjectIdGetDatum
(
relOid
),
0
,
0
,
0
);
...
...
@@ -148,7 +165,8 @@ CheckDropPermissions(RangeVar *rel, char rightkind)
classform
=
(
Form_pg_class
)
GETSTRUCT
(
tuple
);
if
(
classform
->
relkind
!=
rightkind
)
DropErrorMsg
(
rel
->
relname
,
classform
->
relkind
,
rightkind
);
DropErrorMsgWrongType
(
rel
->
relname
,
classform
->
relkind
,
rightkind
);
/* Allow DROP to either table owner or schema owner */
if
(
!
pg_class_ownercheck
(
relOid
,
GetUserId
())
&&
...
...
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