Re: [GENERAL] to know what columns are getting updated

2013-07-30 Thread Luca Ferrari
On Tue, Jul 30, 2013 at 6:05 AM, Sajeev Mayandi sajeev_maya...@symantec.com wrote: Hi, I have bunch of rules created for tables to implement upsert functionality. My problem is our tables gets updated from multiple places , non –necessarily with the same no of columns. I want to figure out

Re: [GENERAL] how to get UPDATEXML function in postgresql as it works in oracle

2013-07-30 Thread Raghavendra
On Tue, Jul 30, 2013 at 9:51 AM, saritha N saritha.0...@gmail.com wrote: Thanks for your reply Raghavendra, Thanks for the update. Request to mark postgresql group email while replying so it will help much if other's have better idea as well if any correction in my test case. Whatever you

Re: [GENERAL] Fwd: corrupted files

2013-07-30 Thread raghu ram
On Tue, Jul 30, 2013 at 4:07 AM, Klaus Ita kl...@worstofall.com wrote: Sorry for cross-posting, i read that pg-bug was not the right place for this email Hi list! depressed me gets error messages like these: 2013-07-29 20:57:09 UTC xaxos_mailer%xaxos_de ERROR: could not access status of

[GENERAL] Recovery failure

2013-07-30 Thread Klaus Ita
Hi List! On an originally designated hot_standby that had been not so hot for the last 24h i tried to replay the wal_files left over from a (seemingly corrupted) master server [missing clog... ]. I get this output: /etc/postgresql/9.1/main/postgresql.conf 584L, 19942C written

Re: [GENERAL] Fwd: corrupted files

