Skip to content

Commit 722ddb0

Browse files
committed
Add support of ALTER TABLE .. DETACH PARTITION
1 parent 84682ff commit 722ddb0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/declarative.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,32 @@ void handle_attach_partition(AlterTableStmt *stmt, AlterTableCmd *cmd)
233233
/* handle ALTER TABLE .. DETACH PARTITION command */
234234
void 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+
236244
Assert(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
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy