Re: [GENERAL] Atomicity of INSERT INTO ... SELECT ... WHERE NOT EXISTS ...

2014-08-27 Thread Craig Ringer
On 08/28/2014 06:22 AM, Jim Garrison wrote: > Given (pseudocode) > > CREATE TABLE kvstore ( > k varchar primary key, > v varchar); > > CREATE OR REPLACE FUNCTION store_key_value_pair(k varchar, v varchar) > returns boolean as $$ > BEGIN > INSERT INTO kvstore (k,

Re: [GENERAL] WAL receive process dies

2014-08-27 Thread Craig Ringer
On 08/28/2014 09:39 AM, Patrick Krecker wrote: > We have a periodic network connectivity issue (unrelated to Postgres) > that is causing the replication to fail. > > We are running Postgres 9.3 using streaming replication. We also have > WAL archives available to be replayed with restore_command.

[GENERAL] WAL receive process dies

2014-08-27 Thread Patrick Krecker
We have a periodic network connectivity issue (unrelated to Postgres) that is causing the replication to fail. We are running Postgres 9.3 using streaming replication. We also have WAL archives available to be replayed with restore_command. Typically when I bring up a slave it copies over WAL arch

Re: [GENERAL] Atomicity of INSERT INTO ... SELECT ... WHERE NOT EXISTS ...

2014-08-27 Thread Jerry Sievers
Jim Garrison writes: > Given (pseudocode) > > CREATE TABLE kvstore ( > k varchar primary key, > v varchar); > > CREATE OR REPLACE FUNCTION store_key_value_pair(k varchar, v varchar) > returns boolean as $$ > BEGIN > INSERT INTO kvstore (k, v) > SELECT :k,

Re: [GENERAL] how to query against nested hstore data type

2014-08-27 Thread Huang, Suya
-Original Message- From: Adrian Klaver [mailto:adrian.kla...@aklaver.com] Sent: Wednesday, August 27, 2014 12:42 PM To: Huang, Suya; pgsql-general@postgresql.org Subject: Re: [GENERAL] how to query against nested hstore data type On 08/26/2014 06:50 PM, Huang, Suya wrote: > > > -Origi

Re: [GENERAL] Atomicity of INSERT INTO ... SELECT ... WHERE NOT EXISTS ...

2014-08-27 Thread David G Johnston
Jim Garrison wrote > Given (pseudocode) > > CREATE TABLE kvstore ( > k varchar primary key, > v varchar); > > CREATE OR REPLACE FUNCTION store_key_value_pair(k varchar, v varchar) > returns boolean as $$ > BEGIN > INSERT INTO kvstore (k, v) > SELECT :k, :v

Re: [GENERAL] UPDATE table: Syntax to Remove Terminal '\n' [RESOLVED]

2014-08-27 Thread Rich Shepard
On Wed, 27 Aug 2014, Jeff Ross wrote: You want the E in front of the entire string, not just before the \n. select 'Use Discover: ' || E'\t' || 'Yes' || E'\n' Jeff, That did the trick. Turns out that 202 of 204 rows had the newline! The syntax that worked: update benthos set stream = 'Sta

Re: [GENERAL] UPDATE table: Syntax to Remove Terminal '\n'

2014-08-27 Thread Ian Barwick
On 14/08/28 8:04, Ian Barwick wrote: > On 14/08/28 7:31, Rich Shepard wrote: >> I have some rows in a table where a column attribute has a newline (\n) >> appended to the string. How do I represent that newline character in a SQL >> statement using psql? >> >> I've tried adding E'\n' to the end

Re: [GENERAL] UPDATE table: Syntax to Remove Terminal '\n'

2014-08-27 Thread Ian Barwick
On 14/08/28 7:31, Rich Shepard wrote: > I have some rows in a table where a column attribute has a newline (\n) > appended to the string. How do I represent that newline character in a SQL > statement using psql? > > I've tried adding E'\n' to the end of the string but that doesn't work. > >

[GENERAL] UPDATE table: Syntax to Remove Terminal '\n'

2014-08-27 Thread Rich Shepard
I have some rows in a table where a column attribute has a newline (\n) appended to the string. How do I represent that newline character in a SQL statement using psql? I've tried adding E'\n' to the end of the string but that doesn't work. Here's what I see when I select distinct for that

[GENERAL] Atomicity of INSERT INTO ... SELECT ... WHERE NOT EXISTS ...

2014-08-27 Thread Jim Garrison
Given (pseudocode) CREATE TABLE kvstore ( k varchar primary key, v varchar); CREATE OR REPLACE FUNCTION store_key_value_pair(k varchar, v varchar) returns boolean as $$ BEGIN INSERT INTO kvstore (k, v) SELECT :k, :v WHERE NOT EXISTS (select 1 from kv

Re: [GENERAL] error restarting DB

2014-08-27 Thread Adrian Klaver
On 08/27/2014 02:19 PM, John R Pierce wrote: On 8/27/2014 2:17 PM, Prabhjot Sheena wrote: Database postgresql 8.4 i shutdown the database and restarted database and now its not starting and i m getting this error [caesius@dbtest05 pg_log]$ 2014-08-27 14:14:24 PDT FATAL: database files are i

Re: [GENERAL] error restarting DB

2014-08-27 Thread John R Pierce
On 8/27/2014 2:17 PM, Prabhjot Sheena wrote: Database postgresql 8.4 i shutdown the database and restarted database and now its not starting and i m getting this error [caesius@dbtest05 pg_log]$ 2014-08-27 14:14:24 PDT FATAL: database files are incompatible with server 2014-08-27 14:14:24

[GENERAL] error restarting DB

2014-08-27 Thread Prabhjot Sheena
Database postgresql 8.4 i shutdown the database and restarted database and now its not starting and i m getting this error [caesius@dbtest05 pg_log]$ 2014-08-27 14:14:24 PDT FATAL: database files are incompatible with server 2014-08-27 14:14:24 PDT DETAIL: The database cluster was initiali

Re: [GENERAL] Deletion

2014-08-27 Thread Adrian Klaver
On 08/27/2014 11:59 AM, Ramesh T wrote: In oracle I ran the deletion script to clean up the particular database using custid.custid is the parameter .&&1 is used in the oracle Inthe same way tried but $1 not possible ?but using function is possible is their any problem with fun to Clean the data

Re: [GENERAL] Deletion

2014-08-27 Thread Pavel Stehule
Hi psql variables has different format and its is not directly related to psql options. But you can do: [pavel@localhost ~]$ psql postgres --set=myproname=upper psql (9.5devel) Type "help" for help. postgres=# select proname, prosrc from pg_proc where proname = :'myproname'; proname | prosrc

Re: [GENERAL] Deletion

2014-08-27 Thread John R Pierce
On 8/27/2014 11:59 AM, Ramesh T wrote: In oracle I ran the deletion script to clean up the particular database using custid.custid is the parameter .&&1 is used in the oracle Inthe same way tried but $1 not possible ?but using function is possible is their any problem with fun to Clean the da

Re: [GENERAL] Deletion

2014-08-27 Thread Ramesh T
In oracle I ran the deletion script to clean up the particular database using custid.custid is the parameter .&&1 is used in the oracle Inthe same way tried but $1 not possible ?but using function is possible is their any problem with fun to Clean the database I have 100 statements in script ... On

Re: [GENERAL] query does not return after increasing range in 'between' clause

2014-08-27 Thread Tom Lane
Dennis writes: > Hi, I am having bad luck with a query that should return zero rows but > actually never returns (completes execution.) Seems like you need a multicolumn index on t_week_f, and maybe also on nb_products, so that the conditions shown as "filters" here could be applied as index con

Re: [GENERAL] query does not return after increasing range in 'between' clause

2014-08-27 Thread Dennis
Oh ya… select fact.store_tag,fact.period,fact.upc upcid, case when mkt_tag = 4480 then market.description else '' end retailmarket, case when mkt_tag = 100 then market.description else '' end compmarket, case when mkt_tag = 4480 then dollars else 0 end base_dollars, case when mkt_tag = 100 then do

Re: [GENERAL] query does not return after increasing range in 'between' clause

2014-08-27 Thread Adrian Klaver
On 08/27/2014 11:02 AM, Dennis wrote: Hi, I am having bad luck with a query that should return zero rows but actually never returns (completes execution.) And the query is :) ? -- Adrian Klaver adrian.kla...@aklaver.com -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org)

