delete from tmplog;
copy tmplog (log) from '/root/westdclog/westdc-step2.log';
insert into accesslog1 (datetime,ip,method,path,size,uuid)
select t.datetime,t.ip::inet,t.method,t.path,t.size,t.u[1]::uuid from
(
select
    (to_char(to_timestamp(m[1], 'DD/Mon/YYYY:HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS '))::timestamp without time zone as datetime,m[2] as ip,
    m[3] as method,m[4] as path,m[5]::integer as size,regexp_matches(m[4],E'[0-9a-fA-F]\{8\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{12\}') as u from
      (select regexp_matches(log, E'\\[(.*)\\s(.*)\\s"(.*)\\s(.*)\\s(\\d+)') as m from tmplog) s
      ) t;
