@@ -135,6 +135,7 @@ DefineType(ParseState *pstate, List *names, List *parameters)
135135char alignment = 'i' ;/* default alignment */
136136char storage = 'p' ;/* default TOAST storage method */
137137Oid collation = InvalidOid ;
138+ char * nullcmName = NULL ;
138139DefElem * likeTypeEl = NULL ;
139140DefElem * internalLengthEl = NULL ;
140141DefElem * inputNameEl = NULL ;
@@ -153,6 +154,7 @@ DefineType(ParseState *pstate, List *names, List *parameters)
153154DefElem * alignmentEl = NULL ;
154155DefElem * storageEl = NULL ;
155156DefElem * collatableEl = NULL ;
157+ DefElem * nullcmNameEl = NULL ;
156158Oid inputOid ;
157159Oid outputOid ;
158160Oid receiveOid = InvalidOid ;
@@ -164,6 +166,7 @@ DefineType(ParseState *pstate, List *names, List *parameters)
164166Oid array_oid ;
165167Oid typoid ;
166168Oid resulttype ;
169+ Oid nullcmOid = InvalidOid ;
167170ListCell * pl ;
168171ObjectAddress address ;
169172
@@ -283,6 +286,8 @@ DefineType(ParseState *pstate, List *names, List *parameters)
283286defelp = & storageEl ;
284287else if (pg_strcasecmp (defel -> defname ,"collatable" )== 0 )
285288defelp = & collatableEl ;
289+ else if (pg_strcasecmp (defel -> defname ,"nullcm" )== 0 )
290+ defelp = & nullcmNameEl ;
286291else
287292{
288293/* WARNING, not ERROR, for historical backwards-compatibility */
@@ -416,6 +421,8 @@ DefineType(ParseState *pstate, List *names, List *parameters)
416421}
417422if (collatableEl )
418423collation = defGetBoolean (collatableEl ) ?DEFAULT_COLLATION_OID :InvalidOid ;
424+ if (nullcmNameEl )
425+ nullcmName = defGetString (nullcmNameEl );
419426
420427/*
421428 * make sure we have our required definitions
@@ -516,6 +523,8 @@ DefineType(ParseState *pstate, List *names, List *parameters)
516523if (analyzeName )
517524analyzeOid = findTypeAnalyzeFunction (analyzeName ,typoid );
518525
526+ if (nullcmName )
527+ nullcmOid = get_compression_method_oid (nullcmName , false);
519528/*
520529 * Check permissions on functions. We choose to require the creator/owner
521530 * of a type to also own the underlying functions. Since creating a type
@@ -635,7 +644,8 @@ DefineType(ParseState *pstate, List *names, List *parameters)
635644-1 ,/* typMod (Domains only) */
6366450 ,/* Array Dimensions of typbasetype */
637646 false,/* Type NOT NULL */
638- collation );/* type's collation */
647+ collation ,/* type's collation */
648+ nullcmOid );/* compression method */
639649Assert (typoid == address .objectId );
640650
641651/*
@@ -676,7 +686,8 @@ DefineType(ParseState *pstate, List *names, List *parameters)
676686-1 ,/* typMod (Domains only) */
6776870 ,/* Array dimensions of typbasetype */
678688 false,/* Type NOT NULL */
679- collation );/* type's collation */
689+ collation ,/* type's collation */
690+ InvalidOid );/* compression method - none */
680691
681692pfree (array_type );
682693
@@ -1062,7 +1073,8 @@ DefineDomain(CreateDomainStmt *stmt)
10621073basetypeMod ,/* typeMod value */
10631074typNDims ,/* Array dimensions for base type */
10641075typNotNull ,/* Type NOT NULL */
1065- domaincoll );/* type's collation */
1076+ domaincoll ,/* type's collation */
1077+ InvalidOid );/* compression method - none */
10661078
10671079/*
10681080 * Process constraints which refer to the domain ID returned by TypeCreate
@@ -1174,7 +1186,8 @@ DefineEnum(CreateEnumStmt *stmt)
11741186-1 ,/* typMod (Domains only) */
117511870 ,/* Array dimensions of typbasetype */
11761188 false,/* Type NOT NULL */
1177- InvalidOid );/* type's collation */
1189+ InvalidOid ,/* type's collation */
1190+ InvalidOid );/* compression method - none */
11781191
11791192/* Enter the enum's values into pg_enum */
11801193EnumValuesCreate (enumTypeAddr .objectId ,stmt -> vals );
@@ -1214,7 +1227,8 @@ DefineEnum(CreateEnumStmt *stmt)
12141227-1 ,/* typMod (Domains only) */
121512280 ,/* Array dimensions of typbasetype */
12161229 false,/* Type NOT NULL */
1217- InvalidOid );/* type's collation */
1230+ InvalidOid ,/* type's collation */
1231+ InvalidOid );/* compression method - none */
12181232
12191233pfree (enumArrayName );
12201234
@@ -1502,7 +1516,8 @@ DefineRange(CreateRangeStmt *stmt)
15021516-1 ,/* typMod (Domains only) */
150315170 ,/* Array dimensions of typbasetype */
15041518 false,/* Type NOT NULL */
1505- InvalidOid );/* type's collation (ranges never have one) */
1519+ InvalidOid ,/* type's collation (ranges never have one) */
1520+ InvalidOid );/* compression method - none */
15061521Assert (typoid == address .objectId );
15071522
15081523/* Create the entry in pg_range */
@@ -1544,7 +1559,8 @@ DefineRange(CreateRangeStmt *stmt)
15441559-1 ,/* typMod (Domains only) */
154515600 ,/* Array dimensions of typbasetype */
15461561 false,/* Type NOT NULL */
1547- InvalidOid );/* typcollation */
1562+ InvalidOid ,/* typcollation */
1563+ InvalidOid );/* compression method - none */
15481564
15491565pfree (rangeArrayName );
15501566
@@ -2242,6 +2258,7 @@ AlterDomainDefault(List *names, Node *defaultRaw)
22422258typTup -> typbasetype ,
22432259typTup -> typcollation ,
22442260defaultExpr ,
2261+ InvalidOid ,
22452262 true);/* Rebuild is true */
22462263
22472264InvokeObjectPostAlterHook (TypeRelationId ,domainoid ,0 );
@@ -3639,6 +3656,9 @@ AlterTypeDefaultCompression(Oid typeid, ColumnCompression *compression)
36393656?get_compression_method_oid (compression -> methodName , false)
36403657:InvalidOid ;
36413658
3659+ if (cmoid == oldtype -> typnullcm )
3660+ cmoid = InvalidOid ;
3661+
36423662if (oldtype -> typdefaultcm != cmoid )
36433663{
36443664Relation typrel ;
@@ -3665,9 +3685,12 @@ AlterTypeDefaultCompression(Oid typeid, ColumnCompression *compression)
36653685heap_close (typrel ,RowExclusiveLock );
36663686
36673687if (OidIsValid (oldtype -> typdefaultcm ))
3688+ {
3689+ Assert (oldtype -> typdefaultcm != oldtype -> typnullcm );
36683690deleteDependencyRecordsForClass (TypeRelationId ,typeid ,0 ,
36693691CompressionMethodRelationId ,
36703692DEPENDENCY_NORMAL );
3693+ }
36713694
36723695if (OidIsValid (cmoid ))
36733696{