Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Michael Paquier
On Tue, Jan 21, 2014 at 2:33 PM, Sameer Kumar wrote: >> >> >> We are already using the following query: >> >> SELECT CASE WHEN pg_last_xlog_receive_location( >> ) = pg_last_xlog_replay_location() THEN 0 ELSE EXTRACT (EPOCH FROM now() - >> pg_last_xact_replay_timestamp()) END AS log_delay; >> > Thi

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Sameer Kumar
> > > > We are already using the following query: > > SELECT CASE WHEN pg_last_xlog_receive_location( > ) = pg_last_xlog_replay_location() THEN 0 ELSE EXTRACT (EPOCH FROM now() - > pg_last_xact_replay_timestamp()) END AS log_delay; > > This is (delay) not the correct thing to monitor. We cannot u

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Michael Paquier
On Tue, Jan 21, 2014 at 1:30 PM, Sameer Kumar wrote: > > On Tue, Jan 21, 2014 at 12:12 PM, Michael Paquier < > michael.paqu...@gmail.com> wrote: > >> Mind you, here is a simple suggestion: >> SELECT application_name, pg_xlog_location_diff(sent_location, >> flush_location) AS replay_delta, sync_pri

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Sameer Kumar
On Tue, Jan 21, 2014 at 12:12 PM, Michael Paquier wrote: > Mind you, here is a simple suggestion: > SELECT application_name, pg_xlog_location_diff(sent_location, > flush_location) AS replay_delta, sync_priority, sync_state FROM > pg_stat_replication ORDER BY replay_delta ASC, application_name; >

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Michael Paquier
On Tue, Jan 21, 2014 at 12:41 PM, Sameer Kumar wrote: > > On Mon, Jan 20, 2014 at 1:53 PM, Granthana Biswas wrote: > >> Yes we already do that. Count the number of ready wal files. > > > I guess a better place to check would be pg_stat_replication > > > Check this discussion: > http://www.postgres

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Sameer Kumar
On Mon, Jan 20, 2014 at 1:53 PM, Granthana Biswas wrote: > Yes we already do that. Count the number of ready wal files. I guess a better place to check would be pg_stat_replication Check this discussion: http://www.postgresql.org/message-id/4f13ed11.6080...@gmail.com Another way is explained

Re: [GENERAL] Filtering queries by IP

2014-01-20 Thread bricklen
On Mon, Jan 20, 2014 at 6:20 PM, Sergey Konoplev wrote: > On Mon, Jan 20, 2014 at 5:21 AM, Leonardo M. Ramé > wrote: > > Hi, I'm trying to find the cause of slow performance on some screens of > > an application. To do that, I would like to be able to log all the > > queries made by an specific

Re: [GENERAL] Filtering queries by IP

2014-01-20 Thread Sergey Konoplev
On Mon, Jan 20, 2014 at 5:21 AM, Leonardo M. Ramé wrote: > Hi, I'm trying to find the cause of slow performance on some screens of > an application. To do that, I would like to be able to log all the > queries made by an specific IP addres, is this possible?. I don't think it's possible with pure

Re: [GENERAL] Filtering queries by IP

2014-01-20 Thread Guillaume Lelarge
On Mon, 2014-01-20 at 10:21 -0300, Leonardo M. Ramé wrote: > Hi, I'm trying to find the cause of slow performance on some screens of > an application. To do that, I would like to be able to log all the > queries made by an specific IP addres, is this possible?. > Not by default, but you can use t

Re: [GENERAL] incrementing without violating a constraint

2014-01-20 Thread Tom Lane
"Michael P. Soulier" writes: > On 20/01/14 Michael P. Soulier said: >> This violates the uniquness constraint. Is there a way to say, turn off the >> constraint, run the update and then turn it back on? > Hmm. This didn't work. > tugdb=# SET CONSTRAINTS ALL DEFERRED; > SET CONSTRAINTS > tugdb=#

Re: [GENERAL] incrementing without violating a constraint

2014-01-20 Thread Alban Hertroys
On 20 January 2014 15:33, Michael P. Soulier wrote: > Hi, > > I have a uniqueness constraint on an integer value in a table where I would > like to mass increment all of the existing rows. > > ie. > update rules set rule_number = rule_number + 1; > > This violates the uniquness constraint. Is ther

Re: [GENERAL] to_date() and invalid dates

2014-01-20 Thread Adrian Klaver
On 01/20/2014 07:32 AM, Thomas Kellerer wrote: Michael Nolan, 20.01.2014 16:17: Thomas, try this: '2013-02-31'::date Thanks, I know this "works", but this can't be used if you have a non-ISO date string Hmm: test=> SELECT '2013-02-31'::date; ERROR: date/time field value out of range: "

Re: [GENERAL] to_date() and invalid dates

