PostgreSQL 的 target_list分析(三)

struct ListCell

struct ListCell
{
     union
     {
           void  *ptr_value;
           int int_value;
           Oid  oid_value;
     } data;

     ListCell  *next;
}

由于在 target_list 相关部分,其 ptr_value 指向 ResTarget

typedef struct ResTarget
{

      NodeTag  type;
      char         *name;
      List          *indirection;
      Node        *val;
      int           Location;
}ResTarget;

如果想要使用,可以采用如下方式强制转换:

在  gram.y 的 simple_select 段,可以试着用:

{

       ...

      ResTarget *restar= (ResTarget *)(n->targetList->head->data.ptr_value);

      ...

}

原文地址:https://www.cnblogs.com/gaojian/p/2678797.html