[GENERAL] String concatenation operator which keeps trailing spaces in CHAR(n) columns

2014-07-30 Thread Andrus
How to create string concatenation operator which preserves trailing spaces on CHAR(n) type columns ? I tried code below, but it returns AB (without spaces). How to force it to return A B (keep space after A) ? Andrus. CREATE OR REPLACE FUNCTION public.stringconcat(left text, right text) RETURN

Re: [GENERAL] String concatenation operator which keeps trailing spaces in CHAR(n) columns

2014-07-30 Thread Albe Laurenz
Andrus wrote: > How to create string concatenation operator which preserves trailing spaces > on CHAR(n) type columns ? > > I tried code below, but it returns AB (without spaces). > How to force it to return A B (keep space after A) ? > > Andrus. > > CREATE OR REPLACE FUNCTION public.stringconca

Re: [GENERAL] String concatenation operator which keeps trailing spaces in CHAR(n) columns

2014-07-30 Thread Andrus
Hi! Use "bpchar" instead of "text" in the definition of function and operator. Otherwise col1 gets cast to "text" and loses its trailing spaces. Thank you very much. It worked. Which notation to use for this ? Is it reasonable use "+" as such operator for strings or should some other notatio

Re: [GENERAL] String concatenation operator which keeps trailing spaces in CHAR(n) columns

2014-07-30 Thread Albe Laurenz
Andrus wrote: >> Use "bpchar" instead of "text" in the definition of function and operator. >> Otherwise col1 gets cast to "text" and loses its trailing spaces. > > Thank you very much. > It worked. > Which notation to use for this ? > > Is it reasonable use "+" as such operator for strings or sh

Re: [GENERAL] pgbouncer not finding pidfile

2014-07-30 Thread Adrian Klaver
On 07/28/2014 09:33 PM, Tobias Fielitz wrote: Hi, I am trying to start pgbouncer via upstart script. The upstart logs (/var/log/upstart/pgbouncer.log) tell me: /var/run/postgresql/pgbouncer.pid: No such file or directory [2] but when starting pgbouncer from the console with: > sudo service pg

[GENERAL] How to detect txid visibility on standby server?