2014-01-20 Thread Thomas Kellerer
Michael Nolan, 20.01.2014 16:17: > Thomas, try this: > > '2013-02-31'::date Thanks, I know this "works", but this can't be used if you have a non-ISO date string -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgre

Re: [GENERAL] to_date() and invalid dates

2014-01-20 Thread Thomas Kellerer
Albe Laurenz, 20.01.2014 15:29: >> I asked this a while back already: >> >>select to_date('2013-02-31', '-mm-dd'); >> >> will not generate an error (unlike e.g. Oracle) > > This is by design. When I previously asked this question the answer as "this is based on Oracle's to_date()": http:

Re: [GENERAL] incrementing without violating a constraint

2014-01-20 Thread Adrian Klaver
On 01/20/2014 06:40 AM, Michael P. Soulier wrote: On 20/01/14 Michael P. Soulier said: This violates the uniquness constraint. Is there a way to say, turn off the constraint, run the update and then turn it back on? Hmm. This didn't work. tugdb=# SET CONSTRAINTS ALL DEFERRED; SET CONSTRAINTS

Re: [GENERAL] to_date() and invalid dates

2014-01-20 Thread Michael Nolan
Thomas, try this: '2013-02-31'::date -- Mike Nolan On Mon, Jan 20, 2014 at 7:44 AM, Thomas Kellerer wrote: > Hi, > > I asked this a while back already: > >select to_date('2013-02-31', '-mm-dd'); > > will not generate an error (unlike e.g. Oracle) > > > However in the release notes of 9

Re: [GENERAL] incrementing without violating a constraint

2014-01-20 Thread Andreas Kretschmer
"Michael P. Soulier" hat am 20. Januar 2014 um 15:33 geschrieben: > Hi, > > I have a uniqueness constraint on an integer value in a table where I would > like to mass increment all of the existing rows. > > ie. > update rules set rule_number = rule_number + 1; > > This violates the uniquness con

Re: [GENERAL] incrementing without violating a constraint

2014-01-20 Thread Michael P. Soulier
On 20/01/14 Michael P. Soulier said: > This violates the uniquness constraint. Is there a way to say, turn off the > constraint, run the update and then turn it back on? Hmm. This didn't work. tugdb=# SET CONSTRAINTS ALL DEFERRED; SET CONSTRAINTS tugdb=# update siptrunkroutingrules set rule_numb

[GENERAL] incrementing without violating a constraint

2014-01-20 Thread Michael P. Soulier
Hi, I have a uniqueness constraint on an integer value in a table where I would like to mass increment all of the existing rows. ie. update rules set rule_number = rule_number + 1; This violates the uniquness constraint. Is there a way to say, turn off the constraint, run the update and then tur

Re: [GENERAL] to_date() and invalid dates

