@@ -5165,84 +5165,15 @@ interval_part(PG_FUNCTION_ARGS)
5165
5165
5166
5166
5167
5167
/* timestamp_zone_transform()
5168
- * If the zone argument of a timestamp_zone() or timestamptz_zone() call is a
5169
- * plan-time constant denoting a zone equivalent to UTC, the call will always
5170
- * return its second argument unchanged. Simplify the expression tree
5171
- * accordingly. Civil time zones almost never qualify, because jurisdictions
5172
- * that follow UTC today have not done so continuously.
5168
+ * The original optimization here caused problems by relabeling Vars that
5169
+ * could be matched to index entries. It might be possible to resurrect it
5170
+ * at some point by teaching the planner to be less cavalier with RelabelType
5171
+ * nodes, but that will take careful analysis.
5173
5172
*/
5174
5173
Datum
5175
5174
timestamp_zone_transform (PG_FUNCTION_ARGS )
5176
5175
{
5177
- Node * func_node = (Node * ) PG_GETARG_POINTER (0 );
5178
- FuncExpr * expr = (FuncExpr * ) func_node ;
5179
- Node * ret = NULL ;
5180
- Node * zone_node ;
5181
-
5182
- Assert (IsA (expr , FuncExpr ));
5183
- Assert (list_length (expr -> args ) == 2 );
5184
-
5185
- zone_node = (Node * ) linitial (expr -> args );
5186
-
5187
- if (IsA (zone_node , Const ) && !((Const * ) zone_node )-> constisnull )
5188
- {
5189
- text * zone = DatumGetTextPP (((Const * ) zone_node )-> constvalue );
5190
- char tzname [TZ_STRLEN_MAX + 1 ];
5191
- char * lowzone ;
5192
- int type ,
5193
- abbrev_offset ;
5194
- pg_tz * tzp ;
5195
- bool noop = false;
5196
-
5197
- /*
5198
- * If the timezone is forever UTC+0, the FuncExpr function call is a
5199
- * no-op for all possible timestamps. This passage mirrors code in
5200
- * timestamp_zone().
5201
- */
5202
- text_to_cstring_buffer (zone , tzname , sizeof (tzname ));
5203
- lowzone = downcase_truncate_identifier (tzname ,
5204
- strlen (tzname ),
5205
- false);
5206
- type = DecodeTimezoneAbbrev (0 , lowzone , & abbrev_offset , & tzp );
5207
- if (type == TZ || type == DTZ )
5208
- noop = (abbrev_offset == 0 );
5209
- else if (type == DYNTZ )
5210
- {
5211
- /*
5212
- * An abbreviation of a single-offset timezone ought not to be
5213
- * configured as a DYNTZ, so don't bother checking.
5214
- */
5215
- }
5216
- else
5217
- {
5218
- long tzname_offset ;
5219
-
5220
- tzp = pg_tzset (tzname );
5221
- if (tzp && pg_get_timezone_offset (tzp , & tzname_offset ))
5222
- noop = (tzname_offset == 0 );
5223
- }
5224
-
5225
- if (noop )
5226
- {
5227
- Node * timestamp = (Node * ) lsecond (expr -> args );
5228
-
5229
- /* Strip any existing RelabelType node(s) */
5230
- while (timestamp && IsA (timestamp , RelabelType ))
5231
- timestamp = (Node * ) ((RelabelType * ) timestamp )-> arg ;
5232
-
5233
- /*
5234
- * Replace the FuncExpr with its timestamp argument, relabeled as
5235
- * though the function call had computed it.
5236
- */
5237
- ret = (Node * ) makeRelabelType ((Expr * ) timestamp ,
5238
- exprType (func_node ),
5239
- exprTypmod (func_node ),
5240
- exprCollation (func_node ),
5241
- COERCE_EXPLICIT_CAST );
5242
- }
5243
- }
5244
-
5245
- PG_RETURN_POINTER (ret );
5176
+ PG_RETURN_POINTER (NULL );
5246
5177
}
5247
5178
5248
5179
/* timestamp_zone()
@@ -5339,49 +5270,15 @@ timestamp_zone(PG_FUNCTION_ARGS)
5339
5270
}
5340
5271
5341
5272
/* timestamp_izone_transform()
5342
- * If we deduce at plan time that a particular timestamp_izone() or
5343
- * timestamptz_izone() call can only compute tz=0, the call will always return
5344
- * its second argument unchanged. Simplify the expression tree accordingly.
5273
+ * The original optimization here caused problems by relabeling Vars that
5274
+ * could be matched to index entries. It might be possible to resurrect it
5275
+ * at some point by teaching the planner to be less cavalier with RelabelType
5276
+ * nodes, but that will take careful analysis.
5345
5277
*/
5346
5278
Datum
5347
5279
timestamp_izone_transform (PG_FUNCTION_ARGS )
5348
5280
{
5349
- Node * func_node = (Node * ) PG_GETARG_POINTER (0 );
5350
- FuncExpr * expr = (FuncExpr * ) func_node ;
5351
- Node * ret = NULL ;
5352
- Node * zone_node ;
5353
-
5354
- Assert (IsA (expr , FuncExpr ));
5355
- Assert (list_length (expr -> args ) == 2 );
5356
-
5357
- zone_node = (Node * ) linitial (expr -> args );
5358
-
5359
- if (IsA (zone_node , Const ) && !((Const * ) zone_node )-> constisnull )
5360
- {
5361
- Interval * zone ;
5362
-
5363
- zone = DatumGetIntervalP (((Const * ) zone_node )-> constvalue );
5364
- if (zone -> month == 0 && zone -> day == 0 && zone -> time == 0 )
5365
- {
5366
- Node * timestamp = (Node * ) lsecond (expr -> args );
5367
-
5368
- /* Strip any existing RelabelType node(s) */
5369
- while (timestamp && IsA (timestamp , RelabelType ))
5370
- timestamp = (Node * ) ((RelabelType * ) timestamp )-> arg ;
5371
-
5372
- /*
5373
- * Replace the FuncExpr with its timestamp argument, relabeled as
5374
- * though the function call had computed it.
5375
- */
5376
- ret = (Node * ) makeRelabelType ((Expr * ) timestamp ,
5377
- exprType (func_node ),
5378
- exprTypmod (func_node ),
5379
- exprCollation (func_node ),
5380
- COERCE_EXPLICIT_CAST );
5381
- }
5382
- }
5383
-
5384
- PG_RETURN_POINTER (ret );
5281
+ PG_RETURN_POINTER (NULL );
5385
5282
}
5386
5283
5387
5284
/* timestamp_izone()
0 commit comments