Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id DB4652E34D8 for ; Mon, 7 Jan 2008 16:47:15 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 73902-09 for ; Mon, 7 Jan 2008 16:47:10 -0400 (AST) Received: from mail.fmed.uba.ar (mail.fmed.uba.ar [157.92.152.1]) by postgresql.org (Postfix) with ESMTP id D3F602E33D0 for ; Mon, 7 Jan 2008 16:47:12 -0400 (AST) Received: from www.webmail.fmed.uba.ar (localhost [127.0.0.1]) by mail.fmed.uba.ar (Postfix) with ESMTP id 0C3A611D067 for ; Mon, 7 Jan 2008 18:47:09 -0200 (ARST) Received: from 190.55.98.232 (SquirrelMail authenticated user gherzig) by www.webmail.fmed.uba.ar with HTTP; Mon, 7 Jan 2008 18:47:09 -0200 (ARST) Message-ID: <2855.190.55.98.232.1199738829.squirrel@www.webmail.fmed.uba.ar> In-Reply-To: References: <478226FB.6030306@fmed.uba.ar> Date: Mon, 7 Jan 2008 18:47:09 -0200 (ARST) Subject: Re: reading WAL files in python From: gherzig@fmed.uba.ar To: pgsql-sql@postgresql.org User-Agent: SquirrelMail/1.4.10a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/32 X-Sequence-Number: 29885 > > On Jan 7, 2008, at 7:19 AM, Gerardo Herzig wrote: > >> Hi all. Im having some fun trying to write my own replication >> system using python. I will use the postgres own WAL archiving to >> write the files, then my app will read them and do some stuff. As >> im not a C programmer, im stuck in the mission of reading the >> binary files. >> >> I guess im needing to know the internals of how wals archives are, >> how big the buffer has to be, in order to have a complete sql command. >> >> Can someone point some advice? >> I was trying to understad src/backend/access/transam/xlog.c, but >> seems too difficult to me :( > > The biggest problem with what you're wanting to do here is that the > data written to the WALL archives isn't going to be at all easily > translatable into SQL statements. AFAIK, the WAL data records on- > disk file changes, i.e. it's strictly a binary mode scenario. As > someone has already suggested, if you want to learn more about > Postgres and Python, look at Skytools. I'm not just saying to use > it, read the code and, if you like, offer help with patches. > > Erik Jones So the fun ends in 3, 2, 1.... Well, so it looks like the trigger approach is now my path to follow. Yeah, im looking for skytools code, looks very nice, maybe a little outdate (just a quick look, it uses old-style python classes). BTW, the information about WAL system you gave me, just saves me a lot of time. Thanks you for that! Gerardo