| From: | Mike Martin <redtux1(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Problem with commit in function |
| Date: | 2018-10-30 10:51:17 |
| Message-ID: | CAOwYNKZBLP2WZdgqXMD421_hqfVt=KNj7OXk3an7Z89v2ybLmw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
I have the following function
-- FUNCTION: public.update_log()
-- DROP FUNCTION public.update_log();
CREATE OR REPLACE FUNCTION public.update_log(
)
RETURNS void
LANGUAGE 'sql'
COST 100
VOLATILE
AS $BODY$
truncate table postgres_log_tmp ;
COPY postgres_log_tmp FROM '/mnt/pgdata/data/log/postgresql-Mon.csv' WITH
csv;
COPY postgres_log_tmp FROM '/mnt/pgdata/data/log/postgresql-Tue.csv' WITH
csv;
COPY postgres_log_tmp FROM '/mnt/pgdata/data/log/postgresql-Wed.csv' WITH
csv;
COPY postgres_log_tmp FROM '/mnt/pgdata/data/log/postgresql-Thu.csv' WITH
csv;
COPY postgres_log_tmp FROM '/mnt/pgdata/data/log/postgresql-Fri.csv' WITH
csv;
COPY postgres_log_tmp FROM '/mnt/pgdata/data/log/postgresql-Sat.csv' WITH
csv;
COPY postgres_log_tmp FROM '/mnt/pgdata/data/log/postgresql-Sun.csv' WITH
csv;
INSERT INTO postgres_log SELECT * from postgres_log_tmp ON
CONFLICT(session_id, session_line_num) DO NOTHING;
--COMMIT;
truncate table postgres_log_tmp ;
$BODY$;
ALTER FUNCTION public.update_log()
OWNER TO postgres;
If I leave the second truncate statement nothing is written to
postgres_log. I assume the insert doesnt finish
Any way to force it to finish before the truncation?
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Madan Kumar | 2018-10-30 11:19:39 | How to change standby node to sync from the new master without rebooting the PostgreSQL service? |
| Previous Message | GPT | 2018-10-30 10:19:20 | Re: rw_redis_fdw: SQL Errors when statement is within a function |