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
9bccdf17
Commit
9bccdf17
authored
22 years ago
by
Peter Eisentraut
Browse files
Options
Downloads
Patches
Plain Diff
Create/drop cast now requires ownership of at least one of the types.
parent
014a86ac
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/src/sgml/ref/create_cast.sgml
+3
-9
3 additions, 9 deletions
doc/src/sgml/ref/create_cast.sgml
doc/src/sgml/ref/drop_cast.sgml
+4
-10
4 additions, 10 deletions
doc/src/sgml/ref/drop_cast.sgml
src/backend/commands/functioncmds.c
+12
-28
12 additions, 28 deletions
src/backend/commands/functioncmds.c
with
19 additions
and
47 deletions
doc/src/sgml/ref/create_cast.sgml
+
3
−
9
View file @
9bccdf17
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_cast.sgml,v 1.
1
2002/0
7
/1
8 23:11:27
petere Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_cast.sgml,v 1.
2
2002/0
8
/1
1 17:44:12
petere Exp $ -->
<refentry id="SQL-CREATECAST">
<refentry id="SQL-CREATECAST">
<refmeta>
<refmeta>
...
@@ -81,9 +81,8 @@ INSERT INTO foo(f1) VALUES(42);
...
@@ -81,9 +81,8 @@ INSERT INTO foo(f1) VALUES(42);
</para>
</para>
<para>
<para>
To be able to create a cast, you must own the underlying function.
To be able to create a cast, you must own the source or the target
To be able to create a binary compatible cast, you must own both
data type.
the source and the target data type.
</para>
</para>
<variablelist>
<variablelist>
...
@@ -154,11 +153,6 @@ INSERT INTO foo(f1) VALUES(42);
...
@@ -154,11 +153,6 @@ INSERT INTO foo(f1) VALUES(42);
Use <command>DROP CAST</command> to remove user-defined casts.
Use <command>DROP CAST</command> to remove user-defined casts.
</para>
</para>
<para>
The privileges required to create a cast may be changed in a future
release.
</para>
<para>
<para>
Remember that if you want to be able to convert types both ways you
Remember that if you want to be able to convert types both ways you
need to declare casts both ways explicitly.
need to declare casts both ways explicitly.
...
...
This diff is collapsed.
Click to expand it.
doc/src/sgml/ref/drop_cast.sgml
+
4
−
10
View file @
9bccdf17
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_cast.sgml,v 1.
1
2002/0
7
/1
8 23:11:27
petere Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_cast.sgml,v 1.
2
2002/0
8
/1
1 17:44:12
petere Exp $ -->
<refentry id="SQL-DROPCAST">
<refentry id="SQL-DROPCAST">
<refmeta>
<refmeta>
...
@@ -26,10 +26,9 @@ DROP CAST (<replaceable>sourcetype</replaceable> AS <replaceable>targettype</rep
...
@@ -26,10 +26,9 @@ DROP CAST (<replaceable>sourcetype</replaceable> AS <replaceable>targettype</rep
</para>
</para>
<para>
<para>
To be able to drop a cast, you must own the underlying function.
To be able to drop a cast, you must own the source or the target
To be able to drop a binary compatible cast, you must own both the
data type. These are the same privileges that are required to
source and the target data type. These are the same privileges
create a cast.
that are required to create a cast.
</para>
</para>
<variablelist>
<variablelist>
...
@@ -76,11 +75,6 @@ DROP CAST (<replaceable>sourcetype</replaceable> AS <replaceable>targettype</rep
...
@@ -76,11 +75,6 @@ DROP CAST (<replaceable>sourcetype</replaceable> AS <replaceable>targettype</rep
<para>
<para>
Use <command>CREATE CAST</command> to create user-defined casts.
Use <command>CREATE CAST</command> to create user-defined casts.
</para>
</para>
<para>
The privileges required to drop a cast may be changed in a future
release.
</para>
</refsect1>
</refsect1>
...
...
This diff is collapsed.
Click to expand it.
src/backend/commands/functioncmds.c
+
12
−
28
View file @
9bccdf17
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.1
6
2002/08/
05 03:29:16 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.1
7
2002/08/
11 17:44:12 petere
Exp $
*
*
* DESCRIPTION
* DESCRIPTION
* These routines take the parse tree and pick out the
* These routines take the parse tree and pick out the
...
@@ -621,6 +621,12 @@ CreateCast(CreateCastStmt *stmt)
...
@@ -621,6 +621,12 @@ CreateCast(CreateCastStmt *stmt)
if
(
sourcetypeid
==
targettypeid
)
if
(
sourcetypeid
==
targettypeid
)
elog
(
ERROR
,
"source data type and target data type are the same"
);
elog
(
ERROR
,
"source data type and target data type are the same"
);
if
(
!
pg_type_ownercheck
(
sourcetypeid
,
GetUserId
())
&&
!
pg_type_ownercheck
(
targettypeid
,
GetUserId
()))
elog
(
ERROR
,
"must be owner of type %s or type %s"
,
TypeNameToString
(
stmt
->
sourcetype
),
TypeNameToString
(
stmt
->
targettype
));
relation
=
heap_openr
(
CastRelationName
,
RowExclusiveLock
);
relation
=
heap_openr
(
CastRelationName
,
RowExclusiveLock
);
tuple
=
SearchSysCache
(
CASTSOURCETARGET
,
tuple
=
SearchSysCache
(
CASTSOURCETARGET
,
...
@@ -639,10 +645,6 @@ CreateCast(CreateCastStmt *stmt)
...
@@ -639,10 +645,6 @@ CreateCast(CreateCastStmt *stmt)
false
,
false
,
"CreateCast"
);
"CreateCast"
);
if
(
!
pg_proc_ownercheck
(
funcid
,
GetUserId
()))
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
NameListToString
(
stmt
->
func
->
funcname
));
tuple
=
SearchSysCache
(
PROCOID
,
ObjectIdGetDatum
(
funcid
),
0
,
0
,
0
);
tuple
=
SearchSysCache
(
PROCOID
,
ObjectIdGetDatum
(
funcid
),
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"cache lookup of function %u failed"
,
funcid
);
elog
(
ERROR
,
"cache lookup of function %u failed"
,
funcid
);
...
@@ -666,12 +668,6 @@ CreateCast(CreateCastStmt *stmt)
...
@@ -666,12 +668,6 @@ CreateCast(CreateCastStmt *stmt)
else
else
{
{
/* indicates binary compatibility */
/* indicates binary compatibility */
if
(
!
pg_type_ownercheck
(
sourcetypeid
,
GetUserId
()))
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
TypeNameToString
(
stmt
->
sourcetype
));
if
(
!
pg_type_ownercheck
(
targettypeid
,
GetUserId
()))
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
TypeNameToString
(
stmt
->
targettype
));
funcid
=
InvalidOid
;
funcid
=
InvalidOid
;
}
}
...
@@ -730,7 +726,6 @@ DropCast(DropCastStmt *stmt)
...
@@ -730,7 +726,6 @@ DropCast(DropCastStmt *stmt)
Oid
sourcetypeid
;
Oid
sourcetypeid
;
Oid
targettypeid
;
Oid
targettypeid
;
HeapTuple
tuple
;
HeapTuple
tuple
;
Form_pg_cast
caststruct
;
ObjectAddress
object
;
ObjectAddress
object
;
sourcetypeid
=
LookupTypeName
(
stmt
->
sourcetype
);
sourcetypeid
=
LookupTypeName
(
stmt
->
sourcetype
);
...
@@ -753,22 +748,11 @@ DropCast(DropCastStmt *stmt)
...
@@ -753,22 +748,11 @@ DropCast(DropCastStmt *stmt)
TypeNameToString
(
stmt
->
targettype
));
TypeNameToString
(
stmt
->
targettype
));
/* Permission check */
/* Permission check */
caststruct
=
(
Form_pg_cast
)
GETSTRUCT
(
tuple
);
if
(
!
pg_type_ownercheck
(
sourcetypeid
,
GetUserId
())
if
(
caststruct
->
castfunc
!=
InvalidOid
)
&&
!
pg_type_ownercheck
(
targettypeid
,
GetUserId
()))
{
elog
(
ERROR
,
"must be owner of type %s or type %s"
,
if
(
!
pg_proc_ownercheck
(
caststruct
->
castfunc
,
GetUserId
()))
TypeNameToString
(
stmt
->
sourcetype
),
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
TypeNameToString
(
stmt
->
targettype
));
get_func_name
(
caststruct
->
castfunc
));
}
else
{
if
(
!
pg_type_ownercheck
(
sourcetypeid
,
GetUserId
()))
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
format_type_be
(
sourcetypeid
));
if
(
!
pg_type_ownercheck
(
targettypeid
,
GetUserId
()))
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
format_type_be
(
targettypeid
));
}
/*
/*
* Do the deletion
* Do the deletion
...
...
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