Re: [BUGS] Where clause in pg_dump: need help

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: Prashanth Adiyodi <Prashantha(at)celltick(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: [BUGS] Where clause in pg_dump: need help
Date: 2016-07-11 09:03:53
Message-ID: CA+bJJbxLuaasq8Birr6OtfzR_ZEH4bLSRoq7ooAVYpGV_7ypcQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

Hi Adi: ( Is this correct? Adi is what your message uses to mark your replies ).

On Sun, Jul 10, 2016 at 6:53 PM, Prashanth Adiyodi
<Prashantha(at)celltick(dot)com> wrote:
> Hi Franciso, My comments below inline

Got them. Only problem is your MUA does not signal quotes. It looks
like some kind of outlook by the headers it sends, so I assume it is
normal, I will try to correct it.

>> 1.- You have a backup with a series of tables which get inserted WITH a timestamp.
> Adi-The series of tables may or may not have timestamp
>> 2.- At the end of the day you want to transfer the inserted data, and only the inserted data, to another server and insert it ther.
> Adi-Exactly., somewhere post midnight I need to transfer the inserted data for the day to another DB.

Then you NEED some kind of marker. The tables WITHOUT timestamp (
point 1 above ) are going to be difficult.

For the discussion I assume you are somehow capable of making a SELECT
query which identifies inserted data for the day, and that either you
do not care about updates/deletions ( not having any is a subset of
this condition ) or you can do a query for those too.

> Adi- I am OK with the copy command, however I am not able to understand (my bad, I am not used to postgres and using for the 1st time) the where clause that should be used to achieve this result.

Well, then your problem is on the queries. You need to be able to
identify the data inserted yesterday. There is no magic way to do it.
You NEED some kind of timestamp column. If you lack this you can use a
trigger to mark them into auxiliary tables or, if you feel
adventurous, you can try to use the xmin/xmax columns ( I would NOT
recommend even trying that, given you are having problems with simple
select queries ).

> I tries using something like the below,
> psql -d my_db -c 'copy (select * from mytab WHERE date_trunc('day',NOW() - interval '1 day') TO STDOUT' -o data1.copy;

Your where expresion is a constant of timestamp type, i.e.,
'2016-07-11 12:00:00+00', where needs a BOOLEAN.

YOU need to be able to identify the inserted rows. YOU know your data
definitions. Ar you able to query them ?

> but this, I am sure has some syntax errors, could you help correct this,

NOT, because I do not know the table structure. Only you can do that.

Francisco Olarte.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Magnus Hagander 2016-07-11 10:01:40 Re: BUG #14230: Wrong timeline returned by pg_stop_backup on a standby
Previous Message zzia88 2016-07-11 07:32:04 BUG #14241: i want to do commit and rollback in one plpgsql block..

Browse pgsql-general by date

  From Date Subject
Next Message hamann.w 2016-07-11 09:05:43 Re: Running query without trigger?
Previous Message AMatveev 2016-07-11 08:15:32 Re: Memory usage per session