[GENERAL] query does not return after increasing range in 'between' clause

2014-08-27 Thread Dennis
Hi, I am having bad luck with a query that should return zero rows but actually never returns (completes execution.) When I broaden the ‘between’ clause range from " period.orderno between 1447 and 1450" to " period.orderno between 1446 and 1450” the query plan changes and the query never compl

Re: [GENERAL] Deletion

2014-08-27 Thread David G Johnston
Ramesh T wrote > Hi, > I have deletion script to delete particular cust from > database.I was > saved a file name with custde.sql.i need to run from command line like > putty tool..But have a problem > > example : > > delete from part where part.custid=$1; > > when i ran custde.sql f

Re: [GENERAL] Deletion

2014-08-27 Thread Adrian Klaver
On 08/27/2014 08:24 AM, Ramesh T wrote: any help... Honestly, this is basic programming/scripting. I would suggest picking up an introductory programming book to get the basics down. In the meantime, you have used a parameter variable ($1) with out actually supplying a parameter. So Postgres

[GENERAL] Issue with COPY command

2014-08-27 Thread swaroop
In need of some help - The use case is to insert current time in UTC for a timestamp column using COPY command . It works fine if i just have now() in csv file input. But if i add now() at time zone 'utc' it gives the error as ERROR: invalid input syntax for type timestamp: "now() at time zone

