[GENERAL] Psql Internal Variable question

2011-06-01 Thread Prafulla Tekawade
Hi, I am trying to use psql \set and \echo commands to set some internal variables. My variable starts with single quote and ends with single quote. That is actual value of the variable. Eg. set cur_db 'pgdb' \echo :cur_db --I am expecting here 'pgdb' but psql shows pgdb As mentioned above, I

Re: [GENERAL] Psql Internal Variable question

2011-06-01 Thread Pavel Stehule
Hello \set removes outer quotes if you use PostgreSQL 9.0 you can use \set xxx 'Pavel ''Stěhule' postgres=# \set AUTOCOMMIT = 'on' PROMPT1 = '%/%R%# ' PROMPT2 = '%/%R%# ' PROMPT3 = ' ' VERBOSITY = 'default' VERSION = 'PostgreSQL 9.1beta1 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.5.1

[GENERAL] Need suggestion

2011-06-01 Thread Carl von Clausewitz
Hello Everyone, I got a new project, with 100 user in Europe. In this case, I need to handle production and sales processes an its documentations in PostgreSQL with PHP. The load of the sales process is negligible, but every user produces 2 transaction in the production process, with 10-30

[GENERAL] Returning from insert on view

2011-06-01 Thread Aleksey Chirkin
Hello! I need your advice. My problem is to ensure that the right returning from insert on the view. For example, I have two tables: CREATE TABLE country (id serial, nm text); CREATE TABLE city (id serial, country_id integer, nm text); And one view on table city, which join table county and

Re: [GENERAL] Consistency of distributed transactions

2011-06-01 Thread Pete Chown
Craig Ringer wrote: Distributed transactions will give you atomicity if done right - with two-phase commit (2PC) - but AFAIK will *NOT* give you consistency across the databases in question. That's useful to know -- thanks. At least now I know my idea won't work, so I can forget about it

[GENERAL] Mixed up protocol packets in server response?

2011-06-01 Thread Michal Politowski
I have an instance of what looks like a weird mixup of data returned by the server. This is observed in a Java application using the 9.0-801.jdbc4 JDBC driver connecting to an 8.3.4 server (yes, it's old) running on Solaris. The application hung waiting for the result of one select * from

Re: [GENERAL] troubles with initdb

2011-06-01 Thread jlhgis
Great eyes! It was copied pasted out of some running notes screenshots of the process I was keeping in an OO file. You're a lot more helpful than it was :) Thanks so much for taking the time to look at this. Now, on to the next hurdle - getting pg_ctl to run as an automated service...

Re: [GENERAL] Mixed up protocol packets in server response?

2011-06-01 Thread Tom Lane
Michal Politowski mpol...@meep.pl writes: 2. then looking at the answer array in ReceiveTupleV3: ... So it looks like the server wanted to send D row 1, D row 2, D row 3, D row 4, C SELECT, Z T but the application sees D ro, ow 4, C SELECT, Z T, w 1, D row 2, D row 3, D r What may be the

[GENERAL] currval = currval+1

2011-06-01 Thread salah jubeh
I have the following SQL statements BEGIN; -- account_id is a sequence INSERT INTO account (name) VALUES ('test customer'||random()::text); -- account_id is a foreign key INSERT INTO account_detail (account_id,..) VALUES ((SELECT * from currval('account_acccount_id_seq')), );

Re: [GENERAL] currval = currval+1

2011-06-01 Thread Merlin Moncure
On Wed, Jun 1, 2011 at 9:27 AM, salah jubeh s_ju...@yahoo.com wrote: I have the following SQL statements BEGIN; -- account_id is a sequence INSERT INTO account (name) VALUES ('test customer'||random()::text); -- account_id is a foreign key INSERT INTO account_detail (account_id,..) 

Re: [GENERAL] currval = currval+1

2011-06-01 Thread salah jubeh
I have some rules on the table and I have dropped them and everything went fine. the rule is as follow CREATE OR REPLACE RULE status_change_ins AS ON INSERT TO account DO INSERT INTO account_status_change_log (account_id, account_status_id, status_change_date) VALUES

Re: [GENERAL] currval = currval+1

2011-06-01 Thread Merlin Moncure
On Wed, Jun 1, 2011 at 10:22 AM, salah jubeh s_ju...@yahoo.com wrote: I have some rules on the table and I have dropped them and everything went fine. the rule is as follow CREATE OR REPLACE RULE status_change_ins AS     ON INSERT TO account  DO  INSERT INTO account_status_change_log

Re: [GENERAL] currval = currval+1

2011-06-01 Thread Tom Lane
salah jubeh s_ju...@yahoo.com writes: I have some rules on the table and I have dropped them and everything went fine. Rules are macros, and have the usual issues with multiple evaluations of multiply-referenced arguments. CREATE OR REPLACE RULE status_change_ins AS ON INSERT TO

Re: [GENERAL] Some clarification about TIMESTAMP

2011-06-01 Thread Steve Crawford
On 05/31/2011 09:45 AM, hernan gonzalez wrote: I'm doing some tests with date-time related fields to design my web application. I was already dissatisfied with Postgresql handling of timezones concepts (issue already discussed here - not entirely PG's fault, rather a SQL thing) and I vehemently

