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
216311d5
Commit
216311d5
authored
Jul 18, 2003
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First bits of work on error message editing.
parent
44f665bf
Changes
21
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
1083 additions
and
534 deletions
+1083
-534
doc/src/sgml/sources.sgml
doc/src/sgml/sources.sgml
+29
-15
src/backend/catalog/pg_proc.c
src/backend/catalog/pg_proc.c
+100
-51
src/backend/commands/dbcommands.c
src/backend/commands/dbcommands.c
+134
-58
src/backend/commands/functioncmds.c
src/backend/commands/functioncmds.c
+189
-110
src/backend/commands/opclasscmds.c
src/backend/commands/opclasscmds.c
+74
-42
src/backend/commands/proclang.c
src/backend/commands/proclang.c
+26
-19
src/backend/commands/schemacmds.c
src/backend/commands/schemacmds.c
+25
-18
src/backend/commands/user.c
src/backend/commands/user.c
+171
-93
src/backend/parser/analyze.c
src/backend/parser/analyze.c
+8
-4
src/backend/parser/parse_coerce.c
src/backend/parser/parse_coerce.c
+11
-7
src/backend/parser/parse_expr.c
src/backend/parser/parse_expr.c
+8
-5
src/backend/parser/parse_func.c
src/backend/parser/parse_func.c
+71
-40
src/backend/parser/parse_oper.c
src/backend/parser/parse_oper.c
+35
-17
src/backend/parser/scan.l
src/backend/parser/scan.l
+15
-9
src/backend/utils/error/elog.c
src/backend/utils/error/elog.c
+84
-5
src/backend/utils/fmgr/dfmgr.c
src/backend/utils/fmgr/dfmgr.c
+33
-12
src/include/utils/elog.h
src/include/utils/elog.h
+46
-11
src/test/regress/expected/alter_table.out
src/test/regress/expected/alter_table.out
+2
-2
src/test/regress/expected/create_type.out
src/test/regress/expected/create_type.out
+6
-4
src/test/regress/expected/privileges.out
src/test/regress/expected/privileges.out
+2
-2
src/test/regress/output/create_function_1.source
src/test/regress/output/create_function_1.source
+14
-10
No files found.
doc/src/sgml/sources.sgml
View file @
216311d5
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/sources.sgml,v 2.
8 2003/06/22 16:17:01
tgl Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/sources.sgml,v 2.
9 2003/07/18 23:20:32
tgl Exp $
-->
<chapter id="source">
...
...
@@ -125,11 +125,12 @@ less -x4
Here is a more complex example:
<programlisting>
ereport(ERROR,
(errmsg("Unable to identify an operator %s %s %s",
format_type_be(arg1),
NameListToString(op),
format_type_be(arg2)),
errhint("Try explicitly casting the arguments to appropriate types")));
(errcode(ERRCODE_AMBIGUOUS_FUNCTION),
errmsg("function %s is not unique",
func_signature_string(funcname, nargs,
actual_arg_types)),
errhint("Unable to choose a best candidate function. "
"You may need to add explicit typecasts.")));
</programlisting>
This illustrates the use of format codes to embed run-time values into
a message text. Also, an optional <quote>hint</> message is provided.
...
...
@@ -141,11 +142,14 @@ less -x4
<listitem>
<para>
<function>errcode</>(sqlerrcode) specifies the SQLSTATE error identifier
code for the condition. If this is not specified, it defaults to
<literal>ERRCODE_INTERNAL_ERROR</>, which is a convenient default since
a large number of <function>ereport</> calls are in fact for internal
<quote>can't happen</> conditions. But never use this default when
reporting user mistakes.
code for the condition. If this routine is not called, the error
identifier defaults to
<literal>ERRCODE_INTERNAL_ERROR</> when the error level is
<literal>ERROR</> or higher, <literal>ERRCODE_WARNING</> when the
error level is <literal>WARNING</>, otherwise (for <literal>NOTICE</>
and below) <literal>ERRCODE_SUCCESSFUL_COMPLETION</>.
While these defaults are often convenient, always think whether they
are appropriate before omitting the <function>errcode</>() call.
</para>
</listitem>
<listitem>
...
...
@@ -220,15 +224,25 @@ less -x4
query processing.
</para>
</listitem>
<listitem>
<para>
<function>errcode_for_file_access</>() is a convenience function that
selects an appropriate SQLSTATE error identifier for a failure in a
file-access-related system call. It uses the saved
<literal>errno</> to determine which error code to generate.
Usually this should be used in combination with <literal>%m</> in the
primary error message text.
</para>
</listitem>
</itemizedlist>
</para>
<para>
You may also see uses of the older function <function>elog</>. This
is equivalent to an <function>ereport</> call specifying only severity
level and primary message.
Because the error code always defaults to
<literal>ERRCODE_INTERNAL_ERROR</>, <function>elog</> should only be
used for internal errors
.
level and primary message.
<function>elog</> should only be used if
the default errcode assignment is appropriate; this generally restricts
its use to internal errors and debug logging output
.
</para>
<para>
...
...
@@ -270,7 +284,7 @@ less -x4
write
<programlisting>
Primary: could not create shared memory segment: %m
Detail: Failed syscall was shmget(key=%d, size=%u, 0%o)
Detail: Failed syscall was shmget(key=%d, size=%u, 0%o)
.
Hint: the addendum
</programlisting>
</para>
...
...
src/backend/catalog/pg_proc.c
View file @
216311d5
This diff is collapsed.
Click to expand it.
src/backend/commands/dbcommands.c
View file @
216311d5
This diff is collapsed.
Click to expand it.
src/backend/commands/functioncmds.c
View file @
216311d5
This diff is collapsed.
Click to expand it.
src/backend/commands/opclasscmds.c
View file @
216311d5
...
...
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.1
1 2003/07/04 02:51:33
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.1
2 2003/07/18 23:20:32
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -85,8 +85,10 @@ DefineOpClass(CreateOpClassStmt *stmt)
CStringGetDatum
(
stmt
->
amname
),
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tup
))
elog
(
ERROR
,
"DefineOpClass: access method
\"
%s
\"
not found"
,
stmt
->
amname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"access method
\"
%s
\"
does not exist"
,
stmt
->
amname
)));
amoid
=
HeapTupleGetOid
(
tup
);
numOperators
=
((
Form_pg_am
)
GETSTRUCT
(
tup
))
->
amstrategies
;
...
...
@@ -104,7 +106,9 @@ DefineOpClass(CreateOpClassStmt *stmt)
* if it can be done without solving the halting problem :-(
*/
if
(
!
superuser
())
elog
(
ERROR
,
"Must be superuser to create an operator class"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
errmsg
(
"must be superuser to create an operator class"
)));
/* Look up the datatype */
typeoid
=
typenameTypeId
(
stmt
->
datatype
);
...
...
@@ -143,12 +147,16 @@ DefineOpClass(CreateOpClassStmt *stmt)
{
case
OPCLASS_ITEM_OPERATOR
:
if
(
item
->
number
<=
0
||
item
->
number
>
numOperators
)
elog
(
ERROR
,
"DefineOpClass: invalid operator number %d,"
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_OBJECT_DEFINITION
),
errmsg
(
"invalid operator number %d,"
" must be between 1 and %d"
,
item
->
number
,
numOperators
);
item
->
number
,
numOperators
))
);
if
(
operators
[
item
->
number
-
1
]
!=
InvalidOid
)
elog
(
ERROR
,
"DefineOpClass: operator number %d appears more than once"
,
item
->
number
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_OBJECT_DEFINITION
),
errmsg
(
"operator number %d appears more than once"
,
item
->
number
)));
if
(
item
->
args
!=
NIL
)
{
TypeName
*
typeName1
=
(
TypeName
*
)
lfirst
(
item
->
args
);
...
...
@@ -176,12 +184,16 @@ DefineOpClass(CreateOpClassStmt *stmt)
break
;
case
OPCLASS_ITEM_FUNCTION
:
if
(
item
->
number
<=
0
||
item
->
number
>
numProcs
)
elog
(
ERROR
,
"DefineOpClass: invalid procedure number %d,"
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_OBJECT_DEFINITION
),
errmsg
(
"invalid procedure number %d,"
" must be between 1 and %d"
,
item
->
number
,
numProcs
);
item
->
number
,
numProcs
))
);
if
(
procedures
[
item
->
number
-
1
]
!=
InvalidOid
)
elog
(
ERROR
,
"DefineOpClass: procedure number %d appears more than once"
,
item
->
number
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_OBJECT_DEFINITION
),
errmsg
(
"DefineOpClass: procedure number %d appears more than once"
,
item
->
number
)));
funcOid
=
LookupFuncNameTypeNames
(
item
->
name
,
item
->
args
,
false
);
/* Caller must have execute permission on functions */
...
...
@@ -193,12 +205,13 @@ DefineOpClass(CreateOpClassStmt *stmt)
break
;
case
OPCLASS_ITEM_STORAGETYPE
:
if
(
OidIsValid
(
storageoid
))
elog
(
ERROR
,
"DefineOpClass: storage type specified more than once"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_OBJECT_DEFINITION
),
errmsg
(
"storage type specified more than once"
)));
storageoid
=
typenameTypeId
(
item
->
storedtype
);
break
;
default:
elog
(
ERROR
,
"DefineOpClass: bogus item type %d"
,
item
->
itemtype
);
elog
(
ERROR
,
"unrecognized item type: %d"
,
item
->
itemtype
);
break
;
}
}
...
...
@@ -219,8 +232,10 @@ DefineOpClass(CreateOpClassStmt *stmt)
* favor of adding another boolean column to pg_am ...
*/
if
(
amoid
!=
GIST_AM_OID
)
elog
(
ERROR
,
"Storage type may not be different from datatype for access method %s"
,
stmt
->
amname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_OBJECT_DEFINITION
),
errmsg
(
"storage type may not be different from datatype for access method
\"
%s
\"
"
,
stmt
->
amname
)));
}
}
...
...
@@ -235,8 +250,10 @@ DefineOpClass(CreateOpClassStmt *stmt)
CStringGetDatum
(
opcname
),
ObjectIdGetDatum
(
namespaceoid
),
0
))
elog
(
ERROR
,
"Operator class
\"
%s
\"
already exists for access method
\"
%s
\"
"
,
opcname
,
stmt
->
amname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DUPLICATE_OBJECT
),
errmsg
(
"operator class
\"
%s
\"
already exists for access method
\"
%s
\"
"
,
opcname
,
stmt
->
amname
)));
/*
* If we are creating a default opclass, check there isn't one
...
...
@@ -259,11 +276,13 @@ DefineOpClass(CreateOpClassStmt *stmt)
Form_pg_opclass
opclass
=
(
Form_pg_opclass
)
GETSTRUCT
(
tup
);
if
(
opclass
->
opcintype
==
typeoid
&&
opclass
->
opcdefault
)
elog
(
ERROR
,
"Can't add class
\"
%s
\"
as default for type %s"
"
\n\t
class
\"
%s
\"
already is the default"
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DUPLICATE_OBJECT
),
errmsg
(
"cannot make class
\"
%s
\"
be default for type %s"
,
opcname
,
TypeNameToString
(
stmt
->
datatype
),
NameStr
(
opclass
->
opcname
));
TypeNameToString
(
stmt
->
datatype
)),
errdetail
(
"class
\"
%s
\"
already is the default"
,
NameStr
(
opclass
->
opcname
))));
}
systable_endscan
(
scan
);
...
...
@@ -467,8 +486,10 @@ RemoveOpClass(RemoveOpClassStmt *stmt)
CStringGetDatum
(
stmt
->
amname
),
0
,
0
,
0
);
if
(
!
OidIsValid
(
amID
))
elog
(
ERROR
,
"RemoveOpClass: access method
\"
%s
\"
not found"
,
stmt
->
amname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"access method
\"
%s
\"
does not exist"
,
stmt
->
amname
)));
/*
* Look up the opclass.
...
...
@@ -494,16 +515,20 @@ RemoveOpClass(RemoveOpClassStmt *stmt)
/* Unqualified opclass name, so search the search path */
opcID
=
OpclassnameGetOpcid
(
amID
,
opcname
);
if
(
!
OidIsValid
(
opcID
))
elog
(
ERROR
,
"RemoveOpClass: operator class
\"
%s
\"
not supported by access method
\"
%s
\"
"
,
opcname
,
stmt
->
amname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"operator class
\"
%s
\"
does not exist for access method
\"
%s
\"
"
,
opcname
,
stmt
->
amname
)));
tuple
=
SearchSysCache
(
CLAOID
,
ObjectIdGetDatum
(
opcID
),
0
,
0
,
0
);
}
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"RemoveOpClass: operator class
\"
%s
\"
not supported by access method
\"
%s
\"
"
,
NameListToString
(
stmt
->
opclassname
),
stmt
->
amname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"operator class
\"
%s
\"
does not exist for access method
\"
%s
\"
"
,
NameListToString
(
stmt
->
opclassname
),
stmt
->
amname
)));
opcID
=
HeapTupleGetOid
(
tuple
);
...
...
@@ -546,8 +571,7 @@ RemoveOpClassById(Oid opclassOid)
ObjectIdGetDatum
(
opclassOid
),
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tup
))
/* should not happen */
elog
(
ERROR
,
"RemoveOpClassById: couldn't find pg_opclass entry %u"
,
opclassOid
);
elog
(
ERROR
,
"cache lookup failed for opclass %u"
,
opclassOid
);
simple_heap_delete
(
rel
,
&
tup
->
t_self
);
...
...
@@ -612,7 +636,10 @@ RenameOpClass(List *name, const char *access_method, const char *newname)
CStringGetDatum
(
access_method
),
0
,
0
,
0
);
if
(
!
OidIsValid
(
amOid
))
elog
(
ERROR
,
"access method
\"
%s
\"
not found"
,
access_method
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"access method
\"
%s
\"
does not exist"
,
access_method
)));
rel
=
heap_openr
(
OperatorClassRelationName
,
RowExclusiveLock
);
...
...
@@ -631,8 +658,10 @@ RenameOpClass(List *name, const char *access_method, const char *newname)
ObjectIdGetDatum
(
namespaceOid
),
0
);
if
(
!
HeapTupleIsValid
(
tup
))
elog
(
ERROR
,
"operator class
\"
%s
\"
for access method
\"
%s
\"
does not exist"
,
opcname
,
access_method
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"operator class
\"
%s
\"
does not exist for access method
\"
%s
\"
"
,
opcname
,
access_method
)));
opcOid
=
HeapTupleGetOid
(
tup
);
}
...
...
@@ -640,14 +669,16 @@ RenameOpClass(List *name, const char *access_method, const char *newname)
{
opcOid
=
OpclassnameGetOpcid
(
amOid
,
opcname
);
if
(
!
OidIsValid
(
opcOid
))
elog
(
ERROR
,
"operator class
\"
%s
\"
for access method
\"
%s
\"
does not exist"
,
opcname
,
access_method
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"operator class
\"
%s
\"
does not exist for access method
\"
%s
\"
"
,
opcname
,
access_method
)));
tup
=
SearchSysCacheCopy
(
CLAOID
,
ObjectIdGetDatum
(
opcOid
),
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tup
))
/* should not happen */
elog
(
ERROR
,
"c
ouldn't find pg_opclass tuple for
%u"
,
opcOid
);
elog
(
ERROR
,
"c
ache lookup failed for opclass
%u"
,
opcOid
);
namespaceOid
=
((
Form_pg_opclass
)
GETSTRUCT
(
tup
))
->
opcnamespace
;
}
...
...
@@ -660,9 +691,10 @@ RenameOpClass(List *name, const char *access_method, const char *newname)
0
))
{
ereport
(
ERROR
,
(
errcode
(
ERRCODE_
SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION
),
(
errcode
(
ERRCODE_
DUPLICATE_OBJECT
),
errmsg
(
"operator class
\"
%s
\"
for access method
\"
%s
\"
already exists in schema
\"
%s
\"
"
,
newname
,
access_method
,
get_namespace_name
(
namespaceOid
))));
newname
,
access_method
,
get_namespace_name
(
namespaceOid
))));
}
/* must be owner */
...
...
src/backend/commands/proclang.c
View file @
216311d5
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.4
5 2003/07/04 02:51:33
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.4
6 2003/07/18 23:20:32
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -58,8 +58,9 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
* Check permission
*/
if
(
!
superuser
())
elog
(
ERROR
,
"Only users with superuser privilege are "
"permitted to create procedural languages"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
errmsg
(
"must be superuser to create procedural language"
)));
/*
* Translate the language name and check that this language doesn't
...
...
@@ -70,7 +71,9 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
if
(
SearchSysCacheExists
(
LANGNAME
,
PointerGetDatum
(
languageName
),
0
,
0
,
0
))
elog
(
ERROR
,
"Language %s already exists"
,
languageName
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DUPLICATE_OBJECT
),
errmsg
(
"language
\"
%s
\"
already exists"
,
languageName
)));
/*
* Lookup the PL handler function and check that it is of the expected
...
...
@@ -88,13 +91,17 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
*/
if
(
funcrettype
==
OPAQUEOID
)
{
elog
(
NOTICE
,
"CreateProceduralLanguage: changing return type of function %s() from OPAQUE to LANGUAGE_HANDLER"
,
NameListToString
(
stmt
->
plhandler
));
ereport
(
NOTICE
,
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"changing return type of function %s() from OPAQUE to LANGUAGE_HANDLER"
,
NameListToString
(
stmt
->
plhandler
))));
SetFunctionReturnType
(
procOid
,
LANGUAGE_HANDLEROID
);
}
else
elog
(
ERROR
,
"CreateProceduralLanguage: function %s() must return LANGUAGE_HANDLER"
,
NameListToString
(
stmt
->
plhandler
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"function %s() must return LANGUAGE_HANDLER"
,
NameListToString
(
stmt
->
plhandler
))));
}
/* validate the validator function */
...
...
@@ -174,8 +181,9 @@ DropProceduralLanguage(DropPLangStmt *stmt)
* Check permission
*/
if
(
!
superuser
())
elog
(
ERROR
,
"Only users with superuser privilege are "
"permitted to drop procedural languages"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
errmsg
(
"must be superuser to drop procedural language"
)));
/*
* Translate the language name, check that this language exist and is
...
...
@@ -187,7 +195,9 @@ DropProceduralLanguage(DropPLangStmt *stmt)
CStringGetDatum
(
languageName
),
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
langTup
))
elog
(
ERROR
,
"Language %s doesn't exist"
,
languageName
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"language
\"
%s
\"
does not exist"
,
languageName
)));
object
.
classId
=
get_system_catalog_relid
(
LanguageRelationName
);
object
.
objectId
=
HeapTupleGetOid
(
langTup
);
...
...
@@ -215,9 +225,8 @@ DropProceduralLanguageById(Oid langOid)
langTup
=
SearchSysCache
(
LANGOID
,
ObjectIdGetDatum
(
langOid
),
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
langTup
))
elog
(
ERROR
,
"DropProceduralLanguageById: language %u not found"
,
langOid
);
if
(
!
HeapTupleIsValid
(
langTup
))
/* should not happen */
elog
(
ERROR
,
"cache lookup failed for language %u"
,
langOid
);
simple_heap_delete
(
rel
,
&
langTup
->
t_self
);
...
...
@@ -242,23 +251,21 @@ RenameLanguage(const char *oldname, const char *newname)
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tup
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_
SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION
),
(
errcode
(
ERRCODE_
UNDEFINED_OBJECT
),
errmsg
(
"language
\"
%s
\"
does not exist"
,
oldname
)));
/* make sure the new name doesn't exist */
if
(
SearchSysCacheExists
(
LANGNAME
,
CStringGetDatum
(
newname
),
0
,
0
,
0
))
{
ereport
(
ERROR
,
(
errcode
(
ERRCODE_
SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION
),
(
errcode
(
ERRCODE_
DUPLICATE_OBJECT
),
errmsg
(
"language
\"
%s
\"
already exists"
,
newname
)));
}
/* must be superuser */
if
(
!
superuser
())
ereport
(
ERROR
,
(
errcode
(
ERRCODE_
SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION
),
(
errcode
(
ERRCODE_
INSUFFICIENT_PRIVILEGE
),
errmsg
(
"permission denied"
)));
/* rename */
...
...
src/backend/commands/schemacmds.c
View file @
216311d5
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/schemacmds.c,v 1.1
1 2003/06/27 17:05:46
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/schemacmds.c,v 1.1
2 2003/07/18 23:20:32
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -74,14 +74,16 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
SetUserId
(
owner_userid
);
}
else
/* not superuser */
{
/* not superuser */
owner_userid
=
saved_userid
;
owner_name
=
GetUserNameFromId
(
owner_userid
);
if
(
strcmp
(
authId
,
owner_name
)
!=
0
)
elog
(
ERROR
,
"CREATE SCHEMA: permission denied"
"
\n\t\"
%s
\"
is not a superuser, so cannot create a schema for
\"
%s
\"
"
,
owner_name
,
authId
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
errmsg
(
"permission denied"
),
errdetail
(
"
\"
%s
\"
is not a superuser, so cannot create a schema for
\"
%s
\"
"
,
owner_name
,
authId
)));
}
/*
...
...
@@ -92,8 +94,10 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
aclcheck_error
(
aclresult
,
get_database_name
(
MyDatabaseId
));
if
(
!
allowSystemTableMods
&&
IsReservedName
(
schemaName
))
elog
(
ERROR
,
"CREATE SCHEMA: Illegal schema name:
\"
%s
\"
-- pg_ is reserved for system schemas"
,
schemaName
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_RESERVED_NAME
),
errmsg
(
"unacceptable schema name
\"
%s
\"
"
,
schemaName
),
errdetail
(
"The prefix pg_ is reserved for system schemas."
)));
/* Create the schema's namespace */
namespaceId
=
NamespaceCreate
(
schemaName
,
owner_userid
);
...
...
@@ -162,14 +166,18 @@ RemoveSchema(List *names, DropBehavior behavior)
ObjectAddress
object
;
if
(
length
(
names
)
!=
1
)
elog
(
ERROR
,
"Schema name may not be qualified"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_SYNTAX_ERROR
),
errmsg
(
"schema name may not be qualified"
)));
namespaceName
=
strVal
(
lfirst
(
names
));
namespaceId
=
GetSysCacheOid
(
NAMESPACENAME
,
CStringGetDatum
(
namespaceName
),
0
,
0
,
0
);
if
(
!
OidIsValid
(
namespaceId
))
elog
(
ERROR
,
"Schema
\"
%s
\"
does not exist"
,
namespaceName
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_SCHEMA
),
errmsg
(
"schema
\"
%s
\"
does not exist"
,
namespaceName
)));
/* Permission check */
if
(
!
pg_namespace_ownercheck
(
namespaceId
,
GetUserId
()))
...
...
@@ -205,9 +213,8 @@ RemoveSchemaById(Oid schemaOid)
tup
=
SearchSysCache
(
NAMESPACEOID
,
ObjectIdGetDatum
(
schemaOid
),
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tup
))
elog
(
ERROR
,
"RemoveSchemaById: schema %u not found"
,
schemaOid
);
if
(
!
HeapTupleIsValid
(
tup
))
/* should not happen */
elog
(
ERROR
,
"cache lookup failed for schema %u"
,
schemaOid
);
simple_heap_delete
(
relation
,
&
tup
->
t_self
);
...
...
@@ -234,7 +241,7 @@ RenameSchema(const char *oldname, const char *newname)
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tup
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_
SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION
),
(
errcode
(
ERRCODE_
UNDEFINED_SCHEMA
),
errmsg
(
"schema
\"
%s
\"
does not exist"
,
oldname
)));
/* make sure the new name doesn't exist */
...
...
@@ -242,11 +249,9 @@ RenameSchema(const char *oldname, const char *newname)
SearchSysCache
(
NAMESPACENAME
,
CStringGetDatum
(
newname
),
0
,
0
,
0
)))
{
ereport
(
ERROR
,
(
errcode
(
ERRCODE_
SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION
),
(
errcode
(
ERRCODE_
DUPLICATE_SCHEMA
),
errmsg
(
"schema
\"
%s
\"
already exists"
,
newname
)));
}
/* must be owner */
if
(
!
pg_namespace_ownercheck
(
HeapTupleGetOid
(
tup
),
GetUserId
()))
...
...
@@ -258,8 +263,10 @@ RenameSchema(const char *oldname, const char *newname)
aclcheck_error
(
aclresult
,
get_database_name
(
MyDatabaseId
));
if
(
!
allowSystemTableMods
&&
IsReservedName
(
newname
))
elog
(
ERROR
,
"illegal schema name:
\"
%s
\"
-- pg_ is reserved for system schemas"
,
newname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_RESERVED_NAME
),
errmsg
(
"unacceptable schema name
\"
%s
\"
"
,
newname
),
errdetail
(
"The prefix pg_ is reserved for system schemas."
)));
/* rename */
namestrcpy
(
&
(((
Form_pg_namespace
)
GETSTRUCT
(
tup
))
->
nspname
),
newname
);
...
...
src/backend/commands/user.c
View file @
216311d5
This diff is collapsed.
Click to expand it.
src/backend/parser/analyze.c
View file @
216311d5
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.2
79 2003/07/16 17:25:48
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.2
80 2003/07/18 23:20:32
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -3095,11 +3095,15 @@ check_parameter_resolution_walker(Node *node,
if
(
paramno
<=
0
||
/* shouldn't happen, but... */
paramno
>
context
->
numParams
)
elog
(
ERROR
,
"Parameter '$%d' is out of range"
,
paramno
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_PARAMETER
),
errmsg
(
"there is no parameter $%d"
,
paramno
)));
if
(
param
->
paramtype
!=
context
->
paramTypes
[
paramno
-
1
])
elog
(
ERROR
,
"Could not determine datatype of parameter $%d"
,
paramno
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_AMBIGUOUS_PARAMETER
),
errmsg
(
"could not determine datatype of parameter $%d"
,
paramno
)));
}
return
false
;
}
...
...
src/backend/parser/parse_coerce.c
View file @
216311d5
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.10
3 2003/07/03 19:07:48
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.10
4 2003/07/18 23:20:32
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -228,7 +228,9 @@ coerce_type(ParseState *pstate, Node *node,
if
(
paramno
<=
0
||
/* shouldn't happen, but... */
paramno
>
toppstate
->
p_numparams
)
elog
(
ERROR
,
"Parameter '$%d' is out of range"
,
paramno
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_PARAMETER
),
errmsg
(
"there is no parameter $%d"
,
paramno
)));
if
(
toppstate
->
p_paramtypes
[
paramno
-
1
]
==
UNKNOWNOID
)
{
...
...
@@ -242,11 +244,13 @@ coerce_type(ParseState *pstate, Node *node,
else
{
/* Ooops */
elog
(
ERROR
,
"Inconsistent types deduced for parameter '$%d'"
"
\n\t
Could be either %s or %s"
,
paramno
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_AMBIGUOUS_PARAMETER
),
errmsg
(
"inconsistent types deduced for parameter $%d"
,
paramno
),
errdetail
(
"Could be either %s or %s."
,
format_type_be
(
toppstate
->
p_paramtypes
[
paramno
-
1
]),
format_type_be
(
targetTypeId
));
format_type_be
(
targetTypeId
))
));
}
param
->
paramtype
=
targetTypeId
;
...
...
src/backend/parser/parse_expr.c
View file @
216311d5
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.15
5 2003/07/03 16:34:16
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.15
6 2003/07/18 23:20:32
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -128,13 +128,16 @@ transformExpr(ParseState *pstate, Node *expr)
/* Check parameter number is in range */
if
(
paramno
<=
0
)
/* probably can't happen? */
elog
(
ERROR
,
"Parameter '$%d' is out of range"
,
paramno
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_PARAMETER
),
errmsg
(
"there is no parameter $%d"
,
paramno
)));
if
(
paramno
>
toppstate
->
p_numparams
)
{
if
(
!
toppstate
->
p_variableparams
)
elog
(
ERROR
,
"Parameter '$%d' is out of range"
,
paramno
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_PARAMETER
),
errmsg
(
"there is no parameter $%d"
,
paramno
)));
/* Okay to enlarge param array */
if
(
toppstate
->
p_paramtypes
)
toppstate
->
p_paramtypes
=
...
...
src/backend/parser/parse_func.c
View file @
216311d5
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.15
3 2003/07/04 02:51:33
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.15
4 2003/07/18 23:20:32
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -84,15 +84,15 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
* function, but the test doesn't hurt.
*/
if
(
nargs
>
FUNC_MAX_ARGS
)
elog
(
ERROR
,
"Cannot pass more than %d arguments to a function"
,
FUNC_MAX_ARGS
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_TOO_MANY_ARGUMENTS
),
errmsg
(
"cannot pass more than %d arguments to a function"
,
FUNC_MAX_ARGS
)));
if
(
fargs
)
{
first_arg
=
lfirst
(
fargs
);
if
(
first_arg
==
NULL
)
/* should not happen */
elog
(
ERROR
,
"Function '%s' does not allow NULL input"
,
NameListToString
(
funcname
));
Assert
(
first_arg
!=
NULL
);
}
/*
...
...
@@ -179,7 +179,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
case
RTE_RELATION
:
toid
=
get_rel_type_id
(
rte
->
relid
);
if
(
!
OidIsValid
(
toid
))
elog
(
ERROR
,
"
C
annot find type OID for relation %u"
,
elog
(
ERROR
,
"
c
annot find type OID for relation %u"
,
rte
->
relid
);
/* replace RangeVar in the arg list */
lfirst
(
i
)
=
makeVar
(
vnum
,
...
...
@@ -219,8 +219,10 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
unknown_attribute
(
schemaname
,
relname
,
strVal
(
lfirst
(
funcname
)));
else
elog
(
ERROR
,
"Cannot pass result of sub-select or join %s to a function"
,
relname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"cannot pass result of sub-select or join %s to a function"
,
relname
)));
toid
=
InvalidOid
;
/* keep compiler quiet */
break
;
}
...
...
@@ -258,11 +260,16 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
* an aggregate?
*/
if
(
agg_star
)
elog
(
ERROR
,
"%s(*) specified, but %s is not an aggregate function"
,
NameListToString
(
funcname
),
NameListToString
(
funcname
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"%s(*) specified, but %s is not an aggregate function"
,
NameListToString
(
funcname
),
NameListToString
(
funcname
))));
if
(
agg_distinct
)
elog
(
ERROR
,
"DISTINCT specified, but %s is not an aggregate function"
,
NameListToString
(
funcname
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"DISTINCT specified, but %s is not an aggregate function"
,
NameListToString
(
funcname
))));
}
else
if
(
fdresult
!=
FUNCDETAIL_AGGREGATE
)
{
...
...
@@ -284,11 +291,15 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
colname
);
relTypeId
=
exprType
(
first_arg
);
if
(
!
ISCOMPLEX
(
relTypeId
))
elog
(
ERROR
,
"Attribute notation .%s applied to type %s, which is not a complex type"
,
colname
,
format_type_be
(
relTypeId
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"attribute notation .%s applied to type %s, which is not a complex type"
,
colname
,
format_type_be
(
relTypeId
))));
else
elog
(
ERROR
,
"Attribute
\"
%s
\"
not found in datatype %s"
,
colname
,
format_type_be
(
relTypeId
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_COLUMN
),
errmsg
(
"attribute
\"
%s
\"
not found in datatype %s"
,
colname
,
format_type_be
(
relTypeId
))));
}
/*
...
...
@@ -302,7 +313,6 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
actual_arg_types
)),
errhint
(
"Unable to choose a best candidate function. "
"You may need to add explicit typecasts."
)));
else
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_FUNCTION
),
...
...
@@ -356,7 +366,9 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
retval
=
(
Node
*
)
aggref
;
if
(
retset
)
elog
(
ERROR
,
"Aggregates may not return sets"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_FUNCTION_DEFINITION
),
errmsg
(
"aggregates may not return sets"
)));
}
return
retval
;
...
...
@@ -921,7 +933,7 @@ func_get_detail(List *funcname,
ObjectIdGetDatum
(
best_candidate
->
oid
),
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
ftup
))
/* should not happen */
elog
(
ERROR
,
"cache lookup
of function %u failed
"
,
elog
(
ERROR
,
"cache lookup
failed for function %u
"
,
best_candidate
->
oid
);
pform
=
(
Form_pg_proc
)
GETSTRUCT
(
ftup
);
*
rettype
=
pform
->
prorettype
;
...
...
@@ -1249,8 +1261,10 @@ setup_field_select(Node *input, char *attname, Oid relid)
attno
=
get_attnum
(
relid
,
attname
);
if
(
attno
==
InvalidAttrNumber
)
elog
(
ERROR
,
"Relation
\"
%s
\"
has no column
\"
%s
\"
"
,
get_rel_name
(
relid
),
attname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_COLUMN
),
errmsg
(
"relation
\"
%s
\"
has no column
\"
%s
\"
"
,
get_rel_name
(
relid
),
attname
)));
fselect
->
arg
=
(
Expr
*
)
input
;
fselect
->
fieldnum
=
attno
;
...
...
@@ -1323,18 +1337,22 @@ ParseComplexProjection(char *funcname, Node *first_arg)
}
/*
* Simple helper routine for delivering "
N
o such attribute" error message
* Simple helper routine for delivering "
n
o such attribute" error message
*/
static
void
unknown_attribute
(
const
char
*
schemaname
,
const
char
*
relname
,
const
char
*
attname
)
{
if
(
schemaname
)
elog
(
ERROR
,
"No such attribute %s.%s.%s"
,
schemaname
,
relname
,
attname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_COLUMN
),
errmsg
(
"no such attribute %s.%s.%s"
,
schemaname
,
relname
,
attname
)));
else
elog
(
ERROR
,
"No such attribute %s.%s"
,
relname
,
attname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_COLUMN
),
errmsg
(
"no such attribute %s.%s"
,
relname
,
attname
)));
}
/*
...
...
@@ -1389,11 +1407,16 @@ find_aggregate_func(List *aggname, Oid basetype, bool noError)
if
(
noError
)
return
InvalidOid
;
if
(
basetype
==
ANYOID
)
elog
(
ERROR
,
"aggregate %s(*) does not exist"
,
NameListToString
(
aggname
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_FUNCTION
),
errmsg
(
"aggregate %s(*) does not exist"
,
NameListToString
(
aggname
))));
else
elog
(
ERROR
,
"aggregate %s(%s) does not exist"
,
NameListToString
(
aggname
),
format_type_be
(
basetype
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_FUNCTION
),
errmsg
(
"aggregate %s(%s) does not exist"
,
NameListToString
(
aggname
),
format_type_be
(
basetype
))));
}
/* Make sure it's an aggregate */
...
...
@@ -1401,7 +1424,7 @@ find_aggregate_func(List *aggname, Oid basetype, bool noError)
ObjectIdGetDatum
(
oid
),
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
ftup
))
/* should not happen */
elog
(
ERROR
,
"
function %u not found
"
,
oid
);
elog
(
ERROR
,
"
cache lookup failed for function %u
"
,
oid
);
pform
=
(
Form_pg_proc
)
GETSTRUCT
(
ftup
);
if
(
!
pform
->
proisagg
)
...
...
@@ -1410,8 +1433,10 @@ find_aggregate_func(List *aggname, Oid basetype, bool noError)
if
(
noError
)
return
InvalidOid
;
/* we do not use the (*) notation for functions... */
elog
(
ERROR
,
"function %s(%s) is not an aggregate"
,
NameListToString
(
aggname
),
format_type_be
(
basetype
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"function %s(%s) is not an aggregate"
,
NameListToString
(
aggname
),
format_type_be
(
basetype
))));
}
ReleaseSysCache
(
ftup
);
...
...
@@ -1445,8 +1470,10 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError)
}
if
(
!
noError
)
elog
(
ERROR
,
"function %s does not exist"
,
func_signature_string
(
funcname
,
nargs
,
argtypes
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_FUNCTION
),
errmsg
(
"function %s does not exist"
,
func_signature_string
(
funcname
,
nargs
,
argtypes
))));
return
InvalidOid
;
}
...
...
@@ -1466,8 +1493,10 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
MemSet
(
argoids
,
0
,
FUNC_MAX_ARGS
*
sizeof
(
Oid
));
argcount
=
length
(
argtypes
);
if
(
argcount
>
FUNC_MAX_ARGS
)
elog
(
ERROR
,
"functions cannot have more than %d arguments"
,
FUNC_MAX_ARGS
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_TOO_MANY_ARGUMENTS
),
errmsg
(
"functions cannot have more than %d arguments"
,
FUNC_MAX_ARGS
)));
for
(
i
=
0
;
i
<
argcount
;
i
++
)
{
...
...
@@ -1476,8 +1505,10 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
argoids
[
i
]
=
LookupTypeName
(
t
);
if
(
!
OidIsValid
(
argoids
[
i
]))
elog
(
ERROR
,
"Type
\"
%s
\"
does not exist"
,
TypeNameToString
(
t
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"type
\"
%s
\"
does not exist"
,
TypeNameToString
(
t
))));
argtypes
=
lnext
(
argtypes
);
}
...
...
src/backend/parser/parse_oper.c
View file @
216311d5
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.
69 2003/07/04 02:51:33
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.
70 2003/07/18 23:20:32
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -107,8 +107,10 @@ LookupOperNameTypeNames(List *opername, TypeName *oprleft,
{
leftoid
=
LookupTypeName
(
oprleft
);
if
(
!
OidIsValid
(
leftoid
))
elog
(
ERROR
,
"type %s does not exist"
,
TypeNameToString
(
oprleft
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"type %s does not exist"
,
TypeNameToString
(
oprleft
))));
}
if
(
oprright
==
NULL
)
rightoid
=
InvalidOid
;
...
...
@@ -116,8 +118,10 @@ LookupOperNameTypeNames(List *opername, TypeName *oprleft,
{
rightoid
=
LookupTypeName
(
oprright
);
if
(
!
OidIsValid
(
rightoid
))
elog
(
ERROR
,
"type %s does not exist"
,
TypeNameToString
(
oprright
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"type %s does not exist"
,
TypeNameToString
(
oprright
))));
}
return
LookupOperName
(
opername
,
leftoid
,
rightoid
,
noError
);
...
...
@@ -178,8 +182,10 @@ equality_oper(Oid argtype, bool noError)
}
}
if
(
!
noError
)
elog
(
ERROR
,
"unable to identify an equality operator for type %s"
,
format_type_be
(
argtype
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_FUNCTION
),
errmsg
(
"unable to identify an equality operator for type %s"
,
format_type_be
(
argtype
))));
return
NULL
;
}
...
...
@@ -239,9 +245,11 @@ ordering_oper(Oid argtype, bool noError)
}
}
if
(
!
noError
)
elog
(
ERROR
,
"unable to identify an ordering operator for type %s"
"
\n\t
Use an explicit ordering operator or modify the query"
,
format_type_be
(
argtype
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_FUNCTION
),
errmsg
(
"unable to identify an ordering operator for type %s"
,
format_type_be
(
argtype
)),
errhint
(
"Use an explicit ordering operator or modify the query."
)));
return
NULL
;
}
...
...
@@ -483,8 +491,10 @@ compatible_oper(List *op, Oid arg1, Oid arg2, bool noError)
ReleaseSysCache
(
optup
);
if
(
!
noError
)
elog
(
ERROR
,
"operator requires run-time type coercion: %s"
,
op_signature_string
(
op
,
'b'
,
arg1
,
arg2
));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_FUNCTION
),
errmsg
(
"operator requires run-time type coercion: %s"
,
op_signature_string
(
op
,
'b'
,
arg1
,
arg2
))));
return
(
Operator
)
NULL
;
}
...
...
@@ -773,7 +783,9 @@ make_scalar_array_op(ParseState *pstate, List *opname,
{
rtypeId
=
get_element_type
(
atypeId
);
if
(
!
OidIsValid
(
rtypeId
))
elog
(
ERROR
,
"op ANY/ALL (array) requires array on right side"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"op ANY/ALL (array) requires array on right side"
)));
}
/* Now resolve the operator */
...
...
@@ -800,9 +812,13 @@ make_scalar_array_op(ParseState *pstate, List *opname,
* Check that operator result is boolean
*/
if
(
rettype
!=
BOOLOID
)
elog
(
ERROR
,
"op ANY/ALL (array) requires operator to yield boolean"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"op ANY/ALL (array) requires operator to yield boolean"
)));
if
(
get_func_retset
(
opform
->
oprcode
))
elog
(
ERROR
,
"op ANY/ALL (array) requires operator not to return a set"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"op ANY/ALL (array) requires operator not to return a set"
)));
/*
* Now switch back to the array type on the right, arranging for
...
...
@@ -810,8 +826,10 @@ make_scalar_array_op(ParseState *pstate, List *opname,
*/
res_atypeId
=
get_array_type
(
declared_arg_types
[
1
]);
if
(
!
OidIsValid
(
res_atypeId
))
elog
(
ERROR
,
"unable to find datatype for array of %s"
,
format_type_be
(
declared_arg_types
[
1
]));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"unable to find datatype for array of %s"
,
format_type_be
(
declared_arg_types
[
1
]))));
actual_arg_types
[
1
]
=
atypeId
;
declared_arg_types
[
1
]
=
res_atypeId
;
...
...
src/backend/parser/scan.l
View file @
216311d5
...
...
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.10
8 2003/06/19 23:22:40
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.10
9 2003/07/18 23:20:32
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -403,8 +403,10 @@ other .
len = pg_mbcliplen(literalbuf, literallen,
NAMEDATALEN-1);
elog(NOTICE, "identifier \"%s\" will be truncated to \"%.*s\"",
literalbuf, len, literalbuf);
ereport(NOTICE,
(errcode(ERRCODE_NAME_TOO_LONG),
errmsg("identifier \"%s\" will be truncated to \"%.*s\"",
literalbuf, len, literalbuf)));
literalbuf[len] = '\0';
literallen = len;
}
...
...
@@ -559,8 +561,10 @@ other .
int len;
len = pg_mbcliplen(ident, i, NAMEDATALEN-1);
elog(NOTICE, "identifier \"%s\" will be truncated to \"%.*s\"",
ident, len, ident);
ereport(NOTICE,
(errcode(ERRCODE_NAME_TOO_LONG),
errmsg("identifier \"%s\" will be truncated to \"%.*s\"",
ident, len, ident)));
ident[len] = '\0';
}
yylval.str = ident;
...
...
@@ -582,16 +586,18 @@ yyerror(const char *message)
if (*loc == YY_END_OF_BUFFER_CHAR)
{
/* translator: %s is typically "syntax error" */
ereport(ERROR,
(errmsg("%s at end of input", message),
(errcode(ERRCODE_SYNTAX_ERROR),
/* translator: %s is typically "syntax error" */
errmsg("%s at end of input", message),
errposition(cursorpos)));
}
else
{
/* translator: first %s is typically "syntax error" */
ereport(ERROR,
(errmsg("%s at or near \"%s\"", message, loc),
(errcode(ERRCODE_SYNTAX_ERROR),
/* translator: first %s is typically "syntax error" */
errmsg("%s at or near \"%s\"", message, loc),
errposition(cursorpos)));
}
}
...
...
src/backend/utils/error/elog.c
View file @
216311d5
...
...
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.11
2 2003/06/30 16:47:01
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.11
3 2003/07/18 23:20:32
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -288,7 +288,13 @@ errstart(int elevel, const char *filename, int lineno,
edata
->
filename
=
filename
;
edata
->
lineno
=
lineno
;
edata
->
funcname
=
funcname
;
edata
->
sqlerrcode
=
ERRCODE_INTERNAL_ERROR
;
/* default errcode */
/* Select default errcode based on elevel */
if
(
elevel
>=
ERROR
)
edata
->
sqlerrcode
=
ERRCODE_INTERNAL_ERROR
;
else
if
(
elevel
==
WARNING
)
edata
->
sqlerrcode
=
ERRCODE_WARNING
;
else
edata
->
sqlerrcode
=
ERRCODE_SUCCESSFUL_COMPLETION
;
/* errno is saved here so that error parameter eval can't change it */
edata
->
saved_errno
=
errno
;
...
...
@@ -497,6 +503,76 @@ errcode(int sqlerrcode)
}
/*
* errcode_for_file_access --- add SQLSTATE error code to the current error
*
* The SQLSTATE code is chosen based on the saved errno value. We assume
* that the failing operation was some type of disk file access.
*
* NOTE: the primary error message string should generally include %m
* when this is used.
*/
int
errcode_for_file_access
(
void
)
{
ErrorData
*
edata
=
&
errordata
[
errordata_stack_depth
];
/* we don't bother incrementing recursion_depth */
CHECK_STACK_DEPTH
();
switch
(
edata
->
saved_errno
)
{
/* Permission-denied failures */
case
EPERM
:
/* Not super-user */
case
EACCES
:
/* Permission denied */
#ifdef EROFS
case
EROFS
:
/* Read only file system */
#endif
edata
->
sqlerrcode
=
ERRCODE_INSUFFICIENT_PRIVILEGE
;
break
;
/* Object not found */
case
ENOENT
:
/* No such file or directory */
edata
->
sqlerrcode
=
ERRCODE_UNDEFINED_OBJECT
;
break
;
/* Duplicate object */
case
EEXIST
:
/* File exists */
edata
->
sqlerrcode
=
ERRCODE_DUPLICATE_OBJECT
;
break
;
/* Wrong object type or state */
case
ENOTDIR
:
/* Not a directory */
case
EISDIR
:
/* Is a directory */
case
ENOTEMPTY
:
/* Directory not empty */
edata
->
sqlerrcode
=
ERRCODE_WRONG_OBJECT_TYPE
;
break
;
/* Insufficient resources */
case
ENOSPC
:
/* No space left on device */
edata
->
sqlerrcode
=
ERRCODE_DISK_FULL
;
break
;
case
ENFILE
:
/* File table overflow */
case
EMFILE
:
/* Too many open files */
edata
->
sqlerrcode
=
ERRCODE_INSUFFICIENT_RESOURCES
;
break
;
/* Hardware failure */
case
EIO
:
/* I/O error */
edata
->
sqlerrcode
=
ERRCODE_IO_ERROR
;
break
;
/* All else is classified as internal errors */
default:
edata
->
sqlerrcode
=
ERRCODE_INTERNAL_ERROR
;
break
;
}
return
0
;
/* return value does not matter */
}
/*
* This macro handles expansion of a format string and associated parameters;
* it's common code for errmsg(), errdetail(), etc. Must be called inside
...
...
@@ -759,7 +835,8 @@ DebugFileOpen(void)
if
((
fd
=
open
(
OutputFileName
,
O_CREAT
|
O_APPEND
|
O_WRONLY
,
0666
))
<
0
)
ereport
(
FATAL
,
(
errmsg
(
"failed to open %s: %m"
,
OutputFileName
)));
(
errcode_for_file_access
(),
errmsg
(
"failed to open
\"
%s
\"
: %m"
,
OutputFileName
)));
istty
=
isatty
(
fd
);
close
(
fd
);
...
...
@@ -768,7 +845,8 @@ DebugFileOpen(void)
*/
if
(
!
freopen
(
OutputFileName
,
"a"
,
stderr
))
ereport
(
FATAL
,
(
errmsg
(
"failed to reopen %s as stderr: %m"
,
(
errcode_for_file_access
(),
errmsg
(
"failed to reopen
\"
%s
\"
as stderr: %m"
,
OutputFileName
)));
/*
...
...
@@ -780,7 +858,8 @@ DebugFileOpen(void)
if
(
istty
&&
IsUnderPostmaster
)
if
(
!
freopen
(
OutputFileName
,
"a"
,
stdout
))
ereport
(
FATAL
,
(
errmsg
(
"failed to reopen %s as stdout: %m"
,
(
errcode_for_file_access
(),
errmsg
(
"failed to reopen
\"
%s
\"
as stdout: %m"
,
OutputFileName
)));
}
}
...
...
src/backend/utils/fmgr/dfmgr.c
View file @
216311d5
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.6
0 2003/05/27 17:49:46 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.6
1 2003/07/18 23:20:32 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -58,7 +58,7 @@ static char *substitute_libpath_macro(const char *name);
*
* If the function is not found, we raise an error if signalNotFound is true,
* else return (PGFunction) NULL. Note that errors in loading the library
* will provoke e
log
regardless of signalNotFound.
* will provoke e
report()
regardless of signalNotFound.
*
* If filehandle is not NULL, then *filehandle will be set to a handle
* identifying the library file. The filehandle can be used with
...
...
@@ -94,7 +94,9 @@ load_external_function(char *filename, char *funcname,
* Check for same files - different paths (ie, symlink or link)
*/
if
(
stat
(
fullname
,
&
stat_buf
)
==
-
1
)
elog
(
ERROR
,
"stat failed on file '%s': %m"
,
fullname
);
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not access file
\"
%s
\"
: %m"
,
fullname
)));
for
(
file_scanner
=
file_list
;
file_scanner
!=
(
DynamicFileList
*
)
NULL
&&
...
...
@@ -111,7 +113,9 @@ load_external_function(char *filename, char *funcname,
file_scanner
=
(
DynamicFileList
*
)
malloc
(
sizeof
(
DynamicFileList
)
+
strlen
(
fullname
));
if
(
file_scanner
==
NULL
)
elog
(
ERROR
,
"Out of memory in load_external_function"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INSUFFICIENT_RESOURCES
),
errmsg
(
"out of memory"
)));
MemSet
((
char
*
)
file_scanner
,
0
,
sizeof
(
DynamicFileList
));
strcpy
(
file_scanner
->
filename
,
fullname
);
...
...
@@ -124,7 +128,11 @@ load_external_function(char *filename, char *funcname,
{
load_error
=
(
char
*
)
pg_dlerror
();
free
((
char
*
)
file_scanner
);
elog
(
ERROR
,
"Load of file %s failed: %s"
,
fullname
,
load_error
);
/* errcode_for_file_access might not be appropriate here? */
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not load library
\"
%s
\"
: %s"
,
fullname
,
load_error
)));
}
/* OK to link it into list */
...
...
@@ -151,7 +159,10 @@ load_external_function(char *filename, char *funcname,
retval
=
pg_dlsym
(
file_scanner
->
handle
,
funcname
);
if
(
retval
==
(
PGFunction
)
NULL
&&
signalNotFound
)
elog
(
ERROR
,
"Can't find function %s in file %s"
,
funcname
,
fullname
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_FUNCTION
),
errmsg
(
"could not find function
\"
%s
\"
in file
\"
%s
\"
"
,
funcname
,
fullname
)));
pfree
(
fullname
);
return
retval
;
...
...
@@ -181,7 +192,9 @@ load_file(char *filename)
* good error message if bogus file name given.
*/
if
(
stat
(
fullname
,
&
stat_buf
)
==
-
1
)
elog
(
ERROR
,
"LOAD: could not open file '%s': %m"
,
fullname
);
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not access file
\"
%s
\"
: %m"
,
fullname
)));
if
(
file_list
!=
(
DynamicFileList
*
)
NULL
)
{
...
...
@@ -236,7 +249,9 @@ file_exists(const char *name)
if
(
stat
(
name
,
&
st
)
==
0
)
return
S_ISDIR
(
st
.
st_mode
)
?
false
:
true
;
else
if
(
!
(
errno
==
ENOENT
||
errno
==
ENOTDIR
||
errno
==
EACCES
))
elog
(
ERROR
,
"stat failed on %s: %s"
,
name
,
strerror
(
errno
));
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not access file
\"
%s
\"
: %m"
,
name
)));
return
false
;
}
...
...
@@ -335,7 +350,9 @@ substitute_libpath_macro(const char *name)
if
(
strncmp
(
name
,
"$libdir"
,
macroname_len
)
==
0
)
replacement
=
PKGLIBDIR
;
else
elog
(
ERROR
,
"invalid macro name in dynamic library path"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_NAME
),
errmsg
(
"invalid macro name in dynamic library path"
)));
if
(
name
[
macroname_len
]
==
'\0'
)
return
pstrdup
(
replacement
);
...
...
@@ -385,7 +402,9 @@ find_in_dynamic_libpath(const char *basename)
len
=
strcspn
(
p
,
":"
);
if
(
len
==
0
)
elog
(
ERROR
,
"zero length dynamic_library_path component"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_NAME
),
errmsg
(
"zero-length component in DYNAMIC_LIBRARY_PATH"
)));
piece
=
palloc
(
len
+
1
);
strncpy
(
piece
,
p
,
len
);
...
...
@@ -396,13 +415,15 @@ find_in_dynamic_libpath(const char *basename)
/* only absolute paths */
if
(
!
is_absolute_path
(
mangled
))
elog
(
ERROR
,
"dynamic_library_path component is not absolute"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_NAME
),
errmsg
(
"DYNAMIC_LIBRARY_PATH component is not absolute"
)));
full
=
palloc
(
strlen
(
mangled
)
+
1
+
baselen
+
1
);
sprintf
(
full
,
"%s/%s"
,
mangled
,
basename
);
pfree
(
mangled
);
elog
(
DEBUG3
,
"find_in_dynamic_libpath: trying
%s
"
,
full
);
elog
(
DEBUG3
,
"find_in_dynamic_libpath: trying
\"
%s
\"
"
,
full
);
if
(
file_exists
(
full
))
return
full
;
...
...
src/include/utils/elog.h
View file @
216311d5
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: elog.h,v 1.4
7 2003/07/14 23:36:15
tgl Exp $
* $Id: elog.h,v 1.4
8 2003/07/18 23:20:32
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -177,31 +177,62 @@
#define ERRCODE_INTERNAL_ERROR MAKE_SQLSTATE('X','X', '0','0','0')
#define ERRCODE_INSUFFICIENT_PRIVILEGE MAKE_SQLSTATE('4','2', '5','0','1')
#define ERRCODE_SYNTAX_ERROR MAKE_SQLSTATE('4','2', '6','0','1')
#define ERRCODE_INVALID_NAME MAKE_SQLSTATE('4','2', '6','0','2')
#define ERRCODE_NAME_TOO_LONG MAKE_SQLSTATE('4','2', '6','2','2')
#define ERRCODE_RESERVED_NAME MAKE_SQLSTATE('4','2', '9','3','9')
#define ERRCODE_UNTERMINATED_LITERAL MAKE_SQLSTATE('4','2', '6','0','3')
#define ERRCODE_INVALID_LITERAL MAKE_SQLSTATE('4','2', '6','0','6')
#define ERRCODE_STATEMENT_TOO_COMPLEX MAKE_SQLSTATE('5','4', '0','0','1')
#define ERRCODE_TOO_MANY_ARGUMENTS MAKE_SQLSTATE('4','2', '6','0','5')
#define ERRCODE_
UNDEFINED_COLUMN MAKE_SQLSTATE('4','2', '7','0','3
')
#define ERRCODE_
TOO_MANY_COLUMNS MAKE_SQLSTATE('5','4', '0','1','1
')
/*
* Note: use the above SQL-standard error codes for undefined catalog, schema,
* prepared statement, or cursor names. Curiously, they don't define error
* codes for any other kinds of objects. We choose to define an errcode for
* undefined tables, as well as one for functions (also used for operators);
* all other names (rules, triggers, etc) are lumped as UNDEFINED_OBJECT.
* The same breakdown is used for "ambiguous" and "duplicate" complaints.
* prepared statement, and cursor names. Curiously, they don't define error
* codes for any other kinds of objects. We choose to define separate error
* codes for undefined table and column names, as well as one for functions
* (also used for operators). All other names (rules, triggers, etc) are
* lumped as UNDEFINED_OBJECT.
* The same breakdown is used for "ambiguous" and "duplicate" complaints,
* as well as complaints associated with incorrect declarations.
*/
#define ERRCODE_UNDEFINED_TABLE MAKE_SQLSTATE('4','2', '7','0','4')
#define ERRCODE_UNDEFINED_COLUMN MAKE_SQLSTATE('4','2', '7','0','3')
#define ERRCODE_UNDEFINED_CURSOR ERRCODE_INVALID_CURSOR_NAME
#define ERRCODE_UNDEFINED_DATABASE ERRCODE_INVALID_CATALOG_NAME
#define ERRCODE_UNDEFINED_FUNCTION MAKE_SQLSTATE('4','2', '8','8','3')
#define ERRCODE_UNDEFINED_PSTATEMENT ERRCODE_INVALID_SQL_STATEMENT_NAME
#define ERRCODE_UNDEFINED_SCHEMA ERRCODE_INVALID_SCHEMA_NAME
#define ERRCODE_UNDEFINED_TABLE MAKE_SQLSTATE('4','2', '7','0','4')
#define ERRCODE_UNDEFINED_OBJECT MAKE_SQLSTATE('4','2', '7','0','5')
#define ERRCODE_UNDEFINED_PARAMETER MAKE_SQLSTATE('4','2', '7','1','5')
#define ERRCODE_AMBIGUOUS_COLUMN MAKE_SQLSTATE('4','2', '7','0','2')
#define ERRCODE_AMBIGUOUS_FUNCTION MAKE_SQLSTATE('4','2', '7','2','5')
#define ERRCODE_AMBIGUOUS_PARAMETER MAKE_SQLSTATE('4','2', '7','1','6')
#define ERRCODE_DUPLICATE_COLUMN MAKE_SQLSTATE('4','2', '7','1','1')
#define ERRCODE_DUPLICATE_TABLE MAKE_SQLSTATE('4','2', '7','2','2')
#define ERRCODE_DUPLICATE_CURSOR ERRCODE_DUPLICATE_OBJECT
#define ERRCODE_DUPLICATE_DATABASE ERRCODE_DUPLICATE_OBJECT
#define ERRCODE_DUPLICATE_FUNCTION MAKE_SQLSTATE('4','2', '7','2','3')
#define ERRCODE_DUPLICATE_PSTATEMENT ERRCODE_DUPLICATE_OBJECT
#define ERRCODE_DUPLICATE_SCHEMA ERRCODE_DUPLICATE_OBJECT
#define ERRCODE_DUPLICATE_TABLE MAKE_SQLSTATE('4','2', '7','2','2')
#define ERRCODE_DUPLICATE_OBJECT MAKE_SQLSTATE('4','2', '7','1','0')
#define ERRCODE_INVALID_COLUMN_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','1')
#define ERRCODE_INVALID_CURSOR_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','2')
#define ERRCODE_INVALID_DATABASE_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','3')
#define ERRCODE_INVALID_FUNCTION_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','4')
#define ERRCODE_INVALID_PSTATEMENT_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','5')
#define ERRCODE_INVALID_SCHEMA_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','6')
#define ERRCODE_INVALID_TABLE_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','7')
#define ERRCODE_INVALID_OBJECT_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','8')
#define ERRCODE_WRONG_OBJECT_TYPE MAKE_SQLSTATE('4','2', '8','0','9')
#define ERRCODE_OBJECT_IN_USE MAKE_SQLSTATE('5','5', '0','0','6')
#define ERRCODE_GROUPING_ERROR MAKE_SQLSTATE('4','2', '8','0','3')
#define ERRCODE_TYPE_MISMATCH MAKE_SQLSTATE('4','2', '8','0','4')
#define ERRCODE_CANNOT_COERCE MAKE_SQLSTATE('4','2', '8','4','6')
#define ERRCODE_INVALID_FOREIGN_KEY MAKE_SQLSTATE('4','2', '8','3','0')
#define ERRCODE_TOO_MANY_CONNECTIONS MAKE_SQLSTATE('5','7', '0','3','2')
#define ERRCODE_DISK_FULL MAKE_SQLSTATE('5','4', '1','0','0')
#define ERRCODE_INSUFFICIENT_RESOURCES MAKE_SQLSTATE('5','4', '2','0','0')
#define ERRCODE_IO_ERROR MAKE_SQLSTATE('5','8', '0','3','0')
/* Which __func__ symbol do we have, if any? */
...
...
@@ -219,13 +250,15 @@
/*----------
* New-style error reporting API: to be used in this way:
* ereport(ERROR,
* (errcode(ERRCODE_
INVALID_CURSOR_NAME
),
* (errcode(ERRCODE_
UNDEFINED_CURSOR
),
* errmsg("portal \"%s\" not found", stmt->portalname),
* ... other errxxx() fields as needed ...));
*
* The error level is required, and so is a primary error message (errmsg
* or errmsg_internal). All else is optional. errcode() defaults to
* ERRCODE_INTERNAL_ERROR.
* ERRCODE_INTERNAL_ERROR if elevel is ERROR or more, ERRCODE_WARNING
* if elevel is WARNING, or ERRCODE_SUCCESSFUL_COMPLETION if elevel is
* NOTICE or below.
*----------
*/
#define ereport(elevel, rest) \
...
...
@@ -238,6 +271,8 @@ extern void errfinish(int dummy, ...);
extern
int
errcode
(
int
sqlerrcode
);
extern
int
errcode_for_file_access
(
void
);
extern
int
errmsg
(
const
char
*
fmt
,
...)
/* This extension allows gcc to check the format string for consistency with
the supplied arguments. */
...
...
src/test/regress/expected/alter_table.out
View file @
216311d5
...
...
@@ -775,7 +775,7 @@ select atacc1.* from atacc1;
select a from atacc1;
ERROR: Attribute "a" not found
select atacc1.a from atacc1;
ERROR:
N
o such attribute atacc1.a
ERROR:
n
o such attribute atacc1.a
select b,c,d from atacc1;
b | c | d
---+---+---
...
...
@@ -789,7 +789,7 @@ ERROR: Attribute "a" not found
select "........pg.dropped.1........" from atacc1;
ERROR: Attribute "........pg.dropped.1........" not found
select atacc1."........pg.dropped.1........" from atacc1;
ERROR:
N
o such attribute atacc1.........pg.dropped.1........
ERROR:
n
o such attribute atacc1.........pg.dropped.1........
select "........pg.dropped.1........",b,c,d from atacc1;
ERROR: Attribute "........pg.dropped.1........" not found
select * from atacc1 where "........pg.dropped.1........" = 1;
...
...
src/test/regress/expected/create_type.out
View file @
216311d5
...
...
@@ -19,22 +19,24 @@ CREATE FUNCTION int42_in(cstring)
RETURNS int42
AS 'int4in'
LANGUAGE 'internal' WITH (isStrict);
NOTICE: ProcedureCreate: type int42 is not yet defined
NOTICE: type int42 is not yet defined
DETAIL: Creating a shell type definition.
CREATE FUNCTION int42_out(int42)
RETURNS cstring
AS 'int4out'
LANGUAGE 'internal' WITH (isStrict);
NOTICE:
Argument type "int42"
is only a shell
NOTICE:
argument type int42
is only a shell
CREATE FUNCTION text_w_default_in(cstring)
RETURNS text_w_default
AS 'textin'
LANGUAGE 'internal' WITH (isStrict);
NOTICE: ProcedureCreate: type text_w_default is not yet defined
NOTICE: type text_w_default is not yet defined
DETAIL: Creating a shell type definition.
CREATE FUNCTION text_w_default_out(text_w_default)
RETURNS cstring
AS 'textout'
LANGUAGE 'internal' WITH (isStrict);
NOTICE:
Argument type "text_w_default"
is only a shell
NOTICE:
argument type text_w_default
is only a shell
CREATE TYPE int42 (
internallength = 4,
input = int42_in,
...
...
src/test/regress/expected/privileges.out
View file @
216311d5
...
...
@@ -6,12 +6,12 @@ CREATE USER regressuser2;
CREATE USER regressuser3;
CREATE USER regressuser4;
CREATE USER regressuser4; -- duplicate
ERROR:
CREATE USER: user name
"regressuser4" already exists
ERROR:
user
"regressuser4" already exists
CREATE GROUP regressgroup1;
CREATE GROUP regressgroup2 WITH USER regressuser1, regressuser2;
ALTER GROUP regressgroup1 ADD USER regressuser4;
ALTER GROUP regressgroup2 ADD USER regressuser2; -- duplicate
WARNING:
ALTER GROUP:
user "regressuser2" is already in group "regressgroup2"
WARNING: user "regressuser2" is already in group "regressgroup2"
ALTER GROUP regressgroup2 DROP USER regressuser2;
ALTER GROUP regressgroup2 ADD USER regressuser4;
-- test owner privileges
...
...
src/test/regress/output/create_function_1.source
View file @
216311d5
...
...
@@ -5,22 +5,24 @@ CREATE FUNCTION widget_in(cstring)
RETURNS widget
AS '@abs_builddir@/regress@DLSUFFIX@'
LANGUAGE 'c';
NOTICE: ProcedureCreate: type widget is not yet defined
NOTICE: type widget is not yet defined
DETAIL: Creating a shell type definition.
CREATE FUNCTION widget_out(widget)
RETURNS cstring
AS '@abs_builddir@/regress@DLSUFFIX@'
LANGUAGE 'c';
NOTICE:
Argument type "widget"
is only a shell
NOTICE:
argument type widget
is only a shell
CREATE FUNCTION int44in(cstring)
RETURNS city_budget
AS '@abs_builddir@/regress@DLSUFFIX@'
LANGUAGE 'c';
NOTICE: ProcedureCreate: type city_budget is not yet defined
NOTICE: type city_budget is not yet defined
DETAIL: Creating a shell type definition.
CREATE FUNCTION int44out(city_budget)
RETURNS cstring
AS '@abs_builddir@/regress@DLSUFFIX@'
LANGUAGE 'c';
NOTICE:
Argument type "city_budget"
is only a shell
NOTICE:
argument type city_budget
is only a shell
CREATE FUNCTION check_primary_key ()
RETURNS trigger
AS '@abs_builddir@/../../../contrib/spi/refint@DLSUFFIX@'
...
...
@@ -48,25 +50,27 @@ CREATE FUNCTION set_ttdummy (int4)
-- Things that shouldn't work:
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE sql
AS 'SELECT ''not an integer'';';
ERROR: return type mismatch in function: declared to return integer, returns "unknown"
ERROR: return type mismatch in function declared to return integer
DETAIL: Actual return type is "unknown".
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE sql
AS 'not even SQL';
ERROR: syntax error at or near "not" at character 1
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE sql
AS 'SELECT 1, 2, 3;';
ERROR: function declared to return integer returns multiple columns in final SELECT
ERROR: return type mismatch in function declared to return integer
DETAIL: Final SELECT must return exactly one column.
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE sql
AS 'SELECT $2;';
ERROR:
Parameter '$2' is out of range
ERROR:
there is no parameter $2
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE sql
AS 'a', 'b';
ERROR:
CREATE FUNCTION: only one AS item needed for sql language
ERROR:
only one AS item needed for language "sql"
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE c
AS 'nosuchfile';
ERROR:
stat failed on file 'nosuchfile'
: No such file or directory
ERROR:
could not access file "nosuchfile"
: No such file or directory
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE c
AS '@abs_builddir@/regress@DLSUFFIX@', 'nosuchsymbol';
ERROR:
Can't find function nosuchsymbol in file @abs_builddir@/regress@DLSUFFIX@
ERROR:
could not find function "nosuchsymbol" in file "@abs_builddir@/regress@DLSUFFIX@"
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE internal
AS 'nosuch';
ERROR: there is no built-in function named "nosuch"
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