@@ -2247,99 +2247,31 @@ deparseVar(Var *node, deparse_expr_cxt *context)
2247
2247
static void
2248
2248
deparseConst (Const * node , deparse_expr_cxt * context , int showtype )
2249
2249
{
2250
- StringInfo buf = context -> buf ;
2251
- Oid typoutput ;
2252
- bool typIsVarlena ;
2253
- char * extval ;
2254
- bool isfloat = false;
2255
- bool needlabel ;
2256
-
2257
- if (node -> constisnull )
2250
+ if (context -> params_list )
2258
2251
{
2259
- appendStringInfoString (buf , "NULL" );
2260
- if (showtype >= 0 )
2261
- appendStringInfo (buf , "::%s" ,
2262
- deparse_type_name (node -> consttype ,
2263
- node -> consttypmod ));
2264
- return ;
2265
- }
2252
+ int pindex = 0 ;
2253
+ ListCell * lc ;
2266
2254
2267
- getTypeOutputInfo (node -> consttype ,
2268
- & typoutput , & typIsVarlena );
2269
- extval = OidOutputFunctionCall (typoutput , node -> constvalue );
2255
+ /* find its index in params_list */
2256
+ foreach (lc , * context -> params_list )
2257
+ {
2258
+ pindex ++ ;
2259
+ if (equal (node , (Node * ) lfirst (lc )))
2260
+ break ;
2261
+ }
2262
+ if (lc == NULL )
2263
+ {
2264
+ /* not in list, so add it */
2265
+ pindex ++ ;
2266
+ * context -> params_list = lappend (* context -> params_list , node );
2267
+ }
2270
2268
2271
- switch (node -> consttype )
2272
- {
2273
- case INT2OID :
2274
- case INT4OID :
2275
- case INT8OID :
2276
- case OIDOID :
2277
- case FLOAT4OID :
2278
- case FLOAT8OID :
2279
- case NUMERICOID :
2280
- {
2281
- /*
2282
- * No need to quote unless it's a special value such as 'NaN'.
2283
- * See comments in get_const_expr().
2284
- */
2285
- if (strspn (extval , "0123456789+-eE." ) == strlen (extval ))
2286
- {
2287
- if (extval [0 ] == '+' || extval [0 ] == '-' )
2288
- appendStringInfo (buf , "(%s)" , extval );
2289
- else
2290
- appendStringInfoString (buf , extval );
2291
- if (strcspn (extval , "eE." ) != strlen (extval ))
2292
- isfloat = true; /* it looks like a float */
2293
- }
2294
- else
2295
- appendStringInfo (buf , "'%s'" , extval );
2296
- }
2297
- break ;
2298
- case BITOID :
2299
- case VARBITOID :
2300
- appendStringInfo (buf , "B'%s'" , extval );
2301
- break ;
2302
- case BOOLOID :
2303
- if (strcmp (extval , "t" ) == 0 )
2304
- appendStringInfoString (buf , "true" );
2305
- else
2306
- appendStringInfoString (buf , "false" );
2307
- break ;
2308
- default :
2309
- deparseStringLiteral (buf , extval );
2310
- break ;
2269
+ printRemoteParam (pindex , node -> consttype , node -> consttypmod , context );
2311
2270
}
2312
-
2313
- pfree (extval );
2314
-
2315
- if (showtype < 0 )
2316
- return ;
2317
-
2318
- /*
2319
- * For showtype == 0, append ::typename unless the constant will be
2320
- * implicitly typed as the right type when it is read in.
2321
- *
2322
- * XXX this code has to be kept in sync with the behavior of the parser,
2323
- * especially make_const.
2324
- */
2325
- switch (node -> consttype )
2271
+ else
2326
2272
{
2327
- case BOOLOID :
2328
- case INT4OID :
2329
- case UNKNOWNOID :
2330
- needlabel = false;
2331
- break ;
2332
- case NUMERICOID :
2333
- needlabel = !isfloat || (node -> consttypmod >= 0 );
2334
- break ;
2335
- default :
2336
- needlabel = true;
2337
- break ;
2273
+ printRemotePlaceholder (node -> consttype , node -> consttypmod , context );
2338
2274
}
2339
- if (needlabel || showtype > 0 )
2340
- appendStringInfo (buf , "::%s" ,
2341
- deparse_type_name (node -> consttype ,
2342
- node -> consttypmod ));
2343
2275
}
2344
2276
2345
2277
/*
0 commit comments