2014-07-30 Thread Sergey Burladyan
Hello! Is it possible to detect what master transaction is visible on standby? I try to use txid_current_snapshot() but it return wrong result on standby: _master_: create table tmp.txid_test(txid bigint, ss txid_snapshot) begin; insert into tmp.txid_test values (txid_current(), txid_current_snap

[GENERAL] free RAM not being used for page cache

2014-07-30 Thread Kevin Goess
A couple months ago we upgraded the RAM on our database servers from 48GB to 64GB. Immediately afterwards the new RAM was being used for page cache, which is what we want, but that seems to have dropped off over time, and there's currently actually like 12GB of totally unused RAM. http://s76.phot

[GENERAL] How can I create null value from function call with no results?

2014-07-30 Thread Seref Arikan
Greetings, I want to call a function using a column of a table as the parameter and return the parameter and function results together. The problem is, when the function returns an empty row my select statement that uses the function returns an empty row as well. The following simplified snippet d

Re: [GENERAL] How can I create null value from function call with no results?

2014-07-30 Thread Pavel Stehule
Hello you can try world=# CREATE OR REPLACE FUNCTION xx(int) world-# RETURNS TABLE(a int, b int) AS world-# $$ SELECT $1, $1 WHERE $1 = 1 UNION ALL SELECT NULL, NULL LIMIT 1; $$ world-# LANGUAGE sql; CREATE FUNCTION Time: 74.320 ms world=# SELECT * FROM xx(1); a | b ---+--- 1 | 1 (1 row) Time:

Re: [GENERAL] How can I create null value from function call with no results?

2014-07-30 Thread David G Johnston
Seref Arikan wrote > select 1,test_empty_row(1); SELECT 1, (SELECT test_empty_row(1)) AS func_result You can also adjust the function to either return the result of the query OR "RETURN NULL" if no results were found. i.e., do not use "RETURN QUERY" David J. -- View this message in cont

Re: [GENERAL] free RAM not being used for page cache

2014-07-30 Thread Merlin Moncure
On Wed, Jul 30, 2014 at 12:51 PM, Kevin Goess wrote: > A couple months ago we upgraded the RAM on our database servers from 48GB to > 64GB. Immediately afterwards the new RAM was being used for page cache, > which is what we want, but that seems to have dropped off over time, and > there's curren

Re: [GENERAL] How can I create null value from function call with no results?

2014-07-30 Thread Tom Lane
Seref Arikan writes: > I want to call a function using a column of a table as the parameter and > return the parameter and function results together. > The problem is, when the function returns an empty row my select statement > that uses the function returns an empty row as well. This function i

Re: [GENERAL] free RAM not being used for page cache

2014-07-30 Thread Kevin Goess
Good suggestion, but nope, that ain't it: $ cat /proc/sys/vm/zone_reclaim_mode 0 On Wed, Jul 30, 2014 at 11:49 AM, Merlin Moncure wrote: > On Wed, Jul 30, 2014 at 12:51 PM, Kevin Goess wrote: > > A couple months ago we upgraded the RAM on our database servers from > 48GB to > > 64GB. Immedi

Re: [GENERAL] How can I create null value from function call with no results?

2014-07-30 Thread Seref Arikan
Pavel, thank you so much. This did the trick! On Wed, Jul 30, 2014 at 7:18 PM, Pavel Stehule wrote: > Hello > > you can try > > world=# CREATE OR REPLACE FUNCTION xx(int) > world-# RETURNS TABLE(a int, b int) AS > world-# $$ SELECT $1, $1 WHERE $1 = 1 UNION ALL SELECT NULL, NULL LIMIT 1; > $$

Re: [GENERAL] free RAM not being used for page cache

2014-07-30 Thread Scott Marlowe
On Wed, Jul 30, 2014 at 12:57 PM, Kevin Goess wrote: > On Wed, Jul 30, 2014 at 11:49 AM, Merlin Moncure wrote: >> On Wed, Jul 30, 2014 at 12:51 PM, Kevin Goess wrote: >> > A couple months ago we upgraded the RAM on our database servers from >> > 48GB to >> > 64GB. Immediately afterwards the new

Re: [GENERAL] How can I create null value from function call with no results?

2014-07-30 Thread Seref Arikan
Hi David, Thanks for the feedback. I've actually tried to do what you've suggested, but I always found myself unable to do the check for empty result for query in an elegant way. That is, I end up thinking about creating a temp table to put the query results in (which can be > 1), then check if the

Re: [GENERAL] free RAM not being used for page cache

2014-07-30 Thread Kevin Grittner
Merlin Moncure wrote: > On Wed, Jul 30, 2014 at 12:51 PM, Kevin Goess wrote: > >> A couple months ago we upgraded the RAM on our database servers from 48GB to >> 64GB.  Immediately afterwards the new RAM was being used for page cache, >> which is what we want, but that seems to have dropped off o

Re: [GENERAL] How can I create null value from function call with no results?

2014-07-30 Thread Seref Arikan
Thanks Tom, The function can return multiple rows. It is a very simplified version of a function that is used in the context of an EAV design. It should return 0 or more rows that match the criteria that is calculated in the function. Originally I had a left outer join from the table that I'm usin

Re: [GENERAL] free RAM not being used for page cache

2014-07-30 Thread Scott Marlowe
On Wed, Jul 30, 2014 at 1:05 PM, Kevin Grittner wrote: > Merlin Moncure wrote: >> On Wed, Jul 30, 2014 at 12:51 PM, Kevin Goess wrote: >> >>> A couple months ago we upgraded the RAM on our database servers from 48GB to >>> 64GB. Immediately afterwards the new RAM was being used for page cache,

[GENERAL] Inconsistent results postgresql

2014-07-30 Thread Emir Ibrahimbegovic
Hello all, I've got two queries which should produce the same results but they don't for some reason, please consider these : SELECT date_trunc('day', payments.created_at) "day", SUM("payments"."amount") AS sum_id FROM "payments" INNER JOIN "users" ON "users"."id" = "payments"."user_id" WHERE "

Re: [GENERAL] Inconsistent results postgresql

2014-07-30 Thread David G Johnston
Emir Ibrahimbegovic wrote > Hello all, > > I've got two queries which should produce the same results but they don't > for some reason, please consider these : > > SELECT date_trunc('day', payments.created_at) "day", > SUM("payments"."amount") AS sum_id FROM "payments" > INNER JOIN "users" ON "

Re: [GENERAL] Inconsistent results postgresql

2014-07-30 Thread Chris Curvey
On Wed, Jul 30, 2014 at 8:41 PM, Emir Ibrahimbegovic < emir.ibrahimbego...@gmail.com> wrote: > Hello all, > > I've got two queries which should produce the same results but they don't > for some reason, please consider these : > > SELECT date_trunc('day', payments.created_at) "day", SUM("payments"

[GENERAL] corrupt data from invalid recovery

2014-07-30 Thread CS_DBA
We are trying to help a client, one of their databases was being backed up via snapshots without running a pg_start_backup or pg_stop _backup Recently they had an issue and they recovered from one of these snapshot backups, which are now producing errors such as : Invalid page header in block X

[GENERAL] BDR Postgres

2014-07-30 Thread Tonny
Hi everyone I read that 2ndQuadrant released bidirectional replication for postgres, know whether this package will enter apt.postgresql.org or if there will be any repository for Debian GNU / Linux? thanks -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes

[GENERAL] User-defined operator function: what parameter type to use for uncast character string?

2014-07-30 Thread Adam Mackler
(Cross-posted to StackOverflow: http://stackoverflow.com/questions/25041100/postgresql-user-defined-operator-function-what-parameter-type-to-use-for-uncast ) I'm defining my own domain and a equality operator. I cannot cause PostgreSQL to use my operator function in a query without explicitly c

[GENERAL] Re: User-defined operator function: what parameter type to use for uncast character string?

2014-07-30 Thread David G Johnston
Adam Mackler-5 wrote > (Cross-posted to StackOverflow: > http://stackoverflow.com/questions/25041100/postgresql-user-defined-operator-function-what-parameter-type-to-use-for-uncast > ) > > I'm defining my own domain and a equality operator. > Next I create an equality operator to do case-insensiti

Re: [GENERAL] pgbouncer not finding pidfile

2014-07-30 Thread Tobias Fielitz
I have played around with it a bit more, it seems adding the pre-start section works: pre-start script if [ -d /var/run/postgresql ]; then chmod 2775 /var/run/postgresql else install -d -m 2775 -o postgres -g postgres /var/run/postgresql fi end script Thanks Adrian!