@@ -34,6 +34,7 @@ static int32 typenameTypeMod(ParseState *pstate, const TypeName *typeName,
34
34
check_or_set_default_typmod_hook_type check_or_set_default_typmod_hook = NULL ;
35
35
validate_var_datatype_scale_hook_type validate_var_datatype_scale_hook = NULL ;
36
36
handle_default_collation_hook_type handle_default_collation_hook = NULL ;
37
+ handle_basetype_typmodin_hook_type handle_basetype_typmodin_hook = NULL ;
37
38
38
39
/*
39
40
* LookupTypeName
@@ -338,16 +339,11 @@ typenameTypeMod(ParseState *pstate, const TypeName *typeName, Type typ)
338
339
{
339
340
int32 result ;
340
341
Oid typmodin ;
341
- Oid typbasetype ;
342
- Oid basetypeid ;
343
- Oid typeoid ;
344
342
Datum * datums ;
345
343
int n ;
346
344
ListCell * l ;
347
345
ArrayType * arrtypmod ;
348
346
ParseCallbackState pcbstate ;
349
- const char * dump_restore = GetConfigOption ("babelfishpg_tsql.dump_restore" , true, false);
350
- HeapTuple tup ;
351
347
352
348
/* Return prespecified typmod if no typmod expressions */
353
349
if (typeName -> typmods == NIL )
@@ -366,18 +362,10 @@ typenameTypeMod(ParseState *pstate, const TypeName *typeName, Type typ)
366
362
parser_errposition (pstate , typeName -> location )));
367
363
368
364
typmodin = ((Form_pg_type ) GETSTRUCT (typ ))-> typmodin ;
369
- typeoid = ((Form_pg_type ) GETSTRUCT (typ ))-> oid ;
370
- typbasetype = ((Form_pg_type ) GETSTRUCT (typ ))-> typbasetype ;
371
365
372
- if (dump_restore && (strcmp (dump_restore , "on" ) == 0 ) && !OidIsValid (typmodin ) && OidIsValid (typbasetype ))
373
- {
374
- basetypeid = getBaseType (typeoid );
375
- tup = SearchSysCache1 (TYPEOID , ObjectIdGetDatum (basetypeid ));
376
- if (!HeapTupleIsValid (tup )) /* should not happen */
377
- elog (ERROR , "cache lookup failed for type %u" , basetypeid );
378
- typmodin = ((Form_pg_type ) GETSTRUCT ((Type )tup ))-> typmodin ;
379
- ReleaseSysCache (tup );
380
- }
366
+ /* Handle the typmodin for domains like smallmoney/money and UDTs on them. */
367
+ if (handle_basetype_typmodin_hook )
368
+ (* handle_basetype_typmodin_hook )(typ , & typmodin );
381
369
382
370
if (typmodin == InvalidOid )
383
371
ereport (ERROR ,
0 commit comments