I tried to use function get_rel_name(OID) to get table name, but the output is NULL, could anyone tell me why and how can I get the table name in backend of postgresql? thanks.
for (rti = 1; rti < root->simple_rel_array_size; rti++)
{
RelOptInfo *rel = root->simple_rel_array[rti];
printf("rel->relid=%d %s \n",rel->relid, get_rel_name(rel->relid));
}
In src/backend/optimizer/path/costsize.c in the function below.
void
cost_seqscan(Path *path, PlannerInfo *root,
RelOptInfo *baserel, ParamPathInfo *param_info)
I got it, it should be
for (rti = 1; rti < root->simple_rel_array_size; rti++)
{
RangeTblEntry *rte=root->simple_rte_array[rti];
printf("table name is %s \n",get_rel_name(rte->relid));
}