From 3dd23aadf0746ba53ffe3ca76863a0ffbbeb0c68 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Fri, 22 Aug 1997 00:02:19 +0000 Subject: [PATCH] Allow functions and operators on internally-identical types to succeed. --- src/backend/parser/analyze.c | 4 ++-- src/backend/parser/catalog_utils.c | 14 ++++++++++++-- src/backend/parser/parse_query.c | 5 +++-- src/backend/parser/parser.c | 15 ++++++++++++++- src/include/catalog/pg_type.h | 3 ++- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 6c703b7781..9b4c88b9ae 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.34 1997/08/19 21:32:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.35 1997/08/22 00:02:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1345,7 +1345,7 @@ make_targetlist_expr(ParseState *pstate, } else if (attrtype != type_id) { if ((attrtype == INT2OID) && (type_id == INT4OID)) - lfirst(expr) = lispInteger (INT2OID); + lfirst(expr) = lispInteger (INT2OID); do CASHOID too else if ((attrtype == FLOAT4OID) && (type_id == FLOAT8OID)) lfirst(expr) = lispInteger (FLOAT4OID); else diff --git a/src/backend/parser/catalog_utils.c b/src/backend/parser/catalog_utils.c index 4341988341..043c286506 100644 --- a/src/backend/parser/catalog_utils.c +++ b/src/backend/parser/catalog_utils.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.21 1997/08/19 21:32:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.22 1997/08/22 00:02:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -373,6 +373,7 @@ equivalentOpersAfterPromotion(CandidateList candidates) case FLOAT4OID: case INT4OID: case INT2OID: + case CASHOID: c->args[0] = FLOAT8OID; break; default: @@ -383,6 +384,7 @@ equivalentOpersAfterPromotion(CandidateList candidates) case FLOAT4OID: case INT4OID: case INT2OID: + case CASHOID: c->args[1] = FLOAT8OID; break; default: @@ -570,6 +572,7 @@ unary_oper_get_candidates(char *op, opKey[1].sk_argument = CharGetDatum(rightleft); /* currently, only "unknown" can be coerced */ + /* but we should allow types that are internally the same to be "coerced" */ if (typeId != UNKNOWNOID) { return 0; } @@ -956,7 +959,14 @@ can_coerce(int nargs, Oid *input_typeids, Oid *func_typeids) */ for (i=0; iconstvalue); break; + + case CASHOID: /* money */ + const_string = (char *) palloc(256); + string_palloced = true; + sprintf(const_string,"%ld", + (int) ((Const*)expr)->constvalue); + break; case TEXTOID: /* text */ const_string = DatumGetPointer(((Const)lnext(expr))->constvalue); @@ -350,6 +357,12 @@ parser_typecast2(Node *expr, Oid exprType, Type tp, int typlen) sprintf(const_string,"%f", *floatVal); break; } + case CASHOID: /* money */ + const_string = (char *) palloc(256); + string_palloced = true; + sprintf(const_string,"%ld", + (long) ((Const*)expr)->constvalue); + break; case TEXTOID: /* text */ const_string = DatumGetPointer(((Const*)expr)->constvalue ); diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index c2be12bb48..3ed49b8b5e 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_type.h,v 1.14 1997/08/21 01:37:55 vadim Exp $ + * $Id: pg_type.h,v 1.15 1997/08/22 00:02:19 momjian Exp $ * * NOTES * 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 DATA(insert OID = 718 ( circle PGUID 24 47 f b t \054 0 0 circle_in circle_out circle_in circle_out d _null_ )); DATA(insert OID = 719 ( _circle PGUID -1 -1 f b t \054 0 718 array_in array_out array_in array_out d _null_ )); DATA(insert OID = 790 ( money PGUID 4 24 f b t \054 0 0 cash_in cash_out cash_in cash_out i _null_ )); +#define CASHOID 790 DATA(insert OID = 791 ( _money PGUID -1 -1 f b t \054 0 790 array_in array_out array_in array_out i _null_ )); /* OIDS 800 - 899 */ -- 2.40.0