Skip to content

Commit 95dfd4d

Browse files
author
Tanya Gupta
committed
handling dump restore
Signed-off-by: Tanya Gupta <[email protected]>
1 parent 1731f50 commit 95dfd4d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/backend/parser/parse_type.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,14 @@ typenameTypeMod(ParseState *pstate, const TypeName *typeName, Type typ)
337337
{
338338
int32 result;
339339
Oid typmodin;
340+
Oid typbasetype;
340341
Datum *datums;
341342
int n;
342343
ListCell *l;
343344
ArrayType *arrtypmod;
344345
ParseCallbackState pcbstate;
346+
const char *dump_restore = GetConfigOption("babelfishpg_tsql.dump_restore", true, false);
347+
HeapTuple tup;
345348

346349
/* Return prespecified typmod if no typmod expressions */
347350
if (typeName->typmods == NIL)
@@ -360,6 +363,16 @@ typenameTypeMod(ParseState *pstate, const TypeName *typeName, Type typ)
360363
parser_errposition(pstate, typeName->location)));
361364

362365
typmodin = ((Form_pg_type) GETSTRUCT(typ))->typmodin;
366+
typbasetype = ((Form_pg_type) GETSTRUCT(typ))->typbasetype;
367+
368+
if (dump_restore && (strcmp(dump_restore, "on") == 0) && !typmodin && typbasetype)
369+
{
370+
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typbasetype));
371+
if (!HeapTupleIsValid(tup)) /* should not happen */
372+
elog(ERROR, "cache lookup failed for type %u", typbasetype);
373+
typmodin = ((Form_pg_type) GETSTRUCT((Type)tup))->typmodin;
374+
ReleaseSysCache(tup);
375+
}
363376

364377
if (typmodin == InvalidOid)
365378
ereport(ERROR,

0 commit comments

Comments
 (0)