@@ -233,5 +233,32 @@ void handle_attach_partition(AlterTableStmt *stmt, AlterTableCmd *cmd)
233233/* handle ALTER TABLE .. DETACH PARTITION command */
234234void handle_detach_partition (AlterTableStmt * stmt ,AlterTableCmd * cmd )
235235{
236+ List * proc_name ;
237+ FmgrInfo proc_flinfo ;
238+ FunctionCallInfoData proc_fcinfo ;
239+ char * pathman_schema ;
240+ Oid partition_relid ,
241+ args = REGCLASSOID ;
242+ PartitionCmd * pcmd = (PartitionCmd * )cmd -> def ;
243+
236244Assert (cmd -> subtype == AT_DetachPartition );
245+ partition_relid = RangeVarGetRelid (pcmd -> name ,NoLock , false);
246+
247+ /* Fetch pg_pathman's schema */
248+ pathman_schema = get_namespace_name (get_pathman_schema ());
249+
250+ /* Build function's name */
251+ proc_name = list_make2 (makeString (pathman_schema ),
252+ makeString (CppAsString (detach_range_partition )));
253+
254+ /* Lookup function's Oid and get FmgrInfo */
255+ fmgr_info (LookupFuncName (proc_name ,1 ,& args , false),& proc_flinfo );
256+
257+ InitFunctionCallInfoData (proc_fcinfo ,& proc_flinfo ,
258+ 4 ,InvalidOid ,NULL ,NULL );
259+ proc_fcinfo .arg [0 ]= ObjectIdGetDatum (partition_relid );
260+ proc_fcinfo .argnull [0 ]= false;
261+
262+ /* Invoke the callback */
263+ FunctionCallInvoke (& proc_fcinfo );
237264}