2014-01-20 Thread Albe Laurenz
Thomas Kellerer wrote: > I asked this a while back already: > >select to_date('2013-02-31', '-mm-dd'); > > will not generate an error (unlike e.g. Oracle) This is by design. > However in the release notes of 9.2.3[1] it is mentioned that > > - Reject out-of-range dates in to_date() (

[GENERAL] to_date() and invalid dates

2014-01-20 Thread Thomas Kellerer
Hi, I asked this a while back already: select to_date('2013-02-31', '-mm-dd'); will not generate an error (unlike e.g. Oracle) However in the release notes of 9.2.3[1] it is mentioned that - Reject out-of-range dates in to_date() (Hitoshi Harada) I tried the above statement using 9

[GENERAL] Filtering queries by IP

2014-01-20 Thread Leonardo M . Ramé
Hi, I'm trying to find the cause of slow performance on some screens of an application. To do that, I would like to be able to log all the queries made by an specific IP addres, is this possible?. Regards, -- Leonardo M. Ramé Medical IT - Griensu S.A. Av. Colón 636 - Piso 8 Of. A X5000EPT -- Córd

Re: [GENERAL] Correct query to check streaming replication lag

2014-01-20 Thread Granthana Biswas
Yes we already do that. Count the number of ready wal files. Regards, Granthana On Sat, Jan 18, 2014 at 9:39 PM, Sameer Kumar wrote: > Well in that case monitoring pending wal bytes would make more sense. > > Regards > Sameer > > PS: Sent from my Mobile device. Pls ignore typo n abb >

Re: [GENERAL] using rpmbuild with PostgreSQL 9.2.6 source code

2014-01-20 Thread Boszormenyi Zoltan
2014-01-20 10:50 keltezéssel, Sameer Kumar írta: Hi, I still get issues with uuid-devel. [root@pflex75 SOURCES]# rpmbuild -ba postgresql-9.2.spec error: Failed build dependencies: uuid-devel is needed by postgresql92-9.2.6-2PGDG.el6.ppc64 On googling a bit I found that uuid-devel is

Re: [GENERAL] json_array_elements_text?

2014-01-20 Thread Marti Raudsepp
On Fri, Jan 17, 2014 at 10:20 AM, Laurence Rowe wrote: > I'm trying to unpack a json array into it's constituent text values so I can > join them to a table. I can successfully unpack json values, but am having > trouble converting these to text so I can cast them to the UUIDs needed for > the joi

Re: [GENERAL] json_array_elements_text?

2014-01-20 Thread Marti Raudsepp
On Fri, Jan 17, 2014 at 10:20 AM, Laurence Rowe wrote: > I'm trying to unpack a json array into it's constituent text values so I can > join them to a table. I can successfully unpack json values, but am having > trouble converting these to text so I can cast them to the UUIDs needed for > the joi

Re: [GENERAL] Positional parameters and question mark notation

2014-01-20 Thread Andreas Lubensky
Hi Dmitriy, I considered just doing a string replacement, however this might be potentially dangerous because in theory a query might contain a question mark as part of a string or similar. Although I'm certain it would work for us at the moment, it looks like a problem waiting to happen. Doing a

Re: [GENERAL] Positional parameters and question mark notation

2014-01-20 Thread Dmitriy Igrishin
Hey Andreas, 2014/1/20 Andreas Lubensky > Hi, > > Is there any way to make PostgreSQL support the question mark (?) > notation instead of the dollar sign ($1, $2...) for prepared statements? > Most databases use the question mark notation and we have a set of > simple queries that are supposed

[GENERAL] Positional parameters and question mark notation

2014-01-20 Thread Andreas Lubensky
Hi, Is there any way to make PostgreSQL support the question mark (?) notation instead of the dollar sign ($1, $2...) for prepared statements? Most databases use the question mark notation and we have a set of simple queries that are supposed to be portable across different database systems. So fa

Re: [GENERAL] using rpmbuild with PostgreSQL 9.2.6 source code

2014-01-20 Thread Sameer Kumar
Hi, I still get issues with uuid-devel. [root@pflex75 SOURCES]# rpmbuild -ba postgresql-9.2.spec error: Failed build dependencies: uuid-devel is needed by postgresql92-9.2.6-2PGDG.el6.ppc64 On googling a bit I found that uuid-devel is libuuid-devel on RHEL (is that the case?). I have b

Re: [GENERAL] using rpmbuild with PostgreSQL 9.2.6 source code

2014-01-20 Thread Sameer Kumar
Hi, Thanks everyone for your help! I am trying to build on ppc and also trying to play with a few other parameters e.g. segment size and pagesize. Best Regards, *Sameer Kumar | Database Consultant* *ASHNIK PTE. LTD.*101 Cecil Street, #11-11 Tong Eng Building, Singapore 069533 M : *+65 8110 035

Re: [GENERAL] using rpmbuild with PostgreSQL 9.2.6 source code

2014-01-20 Thread Devrim GÜNDÜZ
Hi, On Mon, 2014-01-20 at 17:05 +0800, Craig Ringer wrote: > Rather than attempting to build PostgreSQL packages, why not use the > existing PGDG packages from http://yum.postgresql.org/ for RHEL / > CentOS 6? I think Sameer is working on a ppc build, which we do not support (yet, at least). >

Re: [GENERAL] using rpmbuild with PostgreSQL 9.2.6 source code

2014-01-20 Thread Craig Ringer
On 01/20/2014 03:46 PM, Sameer Kumar wrote: > Hi, > > I have downloaded the tar source code of PostgreSQL and also the SPEC > file. I am trying to use rpmbuild command but I always get below error: When you mention something you downloaded, also show the URL you downloaded it from. In this case,

[GENERAL] What is the correct way to get the content of a varchar field in pgsql's source code

2014-01-20 Thread Felix . 徐
Hi all, I've learnt from the source code to open a table and scan it, like this: Relation qma = try_relation_open(qmappersta, AccessShareLock); if(qma!=NULL){ HeapScanDesc scan= heap_beginscan(qma,SnapshotNow,0,NULL); HeapTuple tup; TupleDesc tupDesc= RelationGetDescr(qma); Datum *va

Re: [GENERAL] [HACKERS] using rpmbuild with PostgreSQL 9.2.6 source code

2014-01-20 Thread Devrim GÜNDÜZ
Hi, On Mon, 2014-01-20 at 15:46 +0800, Sameer Kumar wrote: > I have downloaded the tar source code of PostgreSQL and also the SPEC file. > I am trying to use rpmbuild command but I always get below error: > > error: Failed build dependencies: > uuid-devel is needed by postgresql92-9.2.6

Re: [GENERAL] [HACKERS] using rpmbuild with PostgreSQL 9.2.6 source code

2014-01-20 Thread Sameer Kumar
> you need installed devel packages > > > I tried to install these packages (uuid-devel and systemd-unit) but yum can not locate these packages. I tried to install selinux-policy but I found out that selinux-policy 3.7.19 is already installed and is the latest package available in Red Hat repositor