77 *
88 *
99 * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.13 1999/05/19 16:46:12 momjian Exp $
10+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.14 1999/05/22 02:55:57 momjian Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -41,18 +41,8 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId)
4141Oid infunc ;
4242Datum val ;
4343
44- #ifdef PARSEDEBUG
45- printf ("coerce_type: argument types are %d -> %u\n" ,
46- inputTypeId ,targetTypeId );
47- #endif
48-
4944if (targetTypeId == InvalidOid )
50- {
51- #ifdef PARSEDEBUG
52- printf ("coerce_type: apparent NULL target argument; suppress type conversion\n" );
53- #endif
5445result = node ;
55- }
5646else if (inputTypeId != targetTypeId )
5747{
5848
@@ -61,13 +51,7 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId)
6151 * through...
6252 */
6353if (IS_BINARY_COMPATIBLE (inputTypeId ,targetTypeId ))
64- {
65- #ifdef PARSEDEBUG
66- printf ("coerce_type: argument type %s is known to be convertible to type %s\n" ,
67- typeidTypeName (inputTypeId ),typeidTypeName (targetTypeId ));
68- #endif
6954result = node ;
70- }
7155
7256/*
7357 * if not unknown input type, try for explicit conversion using
@@ -84,18 +68,10 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId)
8468n -> funcname = typeidTypeName (targetTypeId );
8569n -> args = lcons (node ,NIL );
8670
87- #ifdef PARSEDEBUG
88- printf ("coerce_type: construct function %s(%s)\n" ,
89- typeidTypeName (targetTypeId ),typeidTypeName (inputTypeId ));
90- #endif
91-
9271result = transformExpr (pstate , (Node * )n ,EXPR_COLUMN_FIRST );
9372}
9473else
9574{
96- #ifdef PARSEDEBUG
97- printf ("coerce_type: node is UNKNOWN type\n" );
98- #endif
9975if (nodeTag (node )== T_Const )
10076{
10177Const * con = (Const * )node ;
@@ -117,22 +93,11 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId)
11793result = (Node * )con ;
11894}
11995else
120- {
121- #ifdef PARSEDEBUG
122- printf ("coerce_type: should never get here!\n" );
123- #endif
12496result = node ;
125- }
12697}
12798}
12899else
129- {
130- #ifdef PARSEDEBUG
131- printf ("coerce_type: argument type IDs %u match\n" ,inputTypeId );
132- #endif
133-
134100result = node ;
135- }
136101
137102return result ;
138103}/* coerce_type() */
@@ -163,10 +128,6 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids)
163128/* run through argument list... */
164129for (i = 0 ;i < nargs ;i ++ )
165130{
166- #ifdef PARSEDEBUG
167- printf ("can_coerce_type: argument #%d types are %u -> %u\n" ,
168- i ,input_typeids [i ],func_typeids [i ]);
169- #endif
170131if (input_typeids [i ]!= func_typeids [i ])
171132{
172133
@@ -175,31 +136,14 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids)
175136 * through...
176137 */
177138if (IS_BINARY_COMPATIBLE (input_typeids [i ],func_typeids [i ]))
178- {
179- #ifdef PARSEDEBUG
180- printf ("can_coerce_type: argument #%d type %s is known to be convertible to type %s\n" ,
181- i ,typeidTypeName (input_typeids [i ]),typeidTypeName (func_typeids [i ]));
182- #endif
183- }
139+ ;
184140
185141/* don't know what to do for the output type? then quit... */
186142else if (func_typeids [i ]== InvalidOid )
187- {
188- #ifdef PARSEDEBUG
189- printf ("can_coerce_type: output OID func_typeids[%u] is zero\n" ,i );
190- #endif
191143return false;
192- }
193-
194144/* don't know what to do for the input type? then quit... */
195145else if (input_typeids [i ]== InvalidOid )
196- {
197- #ifdef PARSEDEBUG
198- printf ("can_coerce_type: input OID input_typeids[%u] is zero\n" ,i );
199- #endif
200146return false;
201- }
202-
203147/*
204148 * if not unknown input type, try for explicit conversion
205149 * using functions...
@@ -223,51 +167,13 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids)
223167 * should also check the function return type just to be
224168 * safe...
225169 */
226- if (HeapTupleIsValid (ftup ))
227- {
228- #ifdef PARSEDEBUG
229- printf ("can_coerce_type: found function %s(%s) to convert argument #%d\n" ,
230- typeidTypeName (func_typeids [i ]),typeidTypeName (input_typeids [i ]),i );
231- #endif
232- }
233- else
234- {
235- #ifdef PARSEDEBUG
236- printf ("can_coerce_type: did not find function %s(%s) to convert argument #%d\n" ,
237- typeidTypeName (func_typeids [i ]),typeidTypeName (input_typeids [i ]),i );
238- #endif
170+ if (!HeapTupleIsValid (ftup ))
239171return false;
240- }
241- }
242- else
243- {
244- #ifdef PARSEDEBUG
245- printf ("can_coerce_type: argument #%d type is %u (UNKNOWN)\n" ,
246- i ,input_typeids [i ]);
247- #endif
248172}
249173
250174tp = typeidType (input_typeids [i ]);
251175if (typeTypeFlag (tp )== 'c' )
252- {
253- #ifdef PARSEDEBUG
254- printf ("can_coerce_type: typeTypeFlag for %s is 'c'\n" ,
255- typeidTypeName (input_typeids [i ]));
256- #endif
257176return false;
258- }
259-
260- #ifdef PARSEDEBUG
261- printf ("can_coerce_type: conversion from %s to %s is possible\n" ,
262- typeidTypeName (input_typeids [i ]),typeidTypeName (func_typeids [i ]));
263- #endif
264- }
265- else
266- {
267- #ifdef PARSEDEBUG
268- printf ("can_coerce_type: argument #%d type IDs %u match\n" ,
269- i ,input_typeids [i ]);
270- #endif
271177}
272178}
273179
@@ -396,9 +302,6 @@ PreferredType(CATEGORY category, Oid type)
396302result = UNKNOWNOID ;
397303break ;
398304}
399- #ifdef PARSEDEBUG
400- printf ("PreferredType- (%d) preferred type is %s\n" ,category ,typeidTypeName (result ));
401- #endif
402305return result ;
403306}/* PreferredType() */
404307