Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id B8AD6B5DD20 for ; Fri, 17 Jun 2011 11:02:24 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 69736-03-4 for ; Fri, 17 Jun 2011 14:02:18 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from spinlock.commandprompt.com (host-215.commandprompt.net [207.173.203.215]) by mail.postgresql.org (Postfix) with ESMTP id 0BF37B5DC64 for ; Fri, 17 Jun 2011 11:00:23 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by spinlock.commandprompt.com (Postfix) with ESMTP id 557D5348048; Fri, 17 Jun 2011 07:00:23 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at commandprompt.com Received: from spinlock.commandprompt.com ([127.0.0.1]) by localhost (spinlock.commandprompt.com.commandprompt.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DYyVeydH87UE; Fri, 17 Jun 2011 07:00:17 -0700 (PDT) Received: from perhan.alvh.no-ip.org (unknown [190.95.30.33]) by spinlock.commandprompt.com (Postfix) with ESMTPSA id 3ED3E34804E; Fri, 17 Jun 2011 07:00:17 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id A6F1C6E5BD; Fri, 17 Jun 2011 10:00:14 -0400 (CLT) Content-Type: text/plain; charset=UTF-8 Cc: pgsql-docs Subject: Re: File_FDW with example From: Alvaro Herrera To: Joshua Berkus In-reply-to: <1054372046.268838.1308273696804.JavaMail.root@mail-1.01.com> References: <1054372046.268838.1308273696804.JavaMail.root@mail-1.01.com> Date: Fri, 17 Jun 2011 10:00:14 -0400 Message-Id: <1308319114-sup-5494@alvh.no-ip.org> User-Agent: Sup/git Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/81 X-Sequence-Number: 6855 Excerpts from Joshua Berkus's message of jue jun 16 21:21:36 -0400 2011: > (apologies for prior incomplete post. Webmail spazzed on me). > > Attached is a version of file_FDW.sgml which contains a complete example of how to use it to read your postgresql csv logs. I think this does some neat tying together of how to use FDWs that the docs are currently lacking. Interesting ... The final query is a bit unwieldy. I wonder if this would work CREATE TABLE generic_pglog ( log_time timestamp(3) with time zone, user_name text, database_name text, process_id integer, connection_from text, session_id text, session_line_num bigint, command_tag text, session_start_time timestamp with time zone, virtual_transaction_id text, transaction_id bigint, error_severity text, sql_state_code text, message text, detail text, hint text, internal_query text, internal_query_pos integer, context text, query text, query_pos integer, location text, application_name text ); CREATE FOREIGN TABLE pglog (LIKE generic_pglog) SERVER pglog OPTIONS ( filename '/home/josh/9.1/data/pg_log/pglog.csv', format 'csv' ); Note that you have a "Not" instead of "now" in the last paragraph. -- Álvaro Herrera The PostgreSQL Company - Command Prompt, Inc. PostgreSQL Replication, Consulting, Custom Development, 24x7 support