Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc3086c8

Browse files
committed
Function-call-style type coercions should be treated as explicit
coercions, not implicit ones. For example, 'select abstime(1035497293)'should succeed because there is an explicit binary coercion from int4to abstime.
1 parent6b704bf commitc3086c8

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

‎src/backend/parser/parse_coerce.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.84 2002/09/18 21:35:22 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.85 2002/10/24 22:09:00 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -32,9 +32,6 @@ static Node *coerce_type_typmod(Node *node,
3232
OidtargetTypeId,int32targetTypMod,
3333
CoercionFormcformat);
3434
staticOidPreferredType(CATEGORYcategory,Oidtype);
35-
staticboolfind_coercion_pathway(OidtargetTypeId,OidsourceTypeId,
36-
CoercionContextccontext,
37-
Oid*funcid);
3835
staticNode*build_func_call(Oidfuncid,Oidrettype,List*args,
3936
CoercionFormfformat);
4037

@@ -910,7 +907,7 @@ IsBinaryCoercible(Oid srctype, Oid targettype)
910907
* to the castfunc value (which may be InvalidOid for a binary-compatible
911908
* coercion).
912909
*/
913-
staticbool
910+
bool
914911
find_coercion_pathway(OidtargetTypeId,OidsourceTypeId,
915912
CoercionContextccontext,
916913
Oid*funcid)

‎src/backend/parser/parse_func.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.138 2002/10/19 21:23:20 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.139 2002/10/24 22:09:00 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -770,6 +770,11 @@ func_get_detail(List *funcname,
770770
* and ones that are coercing a previously-unknown-type literal
771771
* constant to a specific type.
772772
*
773+
* The reason we can restrict our check to binary-compatible
774+
* coercions here is that we expect non-binary-compatible coercions
775+
* to have an implementation function named after the target type.
776+
* That function will be found by normal lookup if appropriate.
777+
*
773778
* NB: it's important that this code stays in sync with what
774779
* coerce_type can do, because the caller will try to apply
775780
* coerce_type if we return FUNCDETAIL_COERCION. If we return
@@ -791,7 +796,9 @@ func_get_detail(List *funcname,
791796
Node*arg1=lfirst(fargs);
792797

793798
if ((sourceType==UNKNOWNOID&&IsA(arg1,Const))||
794-
IsBinaryCoercible(sourceType,targetType))
799+
(find_coercion_pathway(targetType,sourceType,
800+
COERCION_EXPLICIT,funcid)&&
801+
*funcid==InvalidOid))
795802
{
796803
/* Yup, it's a type coercion */
797804
*funcid=InvalidOid;

‎src/include/parser/parse_coerce.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: parse_coerce.h,v 1.47 2002/09/18 21:35:24 tgl Exp $
10+
* $Id: parse_coerce.h,v 1.48 2002/10/24 22:09:00 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -54,6 +54,9 @@ extern Oidselect_common_type(List *typeids, const char *context);
5454
externNode*coerce_to_common_type(Node*node,OidtargetTypeId,
5555
constchar*context);
5656

57+
externboolfind_coercion_pathway(OidtargetTypeId,OidsourceTypeId,
58+
CoercionContextccontext,
59+
Oid*funcid);
5760
externOidfind_typmod_coercion_function(OidtypeId,int*nargs);
5861

5962
#endif/* PARSE_COERCE_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp