@@ -5202,84 +5202,15 @@ interval_part(PG_FUNCTION_ARGS)
5202
5202
5203
5203
5204
5204
/* timestamp_zone_transform()
5205
- * If the zone argument of a timestamp_zone() or timestamptz_zone() call is a
5206
- * plan-time constant denoting a zone equivalent to UTC, the call will always
5207
- * return its second argument unchanged. Simplify the expression tree
5208
- * accordingly. Civil time zones almost never qualify, because jurisdictions
5209
- * that follow UTC today have not done so continuously.
5205
+ * The original optimization here caused problems by relabeling Vars that
5206
+ * could be matched to index entries. It might be possible to resurrect it
5207
+ * at some point by teaching the planner to be less cavalier with RelabelType
5208
+ * nodes, but that will take careful analysis.
5210
5209
*/
5211
5210
Datum
5212
5211
timestamp_zone_transform (PG_FUNCTION_ARGS )
5213
5212
{
5214
- Node * func_node = (Node * ) PG_GETARG_POINTER (0 );
5215
- FuncExpr * expr = (FuncExpr * ) func_node ;
5216
- Node * ret = NULL ;
5217
- Node * zone_node ;
5218
-
5219
- Assert (IsA (expr , FuncExpr ));
5220
- Assert (list_length (expr -> args ) == 2 );
5221
-
5222
- zone_node = (Node * ) linitial (expr -> args );
5223
-
5224
- if (IsA (zone_node , Const ) && !((Const * ) zone_node )-> constisnull )
5225
- {
5226
- text * zone = DatumGetTextPP (((Const * ) zone_node )-> constvalue );
5227
- char tzname [TZ_STRLEN_MAX + 1 ];
5228
- char * lowzone ;
5229
- int type ,
5230
- abbrev_offset ;
5231
- pg_tz * tzp ;
5232
- bool noop = false;
5233
-
5234
- /*
5235
- * If the timezone is forever UTC+0, the FuncExpr function call is a
5236
- * no-op for all possible timestamps. This passage mirrors code in
5237
- * timestamp_zone().
5238
- */
5239
- text_to_cstring_buffer (zone , tzname , sizeof (tzname ));
5240
- lowzone = downcase_truncate_identifier (tzname ,
5241
- strlen (tzname ),
5242
- false);
5243
- type = DecodeTimezoneAbbrev (0 , lowzone , & abbrev_offset , & tzp );
5244
- if (type == TZ || type == DTZ )
5245
- noop = (abbrev_offset == 0 );
5246
- else if (type == DYNTZ )
5247
- {
5248
- /*
5249
- * An abbreviation of a single-offset timezone ought not to be
5250
- * configured as a DYNTZ, so don't bother checking.
5251
- */
5252
- }
5253
- else
5254
- {
5255
- long tzname_offset ;
5256
-
5257
- tzp = pg_tzset (tzname );
5258
- if (tzp && pg_get_timezone_offset (tzp , & tzname_offset ))
5259
- noop = (tzname_offset == 0 );
5260
- }
5261
-
5262
- if (noop )
5263
- {
5264
- Node * timestamp = (Node * ) lsecond (expr -> args );
5265
-
5266
- /* Strip any existing RelabelType node(s) */
5267
- while (timestamp && IsA (timestamp , RelabelType ))
5268
- timestamp = (Node * ) ((RelabelType * ) timestamp )-> arg ;
5269
-
5270
- /*
5271
- * Replace the FuncExpr with its timestamp argument, relabeled as
5272
- * though the function call had computed it.
5273
- */
5274
- ret = (Node * ) makeRelabelType ((Expr * ) timestamp ,
5275
- exprType (func_node ),
5276
- exprTypmod (func_node ),
5277
- exprCollation (func_node ),
5278
- COERCE_EXPLICIT_CAST );
5279
- }
5280
- }
5281
-
5282
- PG_RETURN_POINTER (ret );
5213
+ PG_RETURN_POINTER (NULL );
5283
5214
}
5284
5215
5285
5216
/* timestamp_zone()
@@ -5376,49 +5307,15 @@ timestamp_zone(PG_FUNCTION_ARGS)
5376
5307
}
5377
5308
5378
5309
/* timestamp_izone_transform()
5379
- * If we deduce at plan time that a particular timestamp_izone() or
5380
- * timestamptz_izone() call can only compute tz=0, the call will always return
5381
- * its second argument unchanged. Simplify the expression tree accordingly.
5310
+ * The original optimization here caused problems by relabeling Vars that
5311
+ * could be matched to index entries. It might be possible to resurrect it
5312
+ * at some point by teaching the planner to be less cavalier with RelabelType
5313
+ * nodes, but that will take careful analysis.
5382
5314
*/
5383
5315
Datum
5384
5316
timestamp_izone_transform (PG_FUNCTION_ARGS )
5385
5317
{
5386
- Node * func_node = (Node * ) PG_GETARG_POINTER (0 );
5387
- FuncExpr * expr = (FuncExpr * ) func_node ;
5388
- Node * ret = NULL ;
5389
- Node * zone_node ;
5390
-
5391
- Assert (IsA (expr , FuncExpr ));
5392
- Assert (list_length (expr -> args ) == 2 );
5393
-
5394
- zone_node = (Node * ) linitial (expr -> args );
5395
-
5396
- if (IsA (zone_node , Const ) && !((Const * ) zone_node )-> constisnull )
5397
- {
5398
- Interval * zone ;
5399
-
5400
- zone = DatumGetIntervalP (((Const * ) zone_node )-> constvalue );
5401
- if (zone -> month == 0 && zone -> day == 0 && zone -> time == 0 )
5402
- {
5403
- Node * timestamp = (Node * ) lsecond (expr -> args );
5404
-
5405
- /* Strip any existing RelabelType node(s) */
5406
- while (timestamp && IsA (timestamp , RelabelType ))
5407
- timestamp = (Node * ) ((RelabelType * ) timestamp )-> arg ;
5408
-
5409
- /*
5410
- * Replace the FuncExpr with its timestamp argument, relabeled as
5411
- * though the function call had computed it.
5412
- */
5413
- ret = (Node * ) makeRelabelType ((Expr * ) timestamp ,
5414
- exprType (func_node ),
5415
- exprTypmod (func_node ),
5416
- exprCollation (func_node ),
5417
- COERCE_EXPLICIT_CAST );
5418
- }
5419
- }
5420
-
5421
- PG_RETURN_POINTER (ret );
5318
+ PG_RETURN_POINTER (NULL );
5422
5319
}
5423
5320
5424
5321
/* timestamp_izone()
0 commit comments