[GENERAL] Deletion

2014-08-27 Thread Ramesh T
Hi, I have deletion script to delete particular cust from database.I was saved a file name with custde.sql.i need to run from command line like putty tool..But have a problem example : delete from part where part.custid=$1; when i ran custde.sql from putty tool db=#\i custde.sql it

Re: [GENERAL] pgbouncer setup in the architecture

2014-08-27 Thread Gabriele Lohss
Hi, I'd like to add to my former mail that currently I have got pgbouncer running and I can connect to the underlying postgres database servers, but how can I access the pgbouncer database when I'm not running a postgres server on the VM where the pgbouncer is installed? In all the forums and docum

Re: [GENERAL] Issue with COPY command

2014-08-27 Thread David G Johnston
swaroop wrote > In need of some help - The use case is to insert current time in UTC for a > timestamp column > using COPY command . It works fine if i just have now() in csv file input. > But if i add > now() at time zone 'utc' it gives the error as > ERROR: invalid input syntax for type timest

Re: [GENERAL] SELECT 'NOW()' - OK, SELECT 'CLOCK_TIMESTAMP()' - ERROR

2014-08-27 Thread Piotr Gasidło
2014-08-22 9:05 GMT+02:00 David G Johnston : > > Do you have a use-case you'd like to share or is this curiosity after > accidentally finding out that 'now'::timestamp actually works? > I've found it by accident and I had to ask if it is bug or right way. > -- Piotr Gasidło

Re: [GENERAL] pgbouncer setup in the architecture

2014-08-27 Thread Gabriele Lohss
Hi, thanks, you're right. My description wasn't very concrete. Our current set up is a single pgbouncer instance running on a VM in the same network like the webapplications. The database servers are in another firewall protected network. So the pgbouncer is now running on a standalone VM. I was w