Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
7c6baade
Commit
7c6baade
authored
20 years ago
by
Neil Conway
Browse files
Options
Downloads
Patches
Plain Diff
Refactor CheckDropPermissions() to move some initialization code for
printing the proper error message out of the common path.
parent
d9050578
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/tcop/utility.c
+30
-12
30 additions, 12 deletions
src/backend/tcop/utility.c
with
30 additions
and
12 deletions
src/backend/tcop/utility.c
+
30
−
12
View file @
7c6baade
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.21
4
2004/05/0
5 04:48:46 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.21
5
2004/05/0
7 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
())
&&
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment