Re: [GENERAL] Dynamic SQL - transition from ms to pg

2014-01-06 Thread Pavel Stehule
Hello 2014/1/6 Erik Darling edarlin...@gmail.com Hi, I've been developing for MS SQL around four years. I'm starting out with some work in Postgresql next week, and I'd like to know if there's any equivalent way to do something like this (from my word press)

[GENERAL] WAL archive cleanup om master

2014-01-06 Thread Martijn van Oosterhout
Hoi, I've setup a up WAL shipping configuration as described in the wiki. On the master I have: archive_mode= on archive_command = 'cp %p /path_to/archive/%f' and on the slave in the recovery.conf I have: archive_cleanup_command = 'pg_archivecleanup /path/to/archive/ %r' restore_command =

[GENERAL] postgres_fdw foreign table performance Issue

2014-01-06 Thread Shuwn Yuan Tee
We have client databases in 3 different region in the world, namely: cr_master, mx_master mlt_master db. These 3 databases have exactly the same structure, with different subset of client data. For reporting purpose, we aggregate these 3 db to single collector, using Bucardo replication.

[GENERAL] New to postgresql - Do I have to be a superuser to be able to create a database?

2014-01-06 Thread gromitracer
Hello all. I am more accustomed in doing things the Oracle way and I am trying to get a hold postgres :) Below are my roles/users and their attributes. Posgresql version: 9.2 Role name |Attributes | Member of

Re: [GENERAL] Dynamic SQL - transition from ms to pg

2014-01-06 Thread Erik Darling
Thank you Pavel. That's exactly what I needed to get started. On Jan 6, 2014 3:25 AM, Pavel Stehule pavel.steh...@gmail.com wrote: Hello 2014/1/6 Erik Darling edarlin...@gmail.com Hi, I've been developing for MS SQL around four years. I'm starting out with some work in Postgresql next

[GENERAL] Do I have to free storage in a UDF if I raise an error?

2014-01-06 Thread Pfuntner, John
If I've done a palloc() to get storage inside a user-defined function and raise an error using ereport(), should I be using pfree() to release the storage before the ereport()? Consider this example in C: PG_FUNCTION_INFO_V1(Example); Datum Example(PG_FUNCTION_ARGS) { VarChar*

Re: [GENERAL] file system level backup

2014-01-06 Thread zach cruise
I am not sure if you have already answered it and I have somehow missed it: - Are these 'a' and 'b' on two different servers? ( I think they are on different servers) yes - Did you stop the server on 'b' before you replaced the files and attempted a startup? yes thanks. it doesn't help. i

Re: [GENERAL] WAL archive cleanup om master

2014-01-06 Thread Adrian Klaver
On 01/06/2014 03:18 AM, Martijn van Oosterhout wrote: Hoi, I've setup a up WAL shipping configuration as described in the wiki. On the master I have: archive_mode= on archive_command = 'cp %p /path_to/archive/%f' and on the slave in the recovery.conf I have: archive_cleanup_command =

Re: [GENERAL] How to check for pending CancelRequest from C/C++ function

2014-01-06 Thread Tom Lane
Stephen Woodbridge wood...@swoodbridge.com writes: I writing some functions for postgresql extension in C/C++ and I would like to be able to check for a pending CancelRequest from the frontend so I can take appropriate action to honor this request. Put CHECK_FOR_INTERRUPTS(); in some

Re: [GENERAL] WAL archive cleanup om master

2014-01-06 Thread Martijn van Oosterhout
On Mon, Jan 06, 2014 at 07:16:25AM -0800, Adrian Klaver wrote: On 01/06/2014 03:18 AM, Martijn van Oosterhout wrote: Hoi, I've setup a up WAL shipping configuration as described in the wiki. On the master I have: archive_mode= on archive_command = 'cp %p /path_to/archive/%f' and

Re: [GENERAL] WAL archive cleanup om master

2014-01-06 Thread Adrian Klaver
On 01/06/2014 03:18 AM, Martijn van Oosterhout wrote: Hoi, I've setup a up WAL shipping configuration as described in the wiki. On the master I have: archive_mode= on archive_command = 'cp %p /path_to/archive/%f' and on the slave in the recovery.conf I have: archive_cleanup_command =

Re: [GENERAL] Planning error in dynamic string creation in plpgsql

2014-01-06 Thread David Johnston
Adrian Klaver-3 wrote In the real function I'm writing, the columns to be used in the string being created are pulled from a configuration table, so their types could be anything. So casting the quote_literal() calls is not really an option here. Any help would be appreciated. Cast

