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

Commit3dd23aa

Browse files
committed
Allow functions and operators on internally-identical types to succeed.
1 parent0ab2921 commit3dd23aa

File tree

5 files changed

+33
-8
lines changed

5 files changed

+33
-8
lines changed

‎src/backend/parser/analyze.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.34 1997/08/19 21:32:11 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.35 1997/08/22 00:02:04 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1345,7 +1345,7 @@ make_targetlist_expr(ParseState *pstate,
13451345
}else
13461346
if (attrtype!=type_id) {
13471347
if ((attrtype==INT2OID)&& (type_id==INT4OID))
1348-
lfirst(expr)=lispInteger (INT2OID);
1348+
lfirst(expr)=lispInteger (INT2OID);doCASHOIDtoo
13491349
elseif ((attrtype==FLOAT4OID)&& (type_id==FLOAT8OID))
13501350
lfirst(expr)=lispInteger (FLOAT4OID);
13511351
else

‎src/backend/parser/catalog_utils.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.21 1997/08/19 21:32:12 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.22 1997/08/22 00:02:05 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -373,6 +373,7 @@ equivalentOpersAfterPromotion(CandidateList candidates)
373373
caseFLOAT4OID:
374374
caseINT4OID:
375375
caseINT2OID:
376+
caseCASHOID:
376377
c->args[0]=FLOAT8OID;
377378
break;
378379
default:
@@ -383,6 +384,7 @@ equivalentOpersAfterPromotion(CandidateList candidates)
383384
caseFLOAT4OID:
384385
caseINT4OID:
385386
caseINT2OID:
387+
caseCASHOID:
386388
c->args[1]=FLOAT8OID;
387389
break;
388390
default:
@@ -570,6 +572,7 @@ unary_oper_get_candidates(char *op,
570572
opKey[1].sk_argument=CharGetDatum(rightleft);
571573

572574
/* currently, only "unknown" can be coerced */
575+
/* but we should allow types that are internally the same to be "coerced" */
573576
if (typeId!=UNKNOWNOID) {
574577
return0;
575578
}
@@ -956,7 +959,14 @@ can_coerce(int nargs, Oid *input_typeids, Oid *func_typeids)
956959
*/
957960
for (i=0;i<nargs;i++) {
958961
if (input_typeids[i]!=func_typeids[i]) {
959-
if (input_typeids[i]!=UNKNOWNOID||func_typeids[i]==0)
962+
if ((input_typeids[i]==BPCHAROID&&func_typeids[i]==TEXTOID)||
963+
(input_typeids[i]==BPCHAROID&&func_typeids[i]==VARCHAROID)||
964+
(input_typeids[i]==VARCHAROID&&func_typeids[i]==TEXTOID)||
965+
(input_typeids[i]==VARCHAROID&&func_typeids[i]==BPCHAROID)||
966+
(input_typeids[i]==CASHOID&&func_typeids[i]==INT4OID)||
967+
(input_typeids[i]==INT4OID&&func_typeids[i]==CASHOID))
968+
;/* these are OK */
969+
elseif (input_typeids[i]!=UNKNOWNOID||func_typeids[i]==0)
960970
return false;
961971

962972
tp=get_id_type(input_typeids[i]);

‎src/backend/parser/parse_query.c

Lines changed: 3 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/Attic/parse_query.c,v 1.17 1997/08/19 21:32:16 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/parse_query.c,v 1.18 1997/08/22 00:02:07 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -378,7 +378,8 @@ make_op(char *opname, Node *ltree, Node *rtree)
378378
(t) == INT4OID || \
379379
(t) == OIDOID || \
380380
(t) == FLOAT4OID || \
381-
(t) == FLOAT8OID)
381+
(t) == FLOAT8OID || \
382+
(t) == CASHOID)
382383

383384
/* binary operator */
384385
ltypeId= (ltree==NULL) ?UNKNOWNOID :exprType(ltree);

‎src/backend/parser/parser.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.20 1997/08/0302:28:10 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.21 1997/08/22 00:02:08 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -238,6 +238,13 @@ parser_typecast(Value *expr, TypeName *typename, int typlen)
238238
string_palloced= true;
239239
sprintf(const_string,"%f", ((Const)lnext(expr))->constvalue);
240240
break;
241+
242+
caseCASHOID:/* money */
243+
const_string= (char*)palloc(256);
244+
string_palloced= true;
245+
sprintf(const_string,"%ld",
246+
(int) ((Const*)expr)->constvalue);
247+
break;
241248

242249
caseTEXTOID:/* text */
243250
const_string=DatumGetPointer(((Const)lnext(expr))->constvalue);
@@ -350,6 +357,12 @@ parser_typecast2(Node *expr, Oid exprType, Type tp, int typlen)
350357
sprintf(const_string,"%f",*floatVal);
351358
break;
352359
}
360+
caseCASHOID:/* money */
361+
const_string= (char*)palloc(256);
362+
string_palloced= true;
363+
sprintf(const_string,"%ld",
364+
(long) ((Const*)expr)->constvalue);
365+
break;
353366
caseTEXTOID:/* text */
354367
const_string=
355368
DatumGetPointer(((Const*)expr)->constvalue );

‎src/include/catalog/pg_type.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_type.h,v 1.14 1997/08/21 01:37:55 vadim Exp $
10+
* $Id: pg_type.h,v 1.15 1997/08/22 00:02:19 momjian Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -242,6 +242,7 @@ DATA(insert OID = 705 ( unknown PGUID -1 -1 f b t \054 0 18 textin textout
242242
DATA(insertOID=718 (circlePGUID2447fbt \05400circle_incircle_outcircle_incircle_outd_null_ ));
243243
DATA(insertOID=719 (_circlePGUID-1-1fbt \0540718array_inarray_outarray_inarray_outd_null_ ));
244244
DATA(insertOID=790 (moneyPGUID424fbt \05400cash_incash_outcash_incash_outi_null_ ));
245+
#defineCASHOID 790
245246
DATA(insertOID=791 (_moneyPGUID-1-1fbt \0540790array_inarray_outarray_inarray_outi_null_ ));
246247

247248
/* OIDS 800 - 899 */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp