* copy_pathtarget * Copy a PathTarget. * * The new PathTarget has its own exprs List, but shares the underlying * target expression trees with the old one. */
| 886 | * target expression trees with the old one. |
| 887 | */ |
| 888 | PathTarget * |
| 889 | copy_pathtarget(PathTarget *src) |
| 890 | { |
| 891 | PathTarget *dst = makeNode(PathTarget); |
| 892 | |
| 893 | /* Copy scalar fields */ |
| 894 | memcpy(dst, src, sizeof(PathTarget)); |
| 895 | /* Shallow-copy the expression list */ |
| 896 | dst->exprs = list_copy(src->exprs); |
| 897 | /* Duplicate sortgrouprefs if any (if not, the memcpy handled this) */ |
| 898 | if (src->sortgrouprefs) |
| 899 | { |
| 900 | Size nbytes = list_length(src->exprs) * sizeof(Index); |
| 901 | |
| 902 | dst->sortgrouprefs = (Index *) palloc(nbytes); |
| 903 | memcpy(dst->sortgrouprefs, src->sortgrouprefs, nbytes); |
| 904 | } |
| 905 | return dst; |
| 906 | } |
| 907 | |
| 908 | /* |
| 909 | * create_empty_pathtarget |
no test coverage detected