@@ -74,6 +74,7 @@ static ObjectAddress create_table_using_stmt(CreateStmt *create_stmt,
7474Oid relowner );
7575
7676static void copy_foreign_keys (Oid parent_relid ,Oid partition_oid );
77+ static void copy_relation_attributes (Oid partition_relid ,Datum reloptions );
7778static void postprocess_child_table_and_atts (Oid parent_relid ,Oid partition_relid );
7879
7980static Oid text_to_regprocedure (text * proname_args );
@@ -671,6 +672,7 @@ create_single_partition_internal(Oid parent_relid,
671672RangeVar * partition_rv ,
672673char * tablespace )
673674{
675+ HeapTuple tuple = NULL ;
674676Relation parentrel ;
675677
676678/* Value to be returned */
@@ -693,6 +695,7 @@ create_single_partition_internal(Oid parent_relid,
693695Oid save_userid ;
694696int save_sec_context ;
695697bool need_priv_escalation = !superuser ();/* we might be a SU */
698+ Datum reloptions = (Datum )0 ;
696699
697700/* Lock parent and check if it exists */
698701LockRelationOid (parent_relid ,ShareUpdateExclusiveLock );
@@ -736,6 +739,19 @@ create_single_partition_internal(Oid parent_relid,
736739/* Copy attributes */
737740parentrel = heap_open (parent_relid ,NoLock );
738741newrel_rv -> relpersistence = parentrel -> rd_rel -> relpersistence ;
742+ if (parentrel -> rd_options )
743+ {
744+ bool isNull ;
745+
746+ tuple = SearchSysCache1 (RELOID ,ObjectIdGetDatum (parent_relid ));
747+ if (!HeapTupleIsValid (tuple ))
748+ elog (ERROR ,"cache lookup failed for relation %u" ,parent_relid );
749+
750+ reloptions = SysCacheGetAttr (RELOID ,tuple ,Anum_pg_class_reloptions ,
751+ & isNull );
752+ if (isNull )
753+ reloptions = (Datum )0 ;
754+ }
739755heap_close (parentrel ,NoLock );
740756
741757/* If no 'tablespace' is provided, get parent's tablespace */
@@ -787,6 +803,10 @@ create_single_partition_internal(Oid parent_relid,
787803partition_relid = create_table_using_stmt ((CreateStmt * )cur_stmt ,
788804child_relowner ).objectId ;
789805
806+ /* Copy attributes to partition */
807+ if (reloptions )
808+ copy_relation_attributes (partition_relid ,reloptions );
809+
790810/* Copy FOREIGN KEYS of the parent table */
791811copy_foreign_keys (parent_relid ,partition_relid );
792812
@@ -823,6 +843,9 @@ create_single_partition_internal(Oid parent_relid,
823843if (need_priv_escalation )
824844SetUserIdAndSecContext (save_userid ,save_sec_context );
825845
846+ if (tuple != NULL )
847+ ReleaseSysCache (tuple );
848+
826849return partition_relid ;
827850}
828851
@@ -1114,6 +1137,38 @@ copy_foreign_keys(Oid parent_relid, Oid partition_oid)
11141137FunctionCallInvoke (& copy_fkeys_proc_fcinfo );
11151138}
11161139
1140+ /* Copy attributes to partition. Updates partition's tuple in pg_class */
1141+ static void
1142+ copy_relation_attributes (Oid partition_relid ,Datum reloptions )
1143+ {
1144+ Relation classRel ;
1145+ HeapTuple tuple ,
1146+ newtuple ;
1147+ Datum new_val [Natts_pg_class ];
1148+ bool new_null [Natts_pg_class ],
1149+ new_repl [Natts_pg_class ];
1150+
1151+ classRel = heap_open (RelationRelationId ,RowExclusiveLock );
1152+ tuple = SearchSysCacheCopy1 (RELOID ,
1153+ ObjectIdGetDatum (partition_relid ));
1154+ if (!HeapTupleIsValid (tuple ))
1155+ elog (ERROR ,"cache lookup failed for relation %u" ,
1156+ partition_relid );
1157+
1158+ /* Fill in relpartbound value */
1159+ memset (new_val ,0 ,sizeof (new_val ));
1160+ memset (new_null , false,sizeof (new_null ));
1161+ memset (new_repl , false,sizeof (new_repl ));
1162+ new_val [Anum_pg_class_reloptions - 1 ]= reloptions ;
1163+ new_null [Anum_pg_class_reloptions - 1 ]= false;
1164+ new_repl [Anum_pg_class_reloptions - 1 ]= true;
1165+ newtuple = heap_modify_tuple (tuple ,RelationGetDescr (classRel ),
1166+ new_val ,new_null ,new_repl );
1167+ CatalogTupleUpdate (classRel ,& newtuple -> t_self ,newtuple );
1168+ heap_freetuple (newtuple );
1169+ heap_close (classRel ,RowExclusiveLock );
1170+ }
1171+
11171172
11181173/*
11191174 * -----------------------------