Re: [GENERAL] Do I have to free storage in a UDF if I raise an error?

2014-01-06 Thread Stephen Woodbridge
On 1/6/2014 10:00 AM, Pfuntner, John wrote: If I've done a palloc() to get storage inside a user-defined function and raise an error using ereport(), should I be using pfree() to release the storage before the ereport()? Consider this example in C: PG_FUNCTION_INFO_V1(Example);

Re: [GENERAL] WAL archive cleanup om master

2014-01-06 Thread Adrian Klaver
On 01/06/2014 07:35 AM, Martijn van Oosterhout wrote: On Mon, Jan 06, 2014 at 07:16:25AM -0800, Adrian Klaver wrote: On 01/06/2014 03:18 AM, Martijn van Oosterhout wrote: Hoi, I'm not sure what you mean, isn't this the recommended way of doing things? The configuration comes from here:

Re: [GENERAL] Planning error in dynamic string creation in plpgsql

2014-01-06 Thread Adrian Klaver
On 01/06/2014 07:42 AM, David Johnston wrote: Adrian Klaver-3 wrote In the real function I'm writing, the columns to be used in the string being created are pulled from a configuration table, so their types could be anything. So casting the quote_literal() calls is not really an option here.

Re: [GENERAL] How to check for pending CancelRequest from C/C++ function

2014-01-06 Thread Stephen Woodbridge
On 1/6/2014 10:32 AM, Tom Lane wrote: Stephen Woodbridge wood...@swoodbridge.com writes: I writing some functions for postgresql extension in C/C++ and I would like to be able to check for a pending CancelRequest from the frontend so I can take appropriate action to honor this request. Put

Re: [GENERAL] WAL archive cleanup om master

2014-01-06 Thread Martijn van Oosterhout
On Mon, Jan 06, 2014 at 08:17:37AM -0800, Adrian Klaver wrote: On 01/06/2014 07:35 AM, Martijn van Oosterhout wrote: On Mon, Jan 06, 2014 at 07:16:25AM -0800, Adrian Klaver wrote: On 01/06/2014 03:18 AM, Martijn van Oosterhout wrote: Hoi, I'm not sure what you mean, isn't this the

Re: [GENERAL] file system level backup

2014-01-06 Thread Adrian Klaver
On 01/06/2014 07:03 AM, zach cruise wrote: I am not sure if you have already answered it and I have somehow missed it: - Are these 'a' and 'b' on two different servers? ( I think they are on different servers) yes - Did you stop the server on 'b' before you replaced the files and attempted a

Re: [GENERAL] Planning error in dynamic string creation in plpgsql

2014-01-06 Thread Keith Fiske
David, That seems to have fixed it! I was going down a path of grabbing the column's type from pg_attribute and trying to work from there, but was still having some of the same issues. Thanks everyone else that replied as well! -- Keith Fiske Database Administrator OmniTI Computer Consulting,

[GENERAL] How to check for pending CancelRequest from C/C++ function

2014-01-06 Thread Stephen Woodbridge
Hi all, I writing some functions for postgresql extension in C/C++ and I would like to be able to check for a pending CancelRequest from the frontend so I can take appropriate action to honor this request. 1. How to I check if a request is pending? 2. What is the appropriate action? I

Re: [GENERAL] WAL archive cleanup om master

2014-01-06 Thread Adrian Klaver
On 01/06/2014 08:45 AM, Martijn van Oosterhout wrote: On Mon, Jan 06, 2014 at 08:17:37AM -0800, Adrian Klaver wrote: On 01/06/2014 07:35 AM, Martijn van Oosterhout wrote: On Mon, Jan 06, 2014 at 07:16:25AM -0800, Adrian Klaver wrote: On 01/06/2014 03:18 AM, Martijn van Oosterhout wrote: Hoi,

Re: [GENERAL] How to check for pending CancelRequest from C/C++ function

2014-01-06 Thread Tom Lane
Stephen Woodbridge wood...@swoodbridge.com writes: On 1/6/2014 10:32 AM, Tom Lane wrote: Put CHECK_FOR_INTERRUPTS(); in some suitably safe place. So if I need to clean up then I should check do something like: if (InterruptPending) { /* cleanup here */ ProcessInterrupts(); }

Re: [GENERAL] returning json data row from json query

2014-01-06 Thread Merlin Moncure
On Sat, Jan 4, 2014 at 1:44 AM, David Johnston pol...@yahoo.com wrote: john.tiger wrote select * from users where jsondata-'username' = 'jdoe' works but returns field names, etc besides the data row.how can we get json data back ? select row_to_json from users where

