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
d8528630
Commit
d8528630
authored
Jul 21, 2003
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Error message editing in backend/catalog.
parent
da4ed8bf
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
600 additions
and
379 deletions
+600
-379
src/backend/catalog/aclchk.c
src/backend/catalog/aclchk.c
+111
-51
src/backend/catalog/dependency.c
src/backend/catalog/dependency.c
+73
-59
src/backend/catalog/heap.c
src/backend/catalog/heap.c
+75
-44
src/backend/catalog/index.c
src/backend/catalog/index.c
+41
-35
src/backend/catalog/namespace.c
src/backend/catalog/namespace.c
+60
-30
src/backend/catalog/pg_aggregate.c
src/backend/catalog/pg_aggregate.c
+37
-18
src/backend/catalog/pg_constraint.c
src/backend/catalog/pg_constraint.c
+6
-8
src/backend/catalog/pg_conversion.c
src/backend/catalog/pg_conversion.c
+19
-11
src/backend/catalog/pg_largeobject.c
src/backend/catalog/pg_largeobject.c
+4
-2
src/backend/catalog/pg_namespace.c
src/backend/catalog/pg_namespace.c
+4
-2
src/backend/catalog/pg_operator.c
src/backend/catalog/pg_operator.c
+34
-18
src/backend/catalog/pg_proc.c
src/backend/catalog/pg_proc.c
+5
-3
src/backend/catalog/pg_type.c
src/backend/catalog/pg_type.c
+21
-9
src/include/utils/acl.h
src/include/utils/acl.h
+2
-2
src/include/utils/elog.h
src/include/utils/elog.h
+5
-2
src/test/regress/expected/alter_table.out
src/test/regress/expected/alter_table.out
+14
-14
src/test/regress/expected/conversion.out
src/test/regress/expected/conversion.out
+2
-2
src/test/regress/expected/create_type.out
src/test/regress/expected/create_type.out
+1
-1
src/test/regress/expected/domain.out
src/test/regress/expected/domain.out
+2
-2
src/test/regress/expected/errors.out
src/test/regress/expected/errors.out
+6
-6
src/test/regress/expected/foreign_key.out
src/test/regress/expected/foreign_key.out
+4
-4
src/test/regress/expected/polymorphism.out
src/test/regress/expected/polymorphism.out
+36
-18
src/test/regress/expected/privileges.out
src/test/regress/expected/privileges.out
+36
-36
src/test/regress/expected/temp.out
src/test/regress/expected/temp.out
+2
-2
No files found.
src/backend/catalog/aclchk.c
View file @
d8528630
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.8
3 2003/07/04 02:51:33
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.8
4 2003/07/21 01:59:07
tgl Exp $
*
*
* NOTES
* NOTES
* See acl.h.
* See acl.h.
...
@@ -119,7 +119,9 @@ merge_acl_with_grant(Acl *old_acl, bool is_grant,
...
@@ -119,7 +119,9 @@ merge_acl_with_grant(Acl *old_acl, bool is_grant,
* the situation is impossible to clean up.
* the situation is impossible to clean up.
*/
*/
if
(
is_grant
&&
idtype
!=
ACL_IDTYPE_UID
&&
grant_option
)
if
(
is_grant
&&
idtype
!=
ACL_IDTYPE_UID
&&
grant_option
)
elog
(
ERROR
,
"grant options can only be granted to individual users"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_GRANT_OPERATION
),
errmsg
(
"grant options can only be granted to individual users"
)));
aclitem
.
ai_grantor
=
GetUserId
();
aclitem
.
ai_grantor
=
GetUserId
();
...
@@ -163,7 +165,8 @@ ExecuteGrantStmt(GrantStmt *stmt)
...
@@ -163,7 +165,8 @@ ExecuteGrantStmt(GrantStmt *stmt)
ExecuteGrantStmt_Namespace
(
stmt
);
ExecuteGrantStmt_Namespace
(
stmt
);
break
;
break
;
default:
default:
elog
(
ERROR
,
"bogus GrantStmt.objtype %d"
,
(
int
)
stmt
->
objtype
);
elog
(
ERROR
,
"unrecognized GrantStmt.objtype: %d"
,
(
int
)
stmt
->
objtype
);
}
}
}
}
...
@@ -183,8 +186,10 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt)
...
@@ -183,8 +186,10 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt)
AclMode
priv
=
lfirsti
(
i
);
AclMode
priv
=
lfirsti
(
i
);
if
(
priv
&
~
((
AclMode
)
ACL_ALL_RIGHTS_RELATION
))
if
(
priv
&
~
((
AclMode
)
ACL_ALL_RIGHTS_RELATION
))
elog
(
ERROR
,
"invalid privilege type %s for table object"
,
ereport
(
ERROR
,
privilege_to_string
(
priv
));
(
errcode
(
ERRCODE_INVALID_GRANT_OPERATION
),
errmsg
(
"invalid privilege type %s for table"
,
privilege_to_string
(
priv
))));
privileges
|=
priv
;
privileges
|=
priv
;
}
}
}
}
...
@@ -212,7 +217,7 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt)
...
@@ -212,7 +217,7 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt)
ObjectIdGetDatum
(
relOid
),
ObjectIdGetDatum
(
relOid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"
relation %u not found
"
,
relOid
);
elog
(
ERROR
,
"
cache lookup failed for relation %u
"
,
relOid
);
pg_class_tuple
=
(
Form_pg_class
)
GETSTRUCT
(
tuple
);
pg_class_tuple
=
(
Form_pg_class
)
GETSTRUCT
(
tuple
);
if
(
stmt
->
is_grant
if
(
stmt
->
is_grant
...
@@ -220,9 +225,12 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt)
...
@@ -220,9 +225,12 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt)
&&
pg_class_aclcheck
(
relOid
,
GetUserId
(),
ACL_GRANT_OPTION_FOR
(
privileges
))
!=
ACLCHECK_OK
)
&&
pg_class_aclcheck
(
relOid
,
GetUserId
(),
ACL_GRANT_OPTION_FOR
(
privileges
))
!=
ACLCHECK_OK
)
aclcheck_error
(
ACLCHECK_NO_PRIV
,
relvar
->
relname
);
aclcheck_error
(
ACLCHECK_NO_PRIV
,
relvar
->
relname
);
/* Not sensible to grant on an index */
if
(
pg_class_tuple
->
relkind
==
RELKIND_INDEX
)
if
(
pg_class_tuple
->
relkind
==
RELKIND_INDEX
)
elog
(
ERROR
,
"
\"
%s
\"
is an index"
,
ereport
(
ERROR
,
relvar
->
relname
);
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"
\"
%s
\"
is an index"
,
relvar
->
relname
)));
/*
/*
* If there's no ACL, create a default using the pg_class.relowner
* If there's no ACL, create a default using the pg_class.relowner
...
@@ -281,8 +289,10 @@ ExecuteGrantStmt_Database(GrantStmt *stmt)
...
@@ -281,8 +289,10 @@ ExecuteGrantStmt_Database(GrantStmt *stmt)
AclMode
priv
=
lfirsti
(
i
);
AclMode
priv
=
lfirsti
(
i
);
if
(
priv
&
~
((
AclMode
)
ACL_ALL_RIGHTS_DATABASE
))
if
(
priv
&
~
((
AclMode
)
ACL_ALL_RIGHTS_DATABASE
))
elog
(
ERROR
,
"invalid privilege type %s for database object"
,
ereport
(
ERROR
,
privilege_to_string
(
priv
));
(
errcode
(
ERRCODE_INVALID_GRANT_OPERATION
),
errmsg
(
"invalid privilege type %s for database"
,
privilege_to_string
(
priv
))));
privileges
|=
priv
;
privileges
|=
priv
;
}
}
}
}
...
@@ -311,7 +321,9 @@ ExecuteGrantStmt_Database(GrantStmt *stmt)
...
@@ -311,7 +321,9 @@ ExecuteGrantStmt_Database(GrantStmt *stmt)
scan
=
heap_beginscan
(
relation
,
SnapshotNow
,
1
,
entry
);
scan
=
heap_beginscan
(
relation
,
SnapshotNow
,
1
,
entry
);
tuple
=
heap_getnext
(
scan
,
ForwardScanDirection
);
tuple
=
heap_getnext
(
scan
,
ForwardScanDirection
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"database
\"
%s
\"
not found"
,
dbname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_DATABASE
),
errmsg
(
"database
\"
%s
\"
does not exist"
,
dbname
)));
pg_database_tuple
=
(
Form_pg_database
)
GETSTRUCT
(
tuple
);
pg_database_tuple
=
(
Form_pg_database
)
GETSTRUCT
(
tuple
);
if
(
stmt
->
is_grant
if
(
stmt
->
is_grant
...
@@ -375,8 +387,10 @@ ExecuteGrantStmt_Function(GrantStmt *stmt)
...
@@ -375,8 +387,10 @@ ExecuteGrantStmt_Function(GrantStmt *stmt)
AclMode
priv
=
lfirsti
(
i
);
AclMode
priv
=
lfirsti
(
i
);
if
(
priv
&
~
((
AclMode
)
ACL_ALL_RIGHTS_FUNCTION
))
if
(
priv
&
~
((
AclMode
)
ACL_ALL_RIGHTS_FUNCTION
))
elog
(
ERROR
,
"invalid privilege type %s for function object"
,
ereport
(
ERROR
,
privilege_to_string
(
priv
));
(
errcode
(
ERRCODE_INVALID_GRANT_OPERATION
),
errmsg
(
"invalid privilege type %s for function"
,
privilege_to_string
(
priv
))));
privileges
|=
priv
;
privileges
|=
priv
;
}
}
}
}
...
@@ -404,7 +418,7 @@ ExecuteGrantStmt_Function(GrantStmt *stmt)
...
@@ -404,7 +418,7 @@ ExecuteGrantStmt_Function(GrantStmt *stmt)
ObjectIdGetDatum
(
oid
),
ObjectIdGetDatum
(
oid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"
function %u not found
"
,
oid
);
elog
(
ERROR
,
"
cache lookup failed for function %u
"
,
oid
);
pg_proc_tuple
=
(
Form_pg_proc
)
GETSTRUCT
(
tuple
);
pg_proc_tuple
=
(
Form_pg_proc
)
GETSTRUCT
(
tuple
);
if
(
stmt
->
is_grant
if
(
stmt
->
is_grant
...
@@ -470,8 +484,10 @@ ExecuteGrantStmt_Language(GrantStmt *stmt)
...
@@ -470,8 +484,10 @@ ExecuteGrantStmt_Language(GrantStmt *stmt)
AclMode
priv
=
lfirsti
(
i
);
AclMode
priv
=
lfirsti
(
i
);
if
(
priv
&
~
((
AclMode
)
ACL_ALL_RIGHTS_LANGUAGE
))
if
(
priv
&
~
((
AclMode
)
ACL_ALL_RIGHTS_LANGUAGE
))
elog
(
ERROR
,
"invalid privilege type %s for language object"
,
ereport
(
ERROR
,
privilege_to_string
(
priv
));
(
errcode
(
ERRCODE_INVALID_GRANT_OPERATION
),
errmsg
(
"invalid privilege type %s for language"
,
privilege_to_string
(
priv
))));
privileges
|=
priv
;
privileges
|=
priv
;
}
}
}
}
...
@@ -496,11 +512,15 @@ ExecuteGrantStmt_Language(GrantStmt *stmt)
...
@@ -496,11 +512,15 @@ ExecuteGrantStmt_Language(GrantStmt *stmt)
PointerGetDatum
(
langname
),
PointerGetDatum
(
langname
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"language
\"
%s
\"
not found"
,
langname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"language
\"
%s
\"
does not exist"
,
langname
)));
pg_language_tuple
=
(
Form_pg_language
)
GETSTRUCT
(
tuple
);
pg_language_tuple
=
(
Form_pg_language
)
GETSTRUCT
(
tuple
);
if
(
!
pg_language_tuple
->
lanpltrusted
&&
stmt
->
is_grant
)
if
(
!
pg_language_tuple
->
lanpltrusted
&&
stmt
->
is_grant
)
elog
(
ERROR
,
"language
\"
%s
\"
is not trusted"
,
langname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"language
\"
%s
\"
is not trusted"
,
langname
)));
if
(
stmt
->
is_grant
if
(
stmt
->
is_grant
&&
!
superuser
()
&&
!
superuser
()
...
@@ -563,8 +583,10 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt)
...
@@ -563,8 +583,10 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt)
AclMode
priv
=
lfirsti
(
i
);
AclMode
priv
=
lfirsti
(
i
);
if
(
priv
&
~
((
AclMode
)
ACL_ALL_RIGHTS_NAMESPACE
))
if
(
priv
&
~
((
AclMode
)
ACL_ALL_RIGHTS_NAMESPACE
))
elog
(
ERROR
,
"invalid privilege type %s for namespace object"
,
ereport
(
ERROR
,
privilege_to_string
(
priv
));
(
errcode
(
ERRCODE_INVALID_GRANT_OPERATION
),
errmsg
(
"invalid privilege type %s for schema"
,
privilege_to_string
(
priv
))));
privileges
|=
priv
;
privileges
|=
priv
;
}
}
}
}
...
@@ -589,7 +611,9 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt)
...
@@ -589,7 +611,9 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt)
CStringGetDatum
(
nspname
),
CStringGetDatum
(
nspname
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"namespace
\"
%s
\"
not found"
,
nspname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_SCHEMA
),
errmsg
(
"schema
\"
%s
\"
does not exist"
,
nspname
)));
pg_namespace_tuple
=
(
Form_pg_namespace
)
GETSTRUCT
(
tuple
);
pg_namespace_tuple
=
(
Form_pg_namespace
)
GETSTRUCT
(
tuple
);
if
(
stmt
->
is_grant
if
(
stmt
->
is_grant
...
@@ -668,8 +692,7 @@ privilege_to_string(AclMode privilege)
...
@@ -668,8 +692,7 @@ privilege_to_string(AclMode privilege)
case
ACL_CREATE_TEMP
:
case
ACL_CREATE_TEMP
:
return
"TEMP"
;
return
"TEMP"
;
default:
default:
elog
(
ERROR
,
"privilege_to_string: unrecognized privilege %d"
,
elog
(
ERROR
,
"unrecognized privilege: %d"
,
(
int
)
privilege
);
privilege
);
}
}
return
NULL
;
/* appease compiler */
return
NULL
;
/* appease compiler */
}
}
...
@@ -690,7 +713,9 @@ get_grosysid(char *groname)
...
@@ -690,7 +713,9 @@ get_grosysid(char *groname)
ReleaseSysCache
(
tuple
);
ReleaseSysCache
(
tuple
);
}
}
else
else
elog
(
ERROR
,
"non-existent group
\"
%s
\"
"
,
groname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"group
\"
%s
\"
does not exist"
,
groname
)));
return
id
;
return
id
;
}
}
...
@@ -760,7 +785,9 @@ in_group(AclId uid, AclId gid)
...
@@ -760,7 +785,9 @@ in_group(AclId uid, AclId gid)
ReleaseSysCache
(
tuple
);
ReleaseSysCache
(
tuple
);
}
}
else
else
elog
(
WARNING
,
"in_group: group %u not found"
,
gid
);
ereport
(
WARNING
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"group with ID %u does not exist"
,
gid
)));
return
result
;
return
result
;
}
}
...
@@ -785,7 +812,7 @@ aclcheck(Acl *acl, AclId userid, AclMode mode)
...
@@ -785,7 +812,7 @@ aclcheck(Acl *acl, AclId userid, AclMode mode)
*/
*/
if
(
acl
==
NULL
)
if
(
acl
==
NULL
)
{
{
elog
(
ERROR
,
"
aclcheck: internal error --
null ACL"
);
elog
(
ERROR
,
"null ACL"
);
return
ACLCHECK_NO_PRIV
;
return
ACLCHECK_NO_PRIV
;
}
}
...
@@ -823,22 +850,25 @@ aclcheck(Acl *acl, AclId userid, AclMode mode)
...
@@ -823,22 +850,25 @@ aclcheck(Acl *acl, AclId userid, AclMode mode)
* Standardized reporting of aclcheck permissions failures.
* Standardized reporting of aclcheck permissions failures.
*/
*/
void
void
aclcheck_error
(
AclResult
errcode
,
const
char
*
objectname
)
aclcheck_error
(
AclResult
aclerr
,
const
char
*
objectname
)
{
{
switch
(
errcode
)
switch
(
aclerr
)
{
{
case
ACLCHECK_OK
:
case
ACLCHECK_OK
:
/* no error, so return to caller */
/* no error, so return to caller */
break
;
break
;
case
ACLCHECK_NO_PRIV
:
case
ACLCHECK_NO_PRIV
:
elog
(
ERROR
,
"%s: permission denied"
,
objectname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
errmsg
(
"permission denied for
\"
%s
\"
"
,
objectname
)));
break
;
break
;
case
ACLCHECK_NOT_OWNER
:
case
ACLCHECK_NOT_OWNER
:
elog
(
ERROR
,
"%s: must be owner"
,
objectname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
errmsg
(
"must be owner of
\"
%s
\"
"
,
objectname
)));
break
;
break
;
default:
default:
elog
(
ERROR
,
"%s: unexpected AclResult %d"
,
elog
(
ERROR
,
"unrecognized AclResult: %d"
,
(
int
)
aclerr
);
objectname
,
(
int
)
errcode
);
break
;
break
;
}
}
}
}
...
@@ -846,6 +876,11 @@ aclcheck_error(AclResult errcode, const char *objectname)
...
@@ -846,6 +876,11 @@ aclcheck_error(AclResult errcode, const char *objectname)
/*
/*
* Exported routine for checking a user's access privileges to a table
* Exported routine for checking a user's access privileges to a table
*
* Note: we give lookup failure the full ereport treatment because the
* has_table_privilege() family of functions allow users to pass
* any random OID to this function. Likewise for the sibling functions
* below.
*/
*/
AclResult
AclResult
pg_class_aclcheck
(
Oid
table_oid
,
AclId
userid
,
AclMode
mode
)
pg_class_aclcheck
(
Oid
table_oid
,
AclId
userid
,
AclMode
mode
)
...
@@ -865,7 +900,9 @@ pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode)
...
@@ -865,7 +900,9 @@ pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode)
ObjectIdGetDatum
(
userid
),
ObjectIdGetDatum
(
userid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"pg_class_aclcheck: invalid user id %u"
,
userid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"user with ID %u does not exist"
,
userid
)));
usecatupd
=
((
Form_pg_shadow
)
GETSTRUCT
(
tuple
))
->
usecatupd
;
usecatupd
=
((
Form_pg_shadow
)
GETSTRUCT
(
tuple
))
->
usecatupd
;
...
@@ -880,7 +917,9 @@ pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode)
...
@@ -880,7 +917,9 @@ pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode)
ObjectIdGetDatum
(
table_oid
),
ObjectIdGetDatum
(
table_oid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"pg_class_aclcheck: relation %u not found"
,
table_oid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_TABLE
),
errmsg
(
"relation with OID %u does not exist"
,
table_oid
)));
/*
/*
* Deny anyone permission to update a system catalog unless
* Deny anyone permission to update a system catalog unless
...
@@ -893,7 +932,7 @@ pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode)
...
@@ -893,7 +932,7 @@ pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode)
!
usecatupd
)
!
usecatupd
)
{
{
#ifdef ACLDEBUG
#ifdef ACLDEBUG
elog
(
DEBUG2
,
"p
g_class_aclcheck: catalog update: permission denied
"
);
elog
(
DEBUG2
,
"p
ermission denied for system catalog update
"
);
#endif
#endif
ReleaseSysCache
(
tuple
);
ReleaseSysCache
(
tuple
);
return
ACLCHECK_NO_PRIV
;
return
ACLCHECK_NO_PRIV
;
...
@@ -905,7 +944,7 @@ pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode)
...
@@ -905,7 +944,7 @@ pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode)
if
(
usesuper
)
if
(
usesuper
)
{
{
#ifdef ACLDEBUG
#ifdef ACLDEBUG
elog
(
DEBUG2
,
"
pg_class_aclcheck: %u is superuser
"
,
userid
);
elog
(
DEBUG2
,
"
%u is superuser, home free
"
,
userid
);
#endif
#endif
ReleaseSysCache
(
tuple
);
ReleaseSysCache
(
tuple
);
return
ACLCHECK_OK
;
return
ACLCHECK_OK
;
...
@@ -973,7 +1012,9 @@ pg_database_aclcheck(Oid db_oid, AclId userid, AclMode mode)
...
@@ -973,7 +1012,9 @@ pg_database_aclcheck(Oid db_oid, AclId userid, AclMode mode)
scan
=
heap_beginscan
(
pg_database
,
SnapshotNow
,
1
,
entry
);
scan
=
heap_beginscan
(
pg_database
,
SnapshotNow
,
1
,
entry
);
tuple
=
heap_getnext
(
scan
,
ForwardScanDirection
);
tuple
=
heap_getnext
(
scan
,
ForwardScanDirection
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"pg_database_aclcheck: database %u not found"
,
db_oid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_DATABASE
),
errmsg
(
"database with OID %u does not exist"
,
db_oid
)));
aclDatum
=
heap_getattr
(
tuple
,
Anum_pg_database_datacl
,
aclDatum
=
heap_getattr
(
tuple
,
Anum_pg_database_datacl
,
RelationGetDescr
(
pg_database
),
&
isNull
);
RelationGetDescr
(
pg_database
),
&
isNull
);
...
@@ -1028,7 +1069,9 @@ pg_proc_aclcheck(Oid proc_oid, AclId userid, AclMode mode)
...
@@ -1028,7 +1069,9 @@ pg_proc_aclcheck(Oid proc_oid, AclId userid, AclMode mode)
ObjectIdGetDatum
(
proc_oid
),
ObjectIdGetDatum
(
proc_oid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"pg_proc_aclcheck: function %u not found"
,
proc_oid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_FUNCTION
),
errmsg
(
"function with OID %u does not exist"
,
proc_oid
)));
aclDatum
=
SysCacheGetAttr
(
PROCOID
,
tuple
,
Anum_pg_proc_proacl
,
aclDatum
=
SysCacheGetAttr
(
PROCOID
,
tuple
,
Anum_pg_proc_proacl
,
&
isNull
);
&
isNull
);
...
@@ -1075,13 +1118,15 @@ pg_language_aclcheck(Oid lang_oid, AclId userid, AclMode mode)
...
@@ -1075,13 +1118,15 @@ pg_language_aclcheck(Oid lang_oid, AclId userid, AclMode mode)
return
ACLCHECK_OK
;
return
ACLCHECK_OK
;
/*
/*
* Get the
function
's ACL from pg_language
* Get the
language
's ACL from pg_language
*/
*/
tuple
=
SearchSysCache
(
LANGOID
,
tuple
=
SearchSysCache
(
LANGOID
,
ObjectIdGetDatum
(
lang_oid
),
ObjectIdGetDatum
(
lang_oid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"pg_language_aclcheck: language %u not found"
,
lang_oid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"language with OID %u does not exist"
,
lang_oid
)));
aclDatum
=
SysCacheGetAttr
(
LANGOID
,
tuple
,
Anum_pg_language_lanacl
,
aclDatum
=
SysCacheGetAttr
(
LANGOID
,
tuple
,
Anum_pg_language_lanacl
,
&
isNull
);
&
isNull
);
...
@@ -1132,13 +1177,15 @@ pg_namespace_aclcheck(Oid nsp_oid, AclId userid, AclMode mode)
...
@@ -1132,13 +1177,15 @@ pg_namespace_aclcheck(Oid nsp_oid, AclId userid, AclMode mode)
return
ACLCHECK_OK
;
return
ACLCHECK_OK
;
/*
/*
* Get the
function
's ACL from pg_namespace
* Get the
schema
's ACL from pg_namespace
*/
*/
tuple
=
SearchSysCache
(
NAMESPACEOID
,
tuple
=
SearchSysCache
(
NAMESPACEOID
,
ObjectIdGetDatum
(
nsp_oid
),
ObjectIdGetDatum
(
nsp_oid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"pg_namespace_aclcheck: namespace %u not found"
,
nsp_oid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_SCHEMA
),
errmsg
(
"schema with OID %u does not exist"
,
nsp_oid
)));
aclDatum
=
SysCacheGetAttr
(
NAMESPACEOID
,
tuple
,
Anum_pg_namespace_nspacl
,
aclDatum
=
SysCacheGetAttr
(
NAMESPACEOID
,
tuple
,
Anum_pg_namespace_nspacl
,
&
isNull
);
&
isNull
);
...
@@ -1186,7 +1233,9 @@ pg_class_ownercheck(Oid class_oid, AclId userid)
...
@@ -1186,7 +1233,9 @@ pg_class_ownercheck(Oid class_oid, AclId userid)
ObjectIdGetDatum
(
class_oid
),
ObjectIdGetDatum
(
class_oid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"pg_class_ownercheck: relation %u not found"
,
class_oid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_TABLE
),
errmsg
(
"relation with OID %u does not exist"
,
class_oid
)));
owner_id
=
((
Form_pg_class
)
GETSTRUCT
(
tuple
))
->
relowner
;
owner_id
=
((
Form_pg_class
)
GETSTRUCT
(
tuple
))
->
relowner
;
...
@@ -1212,7 +1261,9 @@ pg_type_ownercheck(Oid type_oid, AclId userid)
...
@@ -1212,7 +1261,9 @@ pg_type_ownercheck(Oid type_oid, AclId userid)
ObjectIdGetDatum
(
type_oid
),
ObjectIdGetDatum
(
type_oid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"pg_type_ownercheck: type %u not found"
,
type_oid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"type with OID %u does not exist"
,
type_oid
)));
owner_id
=
((
Form_pg_type
)
GETSTRUCT
(
tuple
))
->
typowner
;
owner_id
=
((
Form_pg_type
)
GETSTRUCT
(
tuple
))
->
typowner
;
...
@@ -1238,7 +1289,9 @@ pg_oper_ownercheck(Oid oper_oid, AclId userid)
...
@@ -1238,7 +1289,9 @@ pg_oper_ownercheck(Oid oper_oid, AclId userid)
ObjectIdGetDatum
(
oper_oid
),
ObjectIdGetDatum
(
oper_oid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"pg_oper_ownercheck: operator %u not found"
,
oper_oid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_FUNCTION
),
errmsg
(
"operator with OID %u does not exist"
,
oper_oid
)));
owner_id
=
((
Form_pg_operator
)
GETSTRUCT
(
tuple
))
->
oprowner
;
owner_id
=
((
Form_pg_operator
)
GETSTRUCT
(
tuple
))
->
oprowner
;
...
@@ -1264,7 +1317,9 @@ pg_proc_ownercheck(Oid proc_oid, AclId userid)
...
@@ -1264,7 +1317,9 @@ pg_proc_ownercheck(Oid proc_oid, AclId userid)
ObjectIdGetDatum
(
proc_oid
),
ObjectIdGetDatum
(
proc_oid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"pg_proc_ownercheck: function %u not found"
,
proc_oid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_FUNCTION
),
errmsg
(
"function with OID %u does not exist"
,
proc_oid
)));
owner_id
=
((
Form_pg_proc
)
GETSTRUCT
(
tuple
))
->
proowner
;
owner_id
=
((
Form_pg_proc
)
GETSTRUCT
(
tuple
))
->
proowner
;
...
@@ -1290,8 +1345,9 @@ pg_namespace_ownercheck(Oid nsp_oid, AclId userid)
...
@@ -1290,8 +1345,9 @@ pg_namespace_ownercheck(Oid nsp_oid, AclId userid)
ObjectIdGetDatum
(
nsp_oid
),
ObjectIdGetDatum
(
nsp_oid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"pg_namespace_ownercheck: namespace %u not found"
,
ereport
(
ERROR
,
nsp_oid
);
(
errcode
(
ERRCODE_UNDEFINED_SCHEMA
),
errmsg
(
"schema with OID %u does not exist"
,
nsp_oid
)));
owner_id
=
((
Form_pg_namespace
)
GETSTRUCT
(
tuple
))
->
nspowner
;
owner_id
=
((
Form_pg_namespace
)
GETSTRUCT
(
tuple
))
->
nspowner
;
...
@@ -1317,8 +1373,10 @@ pg_opclass_ownercheck(Oid opc_oid, AclId userid)
...
@@ -1317,8 +1373,10 @@ pg_opclass_ownercheck(Oid opc_oid, AclId userid)
ObjectIdGetDatum
(
opc_oid
),
ObjectIdGetDatum
(
opc_oid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"pg_opclass_ownercheck: operator class %u not found"
,
ereport
(
ERROR
,
opc_oid
);
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"operator class with OID %u does not exist"
,
opc_oid
)));
owner_id
=
((
Form_pg_opclass
)
GETSTRUCT
(
tuple
))
->
opcowner
;
owner_id
=
((
Form_pg_opclass
)
GETSTRUCT
(
tuple
))
->
opcowner
;
...
@@ -1354,7 +1412,9 @@ pg_database_ownercheck(Oid db_oid, AclId userid)
...
@@ -1354,7 +1412,9 @@ pg_database_ownercheck(Oid db_oid, AclId userid)
dbtuple
=
heap_getnext
(
scan
,
ForwardScanDirection
);
dbtuple
=
heap_getnext
(
scan
,
ForwardScanDirection
);
if
(
!
HeapTupleIsValid
(
dbtuple
))
if
(
!
HeapTupleIsValid
(
dbtuple
))
elog
(
ERROR
,
"database %u does not exist"
,
db_oid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_DATABASE
),
errmsg
(
"database with OID %u does not exist"
,
db_oid
)));
dba
=
((
Form_pg_database
)
GETSTRUCT
(
dbtuple
))
->
datdba
;
dba
=
((
Form_pg_database
)
GETSTRUCT
(
dbtuple
))
->
datdba
;
...
...
src/backend/catalog/dependency.c
View file @
d8528630
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.2
6 2003/06/29 00:33:42
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.2
7 2003/07/21 01:59:07
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -168,9 +168,11 @@ performDeletion(const ObjectAddress *object,
...
@@ -168,9 +168,11 @@ performDeletion(const ObjectAddress *object,
if
(
!
recursiveDeletion
(
object
,
behavior
,
NOTICE
,
if
(
!
recursiveDeletion
(
object
,
behavior
,
NOTICE
,
NULL
,
&
oktodelete
,
depRel
))
NULL
,
&
oktodelete
,
depRel
))
elog
(
ERROR
,
"Cannot drop %s because other objects depend on it"
ereport
(
ERROR
,
"
\n\t
Use DROP ... CASCADE to drop the dependent objects too"
,
(
errcode
(
ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST
),
objDescription
);
errmsg
(
"cannot drop %s because other objects depend on it"
,
objDescription
),
errhint
(
"Use DROP ... CASCADE to drop the dependent objects too."
)));
term_object_addresses
(
&
oktodelete
);
term_object_addresses
(
&
oktodelete
);
...
@@ -226,8 +228,10 @@ deleteWhatDependsOn(const ObjectAddress *object,
...
@@ -226,8 +228,10 @@ deleteWhatDependsOn(const ObjectAddress *object,
DROP_CASCADE
,
DROP_CASCADE
,
showNotices
?
NOTICE
:
DEBUG2
,
showNotices
?
NOTICE
:
DEBUG2
,
&
oktodelete
,
depRel
))
&
oktodelete
,
depRel
))
elog
(
ERROR
,
"Failed to drop all objects depending on %s"
,
ereport
(
ERROR
,
objDescription
);
(
errcode
(
ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST
),
errmsg
(
"failed to drop all objects depending on %s"
,
objDescription
)));
/*
/*
* We do not need CommandCounterIncrement here, since if step 2 did
* We do not need CommandCounterIncrement here, since if step 2 did
...
@@ -316,15 +320,17 @@ findAutoDeletableObjects(const ObjectAddress *object,
...
@@ -316,15 +320,17 @@ findAutoDeletableObjects(const ObjectAddress *object,
break
;
break
;
case
DEPENDENCY_PIN
:
case
DEPENDENCY_PIN
:
/*
/*
* For a PIN dependency we just e
log
immediately; there
* For a PIN dependency we just e
report
immediately; there
* won't be any others to examine, and we aren't ever
* won't be any others to examine, and we aren't ever
* going to let the user delete it.
* going to let the user delete it.
*/
*/
elog
(
ERROR
,
"Cannot drop %s because it is required by the database system"
,
ereport
(
ERROR
,
getObjectDescription
(
object
));
(
errcode
(
ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST
),
errmsg
(
"cannot drop %s because it is required by the database system"
,
getObjectDescription
(
object
))));
break
;
break
;
default:
default:
elog
(
ERROR
,
"
findAutoDeletableObjects: unknown
dependency type '%c' for %s"
,
elog
(
ERROR
,
"
unrecognized
dependency type '%c' for %s"
,
foundDep
->
deptype
,
getObjectDescription
(
object
));
foundDep
->
deptype
,
getObjectDescription
(
object
));
break
;
break
;
}
}
...
@@ -349,7 +355,7 @@ findAutoDeletableObjects(const ObjectAddress *object,
...
@@ -349,7 +355,7 @@ findAutoDeletableObjects(const ObjectAddress *object,
* depRel is the already-open pg_depend relation.
* depRel is the already-open pg_depend relation.
*
*
*
*
* In RESTRICT mode, we perform all the deletions anyway, but e
log
a message
* In RESTRICT mode, we perform all the deletions anyway, but e
report
a message
* and return FALSE if we find a restriction violation. performDeletion
* and return FALSE if we find a restriction violation. performDeletion
* will then abort the transaction to nullify the deletions. We have to
* will then abort the transaction to nullify the deletions. We have to
* do it this way to (a) report all the direct and indirect dependencies
* do it this way to (a) report all the direct and indirect dependencies
...
@@ -447,16 +453,19 @@ recursiveDeletion(const ObjectAddress *object,
...
@@ -447,16 +453,19 @@ recursiveDeletion(const ObjectAddress *object,
* another object. We have three cases:
* another object. We have three cases:
*
*
* 1. At the outermost recursion level, disallow the DROP.
* 1. At the outermost recursion level, disallow the DROP.
* (We just e
log
here, rather than proceeding, since no
* (We just e
report
here, rather than proceeding, since no
* other dependencies are likely to be interesting.)
* other dependencies are likely to be interesting.)
*/
*/
if
(
callingObject
==
NULL
)
if
(
callingObject
==
NULL
)
{
{
char
*
otherObjDesc
=
getObjectDescription
(
&
otherObject
);
char
*
otherObjDesc
=
getObjectDescription
(
&
otherObject
);
elog
(
ERROR
,
"Cannot drop %s because %s requires it"
ereport
(
ERROR
,
"
\n\t
You may drop %s instead"
,
(
errcode
(
ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST
),
objDescription
,
otherObjDesc
,
otherObjDesc
);
errmsg
(
"cannot drop %s because %s requires it"
,
objDescription
,
otherObjDesc
),
errhint
(
"You may drop %s instead."
,
otherObjDesc
)));
}
}
/*
/*
...
@@ -480,7 +489,7 @@ recursiveDeletion(const ObjectAddress *object,
...
@@ -480,7 +489,7 @@ recursiveDeletion(const ObjectAddress *object,
* owning object to recurse back to me.
* owning object to recurse back to me.
*/
*/
if
(
amOwned
)
/* shouldn't happen */
if
(
amOwned
)
/* shouldn't happen */
elog
(
ERROR
,
"
recursiveDeletion:
multiple INTERNAL dependencies for %s"
,
elog
(
ERROR
,
"multiple INTERNAL dependencies for %s"
,
objDescription
);
objDescription
);
owningObject
=
otherObject
;
owningObject
=
otherObject
;
amOwned
=
true
;
amOwned
=
true
;
...
@@ -492,11 +501,11 @@ recursiveDeletion(const ObjectAddress *object,
...
@@ -492,11 +501,11 @@ recursiveDeletion(const ObjectAddress *object,
* Should not happen; PIN dependencies should have zeroes
* Should not happen; PIN dependencies should have zeroes
* in the depender fields...
* in the depender fields...
*/
*/
elog
(
ERROR
,
"
recursiveDeletion:
incorrect use of PIN dependency with %s"
,
elog
(
ERROR
,
"incorrect use of PIN dependency with %s"
,
objDescription
);
objDescription
);
break
;
break
;
default:
default:
elog
(
ERROR
,
"
recursiveDeletion: unknown
dependency type '%c' for %s"
,
elog
(
ERROR
,
"
unrecognized
dependency type '%c' for %s"
,
foundDep
->
deptype
,
objDescription
);
foundDep
->
deptype
,
objDescription
);
break
;
break
;
}
}
...
@@ -522,18 +531,21 @@ recursiveDeletion(const ObjectAddress *object,
...
@@ -522,18 +531,21 @@ recursiveDeletion(const ObjectAddress *object,
if
(
amOwned
)
if
(
amOwned
)
{
{
if
(
object_address_present
(
&
owningObject
,
oktodelete
))
if
(
object_address_present
(
&
owningObject
,
oktodelete
))
elog
(
DEBUG2
,
"Drop auto-cascades to %s"
,
ereport
(
DEBUG2
,
getObjectDescription
(
&
owningObject
));
(
errmsg
(
"drop auto-cascades to %s"
,
getObjectDescription
(
&
owningObject
))));
else
if
(
behavior
==
DROP_RESTRICT
)
else
if
(
behavior
==
DROP_RESTRICT
)
{
{
elog
(
msglevel
,
"%s depends on %s"
,
ereport
(
msglevel
,
getObjectDescription
(
&
owningObject
),
(
errmsg
(
"%s depends on %s"
,
objDescription
);
getObjectDescription
(
&
owningObject
),
objDescription
)));
ok
=
false
;
ok
=
false
;
}
}
else
else
elog
(
msglevel
,
"Drop cascades to %s"
,
ereport
(
msglevel
,
getObjectDescription
(
&
owningObject
));
(
errmsg
(
"drop cascades to %s"
,
getObjectDescription
(
&
owningObject
))));
if
(
!
recursiveDeletion
(
&
owningObject
,
behavior
,
msglevel
,
if
(
!
recursiveDeletion
(
&
owningObject
,
behavior
,
msglevel
,
object
,
oktodelete
,
depRel
))
object
,
oktodelete
,
depRel
))
...
@@ -669,18 +681,21 @@ deleteDependentObjects(const ObjectAddress *object,
...
@@ -669,18 +681,21 @@ deleteDependentObjects(const ObjectAddress *object,
* In that case, act like this link is AUTO, too.
* In that case, act like this link is AUTO, too.
*/
*/
if
(
object_address_present
(
&
otherObject
,
oktodelete
))
if
(
object_address_present
(
&
otherObject
,
oktodelete
))
elog
(
DEBUG2
,
"Drop auto-cascades to %s"
,
ereport
(
DEBUG2
,
getObjectDescription
(
&
otherObject
));
(
errmsg
(
"drop auto-cascades to %s"
,
getObjectDescription
(
&
otherObject
))));
else
if
(
behavior
==
DROP_RESTRICT
)
else
if
(
behavior
==
DROP_RESTRICT
)
{
{
elog
(
msglevel
,
"%s depends on %s"
,
ereport
(
msglevel
,
getObjectDescription
(
&
otherObject
),
(
errmsg
(
"%s depends on %s"
,
objDescription
);
getObjectDescription
(
&
otherObject
),
objDescription
)));
ok
=
false
;
ok
=
false
;
}
}
else
else
elog
(
msglevel
,
"Drop cascades to %s"
,
ereport
(
msglevel
,
getObjectDescription
(
&
otherObject
));
(
errmsg
(
"drop cascades to %s"
,
getObjectDescription
(
&
otherObject
))));
if
(
!
recursiveDeletion
(
&
otherObject
,
behavior
,
msglevel
,
if
(
!
recursiveDeletion
(
&
otherObject
,
behavior
,
msglevel
,
object
,
oktodelete
,
depRel
))
object
,
oktodelete
,
depRel
))
...
@@ -694,8 +709,9 @@ deleteDependentObjects(const ObjectAddress *object,
...
@@ -694,8 +709,9 @@ deleteDependentObjects(const ObjectAddress *object,
* RESTRICT case. (However, normal dependencies on the
* RESTRICT case. (However, normal dependencies on the
* component object could still cause failure.)
* component object could still cause failure.)
*/
*/
elog
(
DEBUG2
,
"Drop auto-cascades to %s"
,
ereport
(
DEBUG2
,
getObjectDescription
(
&
otherObject
));
(
errmsg
(
"drop auto-cascades to %s"
,
getObjectDescription
(
&
otherObject
))));
if
(
!
recursiveDeletion
(
&
otherObject
,
behavior
,
msglevel
,
if
(
!
recursiveDeletion
(
&
otherObject
,
behavior
,
msglevel
,
object
,
oktodelete
,
depRel
))
object
,
oktodelete
,
depRel
))
...
@@ -704,14 +720,16 @@ deleteDependentObjects(const ObjectAddress *object,
...
@@ -704,14 +720,16 @@ deleteDependentObjects(const ObjectAddress *object,
case
DEPENDENCY_PIN
:
case
DEPENDENCY_PIN
:
/*
/*
* For a PIN dependency we just e
log
immediately; there
* For a PIN dependency we just e
report
immediately; there
* won't be any others to report.
* won't be any others to report.
*/
*/
elog
(
ERROR
,
"Cannot drop %s because it is required by the database system"
,
ereport
(
ERROR
,
objDescription
);
(
errcode
(
ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST
),
errmsg
(
"cannot drop %s because it is required by the database system"
,
objDescription
)));
break
;
break
;
default:
default:
elog
(
ERROR
,
"
recursiveDeletion: unknown
dependency type '%c' for %s"
,
elog
(
ERROR
,
"
unrecognized
dependency type '%c' for %s"
,
foundDep
->
deptype
,
objDescription
);
foundDep
->
deptype
,
objDescription
);
break
;
break
;
}
}
...
@@ -800,7 +818,7 @@ doDeletion(const ObjectAddress *object)
...
@@ -800,7 +818,7 @@ doDeletion(const ObjectAddress *object)
break
;
break
;
default:
default:
elog
(
ERROR
,
"
doDeletion: Unsupported object class
%u"
,
elog
(
ERROR
,
"
unrecognized object class:
%u"
,
object
->
classId
);
object
->
classId
);
}
}
}
}
...
@@ -968,12 +986,10 @@ find_expr_references_walker(Node *node,
...
@@ -968,12 +986,10 @@ find_expr_references_walker(Node *node,
rtables
=
lnext
(
rtables
);
rtables
=
lnext
(
rtables
);
}
}
if
(
rtables
==
NIL
)
if
(
rtables
==
NIL
)
elog
(
ERROR
,
"find_expr_references_walker: bogus varlevelsup %d"
,
elog
(
ERROR
,
"invalid varlevelsup %d"
,
var
->
varlevelsup
);
var
->
varlevelsup
);
rtable
=
lfirst
(
rtables
);
rtable
=
lfirst
(
rtables
);
if
(
var
->
varno
<=
0
||
var
->
varno
>
length
(
rtable
))
if
(
var
->
varno
<=
0
||
var
->
varno
>
length
(
rtable
))
elog
(
ERROR
,
"find_expr_references_walker: bogus varno %d"
,
elog
(
ERROR
,
"invalid varno %d"
,
var
->
varno
);
var
->
varno
);
rte
=
rt_fetch
(
var
->
varno
,
rtable
);
rte
=
rt_fetch
(
var
->
varno
,
rtable
);
if
(
rte
->
rtekind
==
RTE_RELATION
)
if
(
rte
->
rtekind
==
RTE_RELATION
)
{
{
...
@@ -992,8 +1008,7 @@ find_expr_references_walker(Node *node,
...
@@ -992,8 +1008,7 @@ find_expr_references_walker(Node *node,
context
->
rtables
=
rtables
;
context
->
rtables
=
rtables
;
if
(
var
->
varattno
<=
0
||
if
(
var
->
varattno
<=
0
||
var
->
varattno
>
length
(
rte
->
joinaliasvars
))
var
->
varattno
>
length
(
rte
->
joinaliasvars
))
elog
(
ERROR
,
"find_expr_references_walker: bogus varattno %d"
,
elog
(
ERROR
,
"invalid varattno %d"
,
var
->
varattno
);
var
->
varattno
);
find_expr_references_walker
((
Node
*
)
nth
(
var
->
varattno
-
1
,
find_expr_references_walker
((
Node
*
)
nth
(
var
->
varattno
-
1
,
rte
->
joinaliasvars
),
rte
->
joinaliasvars
),
context
);
context
);
...
@@ -1064,7 +1079,7 @@ find_expr_references_walker(Node *node,
...
@@ -1064,7 +1079,7 @@ find_expr_references_walker(Node *node,
if
(
is_subplan
(
node
))
if
(
is_subplan
(
node
))
{
{
/* Extra work needed here if we ever need this case */
/* Extra work needed here if we ever need this case */
elog
(
ERROR
,
"
find_expr_references_walker:
already-planned subqueries not supported"
);
elog
(
ERROR
,
"already-planned subqueries not supported"
);
}
}
if
(
IsA
(
node
,
Query
))
if
(
IsA
(
node
,
Query
))
{
{
...
@@ -1400,8 +1415,7 @@ getObjectClass(const ObjectAddress *object)
...
@@ -1400,8 +1415,7 @@ getObjectClass(const ObjectAddress *object)
return
OCLASS_SCHEMA
;
return
OCLASS_SCHEMA
;
}
}
elog
(
ERROR
,
"getObjectClass: Unknown object class %u"
,
elog
(
ERROR
,
"unrecognized object class: %u"
,
object
->
classId
);
object
->
classId
);
return
OCLASS_CLASS
;
/* keep compiler quiet */
return
OCLASS_CLASS
;
/* keep compiler quiet */
}
}
...
@@ -1457,7 +1471,7 @@ getObjectDescription(const ObjectAddress *object)
...
@@ -1457,7 +1471,7 @@ getObjectDescription(const ObjectAddress *object)
tup
=
systable_getnext
(
rcscan
);
tup
=
systable_getnext
(
rcscan
);
if
(
!
HeapTupleIsValid
(
tup
))
if
(
!
HeapTupleIsValid
(
tup
))
elog
(
ERROR
,
"
getObjectDescription: Cast %u does not exist
"
,
elog
(
ERROR
,
"
could not find tuple for cast %u
"
,
object
->
objectId
);
object
->
objectId
);
castForm
=
(
Form_pg_cast
)
GETSTRUCT
(
tup
);
castForm
=
(
Form_pg_cast
)
GETSTRUCT
(
tup
);
...
@@ -1491,7 +1505,7 @@ getObjectDescription(const ObjectAddress *object)
...
@@ -1491,7 +1505,7 @@ getObjectDescription(const ObjectAddress *object)
tup
=
systable_getnext
(
rcscan
);
tup
=
systable_getnext
(
rcscan
);
if
(
!
HeapTupleIsValid
(
tup
))
if
(
!
HeapTupleIsValid
(
tup
))
elog
(
ERROR
,
"
getObjectDescription: Constraint %u does not exist
"
,
elog
(
ERROR
,
"
could not find tuple for constraint %u
"
,
object
->
objectId
);
object
->
objectId
);
con
=
(
Form_pg_constraint
)
GETSTRUCT
(
tup
);
con
=
(
Form_pg_constraint
)
GETSTRUCT
(
tup
);
...
@@ -1521,7 +1535,7 @@ getObjectDescription(const ObjectAddress *object)
...
@@ -1521,7 +1535,7 @@ getObjectDescription(const ObjectAddress *object)
ObjectIdGetDatum
(
object
->
objectId
),
ObjectIdGetDatum
(
object
->
objectId
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
conTup
))
if
(
!
HeapTupleIsValid
(
conTup
))
elog
(
ERROR
,
"
getObjectDescription: Conversion %u does not exist
"
,
elog
(
ERROR
,
"
cache lookup failed for conversion %u
"
,
object
->
objectId
);
object
->
objectId
);
appendStringInfo
(
&
buffer
,
"conversion %s"
,
appendStringInfo
(
&
buffer
,
"conversion %s"
,
NameStr
(((
Form_pg_conversion
)
GETSTRUCT
(
conTup
))
->
conname
));
NameStr
(((
Form_pg_conversion
)
GETSTRUCT
(
conTup
))
->
conname
));
...
@@ -1550,7 +1564,7 @@ getObjectDescription(const ObjectAddress *object)
...
@@ -1550,7 +1564,7 @@ getObjectDescription(const ObjectAddress *object)
tup
=
systable_getnext
(
adscan
);
tup
=
systable_getnext
(
adscan
);
if
(
!
HeapTupleIsValid
(
tup
))
if
(
!
HeapTupleIsValid
(
tup
))
elog
(
ERROR
,
"
getObjectDescription: Default %u does not exist
"
,
elog
(
ERROR
,
"
could not find tuple for attrdef %u
"
,
object
->
objectId
);
object
->
objectId
);
attrdef
=
(
Form_pg_attrdef
)
GETSTRUCT
(
tup
);
attrdef
=
(
Form_pg_attrdef
)
GETSTRUCT
(
tup
);
...
@@ -1575,7 +1589,7 @@ getObjectDescription(const ObjectAddress *object)
...
@@ -1575,7 +1589,7 @@ getObjectDescription(const ObjectAddress *object)
ObjectIdGetDatum
(
object
->
objectId
),
ObjectIdGetDatum
(
object
->
objectId
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
langTup
))
if
(
!
HeapTupleIsValid
(
langTup
))
elog
(
ERROR
,
"
getObjectDescription: Language %u does not exist
"
,
elog
(
ERROR
,
"
cache lookup failed for language %u
"
,
object
->
objectId
);
object
->
objectId
);
appendStringInfo
(
&
buffer
,
"language %s"
,
appendStringInfo
(
&
buffer
,
"language %s"
,
NameStr
(((
Form_pg_language
)
GETSTRUCT
(
langTup
))
->
lanname
));
NameStr
(((
Form_pg_language
)
GETSTRUCT
(
langTup
))
->
lanname
));
...
@@ -1600,7 +1614,7 @@ getObjectDescription(const ObjectAddress *object)
...
@@ -1600,7 +1614,7 @@ getObjectDescription(const ObjectAddress *object)
ObjectIdGetDatum
(
object
->
objectId
),
ObjectIdGetDatum
(
object
->
objectId
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
opcTup
))
if
(
!
HeapTupleIsValid
(
opcTup
))
elog
(
ERROR
,
"cache lookup
of opclass %u failed
"
,
elog
(
ERROR
,
"cache lookup
failed for opclass %u
"
,
object
->
objectId
);
object
->
objectId
);
opcForm
=
(
Form_pg_opclass
)
GETSTRUCT
(
opcTup
);
opcForm
=
(
Form_pg_opclass
)
GETSTRUCT
(
opcTup
);
...
@@ -1618,7 +1632,7 @@ getObjectDescription(const ObjectAddress *object)
...
@@ -1618,7 +1632,7 @@ getObjectDescription(const ObjectAddress *object)
ObjectIdGetDatum
(
opcForm
->
opcamid
),
ObjectIdGetDatum
(
opcForm
->
opcamid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
amTup
))
if
(
!
HeapTupleIsValid
(
amTup
))
elog
(
ERROR
,
"
syscache lookup for AM %u failed
"
,
elog
(
ERROR
,
"
cache lookup failed for access method %u
"
,
opcForm
->
opcamid
);
opcForm
->
opcamid
);
amForm
=
(
Form_pg_am
)
GETSTRUCT
(
amTup
);
amForm
=
(
Form_pg_am
)
GETSTRUCT
(
amTup
);
...
@@ -1650,7 +1664,7 @@ getObjectDescription(const ObjectAddress *object)
...
@@ -1650,7 +1664,7 @@ getObjectDescription(const ObjectAddress *object)
tup
=
systable_getnext
(
rcscan
);
tup
=
systable_getnext
(
rcscan
);
if
(
!
HeapTupleIsValid
(
tup
))
if
(
!
HeapTupleIsValid
(
tup
))
elog
(
ERROR
,
"
getObjectDescription: Rule %u does not exist
"
,
elog
(
ERROR
,
"
could not find tuple for rule %u
"
,
object
->
objectId
);
object
->
objectId
);
rule
=
(
Form_pg_rewrite
)
GETSTRUCT
(
tup
);
rule
=
(
Form_pg_rewrite
)
GETSTRUCT
(
tup
);
...
@@ -1684,7 +1698,7 @@ getObjectDescription(const ObjectAddress *object)
...
@@ -1684,7 +1698,7 @@ getObjectDescription(const ObjectAddress *object)
tup
=
systable_getnext
(
tgscan
);
tup
=
systable_getnext
(
tgscan
);
if
(
!
HeapTupleIsValid
(
tup
))
if
(
!
HeapTupleIsValid
(
tup
))
elog
(
ERROR
,
"
getObjectDescription: Trigger %u does not exist
"
,
elog
(
ERROR
,
"
could not find tuple for trigger %u
"
,
object
->
objectId
);
object
->
objectId
);
trig
=
(
Form_pg_trigger
)
GETSTRUCT
(
tup
);
trig
=
(
Form_pg_trigger
)
GETSTRUCT
(
tup
);
...
@@ -1704,7 +1718,7 @@ getObjectDescription(const ObjectAddress *object)
...
@@ -1704,7 +1718,7 @@ getObjectDescription(const ObjectAddress *object)
nspname
=
get_namespace_name
(
object
->
objectId
);
nspname
=
get_namespace_name
(
object
->
objectId
);
if
(
!
nspname
)
if
(
!
nspname
)
elog
(
ERROR
,
"
getObjectDescription: Schema %u does not exist
"
,
elog
(
ERROR
,
"
cache lookup failed for namespace %u
"
,
object
->
objectId
);
object
->
objectId
);
appendStringInfo
(
&
buffer
,
"schema %s"
,
nspname
);
appendStringInfo
(
&
buffer
,
"schema %s"
,
nspname
);
break
;
break
;
...
@@ -1736,7 +1750,7 @@ getRelationDescription(StringInfo buffer, Oid relid)
...
@@ -1736,7 +1750,7 @@ getRelationDescription(StringInfo buffer, Oid relid)
ObjectIdGetDatum
(
relid
),
ObjectIdGetDatum
(
relid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
relTup
))
if
(
!
HeapTupleIsValid
(
relTup
))
elog
(
ERROR
,
"cache lookup
of relation %u failed
"
,
relid
);
elog
(
ERROR
,
"cache lookup
failed for relation %u
"
,
relid
);
relForm
=
(
Form_pg_class
)
GETSTRUCT
(
relTup
);
relForm
=
(
Form_pg_class
)
GETSTRUCT
(
relTup
);
/* Qualify the name if not visible in search path */
/* Qualify the name if not visible in search path */
...
...
src/backend/catalog/heap.c
View file @
d8528630
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.24
7 2003/07/20 21:56:32
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.24
8 2003/07/21 01:59:08
tgl Exp $
*
*
*
*
* INTERFACE ROUTINES
* INTERFACE ROUTINES
...
@@ -147,17 +147,16 @@ static Form_pg_attribute SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6, &a7};
...
@@ -147,17 +147,16 @@ static Form_pg_attribute SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6, &a7};
/*
/*
* This function returns a Form_pg_attribute pointer for a system attribute.
* This function returns a Form_pg_attribute pointer for a system attribute.
* Note that we elog if the presented attno is invalid.
* Note that we elog if the presented attno is invalid, which would only
* happen if there's a problem upstream.
*/
*/
Form_pg_attribute
Form_pg_attribute
SystemAttributeDefinition
(
AttrNumber
attno
,
bool
relhasoids
)
SystemAttributeDefinition
(
AttrNumber
attno
,
bool
relhasoids
)
{
{
if
(
attno
>=
0
||
attno
<
-
(
int
)
lengthof
(
SysAtt
))
if
(
attno
>=
0
||
attno
<
-
(
int
)
lengthof
(
SysAtt
))
elog
(
ERROR
,
"SystemAttributeDefinition: invalid attribute number %d"
,
elog
(
ERROR
,
"invalid system attribute number %d"
,
attno
);
attno
);
if
(
attno
==
ObjectIdAttributeNumber
&&
!
relhasoids
)
if
(
attno
==
ObjectIdAttributeNumber
&&
!
relhasoids
)
elog
(
ERROR
,
"SystemAttributeDefinition: invalid attribute number %d"
,
elog
(
ERROR
,
"invalid system attribute number %d"
,
attno
);
attno
);
return
SysAtt
[
-
attno
-
1
];
return
SysAtt
[
-
attno
-
1
];
}
}
...
@@ -223,9 +222,11 @@ heap_create(const char *relname,
...
@@ -223,9 +222,11 @@ heap_create(const char *relname,
if
(
!
allow_system_table_mods
&&
if
(
!
allow_system_table_mods
&&
(
IsSystemNamespace
(
relnamespace
)
||
IsToastNamespace
(
relnamespace
))
&&
(
IsSystemNamespace
(
relnamespace
)
||
IsToastNamespace
(
relnamespace
))
&&
IsNormalProcessingMode
())
IsNormalProcessingMode
())
elog
(
ERROR
,
"cannot create %s.%s: "
ereport
(
ERROR
,
"system catalog modifications are currently disallowed"
,
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
get_namespace_name
(
relnamespace
),
relname
);
errmsg
(
"permission denied to create
\"
%s.%s
\"
"
,
get_namespace_name
(
relnamespace
),
relname
),
errdetail
(
"System catalog modifications are currently disallowed."
)));
/*
/*
* Real ugly stuff to assign the proper relid in the relation
* Real ugly stuff to assign the proper relid in the relation
...
@@ -338,7 +339,7 @@ heap_storage_create(Relation rel)
...
@@ -338,7 +339,7 @@ heap_storage_create(Relation rel)
*
*
* this is used to make certain the tuple descriptor contains a
* this is used to make certain the tuple descriptor contains a
* valid set of attribute names and datatypes. a problem simply
* valid set of attribute names and datatypes. a problem simply
* generates e
log
(ERROR) which aborts the current transaction.
* generates e
report
(ERROR) which aborts the current transaction.
* --------------------------------
* --------------------------------
*/
*/
void
void
...
@@ -367,8 +368,10 @@ CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind)
...
@@ -367,8 +368,10 @@ CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind)
{
{
if
(
SystemAttributeByName
(
NameStr
(
tupdesc
->
attrs
[
i
]
->
attname
),
if
(
SystemAttributeByName
(
NameStr
(
tupdesc
->
attrs
[
i
]
->
attname
),
tupdesc
->
tdhasoid
)
!=
NULL
)
tupdesc
->
tdhasoid
)
!=
NULL
)
elog
(
ERROR
,
"name of column
\"
%s
\"
conflicts with an existing system column"
,
ereport
(
ERROR
,
NameStr
(
tupdesc
->
attrs
[
i
]
->
attname
));
(
errcode
(
ERRCODE_DUPLICATE_COLUMN
),
errmsg
(
"column name
\"
%s
\"
conflicts with a system column name"
,
NameStr
(
tupdesc
->
attrs
[
i
]
->
attname
))));
}
}
}
}
...
@@ -381,8 +384,10 @@ CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind)
...
@@ -381,8 +384,10 @@ CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind)
{
{
if
(
strcmp
(
NameStr
(
tupdesc
->
attrs
[
j
]
->
attname
),
if
(
strcmp
(
NameStr
(
tupdesc
->
attrs
[
j
]
->
attname
),
NameStr
(
tupdesc
->
attrs
[
i
]
->
attname
))
==
0
)
NameStr
(
tupdesc
->
attrs
[
i
]
->
attname
))
==
0
)
elog
(
ERROR
,
"column name
\"
%s
\"
is duplicated"
,
ereport
(
ERROR
,
NameStr
(
tupdesc
->
attrs
[
j
]
->
attname
));
(
errcode
(
ERRCODE_DUPLICATE_COLUMN
),
errmsg
(
"column name
\"
%s
\"
is duplicated"
,
NameStr
(
tupdesc
->
attrs
[
j
]
->
attname
))));
}
}
}
}
...
@@ -419,23 +424,28 @@ CheckAttributeType(const char *attname, Oid atttypid)
...
@@ -419,23 +424,28 @@ CheckAttributeType(const char *attname, Oid atttypid)
* Berkeley-derived code that thinks it can do this...)
* Berkeley-derived code that thinks it can do this...)
*/
*/
if
(
atttypid
==
UNKNOWNOID
)
if
(
atttypid
==
UNKNOWNOID
)
elog
(
WARNING
,
"Attribute
\"
%s
\"
has an unknown type"
ereport
(
WARNING
,
"
\n\t
Proceeding with relation creation anyway"
,
(
errcode
(
ERRCODE_INVALID_TABLE_DEFINITION
),
attname
);
errmsg
(
"attribute
\"
%s
\"
has type UNKNOWN"
,
attname
),
errdetail
(
"Proceeding with relation creation anyway."
)));
else
if
(
att_typtype
==
'p'
)
else
if
(
att_typtype
==
'p'
)
{
{
/* Special hack for pg_statistic: allow ANYARRAY during initdb */
/* Special hack for pg_statistic: allow ANYARRAY during initdb */
if
(
atttypid
!=
ANYARRAYOID
||
IsUnderPostmaster
)
if
(
atttypid
!=
ANYARRAYOID
||
IsUnderPostmaster
)
elog
(
ERROR
,
"Attribute
\"
%s
\"
has pseudo-type %s"
,
ereport
(
ERROR
,
attname
,
format_type_be
(
atttypid
));
(
errcode
(
ERRCODE_INVALID_TABLE_DEFINITION
),
errmsg
(
"attribute
\"
%s
\"
has pseudo-type %s"
,
attname
,
format_type_be
(
atttypid
))));
}
}
else
if
(
att_typtype
==
'c'
)
else
if
(
att_typtype
==
'c'
)
{
{
Oid
typrelid
=
get_typ_typrelid
(
atttypid
);
Oid
typrelid
=
get_typ_typrelid
(
atttypid
);
if
(
get_rel_relkind
(
typrelid
)
==
RELKIND_COMPOSITE_TYPE
)
if
(
get_rel_relkind
(
typrelid
)
==
RELKIND_COMPOSITE_TYPE
)
elog
(
ERROR
,
"Attribute
\"
%s
\"
has composite type %s"
,
ereport
(
ERROR
,
attname
,
format_type_be
(
atttypid
));
(
errcode
(
ERRCODE_INVALID_TABLE_DEFINITION
),
errmsg
(
"attribute
\"
%s
\"
has composite type %s"
,
attname
,
format_type_be
(
atttypid
))));
}
}
}
}
...
@@ -719,7 +729,9 @@ heap_create_with_catalog(const char *relname,
...
@@ -719,7 +729,9 @@ heap_create_with_catalog(const char *relname,
CheckAttributeNamesTypes
(
tupdesc
,
relkind
);
CheckAttributeNamesTypes
(
tupdesc
,
relkind
);
if
(
get_relname_relid
(
relname
,
relnamespace
))
if
(
get_relname_relid
(
relname
,
relnamespace
))
elog
(
ERROR
,
"Relation '%s' already exists"
,
relname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DUPLICATE_TABLE
),
errmsg
(
"relation
\"
%s
\"
already exists"
,
relname
)));
/*
/*
* Create the relcache entry (mostly dummy at this point) and the
* Create the relcache entry (mostly dummy at this point) and the
...
@@ -955,7 +967,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
...
@@ -955,7 +967,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
Int16GetDatum
(
attnum
),
Int16GetDatum
(
attnum
),
0
,
0
);
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
/* shouldn't happen */
if
(
!
HeapTupleIsValid
(
tuple
))
/* shouldn't happen */
elog
(
ERROR
,
"
RemoveAttributeById: Failed to find attribute %d in
relation %u"
,
elog
(
ERROR
,
"
cache lookup failed for attribute %d of
relation %u"
,
attnum
,
relid
);
attnum
,
relid
);
attStruct
=
(
Form_pg_attribute
)
GETSTRUCT
(
tuple
);
attStruct
=
(
Form_pg_attribute
)
GETSTRUCT
(
tuple
);
...
@@ -1047,7 +1059,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
...
@@ -1047,7 +1059,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
heap_close
(
attrdef_rel
,
RowExclusiveLock
);
heap_close
(
attrdef_rel
,
RowExclusiveLock
);
if
(
complain
&&
!
found
)
if
(
complain
&&
!
found
)
elog
(
ERROR
,
"
RemoveAttrDefault: no default found for rel
%u attnum %d"
,
elog
(
ERROR
,
"
could not find attrdef tuple for relation
%u attnum %d"
,
relid
,
attnum
);
relid
,
attnum
);
}
}
...
@@ -1160,8 +1172,7 @@ heap_drop_with_catalog(Oid rid)
...
@@ -1160,8 +1172,7 @@ heap_drop_with_catalog(Oid rid)
*/
*/
i
=
FlushRelationBuffers
(
rel
,
(
BlockNumber
)
0
);
i
=
FlushRelationBuffers
(
rel
,
(
BlockNumber
)
0
);
if
(
i
<
0
)
if
(
i
<
0
)
elog
(
ERROR
,
"heap_drop_with_catalog: FlushRelationBuffers returned %d"
,
elog
(
ERROR
,
"FlushRelationBuffers returned %d"
,
i
);
i
);
/*
/*
* remove inheritance information
* remove inheritance information
...
@@ -1539,8 +1550,10 @@ AddRelationRawConstraints(Relation rel,
...
@@ -1539,8 +1550,10 @@ AddRelationRawConstraints(Relation rel,
RelationGetRelid
(
rel
),
RelationGetRelid
(
rel
),
RelationGetNamespace
(
rel
),
RelationGetNamespace
(
rel
),
ccname
))
ccname
))
elog
(
ERROR
,
"constraint
\"
%s
\"
for relation
\"
%s
\"
already exists"
,
ereport
(
ERROR
,
ccname
,
RelationGetRelationName
(
rel
));
(
errcode
(
ERRCODE_DUPLICATE_OBJECT
),
errmsg
(
"constraint
\"
%s
\"
for relation
\"
%s
\"
already exists"
,
ccname
,
RelationGetRelationName
(
rel
))));
/* Check against other new constraints */
/* Check against other new constraints */
/* Needed because we don't do CommandCounterIncrement in loop */
/* Needed because we don't do CommandCounterIncrement in loop */
foreach
(
listptr2
,
rawConstraints
)
foreach
(
listptr2
,
rawConstraints
)
...
@@ -1553,8 +1566,10 @@ AddRelationRawConstraints(Relation rel,
...
@@ -1553,8 +1566,10 @@ AddRelationRawConstraints(Relation rel,
cdef2
->
name
==
NULL
)
cdef2
->
name
==
NULL
)
continue
;
continue
;
if
(
strcmp
(
cdef2
->
name
,
ccname
)
==
0
)
if
(
strcmp
(
cdef2
->
name
,
ccname
)
==
0
)
elog
(
ERROR
,
"Duplicate CHECK constraint name: '%s'"
,
ereport
(
ERROR
,
ccname
);
(
errcode
(
ERRCODE_DUPLICATE_OBJECT
),
errmsg
(
"CHECK constraint
\"
%s
\"
already exists"
,
ccname
)));
}
}
}
}
else
else
...
@@ -1613,16 +1628,22 @@ AddRelationRawConstraints(Relation rel,
...
@@ -1613,16 +1628,22 @@ AddRelationRawConstraints(Relation rel,
* Make sure no outside relations are referred to.
* Make sure no outside relations are referred to.
*/
*/
if
(
length
(
pstate
->
p_rtable
)
!=
1
)
if
(
length
(
pstate
->
p_rtable
)
!=
1
)
elog
(
ERROR
,
"Only relation
\"
%s
\"
can be referenced in CHECK constraint expression"
,
ereport
(
ERROR
,
relname
);
(
errcode
(
ERRCODE_INVALID_COLUMN_REFERENCE
),
errmsg
(
"only relation
\"
%s
\"
can be referenced in CHECK constraint"
,
relname
)));
/*
/*
* No subplans or aggregates, either...
* No subplans or aggregates, either...
*/
*/
if
(
pstate
->
p_hasSubLinks
)
if
(
pstate
->
p_hasSubLinks
)
elog
(
ERROR
,
"cannot use subselect in CHECK constraint expression"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"cannot use sub-select in CHECK constraint"
)));
if
(
pstate
->
p_hasAggs
)
if
(
pstate
->
p_hasAggs
)
elog
(
ERROR
,
"cannot use aggregate function in CHECK constraint expression"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_GROUPING_ERROR
),
errmsg
(
"cannot use aggregate in CHECK constraint"
)));
/*
/*
* Constraints are evaluated with execQual, which expects an
* Constraints are evaluated with execQual, which expects an
...
@@ -1727,21 +1748,29 @@ cookDefault(ParseState *pstate,
...
@@ -1727,21 +1748,29 @@ cookDefault(ParseState *pstate,
* Make sure default expr does not refer to any vars.
* Make sure default expr does not refer to any vars.
*/
*/
if
(
contain_var_clause
(
expr
))
if
(
contain_var_clause
(
expr
))
elog
(
ERROR
,
"cannot use column references in DEFAULT clause"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_COLUMN_REFERENCE
),
errmsg
(
"cannot use column references in DEFAULT clause"
)));
/*
/*
* It can't return a set either.
* It can't return a set either.
*/
*/
if
(
expression_returns_set
(
expr
))
if
(
expression_returns_set
(
expr
))
elog
(
ERROR
,
"DEFAULT clause must not return a set"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"DEFAULT clause must not return a set"
)));
/*
/*
* No subplans or aggregates, either...
* No subplans or aggregates, either...
*/
*/
if
(
pstate
->
p_hasSubLinks
)
if
(
pstate
->
p_hasSubLinks
)
elog
(
ERROR
,
"cannot use subselects in DEFAULT clause"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"cannot use sub-select in DEFAULT clause"
)));
if
(
pstate
->
p_hasAggs
)
if
(
pstate
->
p_hasAggs
)
elog
(
ERROR
,
"cannot use aggregate functions in DEFAULT clause"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_GROUPING_ERROR
),
errmsg
(
"cannot use aggregate in DEFAULT clause"
)));
/*
/*
* Check that it will be possible to coerce the expression to the
* Check that it will be possible to coerce the expression to the
...
@@ -1762,12 +1791,14 @@ cookDefault(ParseState *pstate,
...
@@ -1762,12 +1791,14 @@ cookDefault(ParseState *pstate,
atttypid
,
atttypmod
,
atttypid
,
atttypmod
,
COERCION_ASSIGNMENT
,
COERCION_ASSIGNMENT
,
COERCE_IMPLICIT_CAST
)
==
NULL
)
COERCE_IMPLICIT_CAST
)
==
NULL
)
elog
(
ERROR
,
"Column
\"
%s
\"
is of type %s"
ereport
(
ERROR
,
" but default expression is of type %s"
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
"
\n\t
You will need to rewrite or cast the expression"
,
errmsg
(
"column
\"
%s
\"
is of type %s"
attname
,
" but default expression is of type %s"
,
format_type_be
(
atttypid
),
attname
,
format_type_be
(
type_id
));
format_type_be
(
atttypid
),
format_type_be
(
type_id
)),
errhint
(
"You will need to rewrite or cast the expression."
)));
}
}
return
(
expr
);
return
(
expr
);
...
...
src/backend/catalog/index.c
View file @
d8528630
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.21
1 2003/05/29 00:54:42
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.21
2 2003/07/21 01:59:08
tgl Exp $
*
*
*
*
* INTERFACE ROUTINES
* INTERFACE ROUTINES
...
@@ -156,9 +156,8 @@ ConstructTupleDescriptor(Relation heapRelation,
...
@@ -156,9 +156,8 @@ ConstructTupleDescriptor(Relation heapRelation,
/*
/*
* here we are indexing on a normal attribute (1...n)
* here we are indexing on a normal attribute (1...n)
*/
*/
if
(
atnum
>
natts
)
if
(
atnum
>
natts
)
/* safety check */
elog
(
ERROR
,
"cannot create index: column %d does not exist"
,
elog
(
ERROR
,
"invalid column number %d"
,
atnum
);
atnum
);
from
=
heapTupDesc
->
attrs
[
AttrNumberGetAttrOffset
(
atnum
)];
from
=
heapTupDesc
->
attrs
[
AttrNumberGetAttrOffset
(
atnum
)];
}
}
...
@@ -186,7 +185,7 @@ ConstructTupleDescriptor(Relation heapRelation,
...
@@ -186,7 +185,7 @@ ConstructTupleDescriptor(Relation heapRelation,
/* Expressional index */
/* Expressional index */
Node
*
indexkey
;
Node
*
indexkey
;
if
(
indexprs
==
NIL
)
if
(
indexprs
==
NIL
)
/* shouldn't happen */
elog
(
ERROR
,
"too few entries in indexprs list"
);
elog
(
ERROR
,
"too few entries in indexprs list"
);
indexkey
=
(
Node
*
)
lfirst
(
indexprs
);
indexkey
=
(
Node
*
)
lfirst
(
indexprs
);
indexprs
=
lnext
(
indexprs
);
indexprs
=
lnext
(
indexprs
);
...
@@ -205,7 +204,7 @@ ConstructTupleDescriptor(Relation heapRelation,
...
@@ -205,7 +204,7 @@ ConstructTupleDescriptor(Relation heapRelation,
ObjectIdGetDatum
(
keyType
),
ObjectIdGetDatum
(
keyType
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"
Type %u does not exist
"
,
keyType
);
elog
(
ERROR
,
"
cache lookup failed for type %u
"
,
keyType
);
typeTup
=
(
Form_pg_type
)
GETSTRUCT
(
tuple
);
typeTup
=
(
Form_pg_type
)
GETSTRUCT
(
tuple
);
/*
/*
...
@@ -239,7 +238,8 @@ ConstructTupleDescriptor(Relation heapRelation,
...
@@ -239,7 +238,8 @@ ConstructTupleDescriptor(Relation heapRelation,
ObjectIdGetDatum
(
classObjectId
[
i
]),
ObjectIdGetDatum
(
classObjectId
[
i
]),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"Opclass %u does not exist"
,
classObjectId
[
i
]);
elog
(
ERROR
,
"cache lookup failed for opclass %u"
,
classObjectId
[
i
]);
keyType
=
((
Form_pg_opclass
)
GETSTRUCT
(
tuple
))
->
opckeytype
;
keyType
=
((
Form_pg_opclass
)
GETSTRUCT
(
tuple
))
->
opckeytype
;
ReleaseSysCache
(
tuple
);
ReleaseSysCache
(
tuple
);
...
@@ -250,7 +250,7 @@ ConstructTupleDescriptor(Relation heapRelation,
...
@@ -250,7 +250,7 @@ ConstructTupleDescriptor(Relation heapRelation,
ObjectIdGetDatum
(
keyType
),
ObjectIdGetDatum
(
keyType
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"
Type %u does not exist
"
,
keyType
);
elog
(
ERROR
,
"
cache lookup failed for type %u
"
,
keyType
);
typeTup
=
(
Form_pg_type
)
GETSTRUCT
(
tuple
);
typeTup
=
(
Form_pg_type
)
GETSTRUCT
(
tuple
);
to
->
atttypid
=
keyType
;
to
->
atttypid
=
keyType
;
...
@@ -520,7 +520,9 @@ index_create(Oid heapRelationId,
...
@@ -520,7 +520,9 @@ index_create(Oid heapRelationId,
if
(
!
allow_system_table_mods
&&
if
(
!
allow_system_table_mods
&&
IsSystemRelation
(
heapRelation
)
&&
IsSystemRelation
(
heapRelation
)
&&
IsNormalProcessingMode
())
IsNormalProcessingMode
())
elog
(
ERROR
,
"User-defined indexes on system catalogs are not supported"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"user-defined indexes on system catalogs are not supported"
)));
/*
/*
* We cannot allow indexing a shared relation after initdb (because
* We cannot allow indexing a shared relation after initdb (because
...
@@ -530,11 +532,15 @@ index_create(Oid heapRelationId,
...
@@ -530,11 +532,15 @@ index_create(Oid heapRelationId,
* under normal multi-user operation.
* under normal multi-user operation.
*/
*/
if
(
shared_relation
&&
IsUnderPostmaster
)
if
(
shared_relation
&&
IsUnderPostmaster
)
elog
(
ERROR
,
"Shared indexes cannot be created after initdb"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE
),
errmsg
(
"shared indexes cannot be created after initdb"
)));
if
(
get_relname_relid
(
indexRelationName
,
namespaceId
))
if
(
get_relname_relid
(
indexRelationName
,
namespaceId
))
elog
(
ERROR
,
"relation named
\"
%s
\"
already exists"
,
ereport
(
ERROR
,
indexRelationName
);
(
errcode
(
ERRCODE_DUPLICATE_TABLE
),
errmsg
(
"relation
\"
%s
\"
already exists"
,
indexRelationName
)));
/*
/*
* construct tuple descriptor for index tuples
* construct tuple descriptor for index tuples
...
@@ -639,7 +645,7 @@ index_create(Oid heapRelationId,
...
@@ -639,7 +645,7 @@ index_create(Oid heapRelationId,
constraintType
=
CONSTRAINT_UNIQUE
;
constraintType
=
CONSTRAINT_UNIQUE
;
else
else
{
{
elog
(
ERROR
,
"
index_create:
constraint must be PRIMARY or UNIQUE"
);
elog
(
ERROR
,
"constraint must be PRIMARY or UNIQUE"
);
constraintType
=
0
;
/* keep compiler quiet */
constraintType
=
0
;
/* keep compiler quiet */
}
}
...
@@ -807,8 +813,7 @@ index_drop(Oid indexId)
...
@@ -807,8 +813,7 @@ index_drop(Oid indexId)
ObjectIdGetDatum
(
indexId
),
ObjectIdGetDatum
(
indexId
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"index_drop: cache lookup failed for index %u"
,
elog
(
ERROR
,
"cache lookup failed for index %u"
,
indexId
);
indexId
);
simple_heap_delete
(
indexRelation
,
&
tuple
->
t_self
);
simple_heap_delete
(
indexRelation
,
&
tuple
->
t_self
);
...
@@ -820,7 +825,7 @@ index_drop(Oid indexId)
...
@@ -820,7 +825,7 @@ index_drop(Oid indexId)
*/
*/
i
=
FlushRelationBuffers
(
userIndexRelation
,
(
BlockNumber
)
0
);
i
=
FlushRelationBuffers
(
userIndexRelation
,
(
BlockNumber
)
0
);
if
(
i
<
0
)
if
(
i
<
0
)
elog
(
ERROR
,
"
index_drop:
FlushRelationBuffers returned %d"
,
i
);
elog
(
ERROR
,
"FlushRelationBuffers returned %d"
,
i
);
smgrunlink
(
DEFAULT_SMGR
,
userIndexRelation
);
smgrunlink
(
DEFAULT_SMGR
,
userIndexRelation
);
...
@@ -984,8 +989,10 @@ IndexesAreActive(Relation heaprel)
...
@@ -984,8 +989,10 @@ IndexesAreActive(Relation heaprel)
if
(
heaprel
->
rd_rel
->
relkind
!=
RELKIND_RELATION
&&
if
(
heaprel
->
rd_rel
->
relkind
!=
RELKIND_RELATION
&&
heaprel
->
rd_rel
->
relkind
!=
RELKIND_TOASTVALUE
)
heaprel
->
rd_rel
->
relkind
!=
RELKIND_TOASTVALUE
)
elog
(
ERROR
,
"relation %s isn't an indexable relation"
,
ereport
(
ERROR
,
RelationGetRelationName
(
heaprel
));
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"relation
\"
%s
\"
isn't an indexable relation"
,
RelationGetRelationName
(
heaprel
))));
/* If pg_class.relhasindex is set, indexes are active */
/* If pg_class.relhasindex is set, indexes are active */
isactive
=
heaprel
->
rd_rel
->
relhasindex
;
isactive
=
heaprel
->
rd_rel
->
relhasindex
;
...
@@ -1055,8 +1062,7 @@ setRelhasindex(Oid relid, bool hasindex, bool isprimary, Oid reltoastidxid)
...
@@ -1055,8 +1062,7 @@ setRelhasindex(Oid relid, bool hasindex, bool isprimary, Oid reltoastidxid)
}
}
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"setRelhasindex: cannot find relation %u in pg_class"
,
elog
(
ERROR
,
"could not find tuple for relation %u"
,
relid
);
relid
);
/*
/*
* Update fields in the pg_class tuple.
* Update fields in the pg_class tuple.
...
@@ -1171,7 +1177,7 @@ setNewRelfilenode(Relation relation)
...
@@ -1171,7 +1177,7 @@ setNewRelfilenode(Relation relation)
}
}
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"
setNewRelfilenode: cannot find relation %u in pg_class
"
,
elog
(
ERROR
,
"
could not find tuple for relation %u
"
,
RelationGetRelid
(
relation
));
RelationGetRelid
(
relation
));
rd_rel
=
(
Form_pg_class
)
GETSTRUCT
(
tuple
);
rd_rel
=
(
Form_pg_class
)
GETSTRUCT
(
tuple
);
...
@@ -1283,8 +1289,7 @@ UpdateStats(Oid relid, double reltuples)
...
@@ -1283,8 +1289,7 @@ UpdateStats(Oid relid, double reltuples)
}
}
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"UpdateStats: cannot find relation %u in pg_class"
,
elog
(
ERROR
,
"could not find tuple for relation %u"
,
relid
);
relid
);
/*
/*
* Figure values to insert.
* Figure values to insert.
...
@@ -1558,7 +1563,7 @@ IndexBuildHeapScan(Relation heapRelation,
...
@@ -1558,7 +1563,7 @@ IndexBuildHeapScan(Relation heapRelation,
*/
*/
if
(
!
TransactionIdIsCurrentTransactionId
(
if
(
!
TransactionIdIsCurrentTransactionId
(
HeapTupleHeaderGetXmin
(
heapTuple
->
t_data
)))
HeapTupleHeaderGetXmin
(
heapTuple
->
t_data
)))
elog
(
ERROR
,
"
IndexBuildHeapScan:
concurrent insert in progress"
);
elog
(
ERROR
,
"concurrent insert in progress"
);
indexIt
=
true
;
indexIt
=
true
;
tupleIsAlive
=
true
;
tupleIsAlive
=
true
;
break
;
break
;
...
@@ -1573,12 +1578,12 @@ IndexBuildHeapScan(Relation heapRelation,
...
@@ -1573,12 +1578,12 @@ IndexBuildHeapScan(Relation heapRelation,
*/
*/
if
(
!
TransactionIdIsCurrentTransactionId
(
if
(
!
TransactionIdIsCurrentTransactionId
(
HeapTupleHeaderGetXmax
(
heapTuple
->
t_data
)))
HeapTupleHeaderGetXmax
(
heapTuple
->
t_data
)))
elog
(
ERROR
,
"
IndexBuildHeapScan:
concurrent delete in progress"
);
elog
(
ERROR
,
"concurrent delete in progress"
);
indexIt
=
true
;
indexIt
=
true
;
tupleIsAlive
=
false
;
tupleIsAlive
=
false
;
break
;
break
;
default:
default:
elog
(
ERROR
,
"
U
nexpected HeapTupleSatisfiesVacuum result"
);
elog
(
ERROR
,
"
u
nexpected HeapTupleSatisfiesVacuum result"
);
indexIt
=
tupleIsAlive
=
false
;
/* keep compiler quiet */
indexIt
=
tupleIsAlive
=
false
;
/* keep compiler quiet */
break
;
break
;
}
}
...
@@ -1673,8 +1678,7 @@ IndexGetRelation(Oid indexId)
...
@@ -1673,8 +1678,7 @@ IndexGetRelation(Oid indexId)
ObjectIdGetDatum
(
indexId
),
ObjectIdGetDatum
(
indexId
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"IndexGetRelation: can't find index id %u"
,
elog
(
ERROR
,
"cache lookup failed for index %u"
,
indexId
);
indexId
);
index
=
(
Form_pg_index
)
GETSTRUCT
(
tuple
);
index
=
(
Form_pg_index
)
GETSTRUCT
(
tuple
);
Assert
(
index
->
indexrelid
==
indexId
);
Assert
(
index
->
indexrelid
==
indexId
);
...
@@ -1721,8 +1725,6 @@ reindex_index(Oid indexId, bool force, bool inplace)
...
@@ -1721,8 +1725,6 @@ reindex_index(Oid indexId, bool force, bool inplace)
* index is locked down.
* index is locked down.
*/
*/
iRel
=
index_open
(
indexId
);
iRel
=
index_open
(
indexId
);
if
(
iRel
==
NULL
)
elog
(
ERROR
,
"reindex_index: can't open index relation"
);
LockRelation
(
iRel
,
AccessExclusiveLock
);
LockRelation
(
iRel
,
AccessExclusiveLock
);
old
=
SetReindexProcessing
(
true
);
old
=
SetReindexProcessing
(
true
);
...
@@ -1732,8 +1734,6 @@ reindex_index(Oid indexId, bool force, bool inplace)
...
@@ -1732,8 +1734,6 @@ reindex_index(Oid indexId, bool force, bool inplace)
/* Open the parent heap relation */
/* Open the parent heap relation */
heapRelation
=
heap_open
(
heapId
,
AccessExclusiveLock
);
heapRelation
=
heap_open
(
heapId
,
AccessExclusiveLock
);
if
(
heapRelation
==
NULL
)
elog
(
ERROR
,
"reindex_index: can't open heap relation"
);
/*
/*
* If it's a shared index, we must do inplace processing (because we
* If it's a shared index, we must do inplace processing (because we
...
@@ -1747,13 +1747,17 @@ reindex_index(Oid indexId, bool force, bool inplace)
...
@@ -1747,13 +1747,17 @@ reindex_index(Oid indexId, bool force, bool inplace)
if
(
iRel
->
rd_rel
->
relisshared
)
if
(
iRel
->
rd_rel
->
relisshared
)
{
{
if
(
!
IsIgnoringSystemIndexes
())
if
(
!
IsIgnoringSystemIndexes
())
elog
(
ERROR
,
"the target relation %u is shared"
,
indexId
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE
),
errmsg
(
"the target relation %u is shared"
,
indexId
)));
inplace
=
true
;
inplace
=
true
;
}
}
if
(
iRel
->
rd_isnailed
)
if
(
iRel
->
rd_isnailed
)
{
{
if
(
!
IsIgnoringSystemIndexes
())
if
(
!
IsIgnoringSystemIndexes
())
elog
(
ERROR
,
"the target relation %u is nailed"
,
indexId
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE
),
errmsg
(
"the target relation %u is nailed"
,
indexId
)));
inplace
=
true
;
inplace
=
true
;
}
}
...
@@ -1870,7 +1874,9 @@ reindex_relation(Oid relid, bool force)
...
@@ -1870,7 +1874,9 @@ reindex_relation(Oid relid, bool force)
deactivate_needed
=
true
;
deactivate_needed
=
true
;
}
}
else
else
elog
(
ERROR
,
"the target relation %u is shared"
,
relid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE
),
errmsg
(
"the target relation %u is shared"
,
relid
)));
}
}
old
=
SetReindexProcessing
(
true
);
old
=
SetReindexProcessing
(
true
);
...
...
src/backend/catalog/namespace.c
View file @
d8528630
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.5
3 2003/06/27 17:03:2
9 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.5
4 2003/07/21 01:59:0
9 tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -162,7 +162,9 @@ RangeVarGetRelid(const RangeVar *relation, bool failOK)
...
@@ -162,7 +162,9 @@ RangeVarGetRelid(const RangeVar *relation, bool failOK)
if
(
relation
->
catalogname
)
if
(
relation
->
catalogname
)
{
{
if
(
strcmp
(
relation
->
catalogname
,
get_database_name
(
MyDatabaseId
))
!=
0
)
if
(
strcmp
(
relation
->
catalogname
,
get_database_name
(
MyDatabaseId
))
!=
0
)
elog
(
ERROR
,
"Cross-database references are not implemented"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"cross-database references are not implemented"
)));
}
}
if
(
relation
->
schemaname
)
if
(
relation
->
schemaname
)
...
@@ -180,11 +182,15 @@ RangeVarGetRelid(const RangeVar *relation, bool failOK)
...
@@ -180,11 +182,15 @@ RangeVarGetRelid(const RangeVar *relation, bool failOK)
if
(
!
OidIsValid
(
relId
)
&&
!
failOK
)
if
(
!
OidIsValid
(
relId
)
&&
!
failOK
)
{
{
if
(
relation
->
schemaname
)
if
(
relation
->
schemaname
)
elog
(
ERROR
,
"Relation
\"
%s
\"
.
\"
%s
\"
does not exist"
,
ereport
(
ERROR
,
relation
->
schemaname
,
relation
->
relname
);
(
errcode
(
ERRCODE_UNDEFINED_TABLE
),
errmsg
(
"relation
\"
%s.%s
\"
does not exist"
,
relation
->
schemaname
,
relation
->
relname
)));
else
else
elog
(
ERROR
,
"Relation
\"
%s
\"
does not exist"
,
ereport
(
ERROR
,
relation
->
relname
);
(
errcode
(
ERRCODE_UNDEFINED_TABLE
),
errmsg
(
"relation
\"
%s
\"
does not exist"
,
relation
->
relname
)));
}
}
return
relId
;
return
relId
;
}
}
...
@@ -209,14 +215,18 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation)
...
@@ -209,14 +215,18 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation)
if
(
newRelation
->
catalogname
)
if
(
newRelation
->
catalogname
)
{
{
if
(
strcmp
(
newRelation
->
catalogname
,
get_database_name
(
MyDatabaseId
))
!=
0
)
if
(
strcmp
(
newRelation
->
catalogname
,
get_database_name
(
MyDatabaseId
))
!=
0
)
elog
(
ERROR
,
"Cross-database references are not implemented"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"cross-database references are not implemented"
)));
}
}
if
(
newRelation
->
istemp
)
if
(
newRelation
->
istemp
)
{
{
/* TEMP tables are created in our backend-local temp namespace */
/* TEMP tables are created in our backend-local temp namespace */
if
(
newRelation
->
schemaname
)
if
(
newRelation
->
schemaname
)
elog
(
ERROR
,
"TEMP tables may not specify a namespace"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_TABLE_DEFINITION
),
errmsg
(
"TEMP tables may not specify a schema name"
)));
/* Initialize temp namespace if first time through */
/* Initialize temp namespace if first time through */
if
(
!
OidIsValid
(
myTempNamespace
))
if
(
!
OidIsValid
(
myTempNamespace
))
InitTempTableNamespace
();
InitTempTableNamespace
();
...
@@ -230,8 +240,10 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation)
...
@@ -230,8 +240,10 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation)
CStringGetDatum
(
newRelation
->
schemaname
),
CStringGetDatum
(
newRelation
->
schemaname
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
OidIsValid
(
namespaceId
))
if
(
!
OidIsValid
(
namespaceId
))
elog
(
ERROR
,
"Namespace
\"
%s
\"
does not exist"
,
ereport
(
ERROR
,
newRelation
->
schemaname
);
(
errcode
(
ERRCODE_UNDEFINED_SCHEMA
),
errmsg
(
"schema
\"
%s
\"
does not exist"
,
newRelation
->
schemaname
)));
/* we do not check for USAGE rights here! */
/* we do not check for USAGE rights here! */
}
}
else
else
...
@@ -240,7 +252,9 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation)
...
@@ -240,7 +252,9 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation)
recomputeNamespacePath
();
recomputeNamespacePath
();
namespaceId
=
defaultCreationNamespace
;
namespaceId
=
defaultCreationNamespace
;
if
(
!
OidIsValid
(
namespaceId
))
if
(
!
OidIsValid
(
namespaceId
))
elog
(
ERROR
,
"No namespace has been selected to create in"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_SCHEMA
),
errmsg
(
"no schema has been selected to create in"
)));
}
}
/* Note: callers will check for CREATE rights when appropriate */
/* Note: callers will check for CREATE rights when appropriate */
...
@@ -293,7 +307,7 @@ RelationIsVisible(Oid relid)
...
@@ -293,7 +307,7 @@ RelationIsVisible(Oid relid)
ObjectIdGetDatum
(
relid
),
ObjectIdGetDatum
(
relid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
reltup
))
if
(
!
HeapTupleIsValid
(
reltup
))
elog
(
ERROR
,
"
C
ache lookup failed for relation %u"
,
relid
);
elog
(
ERROR
,
"
c
ache lookup failed for relation %u"
,
relid
);
relform
=
(
Form_pg_class
)
GETSTRUCT
(
reltup
);
relform
=
(
Form_pg_class
)
GETSTRUCT
(
reltup
);
recomputeNamespacePath
();
recomputeNamespacePath
();
...
@@ -375,7 +389,7 @@ TypeIsVisible(Oid typid)
...
@@ -375,7 +389,7 @@ TypeIsVisible(Oid typid)
ObjectIdGetDatum
(
typid
),
ObjectIdGetDatum
(
typid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
typtup
))
if
(
!
HeapTupleIsValid
(
typtup
))
elog
(
ERROR
,
"
C
ache lookup failed for type %u"
,
typid
);
elog
(
ERROR
,
"
c
ache lookup failed for type %u"
,
typid
);
typform
=
(
Form_pg_type
)
GETSTRUCT
(
typtup
);
typform
=
(
Form_pg_type
)
GETSTRUCT
(
typtup
);
recomputeNamespacePath
();
recomputeNamespacePath
();
...
@@ -576,7 +590,7 @@ FunctionIsVisible(Oid funcid)
...
@@ -576,7 +590,7 @@ FunctionIsVisible(Oid funcid)
ObjectIdGetDatum
(
funcid
),
ObjectIdGetDatum
(
funcid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
proctup
))
if
(
!
HeapTupleIsValid
(
proctup
))
elog
(
ERROR
,
"
Cache lookup failed for procedure
%u"
,
funcid
);
elog
(
ERROR
,
"
cache lookup failed for function
%u"
,
funcid
);
procform
=
(
Form_pg_proc
)
GETSTRUCT
(
proctup
);
procform
=
(
Form_pg_proc
)
GETSTRUCT
(
proctup
);
recomputeNamespacePath
();
recomputeNamespacePath
();
...
@@ -788,7 +802,7 @@ OperatorIsVisible(Oid oprid)
...
@@ -788,7 +802,7 @@ OperatorIsVisible(Oid oprid)
ObjectIdGetDatum
(
oprid
),
ObjectIdGetDatum
(
oprid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
oprtup
))
if
(
!
HeapTupleIsValid
(
oprtup
))
elog
(
ERROR
,
"
C
ache lookup failed for operator %u"
,
oprid
);
elog
(
ERROR
,
"
c
ache lookup failed for operator %u"
,
oprid
);
oprform
=
(
Form_pg_operator
)
GETSTRUCT
(
oprtup
);
oprform
=
(
Form_pg_operator
)
GETSTRUCT
(
oprtup
);
recomputeNamespacePath
();
recomputeNamespacePath
();
...
@@ -1001,7 +1015,7 @@ OpclassIsVisible(Oid opcid)
...
@@ -1001,7 +1015,7 @@ OpclassIsVisible(Oid opcid)
ObjectIdGetDatum
(
opcid
),
ObjectIdGetDatum
(
opcid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
opctup
))
if
(
!
HeapTupleIsValid
(
opctup
))
elog
(
ERROR
,
"
C
ache lookup failed for opclass %u"
,
opcid
);
elog
(
ERROR
,
"
c
ache lookup failed for opclass %u"
,
opcid
);
opcform
=
(
Form_pg_opclass
)
GETSTRUCT
(
opctup
);
opcform
=
(
Form_pg_opclass
)
GETSTRUCT
(
opctup
);
recomputeNamespacePath
();
recomputeNamespacePath
();
...
@@ -1082,7 +1096,7 @@ ConversionIsVisible(Oid conid)
...
@@ -1082,7 +1096,7 @@ ConversionIsVisible(Oid conid)
ObjectIdGetDatum
(
conid
),
ObjectIdGetDatum
(
conid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
contup
))
if
(
!
HeapTupleIsValid
(
contup
))
elog
(
ERROR
,
"
C
ache lookup failed for conversion %u"
,
conid
);
elog
(
ERROR
,
"
c
ache lookup failed for conversion %u"
,
conid
);
conform
=
(
Form_pg_conversion
)
GETSTRUCT
(
contup
);
conform
=
(
Form_pg_conversion
)
GETSTRUCT
(
contup
);
recomputeNamespacePath
();
recomputeNamespacePath
();
...
@@ -1148,11 +1162,15 @@ DeconstructQualifiedName(List *names,
...
@@ -1148,11 +1162,15 @@ DeconstructQualifiedName(List *names,
* We check the catalog name and then ignore it.
* We check the catalog name and then ignore it.
*/
*/
if
(
strcmp
(
catalogname
,
get_database_name
(
MyDatabaseId
))
!=
0
)
if
(
strcmp
(
catalogname
,
get_database_name
(
MyDatabaseId
))
!=
0
)
elog
(
ERROR
,
"Cross-database references are not implemented"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"cross-database references are not implemented"
)));
break
;
break
;
default:
default:
elog
(
ERROR
,
"Improper qualified name (too many dotted names): %s"
,
ereport
(
ERROR
,
NameListToString
(
names
));
(
errcode
(
ERRCODE_SYNTAX_ERROR
),
errmsg
(
"improper qualified name (too many dotted names): %s"
,
NameListToString
(
names
))));
break
;
break
;
}
}
...
@@ -1165,7 +1183,7 @@ DeconstructQualifiedName(List *names,
...
@@ -1165,7 +1183,7 @@ DeconstructQualifiedName(List *names,
* Process an explicitly-specified schema name: look up the schema
* Process an explicitly-specified schema name: look up the schema
* and verify we have USAGE (lookup) rights in it.
* and verify we have USAGE (lookup) rights in it.
*
*
* Returns the namespace OID. Raises e
log
if any problem.
* Returns the namespace OID. Raises e
report
if any problem.
*/
*/
Oid
Oid
LookupExplicitNamespace
(
const
char
*
nspname
)
LookupExplicitNamespace
(
const
char
*
nspname
)
...
@@ -1177,7 +1195,9 @@ LookupExplicitNamespace(const char *nspname)
...
@@ -1177,7 +1195,9 @@ LookupExplicitNamespace(const char *nspname)
CStringGetDatum
(
nspname
),
CStringGetDatum
(
nspname
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
OidIsValid
(
namespaceId
))
if
(
!
OidIsValid
(
namespaceId
))
elog
(
ERROR
,
"Namespace
\"
%s
\"
does not exist"
,
nspname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_SCHEMA
),
errmsg
(
"schema
\"
%s
\"
does not exist"
,
nspname
)));
aclresult
=
pg_namespace_aclcheck
(
namespaceId
,
GetUserId
(),
ACL_USAGE
);
aclresult
=
pg_namespace_aclcheck
(
namespaceId
,
GetUserId
(),
ACL_USAGE
);
if
(
aclresult
!=
ACLCHECK_OK
)
if
(
aclresult
!=
ACLCHECK_OK
)
...
@@ -1212,8 +1232,9 @@ QualifiedNameGetCreationNamespace(List *names, char **objname_p)
...
@@ -1212,8 +1232,9 @@ QualifiedNameGetCreationNamespace(List *names, char **objname_p)
CStringGetDatum
(
schemaname
),
CStringGetDatum
(
schemaname
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
OidIsValid
(
namespaceId
))
if
(
!
OidIsValid
(
namespaceId
))
elog
(
ERROR
,
"Namespace
\"
%s
\"
does not exist"
,
ereport
(
ERROR
,
schemaname
);
(
errcode
(
ERRCODE_UNDEFINED_SCHEMA
),
errmsg
(
"schema
\"
%s
\"
does not exist"
,
schemaname
)));
/* we do not check for USAGE rights here! */
/* we do not check for USAGE rights here! */
}
}
else
else
...
@@ -1222,7 +1243,9 @@ QualifiedNameGetCreationNamespace(List *names, char **objname_p)
...
@@ -1222,7 +1243,9 @@ QualifiedNameGetCreationNamespace(List *names, char **objname_p)
recomputeNamespacePath
();
recomputeNamespacePath
();
namespaceId
=
defaultCreationNamespace
;
namespaceId
=
defaultCreationNamespace
;
if
(
!
OidIsValid
(
namespaceId
))
if
(
!
OidIsValid
(
namespaceId
))
elog
(
ERROR
,
"No namespace has been selected to create in"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_SCHEMA
),
errmsg
(
"no schema has been selected to create in"
)));
}
}
/* Note: callers will check for CREATE rights when appropriate */
/* Note: callers will check for CREATE rights when appropriate */
...
@@ -1255,7 +1278,10 @@ makeRangeVarFromNameList(List *names)
...
@@ -1255,7 +1278,10 @@ makeRangeVarFromNameList(List *names)
rel
->
relname
=
strVal
(
lthird
(
names
));
rel
->
relname
=
strVal
(
lthird
(
names
));
break
;
break
;
default:
default:
elog
(
ERROR
,
"Improper relation name (too many dotted names)"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_SYNTAX_ERROR
),
errmsg
(
"improper relation name (too many dotted names): %s"
,
NameListToString
(
names
))));
break
;
break
;
}
}
...
@@ -1467,7 +1493,7 @@ recomputeNamespacePath(void)
...
@@ -1467,7 +1493,7 @@ recomputeNamespacePath(void)
{
{
/* syntax error in name list */
/* syntax error in name list */
/* this should not happen if GUC checked check_search_path */
/* this should not happen if GUC checked check_search_path */
elog
(
ERROR
,
"
recomputeNamespacePath:
invalid list syntax"
);
elog
(
ERROR
,
"invalid list syntax"
);
}
}
/*
/*
...
@@ -1596,8 +1622,10 @@ InitTempTableNamespace(void)
...
@@ -1596,8 +1622,10 @@ InitTempTableNamespace(void)
*/
*/
if
(
pg_database_aclcheck
(
MyDatabaseId
,
GetSessionUserId
(),
if
(
pg_database_aclcheck
(
MyDatabaseId
,
GetSessionUserId
(),
ACL_CREATE_TEMP
)
!=
ACLCHECK_OK
)
ACL_CREATE_TEMP
)
!=
ACLCHECK_OK
)
elog
(
ERROR
,
"%s: not authorized to create temp tables"
,
ereport
(
ERROR
,
get_database_name
(
MyDatabaseId
));
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
errmsg
(
"not authorized to create temp tables in database
\"
%s
\"
"
,
get_database_name
(
MyDatabaseId
))));
snprintf
(
namespaceName
,
sizeof
(
namespaceName
),
"pg_temp_%d"
,
MyBackendId
);
snprintf
(
namespaceName
,
sizeof
(
namespaceName
),
"pg_temp_%d"
,
MyBackendId
);
...
@@ -1766,7 +1794,9 @@ assign_search_path(const char *newval, bool doit, bool interactive)
...
@@ -1766,7 +1794,9 @@ assign_search_path(const char *newval, bool doit, bool interactive)
if
(
!
SearchSysCacheExists
(
NAMESPACENAME
,
if
(
!
SearchSysCacheExists
(
NAMESPACENAME
,
CStringGetDatum
(
curname
),
CStringGetDatum
(
curname
),
0
,
0
,
0
))
0
,
0
,
0
))
elog
(
ERROR
,
"Namespace
\"
%s
\"
does not exist"
,
curname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_SCHEMA
),
errmsg
(
"schema
\"
%s
\"
does not exist"
,
curname
)));
}
}
}
}
...
...
src/backend/catalog/pg_aggregate.c
View file @
d8528630
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.6
0 2003/07/04 02:51:33
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.6
1 2003/07/21 01:59:10
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -62,7 +62,7 @@ AggregateCreate(const char *aggName,
...
@@ -62,7 +62,7 @@ AggregateCreate(const char *aggName,
ObjectAddress
myself
,
ObjectAddress
myself
,
referenced
;
referenced
;
/* sanity checks */
/* sanity checks
(caller should have caught these)
*/
if
(
!
aggName
)
if
(
!
aggName
)
elog
(
ERROR
,
"no aggregate name supplied"
);
elog
(
ERROR
,
"no aggregate name supplied"
);
...
@@ -75,8 +75,11 @@ AggregateCreate(const char *aggName,
...
@@ -75,8 +75,11 @@ AggregateCreate(const char *aggName,
*/
*/
if
((
aggTransType
==
ANYARRAYOID
||
aggTransType
==
ANYELEMENTOID
)
&&
if
((
aggTransType
==
ANYARRAYOID
||
aggTransType
==
ANYELEMENTOID
)
&&
!
(
aggBaseType
==
ANYARRAYOID
||
aggBaseType
==
ANYELEMENTOID
))
!
(
aggBaseType
==
ANYARRAYOID
||
aggBaseType
==
ANYELEMENTOID
))
elog
(
ERROR
,
"an aggregate using ANYARRAY or ANYELEMENT as trans type "
ereport
(
ERROR
,
"must also have one of them as its base type"
);
(
errcode
(
ERRCODE_INVALID_FUNCTION_DEFINITION
),
errmsg
(
"cannot determine transition datatype"
),
errdetail
(
"An aggregate using ANYARRAY or ANYELEMENT as "
"trans type must have one of them as its base type."
)));
/* handle transfn */
/* handle transfn */
MemSet
(
fnArgs
,
0
,
FUNC_MAX_ARGS
*
sizeof
(
Oid
));
MemSet
(
fnArgs
,
0
,
FUNC_MAX_ARGS
*
sizeof
(
Oid
));
...
@@ -102,14 +105,17 @@ AggregateCreate(const char *aggName,
...
@@ -102,14 +105,17 @@ AggregateCreate(const char *aggName,
* polymorphic we *must* demand exact equality.
* polymorphic we *must* demand exact equality.
*/
*/
if
(
rettype
!=
aggTransType
)
if
(
rettype
!=
aggTransType
)
elog
(
ERROR
,
"return type of transition function %s is not %s"
,
ereport
(
ERROR
,
NameListToString
(
aggtransfnName
),
format_type_be
(
aggTransType
));
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"return type of transition function %s is not %s"
,
NameListToString
(
aggtransfnName
),
format_type_be
(
aggTransType
))));
tup
=
SearchSysCache
(
PROCOID
,
tup
=
SearchSysCache
(
PROCOID
,
ObjectIdGetDatum
(
transfn
),
ObjectIdGetDatum
(
transfn
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tup
))
if
(
!
HeapTupleIsValid
(
tup
))
elog
(
ERROR
,
"cache lookup
of function %u failed
"
,
transfn
);
elog
(
ERROR
,
"cache lookup
failed for function %u
"
,
transfn
);
proc
=
(
Form_pg_proc
)
GETSTRUCT
(
tup
);
proc
=
(
Form_pg_proc
)
GETSTRUCT
(
tup
);
/*
/*
...
@@ -121,7 +127,9 @@ AggregateCreate(const char *aggName,
...
@@ -121,7 +127,9 @@ AggregateCreate(const char *aggName,
if
(
proc
->
proisstrict
&&
agginitval
==
NULL
)
if
(
proc
->
proisstrict
&&
agginitval
==
NULL
)
{
{
if
(
!
IsBinaryCoercible
(
aggBaseType
,
aggTransType
))
if
(
!
IsBinaryCoercible
(
aggBaseType
,
aggTransType
))
elog
(
ERROR
,
"must not omit initval when transfn is strict and transtype is not compatible with input type"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_FUNCTION_DEFINITION
),
errmsg
(
"must not omit initval when transfn is strict and transtype is not compatible with input type"
)));
}
}
ReleaseSysCache
(
tup
);
ReleaseSysCache
(
tup
);
...
@@ -152,8 +160,11 @@ AggregateCreate(const char *aggName,
...
@@ -152,8 +160,11 @@ AggregateCreate(const char *aggName,
*/
*/
if
((
finaltype
==
ANYARRAYOID
||
finaltype
==
ANYELEMENTOID
)
&&
if
((
finaltype
==
ANYARRAYOID
||
finaltype
==
ANYELEMENTOID
)
&&
!
(
aggBaseType
==
ANYARRAYOID
||
aggBaseType
==
ANYELEMENTOID
))
!
(
aggBaseType
==
ANYARRAYOID
||
aggBaseType
==
ANYELEMENTOID
))
elog
(
ERROR
,
"an aggregate returning ANYARRAY or ANYELEMENT "
ereport
(
ERROR
,
"must also have one of them as its base type"
);
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"cannot determine result datatype"
),
errdetail
(
"An aggregate returning ANYARRAY or ANYELEMENT "
"must have one of them as its base type."
)));
/*
/*
* Everything looks okay. Try to create the pg_proc entry for the
* Everything looks okay. Try to create the pg_proc entry for the
...
@@ -264,11 +275,15 @@ lookup_agg_function(List *fnName,
...
@@ -264,11 +275,15 @@ lookup_agg_function(List *fnName,
/* only valid case is a normal function not returning a set */
/* only valid case is a normal function not returning a set */
if
(
fdresult
!=
FUNCDETAIL_NORMAL
||
!
OidIsValid
(
fnOid
))
if
(
fdresult
!=
FUNCDETAIL_NORMAL
||
!
OidIsValid
(
fnOid
))
elog
(
ERROR
,
"function %s does not exist"
,
ereport
(
ERROR
,
func_signature_string
(
fnName
,
nargs
,
input_types
));
(
errcode
(
ERRCODE_UNDEFINED_FUNCTION
),
errmsg
(
"function %s does not exist"
,
func_signature_string
(
fnName
,
nargs
,
input_types
))));
if
(
retset
)
if
(
retset
)
elog
(
ERROR
,
"function %s returns a set"
,
ereport
(
ERROR
,
func_signature_string
(
fnName
,
nargs
,
input_types
));
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"function %s returns a set"
,
func_signature_string
(
fnName
,
nargs
,
input_types
))));
/*
/*
* If the given type(s) are all polymorphic, there's nothing we
* If the given type(s) are all polymorphic, there's nothing we
...
@@ -296,15 +311,19 @@ lookup_agg_function(List *fnName,
...
@@ -296,15 +311,19 @@ lookup_agg_function(List *fnName,
if
(
true_oid_array
[
0
]
!=
ANYARRAYOID
&&
if
(
true_oid_array
[
0
]
!=
ANYARRAYOID
&&
true_oid_array
[
0
]
!=
ANYELEMENTOID
&&
true_oid_array
[
0
]
!=
ANYELEMENTOID
&&
!
IsBinaryCoercible
(
input_types
[
0
],
true_oid_array
[
0
]))
!
IsBinaryCoercible
(
input_types
[
0
],
true_oid_array
[
0
]))
elog
(
ERROR
,
"function %s requires run-time type coercion"
,
ereport
(
ERROR
,
func_signature_string
(
fnName
,
nargs
,
true_oid_array
));
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"function %s requires run-time type coercion"
,
func_signature_string
(
fnName
,
nargs
,
true_oid_array
))));
if
(
nargs
==
2
&&
if
(
nargs
==
2
&&
true_oid_array
[
1
]
!=
ANYARRAYOID
&&
true_oid_array
[
1
]
!=
ANYARRAYOID
&&
true_oid_array
[
1
]
!=
ANYELEMENTOID
&&
true_oid_array
[
1
]
!=
ANYELEMENTOID
&&
!
IsBinaryCoercible
(
input_types
[
1
],
true_oid_array
[
1
]))
!
IsBinaryCoercible
(
input_types
[
1
],
true_oid_array
[
1
]))
elog
(
ERROR
,
"function %s requires run-time type coercion"
,
ereport
(
ERROR
,
func_signature_string
(
fnName
,
nargs
,
true_oid_array
));
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"function %s requires run-time type coercion"
,
func_signature_string
(
fnName
,
nargs
,
true_oid_array
))));
return
fnOid
;
return
fnOid
;
}
}
src/backend/catalog/pg_constraint.c
View file @
d8528630
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_constraint.c,v 1.1
3 2003/05/28 16:03:56
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_constraint.c,v 1.1
4 2003/07/21 01:59:10
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -427,8 +427,7 @@ RemoveConstraintById(Oid conId)
...
@@ -427,8 +427,7 @@ RemoveConstraintById(Oid conId)
tup
=
systable_getnext
(
conscan
);
tup
=
systable_getnext
(
conscan
);
if
(
!
HeapTupleIsValid
(
tup
))
if
(
!
HeapTupleIsValid
(
tup
))
elog
(
ERROR
,
"RemoveConstraintById: constraint %u not found"
,
elog
(
ERROR
,
"could not find tuple for constraint %u"
,
conId
);
conId
);
con
=
(
Form_pg_constraint
)
GETSTRUCT
(
tup
);
con
=
(
Form_pg_constraint
)
GETSTRUCT
(
tup
);
/*
/*
...
@@ -460,12 +459,12 @@ RemoveConstraintById(Oid conId)
...
@@ -460,12 +459,12 @@ RemoveConstraintById(Oid conId)
ObjectIdGetDatum
(
con
->
conrelid
),
ObjectIdGetDatum
(
con
->
conrelid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
relTup
))
if
(
!
HeapTupleIsValid
(
relTup
))
elog
(
ERROR
,
"cache lookup
of relation %u failed
"
,
elog
(
ERROR
,
"cache lookup
failed for relation %u
"
,
con
->
conrelid
);
con
->
conrelid
);
classForm
=
(
Form_pg_class
)
GETSTRUCT
(
relTup
);
classForm
=
(
Form_pg_class
)
GETSTRUCT
(
relTup
);
if
(
classForm
->
relchecks
==
0
)
if
(
classForm
->
relchecks
==
0
)
/* should not happen */
elog
(
ERROR
,
"
RemoveConstraintById: relation %s
has relchecks = 0"
,
elog
(
ERROR
,
"
relation
\"
%s
\"
has relchecks = 0"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
classForm
->
relchecks
--
;
classForm
->
relchecks
--
;
...
@@ -492,8 +491,7 @@ RemoveConstraintById(Oid conId)
...
@@ -492,8 +491,7 @@ RemoveConstraintById(Oid conId)
}
}
else
else
{
{
elog
(
ERROR
,
"RemoveConstraintById: Constraint %u is not a known type"
,
elog
(
ERROR
,
"constraint %u is not of a known type"
,
conId
);
conId
);
}
}
/* Fry the constraint itself */
/* Fry the constraint itself */
...
...
src/backend/catalog/pg_conversion.c
View file @
d8528630
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_conversion.c,v 1.1
0 2003/01/27 00:45:19
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_conversion.c,v 1.1
1 2003/07/21 01:59:10
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -61,7 +61,9 @@ ConversionCreate(const char *conname, Oid connamespace,
...
@@ -61,7 +61,9 @@ ConversionCreate(const char *conname, Oid connamespace,
PointerGetDatum
(
conname
),
PointerGetDatum
(
conname
),
ObjectIdGetDatum
(
connamespace
),
ObjectIdGetDatum
(
connamespace
),
0
,
0
))
0
,
0
))
elog
(
ERROR
,
"conversion name
\"
%s
\"
already exists"
,
conname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DUPLICATE_OBJECT
),
errmsg
(
"conversion
\"
%s
\"
already exists"
,
conname
)));
if
(
def
)
if
(
def
)
{
{
...
@@ -72,9 +74,11 @@ ConversionCreate(const char *conname, Oid connamespace,
...
@@ -72,9 +74,11 @@ ConversionCreate(const char *conname, Oid connamespace,
if
(
FindDefaultConversion
(
connamespace
,
if
(
FindDefaultConversion
(
connamespace
,
conforencoding
,
conforencoding
,
contoencoding
))
contoencoding
))
elog
(
ERROR
,
"default conversion for %s to %s already exists"
,
ereport
(
ERROR
,
pg_encoding_to_char
(
conforencoding
),
(
errcode
(
ERRCODE_DUPLICATE_OBJECT
),
pg_encoding_to_char
(
contoencoding
));
errmsg
(
"default conversion for
\"
%s
\"
to
\"
%s
\"
already exists"
,
pg_encoding_to_char
(
conforencoding
),
pg_encoding_to_char
(
contoencoding
))));
}
}
/* open pg_conversion */
/* open pg_conversion */
...
@@ -138,12 +142,13 @@ ConversionDrop(Oid conversionOid, DropBehavior behavior)
...
@@ -138,12 +142,13 @@ ConversionDrop(Oid conversionOid, DropBehavior behavior)
ObjectIdGetDatum
(
conversionOid
),
ObjectIdGetDatum
(
conversionOid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"Conversion %u search from syscache failed"
,
elog
(
ERROR
,
"cache lookup failed for conversion %u"
,
conversionOid
);
conversionOid
);
if
(
!
superuser
()
&&
if
(
!
superuser
()
&&
((
Form_pg_conversion
)
GETSTRUCT
(
tuple
))
->
conowner
!=
GetUserId
())
((
Form_pg_conversion
)
GETSTRUCT
(
tuple
))
->
conowner
!=
GetUserId
())
elog
(
ERROR
,
"DROP CONVERSION: permission denied"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
errmsg
(
"permission denied"
)));
ReleaseSysCache
(
tuple
);
ReleaseSysCache
(
tuple
);
...
@@ -189,7 +194,7 @@ RemoveConversionById(Oid conversionOid)
...
@@ -189,7 +194,7 @@ RemoveConversionById(Oid conversionOid)
if
(
HeapTupleIsValid
(
tuple
=
heap_getnext
(
scan
,
ForwardScanDirection
)))
if
(
HeapTupleIsValid
(
tuple
=
heap_getnext
(
scan
,
ForwardScanDirection
)))
simple_heap_delete
(
rel
,
&
tuple
->
t_self
);
simple_heap_delete
(
rel
,
&
tuple
->
t_self
);
else
else
elog
(
ERROR
,
"co
nversion %u does not exist
"
,
conversionOid
);
elog
(
ERROR
,
"co
uld not find tuple for conversion %u
"
,
conversionOid
);
heap_endscan
(
scan
);
heap_endscan
(
scan
);
heap_close
(
rel
,
RowExclusiveLock
);
heap_close
(
rel
,
RowExclusiveLock
);
}
}
...
@@ -299,13 +304,16 @@ pg_convert_using(PG_FUNCTION_ARGS)
...
@@ -299,13 +304,16 @@ pg_convert_using(PG_FUNCTION_ARGS)
parsed_name
=
textToQualifiedNameList
(
conv_name
,
"convert_using"
);
parsed_name
=
textToQualifiedNameList
(
conv_name
,
"convert_using"
);
convoid
=
FindConversionByName
(
parsed_name
);
convoid
=
FindConversionByName
(
parsed_name
);
if
(
!
OidIsValid
(
convoid
))
if
(
!
OidIsValid
(
convoid
))
elog
(
ERROR
,
"conversion %s not found"
,
NameListToString
(
parsed_name
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"conversion
\"
%s
\"
does not exist"
,
NameListToString
(
parsed_name
))));
tuple
=
SearchSysCache
(
CONOID
,
tuple
=
SearchSysCache
(
CONOID
,
ObjectIdGetDatum
(
convoid
),
ObjectIdGetDatum
(
convoid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"
Conversion %u search from syscache failed
"
,
convoid
);
elog
(
ERROR
,
"
cache lookup failed for conversion %u
"
,
convoid
);
body
=
(
Form_pg_conversion
)
GETSTRUCT
(
tuple
);
body
=
(
Form_pg_conversion
)
GETSTRUCT
(
tuple
);
/* Temporary result area should be more than big enough */
/* Temporary result area should be more than big enough */
...
...
src/backend/catalog/pg_largeobject.c
View file @
d8528630
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.1
4 2002/08/05 03:29:16
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.1
5 2003/07/21 01:59:10
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -105,7 +105,9 @@ LargeObjectDrop(Oid loid)
...
@@ -105,7 +105,9 @@ LargeObjectDrop(Oid loid)
heap_close
(
pg_largeobject
,
RowShareLock
);
heap_close
(
pg_largeobject
,
RowShareLock
);
if
(
!
found
)
if
(
!
found
)
elog
(
ERROR
,
"LargeObjectDrop: large object %u not found"
,
loid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"large object %u does not exist"
,
loid
)));
}
}
bool
bool
...
...
src/backend/catalog/pg_namespace.c
View file @
d8528630
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_namespace.c,v 1.
5 2002/08/05 03:29:16
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_namespace.c,v 1.
6 2003/07/21 01:59:10
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -46,7 +46,9 @@ NamespaceCreate(const char *nspName, int32 ownerSysId)
...
@@ -46,7 +46,9 @@ NamespaceCreate(const char *nspName, int32 ownerSysId)
if
(
SearchSysCacheExists
(
NAMESPACENAME
,
if
(
SearchSysCacheExists
(
NAMESPACENAME
,
PointerGetDatum
(
nspName
),
PointerGetDatum
(
nspName
),
0
,
0
,
0
))
0
,
0
,
0
))
elog
(
ERROR
,
"namespace
\"
%s
\"
already exists"
,
nspName
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DUPLICATE_SCHEMA
),
errmsg
(
"schema
\"
%s
\"
already exists"
,
nspName
)));
/* initialize nulls and values */
/* initialize nulls and values */
for
(
i
=
0
;
i
<
Natts_pg_namespace
;
i
++
)
for
(
i
=
0
;
i
<
Natts_pg_namespace
;
i
++
)
...
...
src/backend/catalog/pg_operator.c
View file @
d8528630
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.
79 2003/07/04 02:51:33
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.
80 2003/07/21 01:59:11
tgl Exp $
*
*
* NOTES
* NOTES
* these routines moved here from commands/define.c and somewhat cleaned up.
* these routines moved here from commands/define.c and somewhat cleaned up.
...
@@ -80,7 +80,7 @@ validOperatorName(const char *name)
...
@@ -80,7 +80,7 @@ validOperatorName(const char *name)
/* Can't contain any invalid characters */
/* Can't contain any invalid characters */
/* Test string here should match op_chars in scan.l */
/* Test string here should match op_chars in scan.l */
if
(
strspn
(
name
,
"~!@#^&|`?
$
+-*/%<>="
)
!=
len
)
if
(
strspn
(
name
,
"~!@#^&|`?+-*/%<>="
)
!=
len
)
return
false
;
return
false
;
/* Can't contain slash-star or dash-dash (comment starts) */
/* Can't contain slash-star or dash-dash (comment starts) */
...
@@ -102,7 +102,7 @@ validOperatorName(const char *name)
...
@@ -102,7 +102,7 @@ validOperatorName(const char *name)
for
(
ic
=
len
-
2
;
ic
>=
0
;
ic
--
)
for
(
ic
=
len
-
2
;
ic
>=
0
;
ic
--
)
{
{
if
(
strchr
(
"~!@#^&|`?
$
%"
,
name
[
ic
]))
if
(
strchr
(
"~!@#^&|`?%"
,
name
[
ic
]))
break
;
break
;
}
}
if
(
ic
<
0
)
if
(
ic
<
0
)
...
@@ -212,7 +212,10 @@ OperatorShellMake(const char *operatorName,
...
@@ -212,7 +212,10 @@ OperatorShellMake(const char *operatorName,
* validate operator name
* validate operator name
*/
*/
if
(
!
validOperatorName
(
operatorName
))
if
(
!
validOperatorName
(
operatorName
))
elog
(
ERROR
,
"
\"
%s
\"
is not a valid operator name"
,
operatorName
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_NAME
),
errmsg
(
"
\"
%s
\"
is not a valid operator name"
,
operatorName
)));
/*
/*
* initialize our *nulls and *values arrays
* initialize our *nulls and *values arrays
...
@@ -398,22 +401,35 @@ OperatorCreate(const char *operatorName,
...
@@ -398,22 +401,35 @@ OperatorCreate(const char *operatorName,
* Sanity checks
* Sanity checks
*/
*/
if
(
!
validOperatorName
(
operatorName
))
if
(
!
validOperatorName
(
operatorName
))
elog
(
ERROR
,
"
\"
%s
\"
is not a valid operator name"
,
operatorName
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_NAME
),
errmsg
(
"
\"
%s
\"
is not a valid operator name"
,
operatorName
)));
if
(
!
OidIsValid
(
leftTypeId
)
&&
!
OidIsValid
(
rightTypeId
))
if
(
!
OidIsValid
(
leftTypeId
)
&&
!
OidIsValid
(
rightTypeId
))
elog
(
ERROR
,
"at least one of leftarg or rightarg must be specified"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_FUNCTION_DEFINITION
),
errmsg
(
"at least one of leftarg or rightarg must be specified"
)));
if
(
!
(
OidIsValid
(
leftTypeId
)
&&
OidIsValid
(
rightTypeId
)))
if
(
!
(
OidIsValid
(
leftTypeId
)
&&
OidIsValid
(
rightTypeId
)))
{
{
/* If it's not a binary op, these things mustn't be set: */
/* If it's not a binary op, these things mustn't be set: */
if
(
commutatorName
)
if
(
commutatorName
)
elog
(
ERROR
,
"only binary operators can have commutators"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_FUNCTION_DEFINITION
),
errmsg
(
"only binary operators can have commutators"
)));
if
(
joinName
)
if
(
joinName
)
elog
(
ERROR
,
"only binary operators can have join selectivity"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_FUNCTION_DEFINITION
),
errmsg
(
"only binary operators can have join selectivity"
)));
if
(
canHash
)
if
(
canHash
)
elog
(
ERROR
,
"only binary operators can hash"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_FUNCTION_DEFINITION
),
errmsg
(
"only binary operators can hash"
)));
if
(
leftSortName
||
rightSortName
||
ltCompareName
||
gtCompareName
)
if
(
leftSortName
||
rightSortName
||
ltCompareName
||
gtCompareName
)
elog
(
ERROR
,
"only binary operators can mergejoin"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_FUNCTION_DEFINITION
),
errmsg
(
"only binary operators can mergejoin"
)));
}
}
operatorObjectId
=
OperatorGet
(
operatorName
,
operatorObjectId
=
OperatorGet
(
operatorName
,
...
@@ -423,8 +439,10 @@ OperatorCreate(const char *operatorName,
...
@@ -423,8 +439,10 @@ OperatorCreate(const char *operatorName,
&
operatorAlreadyDefined
);
&
operatorAlreadyDefined
);
if
(
operatorAlreadyDefined
)
if
(
operatorAlreadyDefined
)
elog
(
ERROR
,
"OperatorDef: operator
\"
%s
\"
already defined"
,
ereport
(
ERROR
,
operatorName
);
(
errcode
(
ERRCODE_DUPLICATE_FUNCTION
),
errmsg
(
"operator %s already exists"
,
operatorName
)));
/*
/*
* At this point, if operatorObjectId is not InvalidOid then we are
* At this point, if operatorObjectId is not InvalidOid then we are
...
@@ -615,7 +633,7 @@ OperatorCreate(const char *operatorName,
...
@@ -615,7 +633,7 @@ OperatorCreate(const char *operatorName,
ObjectIdGetDatum
(
operatorObjectId
),
ObjectIdGetDatum
(
operatorObjectId
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tup
))
if
(
!
HeapTupleIsValid
(
tup
))
elog
(
ERROR
,
"
OperatorDef: operator %u not found
"
,
elog
(
ERROR
,
"
cache lookup failed for operator %u
"
,
operatorObjectId
);
operatorObjectId
);
tup
=
heap_modifytuple
(
tup
,
tup
=
heap_modifytuple
(
tup
,
...
@@ -703,7 +721,9 @@ get_other_operator(List *otherOp, Oid otherLeftTypeId, Oid otherRightTypeId,
...
@@ -703,7 +721,9 @@ get_other_operator(List *otherOp, Oid otherLeftTypeId, Oid otherRightTypeId,
* only self-linkage for commutation makes sense.
* only self-linkage for commutation makes sense.
*/
*/
if
(
!
isCommutator
)
if
(
!
isCommutator
)
elog
(
ERROR
,
"operator cannot be its own negator or sort operator"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_FUNCTION_DEFINITION
),
errmsg
(
"operator cannot be its own negator or sort operator"
)));
return
InvalidOid
;
return
InvalidOid
;
}
}
...
@@ -718,10 +738,6 @@ get_other_operator(List *otherOp, Oid otherLeftTypeId, Oid otherRightTypeId,
...
@@ -718,10 +738,6 @@ get_other_operator(List *otherOp, Oid otherLeftTypeId, Oid otherRightTypeId,
otherNamespace
,
otherNamespace
,
otherLeftTypeId
,
otherLeftTypeId
,
otherRightTypeId
);
otherRightTypeId
);
if
(
!
OidIsValid
(
other_oid
))
elog
(
ERROR
,
"OperatorDef: can't create operator shell
\"
%s
\"
"
,
NameListToString
(
otherOp
));
return
other_oid
;
return
other_oid
;
}
}
...
...
src/backend/catalog/pg_proc.c
View file @
d8528630
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.10
0 2003/07/18 23:20:32
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.10
1 2003/07/21 01:59:11
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -108,7 +108,8 @@ ProcedureCreate(const char *procedureName,
...
@@ -108,7 +108,8 @@ ProcedureCreate(const char *procedureName,
if
(
!
genericParam
)
if
(
!
genericParam
)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_FUNCTION_DEFINITION
),
(
errcode
(
ERRCODE_INVALID_FUNCTION_DEFINITION
),
errmsg
(
"functions returning ANYARRAY or ANYELEMENT must have at least one argument of either type"
)));
errmsg
(
"cannot determine result datatype"
),
errdetail
(
"A function returning ANYARRAY or ANYELEMENT must have at least one argument of either type."
)));
}
}
/* Make sure we have a zero-padded param type array */
/* Make sure we have a zero-padded param type array */
...
@@ -532,7 +533,8 @@ check_sql_fn_retval(Oid rettype, char fn_typtype, List *queryTreeList)
...
@@ -532,7 +533,8 @@ check_sql_fn_retval(Oid rettype, char fn_typtype, List *queryTreeList)
/* This should already have been caught ... */
/* This should already have been caught ... */
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_FUNCTION_DEFINITION
),
(
errcode
(
ERRCODE_INVALID_FUNCTION_DEFINITION
),
errmsg
(
"functions returning ANYARRAY or ANYELEMENT must have at least one argument of either type"
)));
errmsg
(
"cannot determine result datatype"
),
errdetail
(
"A function returning ANYARRAY or ANYELEMENT must have at least one argument of either type."
)));
}
}
else
else
ereport
(
ERROR
,
ereport
(
ERROR
,
...
...
src/backend/catalog/pg_type.c
View file @
d8528630
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.8
7 2003/05/08 22:19:56
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.8
8 2003/07/21 01:59:11
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -190,16 +190,22 @@ TypeCreate(const char *typeName,
...
@@ -190,16 +190,22 @@ TypeCreate(const char *typeName,
if
(
!
(
internalSize
>
0
||
if
(
!
(
internalSize
>
0
||
internalSize
==
-
1
||
internalSize
==
-
1
||
internalSize
==
-
2
))
internalSize
==
-
2
))
elog
(
ERROR
,
"TypeCreate: invalid type internal size %d"
,
ereport
(
ERROR
,
internalSize
);
(
errcode
(
ERRCODE_INVALID_OBJECT_DEFINITION
),
errmsg
(
"invalid type internal size %d"
,
internalSize
)));
if
(
passedByValue
&&
if
(
passedByValue
&&
(
internalSize
<=
0
||
internalSize
>
(
int16
)
sizeof
(
Datum
)))
(
internalSize
<=
0
||
internalSize
>
(
int16
)
sizeof
(
Datum
)))
elog
(
ERROR
,
"TypeCreate: invalid type internal size %d"
,
ereport
(
ERROR
,
internalSize
);
(
errcode
(
ERRCODE_INVALID_OBJECT_DEFINITION
),
errmsg
(
"invalid type internal size %d"
,
internalSize
)));
/* Only varlena types can be toasted */
/* Only varlena types can be toasted */
if
(
storage
!=
'p'
&&
internalSize
!=
-
1
)
if
(
storage
!=
'p'
&&
internalSize
!=
-
1
)
elog
(
ERROR
,
"TypeCreate: fixed size types must have storage PLAIN"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_OBJECT_DEFINITION
),
errmsg
(
"fixed-size types must have storage PLAIN"
)));
/*
/*
* initialize arrays needed for heap_formtuple or heap_modifytuple
* initialize arrays needed for heap_formtuple or heap_modifytuple
...
@@ -278,7 +284,9 @@ TypeCreate(const char *typeName,
...
@@ -278,7 +284,9 @@ TypeCreate(const char *typeName,
*/
*/
if
(((
Form_pg_type
)
GETSTRUCT
(
tup
))
->
typisdefined
||
if
(((
Form_pg_type
)
GETSTRUCT
(
tup
))
->
typisdefined
||
assignedTypeOid
!=
InvalidOid
)
assignedTypeOid
!=
InvalidOid
)
elog
(
ERROR
,
"type %s already exists"
,
typeName
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DUPLICATE_OBJECT
),
errmsg
(
"type
\"
%s
\"
already exists"
,
typeName
)));
/*
/*
* Okay to update existing "shell" type tuple
* Okay to update existing "shell" type tuple
...
@@ -489,13 +497,17 @@ TypeRename(const char *oldTypeName, Oid typeNamespace,
...
@@ -489,13 +497,17 @@ TypeRename(const char *oldTypeName, Oid typeNamespace,
ObjectIdGetDatum
(
typeNamespace
),
ObjectIdGetDatum
(
typeNamespace
),
0
,
0
);
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"type %s does not exist"
,
oldTypeName
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"type
\"
%s
\"
does not exist"
,
oldTypeName
)));
if
(
SearchSysCacheExists
(
TYPENAMENSP
,
if
(
SearchSysCacheExists
(
TYPENAMENSP
,
CStringGetDatum
(
newTypeName
),
CStringGetDatum
(
newTypeName
),
ObjectIdGetDatum
(
typeNamespace
),
ObjectIdGetDatum
(
typeNamespace
),
0
,
0
))
0
,
0
))
elog
(
ERROR
,
"type named %s already exists"
,
newTypeName
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DUPLICATE_OBJECT
),
errmsg
(
"type
\"
%s
\"
already exists"
,
newTypeName
)));
namestrcpy
(
&
(((
Form_pg_type
)
GETSTRUCT
(
tuple
))
->
typname
),
newTypeName
);
namestrcpy
(
&
(((
Form_pg_type
)
GETSTRUCT
(
tuple
))
->
typname
),
newTypeName
);
...
...
src/include/utils/acl.h
View file @
d8528630
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: acl.h,v 1.5
6 2003/06/27 14:45:32 petere
Exp $
* $Id: acl.h,v 1.5
7 2003/07/21 01:59:11 tgl
Exp $
*
*
* NOTES
* NOTES
* For backward-compatibility purposes we have to allow there
* For backward-compatibility purposes we have to allow there
...
@@ -207,7 +207,7 @@ extern AclResult pg_proc_aclcheck(Oid proc_oid, AclId userid, AclMode mode);
...
@@ -207,7 +207,7 @@ extern AclResult pg_proc_aclcheck(Oid proc_oid, AclId userid, AclMode mode);
extern
AclResult
pg_language_aclcheck
(
Oid
lang_oid
,
AclId
userid
,
AclMode
mode
);
extern
AclResult
pg_language_aclcheck
(
Oid
lang_oid
,
AclId
userid
,
AclMode
mode
);
extern
AclResult
pg_namespace_aclcheck
(
Oid
nsp_oid
,
AclId
userid
,
AclMode
mode
);
extern
AclResult
pg_namespace_aclcheck
(
Oid
nsp_oid
,
AclId
userid
,
AclMode
mode
);
extern
void
aclcheck_error
(
AclResult
errcode
,
const
char
*
objectname
);
extern
void
aclcheck_error
(
AclResult
aclerr
,
const
char
*
objectname
);
/* ownercheck routines just return true (owner) or false (not) */
/* ownercheck routines just return true (owner) or false (not) */
extern
bool
pg_class_ownercheck
(
Oid
class_oid
,
AclId
userid
);
extern
bool
pg_class_ownercheck
(
Oid
class_oid
,
AclId
userid
);
...
...
src/include/utils/elog.h
View file @
d8528630
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: elog.h,v 1.5
0 2003/07/20 21:56:35
tgl Exp $
* $Id: elog.h,v 1.5
1 2003/07/21 01:59:11
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -83,7 +83,8 @@
...
@@ -83,7 +83,8 @@
#define ERRCODE_WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION MAKE_SQLSTATE('0','1', '0','0','3')
#define ERRCODE_WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION MAKE_SQLSTATE('0','1', '0','0','3')
#define ERRCODE_WARNING_STRING_DATA_RIGHT_TRUNCATION MAKE_SQLSTATE('0','1', '0','0','4')
#define ERRCODE_WARNING_STRING_DATA_RIGHT_TRUNCATION MAKE_SQLSTATE('0','1', '0','0','4')
/* Class 02 - No Data */
/* Class 02 - No Data --- this is also a warning class per SQL99 */
/* (do not use this class for failure conditions!) */
#define ERRCODE_NO_DATA MAKE_SQLSTATE('0','2', '0','0','0')
#define ERRCODE_NO_DATA MAKE_SQLSTATE('0','2', '0','0','0')
#define ERRCODE_NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED MAKE_SQLSTATE('0','2', '0','0','1')
#define ERRCODE_NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED MAKE_SQLSTATE('0','2', '0','0','1')
...
@@ -111,6 +112,7 @@
...
@@ -111,6 +112,7 @@
/* Class 0L - Invalid Grantor */
/* Class 0L - Invalid Grantor */
#define ERRCODE_INVALID_GRANTOR MAKE_SQLSTATE('0','L', '0','0','0')
#define ERRCODE_INVALID_GRANTOR MAKE_SQLSTATE('0','L', '0','0','0')
#define ERRCODE_INVALID_GRANT_OPERATION MAKE_SQLSTATE('0','L', 'P','0','1')
/* Class 0P - Invalid Role Specification */
/* Class 0P - Invalid Role Specification */
#define ERRCODE_INVALID_ROLE_SPECIFICATION MAKE_SQLSTATE('0','P', '0','0','0')
#define ERRCODE_INVALID_ROLE_SPECIFICATION MAKE_SQLSTATE('0','P', '0','0','0')
...
@@ -186,6 +188,7 @@
...
@@ -186,6 +188,7 @@
/* Class 2B - Dependent Privilege Descriptors Still Exist */
/* Class 2B - Dependent Privilege Descriptors Still Exist */
#define ERRCODE_DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST MAKE_SQLSTATE('2','B', '0','0','0')
#define ERRCODE_DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST MAKE_SQLSTATE('2','B', '0','0','0')
#define ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST MAKE_SQLSTATE('2','B', 'P','0','1')
/* Class 2D - Invalid Transaction Termination */
/* Class 2D - Invalid Transaction Termination */
#define ERRCODE_INVALID_TRANSACTION_TERMINATION MAKE_SQLSTATE('2','D', '0','0','0')
#define ERRCODE_INVALID_TRANSACTION_TERMINATION MAKE_SQLSTATE('2','D', '0','0','0')
...
...
src/test/regress/expected/alter_table.out
View file @
d8528630
...
@@ -358,8 +358,8 @@ NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
...
@@ -358,8 +358,8 @@ NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable(ptest1);
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable(ptest1);
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
DROP TABLE pktable cascade;
DROP TABLE pktable cascade;
NOTICE:
D
rop cascades to constraint $2 on table fktable
NOTICE:
d
rop cascades to constraint $2 on table fktable
NOTICE:
D
rop cascades to constraint $1 on table fktable
NOTICE:
d
rop cascades to constraint $1 on table fktable
DROP TABLE fktable;
DROP TABLE fktable;
CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 inet,
CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 inet,
PRIMARY KEY(ptest1, ptest2));
PRIMARY KEY(ptest1, ptest2));
...
@@ -619,9 +619,9 @@ alter table pg_class alter relname set not null;
...
@@ -619,9 +619,9 @@ alter table pg_class alter relname set not null;
ERROR: "pg_class" is a system catalog
ERROR: "pg_class" is a system catalog
-- try altering non-existent table, should fail
-- try altering non-existent table, should fail
alter table non_existent alter column bar set not null;
alter table non_existent alter column bar set not null;
ERROR:
R
elation "non_existent" does not exist
ERROR:
r
elation "non_existent" does not exist
alter table non_existent alter column bar drop not null;
alter table non_existent alter column bar drop not null;
ERROR:
R
elation "non_existent" does not exist
ERROR:
r
elation "non_existent" does not exist
-- test setting columns to null and not null and vice versa
-- test setting columns to null and not null and vice versa
-- test checking for null values and primary key
-- test checking for null values and primary key
create table atacc1 (test int not null);
create table atacc1 (test int not null);
...
@@ -744,7 +744,7 @@ alter table pg_class drop column relname;
...
@@ -744,7 +744,7 @@ alter table pg_class drop column relname;
ERROR: "pg_class" is a system catalog
ERROR: "pg_class" is a system catalog
-- try altering non-existent table, should fail
-- try altering non-existent table, should fail
alter table foo drop column bar;
alter table foo drop column bar;
ERROR:
R
elation "foo" does not exist
ERROR:
r
elation "foo" does not exist
-- test dropping columns
-- test dropping columns
create table atacc1 (a int4 not null, b int4, c int4 not null, d int4);
create table atacc1 (a int4 not null, b int4, c int4 not null, d int4);
insert into atacc1 values (1, 2, 3, 4);
insert into atacc1 values (1, 2, 3, 4);
...
@@ -1074,7 +1074,7 @@ alter table c1 drop column f1;
...
@@ -1074,7 +1074,7 @@ alter table c1 drop column f1;
select f1 from c1;
select f1 from c1;
ERROR: attribute "f1" not found
ERROR: attribute "f1" not found
drop table p1 cascade;
drop table p1 cascade;
NOTICE:
D
rop cascades to table c1
NOTICE:
d
rop cascades to table c1
create table p1 (f1 int, f2 int);
create table p1 (f1 int, f2 int);
create table c1 () inherits(p1);
create table c1 () inherits(p1);
-- should be rejected since c1.f1 is inherited
-- should be rejected since c1.f1 is inherited
...
@@ -1085,7 +1085,7 @@ alter table p1 drop column f1;
...
@@ -1085,7 +1085,7 @@ alter table p1 drop column f1;
select f1 from c1;
select f1 from c1;
ERROR: attribute "f1" not found
ERROR: attribute "f1" not found
drop table p1 cascade;
drop table p1 cascade;
NOTICE:
D
rop cascades to table c1
NOTICE:
d
rop cascades to table c1
create table p1 (f1 int, f2 int);
create table p1 (f1 int, f2 int);
create table c1 () inherits(p1);
create table c1 () inherits(p1);
-- should be rejected since c1.f1 is inherited
-- should be rejected since c1.f1 is inherited
...
@@ -1095,7 +1095,7 @@ alter table only p1 drop column f1;
...
@@ -1095,7 +1095,7 @@ alter table only p1 drop column f1;
-- c1.f1 is NOT dropped, but must now be considered non-inherited
-- c1.f1 is NOT dropped, but must now be considered non-inherited
alter table c1 drop column f1;
alter table c1 drop column f1;
drop table p1 cascade;
drop table p1 cascade;
NOTICE:
D
rop cascades to table c1
NOTICE:
d
rop cascades to table c1
create table p1 (f1 int, f2 int);
create table p1 (f1 int, f2 int);
create table c1 (f1 int not null) inherits(p1);
create table c1 (f1 int not null) inherits(p1);
NOTICE: merging attribute "f1" with inherited definition
NOTICE: merging attribute "f1" with inherited definition
...
@@ -1106,7 +1106,7 @@ alter table only p1 drop column f1;
...
@@ -1106,7 +1106,7 @@ alter table only p1 drop column f1;
-- c1.f1 is still there, but no longer inherited
-- c1.f1 is still there, but no longer inherited
alter table c1 drop column f1;
alter table c1 drop column f1;
drop table p1 cascade;
drop table p1 cascade;
NOTICE:
D
rop cascades to table c1
NOTICE:
d
rop cascades to table c1
create table p1(id int, name text);
create table p1(id int, name text);
create table p2(id2 int, name text, height int);
create table p2(id2 int, name text, height int);
create table c1(age int) inherits(p1,p2);
create table c1(age int) inherits(p1,p2);
...
@@ -1166,8 +1166,8 @@ order by relname, attnum;
...
@@ -1166,8 +1166,8 @@ order by relname, attnum;
(8 rows)
(8 rows)
drop table p1, p2 cascade;
drop table p1, p2 cascade;
NOTICE:
D
rop cascades to table c1
NOTICE:
d
rop cascades to table c1
NOTICE:
D
rop cascades to table gc1
NOTICE:
d
rop cascades to table gc1
--
--
-- Test the ALTER TABLE WITHOUT OIDS command
-- Test the ALTER TABLE WITHOUT OIDS command
--
--
...
@@ -1250,8 +1250,8 @@ select * from p1;
...
@@ -1250,8 +1250,8 @@ select * from p1;
(2 rows)
(2 rows)
drop table p1 cascade;
drop table p1 cascade;
NOTICE:
D
rop cascades to table c1
NOTICE:
d
rop cascades to table c1
NOTICE:
D
rop cascades to constraint p1_a1 on table c1
NOTICE:
d
rop cascades to constraint p1_a1 on table c1
-- test that operations with a dropped column do not try to reference
-- test that operations with a dropped column do not try to reference
-- its datatype
-- its datatype
create domain mytype as text;
create domain mytype as text;
...
@@ -1264,7 +1264,7 @@ select * from foo;
...
@@ -1264,7 +1264,7 @@ select * from foo;
(1 row)
(1 row)
drop domain mytype cascade;
drop domain mytype cascade;
NOTICE:
D
rop cascades to table foo column f2
NOTICE:
d
rop cascades to table foo column f2
select * from foo;
select * from foo;
f1 | f3
f1 | f3
----+----
----+----
...
...
src/test/regress/expected/conversion.out
View file @
d8528630
...
@@ -8,7 +8,7 @@ CREATE CONVERSION myconv FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8;
...
@@ -8,7 +8,7 @@ CREATE CONVERSION myconv FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8;
-- cannot make same name conversion in same schema
-- cannot make same name conversion in same schema
--
--
CREATE CONVERSION myconv FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8;
CREATE CONVERSION myconv FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8;
ERROR: conversion
name
"myconv" already exists
ERROR: conversion "myconv" already exists
--
--
-- create default conversion with qualified name
-- create default conversion with qualified name
--
--
...
@@ -17,7 +17,7 @@ CREATE DEFAULT CONVERSION public.mydef FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_
...
@@ -17,7 +17,7 @@ CREATE DEFAULT CONVERSION public.mydef FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_
-- cannot make default conversion with same shcema/for_encoding/to_encoding
-- cannot make default conversion with same shcema/for_encoding/to_encoding
--
--
CREATE DEFAULT CONVERSION public.mydef2 FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8;
CREATE DEFAULT CONVERSION public.mydef2 FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8;
ERROR: default conversion for
LATIN1 to UNICODE
already exists
ERROR: default conversion for
"LATIN1" to "UNICODE"
already exists
--
--
-- drop user defined conversion
-- drop user defined conversion
--
--
...
...
src/test/regress/expected/create_type.out
View file @
d8528630
...
@@ -72,5 +72,5 @@ SELECT * FROM get_default_test();
...
@@ -72,5 +72,5 @@ SELECT * FROM get_default_test();
(1 row)
(1 row)
DROP TYPE default_test_row CASCADE;
DROP TYPE default_test_row CASCADE;
NOTICE:
D
rop cascades to function get_default_test()
NOTICE:
d
rop cascades to function get_default_test()
DROP TABLE default_test;
DROP TABLE default_test;
src/test/regress/expected/domain.out
View file @
d8528630
...
@@ -214,8 +214,8 @@ alter domain dnotnulltest drop not null; -- fails
...
@@ -214,8 +214,8 @@ alter domain dnotnulltest drop not null; -- fails
NOTICE: "dnotnulltest" is already set to NULL
NOTICE: "dnotnulltest" is already set to NULL
update domnotnull set col1 = null;
update domnotnull set col1 = null;
drop domain dnotnulltest cascade;
drop domain dnotnulltest cascade;
NOTICE:
D
rop cascades to table domnotnull column col2
NOTICE:
d
rop cascades to table domnotnull column col2
NOTICE:
D
rop cascades to table domnotnull column col1
NOTICE:
d
rop cascades to table domnotnull column col1
-- Test ALTER DOMAIN .. DEFAULT ..
-- Test ALTER DOMAIN .. DEFAULT ..
create table domdeftest (col1 ddef1);
create table domdeftest (col1 ddef1);
insert into domdeftest default values;
insert into domdeftest default values;
...
...
src/test/regress/expected/errors.out
View file @
d8528630
...
@@ -25,7 +25,7 @@ select;
...
@@ -25,7 +25,7 @@ select;
ERROR: syntax error at or near ";" at character 7
ERROR: syntax error at or near ";" at character 7
-- no such relation
-- no such relation
select * from nonesuch;
select * from nonesuch;
ERROR:
R
elation "nonesuch" does not exist
ERROR:
r
elation "nonesuch" does not exist
-- missing target list
-- missing target list
select from pg_database;
select from pg_database;
ERROR: syntax error at or near "from" at character 8
ERROR: syntax error at or near "from" at character 8
...
@@ -52,7 +52,7 @@ delete from;
...
@@ -52,7 +52,7 @@ delete from;
ERROR: syntax error at or near ";" at character 12
ERROR: syntax error at or near ";" at character 12
-- no such relation
-- no such relation
delete from nonesuch;
delete from nonesuch;
ERROR:
R
elation "nonesuch" does not exist
ERROR:
r
elation "nonesuch" does not exist
--
--
-- DROP
-- DROP
...
@@ -71,10 +71,10 @@ alter table rename;
...
@@ -71,10 +71,10 @@ alter table rename;
ERROR: syntax error at or near ";" at character 19
ERROR: syntax error at or near ";" at character 19
-- no such relation
-- no such relation
alter table nonesuch rename to newnonesuch;
alter table nonesuch rename to newnonesuch;
ERROR:
R
elation "nonesuch" does not exist
ERROR:
r
elation "nonesuch" does not exist
-- no such relation
-- no such relation
alter table nonesuch rename to stud_emp;
alter table nonesuch rename to stud_emp;
ERROR:
R
elation "nonesuch" does not exist
ERROR:
r
elation "nonesuch" does not exist
-- conflict
-- conflict
alter table stud_emp rename to aggtest;
alter table stud_emp rename to aggtest;
ERROR: relation "aggtest" already exists
ERROR: relation "aggtest" already exists
...
@@ -84,7 +84,7 @@ ERROR: relation "stud_emp" already exists
...
@@ -84,7 +84,7 @@ ERROR: relation "stud_emp" already exists
-- attribute renaming
-- attribute renaming
-- no such relation
-- no such relation
alter table nonesuchrel rename column nonesuchatt to newnonesuchatt;
alter table nonesuchrel rename column nonesuchatt to newnonesuchatt;
ERROR:
R
elation "nonesuchrel" does not exist
ERROR:
r
elation "nonesuchrel" does not exist
-- no such attribute
-- no such attribute
alter table emp rename column nonesuchatt to newnonesuchatt;
alter table emp rename column nonesuchatt to newnonesuchatt;
ERROR: attribute "nonesuchatt" does not exist
ERROR: attribute "nonesuchatt" does not exist
...
@@ -227,7 +227,7 @@ drop rule 314159;
...
@@ -227,7 +227,7 @@ drop rule 314159;
ERROR: syntax error at or near "314159" at character 11
ERROR: syntax error at or near "314159" at character 11
-- no such rule
-- no such rule
drop rule nonesuch on noplace;
drop rule nonesuch on noplace;
ERROR:
R
elation "noplace" does not exist
ERROR:
r
elation "noplace" does not exist
-- bad keyword
-- bad keyword
drop tuple rule nonesuch;
drop tuple rule nonesuch;
ERROR: syntax error at or near "tuple" at character 6
ERROR: syntax error at or near "tuple" at character 6
...
...
src/test/regress/expected/foreign_key.out
View file @
d8528630
...
@@ -138,7 +138,7 @@ SELECT * FROM FKTABLE;
...
@@ -138,7 +138,7 @@ SELECT * FROM FKTABLE;
(5 rows)
(5 rows)
DROP TABLE PKTABLE CASCADE;
DROP TABLE PKTABLE CASCADE;
NOTICE:
D
rop cascades to constraint constrname on table fktable
NOTICE:
d
rop cascades to constraint constrname on table fktable
DROP TABLE FKTABLE;
DROP TABLE FKTABLE;
--
--
-- check set default and table constraint on multiple columns
-- check set default and table constraint on multiple columns
...
@@ -225,10 +225,10 @@ SELECT * FROM FKTABLE;
...
@@ -225,10 +225,10 @@ SELECT * FROM FKTABLE;
-- this should fail for lack of CASCADE
-- this should fail for lack of CASCADE
DROP TABLE PKTABLE;
DROP TABLE PKTABLE;
NOTICE: constraint constrname2 on table fktable depends on table pktable
NOTICE: constraint constrname2 on table fktable depends on table pktable
ERROR:
C
annot drop table pktable because other objects depend on it
ERROR:
c
annot drop table pktable because other objects depend on it
Use DROP ... CASCADE to drop the dependent objects too
HINT: Use DROP ... CASCADE to drop the dependent objects too.
DROP TABLE PKTABLE CASCADE;
DROP TABLE PKTABLE CASCADE;
NOTICE:
D
rop cascades to constraint constrname2 on table fktable
NOTICE:
d
rop cascades to constraint constrname2 on table fktable
DROP TABLE FKTABLE;
DROP TABLE FKTABLE;
--
--
-- First test, check with no on delete or on update
-- First test, check with no on delete or on update
...
...
src/test/regress/expected/polymorphism.out
View file @
d8528630
...
@@ -76,7 +76,8 @@ CREATE AGGREGATE myaggp01a(BASETYPE = "ANY", SFUNC = stfnp, STYPE = int4[],
...
@@ -76,7 +76,8 @@ CREATE AGGREGATE myaggp01a(BASETYPE = "ANY", SFUNC = stfnp, STYPE = int4[],
-- should ERROR: stfnp(anyarray) not matched by stfnp(int[])
-- should ERROR: stfnp(anyarray) not matched by stfnp(int[])
CREATE AGGREGATE myaggp02a(BASETYPE = "ANY", SFUNC = stfnp, STYPE = anyarray,
CREATE AGGREGATE myaggp02a(BASETYPE = "ANY", SFUNC = stfnp, STYPE = anyarray,
FINALFUNC = ffp, INITCOND = '{}');
FINALFUNC = ffp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- N P
-- N P
-- should CREATE
-- should CREATE
CREATE AGGREGATE myaggp03a(BASETYPE = "ANY", SFUNC = stfp, STYPE = int4[],
CREATE AGGREGATE myaggp03a(BASETYPE = "ANY", SFUNC = stfp, STYPE = int4[],
...
@@ -87,10 +88,12 @@ CREATE AGGREGATE myaggp03b(BASETYPE = "ANY", SFUNC = stfp, STYPE = int4[],
...
@@ -87,10 +88,12 @@ CREATE AGGREGATE myaggp03b(BASETYPE = "ANY", SFUNC = stfp, STYPE = int4[],
-- should ERROR: we have no way to resolve S
-- should ERROR: we have no way to resolve S
CREATE AGGREGATE myaggp04a(BASETYPE = "ANY", SFUNC = stfp, STYPE = anyarray,
CREATE AGGREGATE myaggp04a(BASETYPE = "ANY", SFUNC = stfp, STYPE = anyarray,
FINALFUNC = ffp, INITCOND = '{}');
FINALFUNC = ffp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
CREATE AGGREGATE myaggp04b(BASETYPE = "ANY", SFUNC = stfp, STYPE = anyarray,
CREATE AGGREGATE myaggp04b(BASETYPE = "ANY", SFUNC = stfp, STYPE = anyarray,
INITCOND = '{}');
INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- Case2 (R = P) && ((B = P) || (B = N))
-- Case2 (R = P) && ((B = P) || (B = N))
-- -------------------------------------
-- -------------------------------------
-- S tf1 B tf2
-- S tf1 B tf2
...
@@ -144,12 +147,14 @@ ERROR: function tfp(integer[], anyelement) does not exist
...
@@ -144,12 +147,14 @@ ERROR: function tfp(integer[], anyelement) does not exist
-- should ERROR: tfnp(anyarray, int) not matched by tfnp(int[],int)
-- should ERROR: tfnp(anyarray, int) not matched by tfnp(int[],int)
CREATE AGGREGATE myaggp13a(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray,
CREATE AGGREGATE myaggp13a(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray,
FINALFUNC = ffp, INITCOND = '{}');
FINALFUNC = ffp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P N N P
-- P N N P
-- should ERROR: tf2p(anyarray, int) not matched by tf2p(int[],anyelement)
-- should ERROR: tf2p(anyarray, int) not matched by tf2p(int[],anyelement)
CREATE AGGREGATE myaggp14a(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray,
CREATE AGGREGATE myaggp14a(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray,
FINALFUNC = ffp, INITCOND = '{}');
FINALFUNC = ffp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P N P N
-- P N P N
-- should ERROR: tfnp(anyarray, anyelement) not matched by tfnp(int[],int)
-- should ERROR: tfnp(anyarray, anyelement) not matched by tfnp(int[],int)
CREATE AGGREGATE myaggp15a(BASETYPE = anyelement, SFUNC = tfnp,
CREATE AGGREGATE myaggp15a(BASETYPE = anyelement, SFUNC = tfnp,
...
@@ -164,18 +169,22 @@ ERROR: function tf2p(anyarray, anyelement) does not exist
...
@@ -164,18 +169,22 @@ ERROR: function tf2p(anyarray, anyelement) does not exist
-- should ERROR: we have no way to resolve S
-- should ERROR: we have no way to resolve S
CREATE AGGREGATE myaggp17a(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray,
CREATE AGGREGATE myaggp17a(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray,
FINALFUNC = ffp, INITCOND = '{}');
FINALFUNC = ffp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
CREATE AGGREGATE myaggp17b(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray,
CREATE AGGREGATE myaggp17b(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray,
INITCOND = '{}');
INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P P N P
-- P P N P
-- should ERROR: tfp(anyarray, int) not matched by tfp(anyarray, anyelement)
-- should ERROR: tfp(anyarray, int) not matched by tfp(anyarray, anyelement)
CREATE AGGREGATE myaggp18a(BASETYPE = int, SFUNC = tfp, STYPE = anyarray,
CREATE AGGREGATE myaggp18a(BASETYPE = int, SFUNC = tfp, STYPE = anyarray,
FINALFUNC = ffp, INITCOND = '{}');
FINALFUNC = ffp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
CREATE AGGREGATE myaggp18b(BASETYPE = int, SFUNC = tfp, STYPE = anyarray,
CREATE AGGREGATE myaggp18b(BASETYPE = int, SFUNC = tfp, STYPE = anyarray,
INITCOND = '{}');
INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P P P N
-- P P P N
-- should ERROR: tf1p(anyarray, anyelement) not matched by tf1p(anyarray, int)
-- should ERROR: tf1p(anyarray, anyelement) not matched by tf1p(anyarray, int)
CREATE AGGREGATE myaggp19a(BASETYPE = anyelement, SFUNC = tf1p,
CREATE AGGREGATE myaggp19a(BASETYPE = anyelement, SFUNC = tf1p,
...
@@ -204,10 +213,12 @@ CREATE AGGREGATE myaggn01b(BASETYPE = "ANY", SFUNC = stfnp, STYPE = int4[],
...
@@ -204,10 +213,12 @@ CREATE AGGREGATE myaggn01b(BASETYPE = "ANY", SFUNC = stfnp, STYPE = int4[],
-- should ERROR: stfnp(anyarray) not matched by stfnp(int[])
-- should ERROR: stfnp(anyarray) not matched by stfnp(int[])
CREATE AGGREGATE myaggn02a(BASETYPE = "ANY", SFUNC = stfnp, STYPE = anyarray,
CREATE AGGREGATE myaggn02a(BASETYPE = "ANY", SFUNC = stfnp, STYPE = anyarray,
FINALFUNC = ffnp, INITCOND = '{}');
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
CREATE AGGREGATE myaggn02b(BASETYPE = "ANY", SFUNC = stfnp, STYPE = anyarray,
CREATE AGGREGATE myaggn02b(BASETYPE = "ANY", SFUNC = stfnp, STYPE = anyarray,
INITCOND = '{}');
INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- N P
-- N P
-- should CREATE
-- should CREATE
CREATE AGGREGATE myaggn03a(BASETYPE = "ANY", SFUNC = stfp, STYPE = int4[],
CREATE AGGREGATE myaggn03a(BASETYPE = "ANY", SFUNC = stfp, STYPE = int4[],
...
@@ -216,7 +227,8 @@ CREATE AGGREGATE myaggn03a(BASETYPE = "ANY", SFUNC = stfp, STYPE = int4[],
...
@@ -216,7 +227,8 @@ CREATE AGGREGATE myaggn03a(BASETYPE = "ANY", SFUNC = stfp, STYPE = int4[],
-- should ERROR: ffnp(anyarray) not matched by ffnp(int[])
-- should ERROR: ffnp(anyarray) not matched by ffnp(int[])
CREATE AGGREGATE myaggn04a(BASETYPE = "ANY", SFUNC = stfp, STYPE = anyarray,
CREATE AGGREGATE myaggn04a(BASETYPE = "ANY", SFUNC = stfp, STYPE = anyarray,
FINALFUNC = ffnp, INITCOND = '{}');
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- Case4 (R = N) && ((B = P) || (B = N))
-- Case4 (R = N) && ((B = P) || (B = N))
-- -------------------------------------
-- -------------------------------------
-- S tf1 B tf2
-- S tf1 B tf2
...
@@ -269,18 +281,22 @@ ERROR: function tfp(integer[], anyelement) does not exist
...
@@ -269,18 +281,22 @@ ERROR: function tfp(integer[], anyelement) does not exist
-- should ERROR: tfnp(anyarray, int) not matched by tfnp(int[],int)
-- should ERROR: tfnp(anyarray, int) not matched by tfnp(int[],int)
CREATE AGGREGATE myaggn13a(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray,
CREATE AGGREGATE myaggn13a(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray,
FINALFUNC = ffnp, INITCOND = '{}');
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
CREATE AGGREGATE myaggn13b(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray,
CREATE AGGREGATE myaggn13b(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray,
INITCOND = '{}');
INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P N N P
-- P N N P
-- should ERROR: tf2p(anyarray, int) not matched by tf2p(int[],anyelement)
-- should ERROR: tf2p(anyarray, int) not matched by tf2p(int[],anyelement)
CREATE AGGREGATE myaggn14a(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray,
CREATE AGGREGATE myaggn14a(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray,
FINALFUNC = ffnp, INITCOND = '{}');
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
CREATE AGGREGATE myaggn14b(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray,
CREATE AGGREGATE myaggn14b(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray,
INITCOND = '{}');
INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P N P N
-- P N P N
-- should ERROR: tfnp(anyarray, anyelement) not matched by tfnp(int[],int)
-- should ERROR: tfnp(anyarray, anyelement) not matched by tfnp(int[],int)
CREATE AGGREGATE myaggn15a(BASETYPE = anyelement, SFUNC = tfnp,
CREATE AGGREGATE myaggn15a(BASETYPE = anyelement, SFUNC = tfnp,
...
@@ -301,12 +317,14 @@ ERROR: function tf2p(anyarray, anyelement) does not exist
...
@@ -301,12 +317,14 @@ ERROR: function tf2p(anyarray, anyelement) does not exist
-- should ERROR: ffnp(anyarray) not matched by ffnp(int[])
-- should ERROR: ffnp(anyarray) not matched by ffnp(int[])
CREATE AGGREGATE myaggn17a(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray,
CREATE AGGREGATE myaggn17a(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray,
FINALFUNC = ffnp, INITCOND = '{}');
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P P N P
-- P P N P
-- should ERROR: tfp(anyarray, int) not matched by tfp(anyarray, anyelement)
-- should ERROR: tfp(anyarray, int) not matched by tfp(anyarray, anyelement)
CREATE AGGREGATE myaggn18a(BASETYPE = int, SFUNC = tfp, STYPE = anyarray,
CREATE AGGREGATE myaggn18a(BASETYPE = int, SFUNC = tfp, STYPE = anyarray,
FINALFUNC = ffnp, INITCOND = '{}');
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P P P N
-- P P P N
-- should ERROR: tf1p(anyarray, anyelement) not matched by tf1p(anyarray, int)
-- should ERROR: tf1p(anyarray, anyelement) not matched by tf1p(anyarray, int)
CREATE AGGREGATE myaggn19a(BASETYPE = anyelement, SFUNC = tf1p,
CREATE AGGREGATE myaggn19a(BASETYPE = anyelement, SFUNC = tf1p,
...
...
src/test/regress/expected/privileges.out
View file @
d8528630
...
@@ -69,11 +69,11 @@ SELECT * FROM atest2; -- ok
...
@@ -69,11 +69,11 @@ SELECT * FROM atest2; -- ok
INSERT INTO atest1 VALUES (2, 'two'); -- ok
INSERT INTO atest1 VALUES (2, 'two'); -- ok
INSERT INTO atest2 VALUES ('foo', true); -- fail
INSERT INTO atest2 VALUES ('foo', true); -- fail
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
INSERT INTO atest1 SELECT 1, b FROM atest1; -- ok
INSERT INTO atest1 SELECT 1, b FROM atest1; -- ok
UPDATE atest1 SET a = 1 WHERE a = 2; -- ok
UPDATE atest1 SET a = 1 WHERE a = 2; -- ok
UPDATE atest2 SET col2 = NOT col2; -- fail
UPDATE atest2 SET col2 = NOT col2; -- fail
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
SELECT * FROM atest1 FOR UPDATE; -- ok
SELECT * FROM atest1 FOR UPDATE; -- ok
a | b
a | b
---+-----
---+-----
...
@@ -82,15 +82,15 @@ SELECT * FROM atest1 FOR UPDATE; -- ok
...
@@ -82,15 +82,15 @@ SELECT * FROM atest1 FOR UPDATE; -- ok
(2 rows)
(2 rows)
SELECT * FROM atest2 FOR UPDATE; -- fail
SELECT * FROM atest2 FOR UPDATE; -- fail
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
DELETE FROM atest2; -- fail
DELETE FROM atest2; -- fail
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
LOCK atest2 IN ACCESS EXCLUSIVE MODE; -- fail
LOCK atest2 IN ACCESS EXCLUSIVE MODE; -- fail
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
COPY atest2 FROM stdin; -- fail
COPY atest2 FROM stdin; -- fail
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
GRANT ALL ON atest1 TO PUBLIC; -- fail
GRANT ALL ON atest1 TO PUBLIC; -- fail
ERROR:
atest1: permission denied
ERROR:
permission denied for "atest1"
-- checks in subquery, both ok
-- checks in subquery, both ok
SELECT * FROM atest1 WHERE ( b IN ( SELECT col1 FROM atest2 ) );
SELECT * FROM atest1 WHERE ( b IN ( SELECT col1 FROM atest2 ) );
a | b
a | b
...
@@ -117,33 +117,33 @@ SELECT * FROM atest1; -- ok
...
@@ -117,33 +117,33 @@ SELECT * FROM atest1; -- ok
(2 rows)
(2 rows)
SELECT * FROM atest2; -- fail
SELECT * FROM atest2; -- fail
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
INSERT INTO atest1 VALUES (2, 'two'); -- fail
INSERT INTO atest1 VALUES (2, 'two'); -- fail
ERROR:
atest1: permission denied
ERROR:
permission denied for "atest1"
INSERT INTO atest2 VALUES ('foo', true); -- fail
INSERT INTO atest2 VALUES ('foo', true); -- fail
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
INSERT INTO atest1 SELECT 1, b FROM atest1; -- fail
INSERT INTO atest1 SELECT 1, b FROM atest1; -- fail
ERROR:
atest1: permission denied
ERROR:
permission denied for "atest1"
UPDATE atest1 SET a = 1 WHERE a = 2; -- fail
UPDATE atest1 SET a = 1 WHERE a = 2; -- fail
ERROR:
atest1: permission denied
ERROR:
permission denied for "atest1"
UPDATE atest2 SET col2 = NULL; -- ok
UPDATE atest2 SET col2 = NULL; -- ok
UPDATE atest2 SET col2 = NOT col2; -- fails; requires SELECT on atest2
UPDATE atest2 SET col2 = NOT col2; -- fails; requires SELECT on atest2
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
UPDATE atest2 SET col2 = true WHERE atest1.a = 5; -- ok
UPDATE atest2 SET col2 = true WHERE atest1.a = 5; -- ok
SELECT * FROM atest1 FOR UPDATE; -- fail
SELECT * FROM atest1 FOR UPDATE; -- fail
ERROR:
atest1: permission denied
ERROR:
permission denied for "atest1"
SELECT * FROM atest2 FOR UPDATE; -- fail
SELECT * FROM atest2 FOR UPDATE; -- fail
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
DELETE FROM atest2; -- fail
DELETE FROM atest2; -- fail
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
LOCK atest2 IN ACCESS EXCLUSIVE MODE; -- ok
LOCK atest2 IN ACCESS EXCLUSIVE MODE; -- ok
COPY atest2 FROM stdin; -- fail
COPY atest2 FROM stdin; -- fail
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
-- checks in subquery, both fail
-- checks in subquery, both fail
SELECT * FROM atest1 WHERE ( b IN ( SELECT col1 FROM atest2 ) );
SELECT * FROM atest1 WHERE ( b IN ( SELECT col1 FROM atest2 ) );
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
SELECT * FROM atest2 WHERE ( col1 IN ( SELECT b FROM atest1 ) );
SELECT * FROM atest2 WHERE ( col1 IN ( SELECT b FROM atest1 ) );
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
SET SESSION AUTHORIZATION regressuser4;
SET SESSION AUTHORIZATION regressuser4;
COPY atest2 FROM stdin; -- ok
COPY atest2 FROM stdin; -- ok
SELECT * FROM atest1; -- ok
SELECT * FROM atest1; -- ok
...
@@ -159,7 +159,7 @@ CREATE TABLE atest3 (one int, two int, three int);
...
@@ -159,7 +159,7 @@ CREATE TABLE atest3 (one int, two int, three int);
GRANT DELETE ON atest3 TO GROUP regressgroup2;
GRANT DELETE ON atest3 TO GROUP regressgroup2;
SET SESSION AUTHORIZATION regressuser1;
SET SESSION AUTHORIZATION regressuser1;
SELECT * FROM atest3; -- fail
SELECT * FROM atest3; -- fail
ERROR:
atest3: permission denied
ERROR:
permission denied for "atest3"
DELETE FROM atest3; -- ok
DELETE FROM atest3; -- ok
-- views
-- views
SET SESSION AUTHORIZATION regressuser3;
SET SESSION AUTHORIZATION regressuser3;
...
@@ -175,7 +175,7 @@ SELECT * FROM atestv1; -- ok
...
@@ -175,7 +175,7 @@ SELECT * FROM atestv1; -- ok
(2 rows)
(2 rows)
SELECT * FROM atestv2; -- fail
SELECT * FROM atestv2; -- fail
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
GRANT SELECT ON atestv1, atestv3 TO regressuser4;
GRANT SELECT ON atestv1, atestv3 TO regressuser4;
GRANT SELECT ON atestv2 TO regressuser2;
GRANT SELECT ON atestv2 TO regressuser2;
SET SESSION AUTHORIZATION regressuser4;
SET SESSION AUTHORIZATION regressuser4;
...
@@ -187,7 +187,7 @@ SELECT * FROM atestv1; -- ok
...
@@ -187,7 +187,7 @@ SELECT * FROM atestv1; -- ok
(2 rows)
(2 rows)
SELECT * FROM atestv2; -- fail
SELECT * FROM atestv2; -- fail
ERROR:
atestv2: permission denied
ERROR:
permission denied for "atestv2"
SELECT * FROM atestv3; -- ok
SELECT * FROM atestv3; -- ok
one | two | three
one | two | three
-----+-----+-------
-----+-----+-------
...
@@ -203,7 +203,7 @@ GRANT SELECT ON atestv4 TO regressuser2;
...
@@ -203,7 +203,7 @@ GRANT SELECT ON atestv4 TO regressuser2;
SET SESSION AUTHORIZATION regressuser2;
SET SESSION AUTHORIZATION regressuser2;
-- Two complex cases:
-- Two complex cases:
SELECT * FROM atestv3; -- fail
SELECT * FROM atestv3; -- fail
ERROR:
atestv3: permission denied
ERROR:
permission denied for "atestv3"
SELECT * FROM atestv4; -- ok (even though regressuser2 cannot access underlying atestv3)
SELECT * FROM atestv4; -- ok (even though regressuser2 cannot access underlying atestv3)
one | two | three
one | two | three
-----+-----+-------
-----+-----+-------
...
@@ -216,7 +216,7 @@ SELECT * FROM atest2; -- ok
...
@@ -216,7 +216,7 @@ SELECT * FROM atest2; -- ok
(1 row)
(1 row)
SELECT * FROM atestv2; -- fail (even though regressuser2 can access underlying atest2)
SELECT * FROM atestv2; -- fail (even though regressuser2 can access underlying atest2)
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
-- privileges on functions, languages
-- privileges on functions, languages
-- switch to superuser
-- switch to superuser
\c -
\c -
...
@@ -226,13 +226,13 @@ GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail
...
@@ -226,13 +226,13 @@ GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail
ERROR: language "c" is not trusted
ERROR: language "c" is not trusted
SET SESSION AUTHORIZATION regressuser1;
SET SESSION AUTHORIZATION regressuser1;
GRANT USAGE ON LANGUAGE sql TO regressuser2; -- fail
GRANT USAGE ON LANGUAGE sql TO regressuser2; -- fail
ERROR:
sql: permission denied
ERROR:
permission denied for "sql"
CREATE FUNCTION testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql;
CREATE FUNCTION testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql;
CREATE FUNCTION testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
CREATE FUNCTION testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
REVOKE ALL ON FUNCTION testfunc1(int), testfunc2(int) FROM PUBLIC;
REVOKE ALL ON FUNCTION testfunc1(int), testfunc2(int) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION testfunc1(int), testfunc2(int) TO regressuser2;
GRANT EXECUTE ON FUNCTION testfunc1(int), testfunc2(int) TO regressuser2;
GRANT USAGE ON FUNCTION testfunc1(int) TO regressuser3; -- semantic error
GRANT USAGE ON FUNCTION testfunc1(int) TO regressuser3; -- semantic error
ERROR: invalid privilege type USAGE for function
object
ERROR: invalid privilege type USAGE for function
GRANT ALL PRIVILEGES ON FUNCTION testfunc1(int) TO regressuser4;
GRANT ALL PRIVILEGES ON FUNCTION testfunc1(int) TO regressuser4;
GRANT ALL PRIVILEGES ON FUNCTION testfunc_nosuch(int) TO regressuser4;
GRANT ALL PRIVILEGES ON FUNCTION testfunc_nosuch(int) TO regressuser4;
ERROR: function testfunc_nosuch(integer) does not exist
ERROR: function testfunc_nosuch(integer) does not exist
...
@@ -248,12 +248,12 @@ SELECT testfunc1(5), testfunc2(5); -- ok
...
@@ -248,12 +248,12 @@ SELECT testfunc1(5), testfunc2(5); -- ok
(1 row)
(1 row)
CREATE FUNCTION testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql; -- fail
CREATE FUNCTION testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql; -- fail
ERROR:
sql: permission denied
ERROR:
permission denied for "sql"
SET SESSION AUTHORIZATION regressuser3;
SET SESSION AUTHORIZATION regressuser3;
SELECT testfunc1(5); -- fail
SELECT testfunc1(5); -- fail
ERROR:
testfunc1: permission denied
ERROR:
permission denied for "testfunc1"
SELECT col1 FROM atest2 WHERE col2 = true; -- fail
SELECT col1 FROM atest2 WHERE col2 = true; -- fail
ERROR:
atest2: permission denied
ERROR:
permission denied for "atest2"
SELECT testfunc4(true); -- ok
SELECT testfunc4(true); -- ok
testfunc4
testfunc4
-----------
-----------
...
@@ -268,7 +268,7 @@ SELECT testfunc1(5); -- ok
...
@@ -268,7 +268,7 @@ SELECT testfunc1(5); -- ok
(1 row)
(1 row)
DROP FUNCTION testfunc1(int); -- fail
DROP FUNCTION testfunc1(int); -- fail
ERROR:
testfunc1: must be owner
ERROR:
must be owner of "testfunc1"
\c -
\c -
DROP FUNCTION testfunc1(int); -- ok
DROP FUNCTION testfunc1(int); -- ok
-- restore to sanity
-- restore to sanity
...
@@ -282,15 +282,15 @@ select has_table_privilege(NULL,'pg_shadow','select');
...
@@ -282,15 +282,15 @@ select has_table_privilege(NULL,'pg_shadow','select');
(1 row)
(1 row)
select has_table_privilege('pg_shad','select');
select has_table_privilege('pg_shad','select');
ERROR:
R
elation "pg_shad" does not exist
ERROR:
r
elation "pg_shad" does not exist
select has_table_privilege('nosuchuser','pg_shadow','select');
select has_table_privilege('nosuchuser','pg_shadow','select');
ERROR: user "nosuchuser" does not exist
ERROR: user "nosuchuser" does not exist
select has_table_privilege('pg_shadow','sel');
select has_table_privilege('pg_shadow','sel');
ERROR: has_table_privilege: invalid privilege type sel
ERROR: has_table_privilege: invalid privilege type sel
select has_table_privilege(-999999,'pg_shadow','update');
select has_table_privilege(-999999,'pg_shadow','update');
ERROR:
pg_class_aclcheck: invalid user id 4293967297
ERROR:
user with ID 4293967297 does not exist
select has_table_privilege(1,'rule');
select has_table_privilege(1,'rule');
ERROR:
pg_class_aclcheck: relation 1 not found
ERROR:
relation with OID 1 does not exist
-- superuser
-- superuser
\c -
\c -
select has_table_privilege(current_user,'pg_shadow','select');
select has_table_privilege(current_user,'pg_shadow','select');
...
@@ -551,7 +551,7 @@ ERROR: grant options can only be granted to individual users
...
@@ -551,7 +551,7 @@ ERROR: grant options can only be granted to individual users
SET SESSION AUTHORIZATION regressuser2;
SET SESSION AUTHORIZATION regressuser2;
GRANT SELECT ON atest4 TO regressuser3;
GRANT SELECT ON atest4 TO regressuser3;
GRANT UPDATE ON atest4 TO regressuser3; -- fail
GRANT UPDATE ON atest4 TO regressuser3; -- fail
ERROR:
atest4: permission denied
ERROR:
permission denied for "atest4"
SET SESSION AUTHORIZATION regressuser1;
SET SESSION AUTHORIZATION regressuser1;
REVOKE SELECT ON atest4 FROM regressuser3; -- does nothing
REVOKE SELECT ON atest4 FROM regressuser3; -- does nothing
SELECT has_table_privilege('regressuser3', 'atest4', 'SELECT'); -- true
SELECT has_table_privilege('regressuser3', 'atest4', 'SELECT'); -- true
...
@@ -589,8 +589,8 @@ DROP VIEW atestv1;
...
@@ -589,8 +589,8 @@ DROP VIEW atestv1;
DROP VIEW atestv2;
DROP VIEW atestv2;
-- this should cascade to drop atestv4
-- this should cascade to drop atestv4
DROP VIEW atestv3 CASCADE;
DROP VIEW atestv3 CASCADE;
NOTICE:
D
rop cascades to rule _RETURN on view atestv4
NOTICE:
d
rop cascades to rule _RETURN on view atestv4
NOTICE:
D
rop cascades to view atestv4
NOTICE:
d
rop cascades to view atestv4
-- this should complain "does not exist"
-- this should complain "does not exist"
DROP VIEW atestv4;
DROP VIEW atestv4;
ERROR: view "atestv4" does not exist
ERROR: view "atestv4" does not exist
...
...
src/test/regress/expected/temp.out
View file @
d8528630
...
@@ -44,7 +44,7 @@ DROP TABLE temptest;
...
@@ -44,7 +44,7 @@ DROP TABLE temptest;
CREATE TEMP TABLE temptest(col int);
CREATE TEMP TABLE temptest(col int);
\c regression
\c regression
SELECT * FROM temptest;
SELECT * FROM temptest;
ERROR:
R
elation "temptest" does not exist
ERROR:
r
elation "temptest" does not exist
-- Test ON COMMIT DELETE ROWS
-- Test ON COMMIT DELETE ROWS
CREATE TEMP TABLE temptest(col int) ON COMMIT DELETE ROWS;
CREATE TEMP TABLE temptest(col int) ON COMMIT DELETE ROWS;
BEGIN;
BEGIN;
...
@@ -78,7 +78,7 @@ SELECT * FROM temptest;
...
@@ -78,7 +78,7 @@ SELECT * FROM temptest;
COMMIT;
COMMIT;
SELECT * FROM temptest;
SELECT * FROM temptest;
ERROR:
R
elation "temptest" does not exist
ERROR:
r
elation "temptest" does not exist
-- ON COMMIT is only allowed for TEMP
-- ON COMMIT is only allowed for TEMP
CREATE TABLE temptest(col int) ON COMMIT DELETE ROWS;
CREATE TABLE temptest(col int) ON COMMIT DELETE ROWS;
ERROR: ON COMMIT can only be used on TEMP tables
ERROR: ON COMMIT can only be used on TEMP tables
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