• J
    Support 'copy (select statement) to file on segment' (#6077) · bad6cebc
    Jinbao Chen 提交于
    In ‘copy (select statement) to file’, we generate a query plan and set
    its dest receivor to copy_dest_receive. And run the dest receivor on QD.
    In 'copy (select statement) to file on segment', we modify the query plan,
    delete gather mothon, and let dest receivor run on QE.
    
    Change 'isCtas' in Query to 'parentStmtType' to be able to mark the upper
    utility statement type. Add a CopyIntoClause node to store copy
    informations. Add copyIntoClause to PlannedStmt.
    
    In postgres, we don't need to make a different query plan for the
    query in the utility stament. But in greenplum, we need to.
    So we use a field to indicate whether the query is contained in utitily
    statemnt, and the type of utitily statemnt.
    
    Actually the behavior of 'copy (select statement) to file on segment'
    is very similar to 'SELECT ... INTO ...' and 'CREATE TABLE ... AS SELECT ...'.
    We use distribution policy inherent in the query result as the final data
    distribution policy. If not, we use the first clomn in target list as the key,
    and redistribute. The only difference is that we used 'copy_dest_receiver'
    instead of 'intorel_dest_receiver'
    bad6cebc
copy.c 211.1 KB