2013-07-30 Thread Klaus Ita
Hi! Thank you, I actually tried that and it seems that only lead to even more corrupted data. I am currently trying to recover the 'hot-standby' host that is also unhappy about one of the wal_files. I am looking at the wal with less and see only data i do not care about in it (mostly

Re: [GENERAL] Trigger and deadlock

2013-07-30 Thread Loïc Rollus
Hi, It's ok. Before the insert, The foreign key constraint locked the row. If transaction A and B lock the row with FK, before doing UPDATE, they were stuck. I found a solution by creating an before insert trigger with a simple SELECT FROM UPDATE on the row. Loïc 2013/7/29 Loïc Rollus

Re: [GENERAL] Event trigger information accessibility on plpgsql

2013-07-30 Thread Javier de la Torre
Wow Andrew, Great work! Lot of ideas to pick from. Now, like you said it looks rather complicated and fragile. We will take a look at creating a custom C trigger to see if we can have something easier. Pity there was no agreement to just expose the object that fired the trigger. Best, On

Re: [GENERAL] Trigger and deadlock

2013-07-30 Thread Albe Laurenz
Loïc Rollus wrote: It's ok. Before the insert, The foreign key constraint locked the row. If transaction A and B lock the row with FK, before doing UPDATE, they were stuck. I found a solution by creating an before insert trigger with a simple SELECT FROM UPDATE on the row. You mean SELECT

[GENERAL] Reddwarf for PostgreSQL?

2013-07-30 Thread Tatsuo Ishii
Hi, There is an opensource DaaS project called RedDwarf. It seems the project is only for MySQL. Does anybody know if the project will support PostgreSQL in the future? -- Tatsuo Ishii SRA OSS, Inc. Japan English: http://www.sraoss.co.jp/index_en.php Japanese: http://www.sraoss.co.jp -- Sent

Re: [GENERAL] to_char with locale decimal separator

2013-07-30 Thread Ingmar Brouns
On Mon, Jul 29, 2013 at 3:12 PM, Ingmar Brouns swi...@gmail.com wrote: On Mon, Jul 29, 2013 at 1:24 PM, Ingmar Brouns swi...@gmail.com wrote: Hi, I need to convert some numerical values to text using the decimal separator that corresponds to the current locale. However, I do not want to lose

[GENERAL] Fwd: Trigger on VIEW not firing

2013-07-30 Thread Massimo Costantini
Hi, I have a problem with Triggers on VIEW: suppose I have: CREATE TABLE work ( id integer NOT NULL, work TEXT, worktype TEXT ); CREATE VIEW worksub AS SELECT FROM work WHERE worktype='subordinate'; CREATE OR REPLACE FUNCTION wrk_view() RETURNS TRIGGER AS $wrk_tg$ BEGIN

Re: [GENERAL] Fwd: Trigger on VIEW not firing

2013-07-30 Thread Ian Lawrence Barwick
2013/7/30 Massimo Costantini massimo.costant...@gmail.com: Hi, I have a problem with Triggers on VIEW: suppose I have: CREATE TABLE work ( id integer NOT NULL, work TEXT, worktype TEXT ); CREATE VIEW worksub AS SELECT FROM work WHERE worktype='subordinate'; CREATE OR REPLACE

Re: [GENERAL] Fwd: Trigger on VIEW not firing

2013-07-30 Thread Beena Emerson
The trigger is on the view and fires when you query the view: # DELETE FROM worksub; NOTICE: UPDATE VIEW FROM: worksub OPERATION: DELETE ERROR: control reached end of trigger procedure without RETURN CONTEXT: PL/pgSQL function wrk_view() On Tue, Jul 30, 2013 at 6:10 PM, Massimo Costantini

Re: [GENERAL] Fwd: Trigger on VIEW not firing

2013-07-30 Thread Massimo Costantini
Thisi is my real situation, can I do this: CREATE TABLE alarm( name text, id integer, type text, init timestamp, fired timestamp, end timestamp, user test ); CREATE TABLE car ( id integer, type text, speed double ); CREATE VIEW speedv AS SELECT * FROM car WHERE speed100; CREATE OR

Re: [GENERAL] Fwd: Trigger on VIEW not firing

2013-07-30 Thread Beena Emerson
It works fine if you insert into the view: =# INSERT INTO speedv VALUES (1, 'test', 100); INSERT 0 1 =# SELECT * FROM alarm; name | id | type |init| fired | t_end | t_user --++---++---+---+ test | 0 | SPEED |

Re: [GENERAL] Fwd: Trigger on VIEW not firing

2013-07-30 Thread Beena Emerson
Hi again, IIUC you want to update the alarm table only when the speed limit is above 100. You cannot achieve it by the view and triggers you have written here because the trigger will be fired even for values 100 =# INSERT INTO speedv VALUES (1, 'test', 10); INSERT 0 1 =# SELECT * FROM speedv;

Re: [GENERAL] Fwd: Trigger on VIEW not firing

2013-07-30 Thread Massimo Costantini
ok, thank to all On Tue, Jul 30, 2013 at 3:30 PM, Beena Emerson memissemer...@gmail.comwrote: Hi again, IIUC you want to update the alarm table only when the speed limit is above 100. You cannot achieve it by the view and triggers you have written here because the trigger will be fired

Re: [GENERAL] to_char with locale decimal separator

2013-07-30 Thread Adrian Klaver
On 07/30/2013 03:03 AM, Ingmar Brouns wrote: On Mon, Jul 29, 2013 at 3:12 PM, Ingmar Brouns swi...@gmail.com wrote: anyone? Giving a locale corresponding textual representation of a numerical value keeping the exact nr of decimal digits must be a fairly common use case. Would it be an idea

[GENERAL] Alter table never finishes

2013-07-30 Thread Leonardo M . Ramé
Hi, I need to do an alter table on a small table (~300 records), but it never ends. It may be because there are clients using that table. How can I force disconnect all clients to let me alter that table?. Regards, -- Leonardo M. Ramé Medical IT - Griensu S.A. Av. Colón 636 - Piso 8 Of. A

Re: [GENERAL] Fwd: corrupted files

2013-07-30 Thread bricklen
On Mon, Jul 29, 2013 at 11:50 PM, Klaus Ita kl...@worstofall.com wrote: I am trying to remember, there was a tool that plotted the contents of the wal_files in a more readable format ... xlogdump? https://github.com/snaga/xlogdump

Re: [GENERAL] Alter table never finishes

2013-07-30 Thread bricklen
On Tue, Jul 30, 2013 at 7:50 AM, Leonardo M. Ramé l.r...@griensu.comwrote: Hi, I need to do an alter table on a small table (~300 records), but it never ends. It may be because there are clients using that table. How can I force disconnect all clients to let me alter that table?. If you are

Re: [GENERAL] Fwd: corrupted files

2013-07-30 Thread Klaus Ita
Yes, that's it! thank you! It turned out that really there was a corruption in the main pg server which was 'virally' propagated to 1. streaming replica 1. replaying wal receiver 1. old backup that tried to replay the wal's I really thought with a master and 3 backups i'd be safe. lg,k On

Re: [GENERAL] Fwd: corrupted files

2013-07-30 Thread bricklen
On Tue, Jul 30, 2013 at 8:18 AM, Klaus Ita kl...@worstofall.com wrote: thank you! It turned out that really there was a corruption in the main pg server which was 'virally' propagated to 1. streaming replica 1. replaying wal receiver 1. old backup that tried to replay the wal's I really

Re: [GENERAL] to_char with locale decimal separator

2013-07-30 Thread Ingmar Brouns
On Tue, Jul 30, 2013 at 4:42 PM, Adrian Klaver adrian.kla...@gmail.com wrote: On 07/30/2013 03:03 AM, Ingmar Brouns wrote: On Mon, Jul 29, 2013 at 3:12 PM, Ingmar Brouns swi...@gmail.com wrote: anyone? Giving a locale corresponding textual representation of a numerical value keeping the

Re: [GENERAL] Fwd: corrupted files

2013-07-30 Thread Klaus Ita
i guess logical, caused by whatever. i really cannot say, the wal files all *look* ok, still, they lead to a situation that's a definite dead end. we did have a hard-drive failure (one in 13) at the time, but due to raid5 + hot spare no data should have been corrupted. i mean it's an lsi

Re: [GENERAL] How get column-wise table info from an arbitrary query?

2013-07-30 Thread sidthegeek
I really dislike ambiguous column names across tables in a database. Use the convention [tablename]_id for each id so every column name is self describing. That way you can: select * from providers inner join provider_types using(provider_type_id); No need for table aliases, column aliases and

Re: [GENERAL] [BUGS] Incorrect response code after XA recovery

2013-07-30 Thread Tom Jenkinson
Hi Alban, I stripped down the code to a raw XA example using the latest postgres driver available in maven central. It demonstrates that regardless of what the codebase might suggest, it is certainly the case that postgres is returning XAER_RMERR in the scenario where the resource manager no

Re: [GENERAL] Alter table never finishes

2013-07-30 Thread Giuseppe Broccolo
How can I force disconnect all clients to let me alter that table?. Regards, There are two ways: the first|is based on pg_terminate_backend() function and 'pg_stat_activity' catalog |||to kill idle processes. So in a psql session type (tried on PostgreSQL 8.4): ==# SELECT procpid, (SELECT

Re: [GENERAL] [BUGS] Incorrect response code after XA recovery

2013-07-30 Thread Alvaro Herrera
Tom Jenkinson escribió: Hi Alban, I stripped down the code to a raw XA example using the latest postgres driver available in maven central. It demonstrates that regardless of what the codebase might suggest, it is certainly the case that postgres is returning XAER_RMERR in the scenario

Re: [GENERAL] Alter table never finishes

2013-07-30 Thread Leonardo M . Ramé
On 2013-07-30 17:56:16 +0200, Giuseppe Broccolo wrote: How can I force disconnect all clients to let me alter that table?. Regards, There are two ways: the first|is based on pg_terminate_backend() function and 'pg_stat_activity' catalog |||to kill idle processes. So in a psql session type

Re: [GENERAL] Alter table never finishes

2013-07-30 Thread bricklen
On Tue, Jul 30, 2013 at 10:07 AM, Leonardo M. Ramé l.r...@griensu.comwrote: select pg_cancel_backend(pid) from pg_stat_activity where pid pg_backend_pid(); And it returned this: pg_cancel_backend --- t t (2 rows) But when I execute my update table command, it still

Re: [GENERAL] Alter table never finishes

2013-07-30 Thread Leonardo M . Ramé
On 2013-07-30 10:26:39 -0700, bricklen wrote: On Tue, Jul 30, 2013 at 10:07 AM, Leonardo M. Ramé l.r...@griensu.comwrote: select pg_cancel_backend(pid) from pg_stat_activity where pid pg_backend_pid(); And it returned this: pg_cancel_backend --- t t (2

Re: [GENERAL] Alter table never finishes

2013-07-30 Thread bricklen
On Tue, Jul 30, 2013 at 10:29 AM, Leonardo M. Ramé l.r...@griensu.comwrote: select pg_cancel_backend(pid) from pg_stat_activity where pid pg_backend_pid(); As Giuseppe mentioned, if you need to kill not just the queries, but the connection as well, you could use: select

Re: [GENERAL] Alter table never finishes

2013-07-30 Thread Alvaro Herrera
Leonardo M. Ramé escribió: Sorry bricklen, I've killed all idle connections with kill -9 PID, then I was able to execute the alter table. I don't think that was such a great idea. Once you killed the first one, postmaster terminated all other server processes, run recovery, and restarted

Re: [GENERAL] Reddwarf for PostgreSQL?

2013-07-30 Thread John R Pierce
On 7/30/2013 12:38 AM, Tatsuo Ishii wrote: There is an opensource DaaS project called RedDwarf. It seems the project is only for MySQL. Does anybody know if the project will support PostgreSQL in the future? you'd more likely get a useful answer from that project's mail list or forum or

Re: [GENERAL] Alter table never finishes

2013-07-30 Thread bricklen
On Tue, Jul 30, 2013 at 10:34 AM, bricklen brick...@gmail.com wrote: Sorry bricklen, I've killed all idle connections with kill -9 PID, then I was able to execute the alter table. No problem. btw, I meant 'no need to apologize that the queries were gone', not that I recommend kill -9 (I

Re: [GENERAL] How get column-wise table info from an arbitrary query?

2013-07-30 Thread Gavin Flower
I use 'id' for the primary key, and [tablename]_id for each foreign key, I always qualify my column references in SQL, but I would never use SELECT * when selecting from more than one table. Cheers, Gavin On 30/07/13 21:41, sidthegeek wrote: I really dislike ambiguous column names across

Re: [GENERAL] to_char with locale decimal separator

2013-07-30 Thread Adrian Klaver
On 07/30/2013 08:34 AM, Ingmar Brouns wrote: Thanks for your time, appreciate it! As a dirty alternative, you could also do something like: select translate(5.000::text,'.',substr(to_char(.0),2,1)); Not so nice, but would work. Though I still feel there should be a more elegant of doing

Re: [GENERAL] How get column-wise table info from an arbitrary query?

2013-07-30 Thread David Johnston
Gavin Flower-2 wrote I use 'id' for the primary key, and [tablename]_id for each foreign key, I always qualify my column references in SQL, but I would never use SELECT * when selecting from more than one table. Cheers, Gavin On 30/07/13 21:41, sidthegeek wrote: I really dislike

Re: [GENERAL] How get column-wise table info from an arbitrary query?

2013-07-30 Thread Merlin Moncure
On Tue, Jul 30, 2013 at 4:57 PM, David Johnston pol...@yahoo.com wrote: I'm in the prefix the id column camp. I do not use ORM middle-ware so that may be a reason I do not have any difficulties but one of the big advantages to table-prefixing generic column names is that you can then make the

Re: [GENERAL] How get column-wise table info from an arbitrary query?

2013-07-30 Thread Gavin Flower
On 31/07/13 09:57, David Johnston wrote: Gavin Flower-2 wrote I use 'id' for the primary key, and [tablename]_id for each foreign key, I always qualify my column references in SQL, but I would never use SELECT * when selecting from more than one table. Cheers, Gavin On 30/07/13 21:41,

Re: [GENERAL] How get column-wise table info from an arbitrary query?

2013-07-30 Thread David Johnston
Gavin Flower-2 wrote Also, since I know what table I'm looking at, it seemed redundant to also specify the table name as part of the table's primary key! I find this quite the opposite approach. I know I am likely to use a primary key as a foreign key so making it externally friendly makes

Re: [GENERAL] Snapshot backups

2013-07-30 Thread James Sewell
I understand what you are saying, and I understand how the backup_label works - but I still don't understand why the pg_start and pg_stop commands are REQUIRED when doing a snapshot backup to ensure data integrity. Surely not using them and restoring a snapshot is the same as starting after a

[GENERAL] more fun with building 9.3beta2

2013-07-30 Thread Rob Sargent
I'm not getting the xml2 and uuid-ossp control files delivered to the extension directory I've moved to a CentOS box (and dropped pam): cat /etc/system-release CentOS release 6.4 (Final) uname -a Linux co-app-jl-d001 2.6.32-358.11.1.el6.x86_64 #1 SMP Wed Jun 12 03:34:52 UTC 2013 x86_64 x86_64

Re: [GENERAL] more fun with building 9.3beta2

2013-07-30 Thread Adrian Klaver
On 07/30/2013 07:15 PM, Rob Sargent wrote: I'm not getting the xml2 and uuid-ossp control files delivered to the extension directory I've moved to a CentOS box (and dropped pam): cat /etc/system-release CentOS release 6.4 (Final) uname -a Linux co-app-jl-d001 2.6.32-358.11.1.el6.x86_64 #1 SMP

Re: [GENERAL] Snapshot backups

2013-07-30 Thread Jeff Janes
On Tuesday, July 30, 2013, James Sewell wrote: I understand what you are saying, and I understand how the backup_label works - but I still don't understand why the pg_start and pg_stop commands are REQUIRED when doing a snapshot backup to ensure data integrity. Surely not using them and

Re: [GENERAL] Snapshot backups

2013-07-30 Thread Tom Lane
Jeff Janes jeff.ja...@gmail.com writes: On Tuesday, July 30, 2013, James Sewell wrote: I understand what you are saying, and I understand how the backup_label works - but I still don't understand why the pg_start and pg_stop commands are REQUIRED when doing a snapshot backup to ensure data