[GENERAL] proper regex_replace() syntax

2011-06-01 Thread Geoffrey Myers
I want to use regex_replace() to replace characters in multiple records. What I would like to do is this: select regex_replace((select fname from table), 'z', 'Z')); The problem is, the subquery returns more then one row. So, is there a way to do what I'm trying to do? That is, replace the

[GENERAL] How do I repair a corrupted system table in PostgreSQL?

2011-06-01 Thread David Hamilton
I just attempted to do a pg_upgrade on a fairly large PostgreSQL database cluster from version 8.3.0 to version 9.0.4. Everything looked like it was going to work just fine until the new schema was being created on the target cluster. It died trying to create a group role twice for some reason.

Re: [GENERAL] proper regex_replace() syntax

2011-06-01 Thread Ken Tanzer
I think this is the syntax you want: SELECT regexp_replace(fname,'z','Z') FROM table; On Wed, Jun 1, 2011 at 10:22 AM, Geoffrey Myers li...@serioustechnology.com wrote: I want to use regex_replace() to replace characters in multiple records. What I would like to do is this: select

Re: [GENERAL] proper regex_replace() syntax

2011-06-01 Thread Rick Genter
On Wed, Jun 1, 2011 at 10:22 AM, Geoffrey Myers li...@serioustechnology.com wrote: I want to use regex_replace() to replace characters in multiple records. What I would like to do is this: select regex_replace((select fname from table), 'z', 'Z')); The problem is, the subquery returns

[GENERAL] SELECT to_timestamp crash PostgreSQL 9.1beta1

2011-06-01 Thread Paolo Saudin
Trying to convert unix time to date time format, I encountered a database crash. Environment : WINDOWS 7 Professional - Service Pack1 -- -- PostgreSQL 8.4.7, compiled by Visual C++ build 1400, 32-bit -- SELECT to_timestamp(1306760400); 2011-05-30 15:00:00+02 -- -- PostgreSQL 9.1beta1,

[GENERAL] Column aliases in having or where for Postgres 8.3

2011-06-01 Thread Prafulla Tekawade
Hi, Anyone knows if I can use column aliases in having condition? Something like this. pgdb=# select sum(c_acctbal) as p from customer having p 1000; select sum(c_acctbal) as p from customer having p 1000; ERROR: column p does not exist LINE 1: select sum(c_acctbal) as p from customer

[GENERAL] Table with active and historical data

2011-06-01 Thread Robert James
I have a table with a little active data and a lot of historical data. I'd like to be able to access the active data very quickly - quicker than an index. Here are the details: 1. Table has about 1 million records 2. Has a column active_date - on a given date, only about 1% are active.

Re: [GENERAL] Mixed up protocol packets in server response?

2011-06-01 Thread Craig Ringer
On 1/06/2011 9:06 PM, Michal Politowski wrote: What may be the cause of this weird problem? Is it some known or unknown bug in 8.3.4 or is the application/Java side more suspected? It'd be really helpful if you could collect and examine a trace of the client/server communication using

Re: [GENERAL] Table with active and historical data

2011-06-01 Thread Merlin Moncure
On Wed, Jun 1, 2011 at 7:30 PM, Robert James srobertja...@gmail.com wrote: I have a table with a little active data and a lot of historical data.  I'd like to be able to access the active data very quickly - quicker than an index.  Here are the details: 1. Table has about 1 million records

Re: [GENERAL] SELECT to_timestamp crash PostgreSQL 9.1beta1

2011-06-01 Thread Craig Ringer
On 06/02/2011 03:15 AM, Paolo Saudin wrote: Trying to convert unix time to date time format, I encountered a database crash. This is a known issue, and will be addressed in the next beta. Detail from an earlier post by Tom Lane: Tom Lane wrote: This is the known problem with timezone