[GENERAL] EMC SRDF technology for creating replication with Postgresql?

2014-01-06 Thread AI Rumman
Hi, Did any of here use EMC SRDF technology for creating replication with Postgresql? Thanks.

Re: [GENERAL] New to postgresql - Do I have to be a superuser to be able to create a database?

2014-01-06 Thread Jeff Janes
On Sun, Jan 5, 2014 at 7:32 PM, gromitracer george_m...@yahoo.com wrote: Hello all. I am more accustomed in doing things the Oracle way and I am trying to get a hold postgres :) Below are my roles/users and their attributes. Posgresql version: 9.2 Role name |Attributes

Re: [GENERAL] authentication failure

2014-01-06 Thread Tom Lane
Jayadevan M maymala.jayade...@gmail.com writes: I am able to login as postgres with password from the same machine. So it is not an expiry issue (as you too concluded). Output from strace is about 500 lines. I am pasting what I feel may be relevant. I hope this will be useful. Well, this is

Re: [GENERAL] authentication failure

2014-01-06 Thread Rob Sargent
On 01/06/2014 02:42 PM, Tom Lane wrote: Jayadevan M maymala.jayade...@gmail.com writes: I am able to login as postgres with password from the same machine. So it is not an expiry issue (as you too concluded). Output from strace is about 500 lines. I am pasting what I feel may be relevant. I

[GENERAL] Add PK constraint to a Unique Index via updating system catalogs?

2014-01-06 Thread CS DBA
Hi All; We have a few very large tables with unique indexes on a column but the column is not defined as the Primary Key. Can we add a PK constraint via updates to the system catalogs so we can avoid the lengthy checks that would take place if we ran alter table add constraint primary

Re: [GENERAL] Add PK constraint to a Unique Index via updating system catalogs?

2014-01-06 Thread Thomas Kellerer
CS DBA wrote on 06.01.2014 23:30: We have a few very large tables with unique indexes on a column but the column is not defined as the Primary Key. Can we add a PK constraint via updates to the system catalogs so we can avoid the lengthy checks that would take place if we ran alter table add

[GENERAL] Sudden slow down and spike in system CPU causes max_connections to get exhausted

2014-01-06 Thread Anand Kumar, Karthik
Hi, We run postgres 9.1.11, on Centos 6.3, and an ext2 filesystem Everything will run along okay, and every few hours, for about a couple of minutes, postgres will slow way down. A select 1 query takes between 10 and 15 seconds to run, and the box in general gets lethargic. This causes a pile

Re: [GENERAL] Sudden slow down and spike in system CPU causes max_connections to get exhausted

2014-01-06 Thread John R Pierce
On 1/6/2014 5:06 PM, Anand Kumar, Karthik wrote: We run postgres 9.1.11, on Centos 6.3, and an ext2 filesystem please tell me thats a typo, and you're using ext4, or at least ext3. We do typically have a lot of idle connections (1500 connections total, over a 1000 idle at any given time).

[GENERAL] replicate per tablespace

2014-01-06 Thread Andy Colson
Here's an odd question. Kind of an in the future thing. I have two db's on two smaller boxes I'd like to combine to one big box. But one db is replicated and the other doesn't need it. I know currently you must replicate the entire cluster. I was just wondering, would it be a possible way

Re: [GENERAL] Sudden slow down and spike in system CPU causes max_connections to get exhausted

2014-01-06 Thread Tom Lane
Anand Kumar, Karthik karthik.anandku...@classmates.com writes: We run postgres 9.1.11, on Centos 6.3, and an ext2 filesystem Everything will run along okay, and every few hours, for about a couple of minutes, postgres will slow way down. A select 1 query takes between 10 and 15 seconds to

Re: [GENERAL] Sudden slow down and spike in system CPU causes max_connections to get exhausted

2014-01-06 Thread John R Pierce
On 1/6/2014 5:06 PM, Anand Kumar, Karthik wrote: We run postgres 9.1.11, on Centos 6.3, and an ext2 filesystem also, centos 6.3 is a couple year old release, you really should `yum update` and get the latest centos 6.everything. been lots and lots of fixes between 6.3 and now (6.5 was the

Re: [GENERAL] replicate per tablespace

2014-01-06 Thread Keith Fiske
On Mon, Jan 6, 2014 at 9:22 PM, Andy Colson a...@squeakycode.net wrote: Here's an odd question. Kind of an in the future thing. I have two db's on two smaller boxes I'd like to combine to one big box. But one db is replicated and the other doesn't need it. I know currently you must