Fix crash in COPY FROM for non-distributed/non-replicated table
Current code for COPY FROM picks mode as COPY_DISPATCH for non-distributed/non-replicated table as well. This causes crash. It should be using COPY_DIRECT, which is normal/direct mode to be used for such tables. The crash was exposed by following SQL commands: CREATE TABLE public.heap01 (a int, b int) distributed by (a); INSERT INTO public.heap01 VALUES (generate_series(0,99), generate_series(0,98)); ANALYZE public.heap01; COPY (select * from pg_statistic where starelid = 'public.heap01'::regclass) TO '/tmp/heap01.stat'; DELETE FROM pg_statistic where starelid = 'public.heap01'::regclass; COPY pg_statistic from '/tmp/heap01.stat'; Important note: Yes, it's known and strongly recommended to not touch the `pg_statistics` or any other catalog table this way. But it's no good to panic either. The copy to `pg_statictics` is going to ERROR out "correctly" and not crash after this change with `cannot accept a value of type anyarray`, as there just isn't any way at the SQL level to insert data into pg_statistic's anyarray columns. Refer: https://www.postgresql.org/message-id/12138.1277130186%40sss.pgh.pa.us (cherry picked from commit 6793882b)
Showing
想要评论请 注册 或 登录