• X
    Check distribution key restriction for `COPY FROM ON SEGMEN` · 65321259
    Xiaoran Wang 提交于
    When use command `COPY FROM ON SEGMENT`, we copy data from
    local file to the table on the segment directly. When copying
    data, we need to apply the distribution policy on the record to compute
    the target segment. If the target segment ID isn't equal to
    current segment ID, we will report error to keep the distribution
    key restriction.
    
    Because the segment has no meta data info about table distribution policy and
    partition policy,we copy the distribution policy of main table from
    master to segment in the query plan. When the parent table and
    partitioned sub table has different distribution policy, it is difficult
    to check all the distribution key restriction in all sub tables. In this
    case , we will report error.
    
    In case of the partitioned table's distribution policy is
    RANDOMLY and different from the parent table, user can use GUC value
    `gp_enable_segment_copy_checking` to disable this check.
    
    Check the distribution key restriction as follows:
    
    1) Table isn't partioned:
        Compute the data target segment.If the data doesn't belong the
        segment, will report error.
    
    2) Table is partitioned and the distribution policy of partitioned table
    as same as the main table:
        Compute the data target segment.If the data doesn't belong
        the segment, will report error.
    
    3) Table is partitioned and the distribution policy of partitioned
    table is different from main table:
        Not support to check ,report error.
    Signed-off-by: NXiaoran Wang <xiwang@pivotal.io>
    Signed-off-by: NMing LI <mli@apache.org>
    Signed-off-by: NAdam Lee <ali@pivotal.io>
    65321259
cdbcopy.c 18.8 KB