Re: [GENERAL] Scripting function definitions as SQL?

2008-05-12 Thread Gurjeet Singh
On Mon, May 12, 2008 at 10:57 AM, Reece Hart [EMAIL PROTECTED] wrote: On Sun, 2008-05-11 at 06:12 -0700, Postgres User wrote: Has anyone written a function that scripts out all the functions in a database as full SQL statements (Create Function.) You could pg_dump the schema in the

[GENERAL] ORDER BY FIELD feature

2008-05-12 Thread Kevin Reynolds
Does postgresql have something similar to the ORDER BY FIELD feature found in MySQL? Something like ORDER BY FIELD(ID, 10, 2, 56, 40); It is listed here: http://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html I am using the Sphinx Search program, www.sphinxsearch.com, and it

Re: [GENERAL] Returning RECORD from PGSQL without custom type?

2008-05-12 Thread Pavel Stehule
Hello 2008/5/10 D. Dante Lorenso [EMAIL PROTECTED]: Instead of doing this: CREATE OR REPLACE FUNCTION my_custom_func (in_value bigint) RETURNS SETOF record AS $body$ ... $body$ LANGUAGE 'plpgsql' VOLATILE; I'd like to be able to do this: CREATE OR REPLACE FUNCTION

Re: [GENERAL] ORDER BY FIELD feature

2008-05-12 Thread Guillaume Lelarge
Kevin Reynolds a écrit : Does postgresql have something similar to the ORDER BY FIELD feature found in MySQL? Something like ORDER BY FIELD(ID, 10, 2, 56, 40); It is listed here: http://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html I am using the Sphinx Search program,

[GENERAL] Returning RECORD from PGSQL without custom type?

2008-05-12 Thread D. Dante Lorenso
Instead of doing this: CREATE OR REPLACE FUNCTION my_custom_func (in_value bigint) RETURNS SETOF record AS $body$ ... $body$ LANGUAGE 'plpgsql' VOLATILE; I'd like to be able to do this: CREATE OR REPLACE FUNCTION my_custom_func (in_value bigint) RETURNS SETOF (col1name BIGINT,

[GENERAL] PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:

2008-05-12 Thread Abdus Samad Ansari
PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: I have setup PHP/Postgres and is running fine upto document root i.e. /var/www/html, but when i am calling it through a cgi-bin php file it is giving log error as : [error] [client 127.0.0.1] PHP

Re: [GENERAL] PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:

2008-05-12 Thread Tino Wildenhain
Hi, Abdus Samad Ansari wrote: PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: I have setup PHP/Postgres and is running fine upto document root i.e. /var/www/html, but when i am calling it through a cgi-bin php file it is giving log error as :

Re: [GENERAL] PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:

2008-05-12 Thread Harald Armin Massa
hello, most crucial information is missing, like: - your operating system - your postgresql version - on which computer is your database server running - is your database server running But most likely your problem is that you did not configure PostgreSQL to listen to TCP/IP-requests. Which

Re: [GENERAL] PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:

2008-05-12 Thread Tom Lane
Abdus Samad Ansari [EMAIL PROTECTED] writes: I have setup PHP/Postgres and is running fine upto document root i.e. /var/www/html, but when i am calling it through a cgi-bin php file it is giving log error as : [error] [client 127.0.0.1] PHP Warning: pg_connect(): Unable to connect to

Re: [GENERAL] PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:

2008-05-12 Thread Andy Anderson
Abdus Samad Ansari [EMAIL PROTECTED] writes: I have setup PHP/Postgres and is running fine upto document root i.e. /var/www/html, but when i am calling it through a cgi-bin php file it is giving log error as : [error] [client 127.0.0.1] PHP Warning: pg_connect(): Unable to connect to

Re: [GENERAL] How to create a function with multiple RefCursor OUT parameters

2008-05-12 Thread Merlin Moncure
On Sun, May 11, 2008 at 2:43 PM, Chuck Bai [EMAIL PROTECTED] wrote: CREATE OR REPLACE FUNCTION test_refcursor(INOUT tcount integer, OUT o_user refcursor, OUT o_name refcursor) RETURNS record AS $BODY$ BEGIN tcount := tcount + 1; OPEN o_user FOR SELECT * FROM user_table; OPEN

[GENERAL] pg_standby / WAL archive-restore through system restarts

2008-05-12 Thread David Wall
Just wanted to see if others would confirm my impressions about running WAL archiving and pg_standby restore. Server A (Primary): Runs PG 8.3 with WAL archiving enabled. Each WAL is copied over the network to Server B. (A previous 'tar backup' of the database along with the requisite psql

Re: [GENERAL] choiche of function language was: Re: dynamic procedure call

2008-05-12 Thread Chris Browne
[EMAIL PROTECTED] (Ivan Sergio Borgonovo) writes: On Sat, 10 May 2008 07:35:36 +0200 Pavel Stehule [EMAIL PROTECTED] wrote: your application different execution paths. Generally I can say, so plpgsql isn't well language for this games, and better is using plperl, plpython or other external

Re: [GENERAL] Returning RECORD from PGSQL without custom type?

2008-05-12 Thread D. Dante Lorenso
Pavel Stehule wrote: Hello 2008/5/10 D. Dante Lorenso [EMAIL PROTECTED]: Instead of doing this: CREATE OR REPLACE FUNCTION my_custom_func (in_value bigint) RETURNS SETOF record AS $body$ ... $body$ LANGUAGE 'plpgsql' VOLATILE; I'd like to be able to do this: CREATE OR REPLACE FUNCTION

Re: [GENERAL] Hung SQL Update Linux Redhat 4U5 Postgres 8.3.1

2008-05-12 Thread Craig Vosburgh
Craig Vosburgh craig(dot)vosburgh(at)cassatt(dot)com writes: We've dumped the locks and it shows that all locks have been granted so it appears that it is not a lock that is standing in our way. We've also gone in via psql while the update is hung and were able to perform an update on the

[GENERAL] rounding problems

2008-05-12 Thread Justin
I have very annoying problem that i would like to get a work around in place so the data entry people stop trying to kill me. Normally people give quotes out of the price book which was done in Excel like 15 years ago and just has been updated over the years. the problem is excel is

Re: [GENERAL] Returning RECORD from PGSQL without custom type?

2008-05-12 Thread Tom Lane
D. Dante Lorenso [EMAIL PROTECTED] writes: I'd like to be able to do this: CREATE OR REPLACE FUNCTION my_custom_func (in_value bigint) RETURNS SETOF (col1name BIGINT, col2name TEXT, ...) AS You realize of course that you can do this *today* if you use OUT parameters? CREATE OR REPLACE

Re: [GENERAL] rounding problems

2008-05-12 Thread Lincoln Yeoh
At 01:48 AM 5/13/2008, Justin wrote: I have very annoying problem that i would like to get a work around in place so the data entry people stop trying to kill me. Normally people give quotes out of the price book which was done in Excel like 15 years ago and just has been updated over the

Re: [GENERAL] Hung SQL Update Linux Redhat 4U5 Postgres 8.3.1

2008-05-12 Thread Tom Lane
Craig Vosburgh [EMAIL PROTECTED] writes: Got GDB installed on the errant node and did a back trace call (I'm guessing that is what you were looking for when you said stack trace) on the process that shows in the process table as executing the hung SQL command. The backtrace is: (gdb) bt #0

Re: [GENERAL] rounding problems

2008-05-12 Thread Andy Anderson
Can you be more explicit about the rounding that's wrong in Excel? Are you talking about the n5 round-up to n+1 that Excel uses vs. n5 round-to-even n (sometimes called Banker's Rounding)? -- Andy On May 12, 2008, at 1:48 PM, Justin wrote: I have very annoying problem that i would

Re: [GENERAL] Returning RECORD from PGSQL without custom type?

2008-05-12 Thread Pavel Stehule
2008/5/12 Tom Lane [EMAIL PROTECTED]: D. Dante Lorenso [EMAIL PROTECTED] writes: I'd like to be able to do this: CREATE OR REPLACE FUNCTION my_custom_func (in_value bigint) RETURNS SETOF (col1name BIGINT, col2name TEXT, ...) AS You realize of course that you can do this *today* if you use

Re: [GENERAL] rounding problems

2008-05-12 Thread Justin
Andy Anderson wrote: Can you be more explicit about the rounding that's wrong in Excel? Are you talking about the n5 round-up to n+1 that Excel uses vs. n5 round-to-even n (sometimes called Banker's Rounding)? Yes i'm talking about difference between bankers rounding verse Excels

Re: [GENERAL] rounding problems

2008-05-12 Thread Justin
Lincoln Yeoh wrote: At 01:48 AM 5/13/2008, Justin wrote: I have very annoying problem that i would like to get a work around in place so the data entry people stop trying to kill me. Normally people give quotes out of the price book which was done in Excel like 15 years ago and just has

Re: [GENERAL] Hung SQL Update Linux Redhat 4U5 Postgres 8.3.1

2008-05-12 Thread Craig Vosburgh
Tom, Yea, about that lock that I *said* I didn't have... We had been joining through the pg_class and pg_tables tables to get some additional data and it turns out the row in the pg_locks that shows as locked doesn't have a relation so it was filtered out due to the join. So, now that I have

Re: [GENERAL] rounding problems

2008-05-12 Thread Justin
thats how i loaded the price list to start with. The problems with sales orders are entered and the automatic pricing kicks in ( the discounts are calculated * the number or pieces ordered) it goes to down the tubes. I could just rewrite the pricing stored procedures to call a rounding

Re: [GENERAL] Hung SQL Update Linux Redhat 4U5 Postgres 8.3.1

2008-05-12 Thread Tom Lane
Craig Vosburgh [EMAIL PROTECTED] writes: Second, any words of wisdom to help run to ground who's keeping me from getting the lock on the offending row? The row in the lock table that shows granted false does not show as belonging to a database or relation (both null) so I can't join through

Re: [GENERAL] Returning RECORD from PGSQL without custom type?

2008-05-12 Thread D. Dante Lorenso
Tom Lane wrote: D. Dante Lorenso [EMAIL PROTECTED] writes: I'd like to be able to do this: CREATE OR REPLACE FUNCTION my_custom_func (in_value bigint) RETURNS SETOF (col1name BIGINT, col2name TEXT, ...) AS You realize of course that you can do this *today* if you use OUT parameters? No, I

Re: [GENERAL] rounding problems

2008-05-12 Thread Andy Anderson
Andy Anderson wrote: Can you be more explicit about the rounding that's wrong in Excel? Are you talking about the n5 round-up to n+1 that Excel uses vs. n5 round-to-even n (sometimes called Banker's Rounding)? On May 12, 2008, at 2:38 PM, Justin wrote: Yes i'm taking about

[GENERAL] changing the endianness of a database

2008-05-12 Thread Chris Saldanha
Hi, We'd like to ship PostgreSQL as part of a product that runs on both PPC and Intel Macs, but the database files are tied to the build settings and endianness of the computer that the database was initialized on. Is there any way to cause the server to modify the database files in-place for

Re: [GENERAL] changing the endianness of a database

2008-05-12 Thread Merlin Moncure
On Mon, May 12, 2008 at 4:02 PM, Chris Saldanha [EMAIL PROTECTED] wrote: We'd like to ship PostgreSQL as part of a product that runs on both PPC and Intel Macs, but the database files are tied to the build settings and endianness of the computer that the database was initialized on. Is

Re: [GENERAL] rounding problems

2008-05-12 Thread Craig Ringer
Justin wrote: No floating point is being used every variable is declared as numeric on the Postgresql side and in the C++ which is the UI side everything is double. `double' in C++ refers to double precision floating point. `double' is subject to all the usual fun with rational decimals

[GENERAL] Recovering database after disk crash

2008-05-12 Thread Vic Simkus
Hello A disk hosting an instance of 8.2 crashed on me (hardware failure). I was able to pull most of the data off the drive, but the one database that I need the most is corrupt. I'm not really sure where to start... so here are some error messages: [EMAIL PROTECTED]:/var/log/postgresql$

Re: [GENERAL] changing the endianness of a database

2008-05-12 Thread Craig Ringer
Merlin Moncure wrote: Surely it's easier just to have your application dump on schedule and add some front end GUI import feature to your app? It looks like you are maybe trying to solve the wrong problem...namely that it is too difficult for your users to do backup/restore themselves. Maybe

Re: [GENERAL] rounding problems

2008-05-12 Thread Justin
Craig Ringer wrote: Justin wrote: No floating point is being used every variable is declared as numeric on the Postgresql side and in the C++ which is the UI side everything is double. `double' in C++ refers to double precision floating point. `double' is subject to all the usual fun

Re: [GENERAL] rounding problems

2008-05-12 Thread Justin
As i'm playing around with rounding and the numeric field precision ran into a odd set of results i don't understand here is the sql i wrote the first four inserts are calculations we run everyday and they make sense but if division is used the results are not right or am i missing something

Re: [GENERAL] changing the endianness of a database

2008-05-12 Thread Chris Saldanha
Maybe it's an opportunity to introduce the users to backups. Yes, we do backups for the user, but the problem with Apple's migration is that it happens not on a schedule that meshes with the backup schedule. Our applications have fairly frequently changing data. Honestly, though, PostgreSQL

Re: [GENERAL] Making sure \timing is on

2008-05-12 Thread David Fetter
On Sun, May 11, 2008 at 11:48:29PM -0400, Tom Lane wrote: Scott Marlowe [EMAIL PROTECTED] writes: Is it reasonable behavior to have \timing along toggle and \timing on / \timing off be a forced switch? Just thinking of other scripts where this isn't a problem and having to update them.

Re: [GENERAL] Recovering database after disk crash

2008-05-12 Thread Vic Simkus
After doing some more reading I've come to the conclusion that I'm in completely over my head. I got a fresh copy of the corrupt data and am starting from the very beginning. Here's the error I get on startup: [EMAIL PROTECTED]:/usr/lib/postgresql/8.2/bin$ ./postgres -D

Re: [GENERAL] rounding problems

2008-05-12 Thread Justin
I tried casting them to numeric and it was still wrong OK i just added decimal point after the 9 and 1 it work at that point. Thats an odd result i would not have expected it to do that. This prompts another question how does postgres figure out the data types passed in an SQL string??? Andy

Re: [GENERAL] rounding problems

2008-05-12 Thread Craig Ringer
Justin wrote: Craig Ringer wrote: `double' in C++ refers to double precision floating point. `double' is subject to all the usual fun with rational decimals being irrational binary floats (and vice versa). Not according to MS specific if i'm reading it correctly *Microsoft Specific *

Re: [GENERAL] Making sure \timing is on

2008-05-12 Thread Bruce Momjian
David Fetter wrote: On Sun, May 11, 2008 at 11:48:29PM -0400, Tom Lane wrote: Scott Marlowe [EMAIL PROTECTED] writes: Is it reasonable behavior to have \timing along toggle and \timing on / \timing off be a forced switch? Just thinking of other scripts where this isn't a problem and

Re: [GENERAL] Making sure \timing is on

2008-05-12 Thread Alvaro Herrera
David Fetter escribió: On Sun, May 11, 2008 at 11:48:29PM -0400, Tom Lane wrote: Scott Marlowe [EMAIL PROTECTED] writes: Is it reasonable behavior to have \timing along toggle and \timing on / \timing off be a forced switch? Just thinking of other scripts where this isn't a problem

Re: [GENERAL] rounding problems

2008-05-12 Thread Craig Ringer
Justin wrote: I tried casting them to numeric and it was still wrong How do the results differ from what you expect? You've posted a bunch of code, but haven't explained what you think is wrong with the results. Can you post a couple of SMALL examples and explain how the results are

Re: [GENERAL] Making sure \timing is on

2008-05-12 Thread David Fetter
On Mon, May 12, 2008 at 05:30:48PM -0400, Bruce Momjian wrote: David Fetter wrote: On Sun, May 11, 2008 at 11:48:29PM -0400, Tom Lane wrote: Scott Marlowe [EMAIL PROTECTED] writes: Is it reasonable behavior to have \timing along toggle and \timing on / \timing off be a forced switch?

Re: [GENERAL] changing the endianness of a database

2008-05-12 Thread A.M.
On May 12, 2008, at 4:02 PM, Chris Saldanha wrote: Hi, We'd like to ship PostgreSQL as part of a product that runs on both PPC and Intel Macs, but the database files are tied to the build settings and endianness of the computer that the database was initialized on. Is there any way to

Re: [GENERAL] Hung SQL Update Linux Redhat 4U5 Postgres 8.3.1

2008-05-12 Thread Craig Vosburgh
What's the locktype? Yep, locktype is transaction. If (as I suspect) it's a transaction or virtualtransaction lock, then which process holds that lock and what's it doing? As for which process owns that lock, I'm not sure how to find that out (sorry newbie). I can find the PID that is

Re: [GENERAL] rounding problems

2008-05-12 Thread Justin
I guess i have not been very clear. lets take this select (9/10), (9/10)::numeric, (9::numeric/10::numeric), (9./10), (9*.1) With the given select statement i expected the results all to be same, especially sense it cast 4 of the 5 to numeric either with explicit cast or by containing a

Re: [GENERAL] rounding problems

2008-05-12 Thread Christophe
Yet another option, of course, is to simply not do any calculations in PostgreSQL, and accept the results from Excel as definitive... which seems to be what is desired, anyway. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:

Re: [GENERAL] Hung SQL Update Linux Redhat 4U5 Postgres 8.3.1

2008-05-12 Thread Tom Lane
Craig Vosburgh [EMAIL PROTECTED] writes: As for which process owns that lock, I'm not sure how to find that out (sorry newbie). I can find the PID that is waiting for that lock and I can find the table/row that appears to be waiting for the lock to perform the action but I can't figure out

[GENERAL] Server not listening

2008-05-12 Thread D Galen
If this isn't the right place to post this, please advise. I've spent a week trying to get PostgreSQL 8.3 to install correctly on WIN2K. Server will load I see the server processes loaded but none of them have any open ports. I keep getting the message the server isn't listening. Server

Re: [GENERAL] rounding problems

2008-05-12 Thread Andy Anderson
On May 12, 2008, at 6:37 PM, Justin wrote: lets take this select (9/10), (9/10)::numeric, (9::numeric/10::numeric), (9./10), (9*.1) With the given select statement i expected the results all to be same, especially sense it cast 4 of the 5 to numeric either with explicit cast or by

Re: [GENERAL] Recovering database after disk crash

2008-05-12 Thread Tom Lane
Vic Simkus [EMAIL PROTECTED] writes: [EMAIL PROTECTED]:/var/log/postgresql$ reindexdb EPC NOTICE: table pg_class was reindexed reindexdb: reindexing of database EPC failed: ERROR: catalog is missing 4 attribute(s) for relid 10762 If you're really lucky, doing the reindex with

Re: [GENERAL] changing the endianness of a database

2008-05-12 Thread Shane Ambler
A.M. wrote: You know that you don't have to compile postgresql as Universal, right? If you have separate PPC and Intel versions (not lipo'd together), then, presumably, you should be able to figure out which one needs to run. The PPC postgresql would then run on the Macintel under Rosetta

Re: [GENERAL] Recovering database after disk crash

2008-05-12 Thread Vic Simkus
If I'm understanding the errors correctly it seems that the corruption is in the system catalogs (metadata). The database does not use any fancy datatypes. Is there any way for me to rebuild the metadata manually? If I can see the leftover metadata and the data minus the missing metadata I can

Re: [GENERAL] Recovering database after disk crash

2008-05-12 Thread Tom Lane
Vic Simkus [EMAIL PROTECTED] writes: If I'm understanding the errors correctly it seems that the corruption is in the system catalogs (metadata). The database does not use any fancy datatypes. Is there any way for me to rebuild the metadata manually? If I can see the leftover metadata and the

Re: [GENERAL] Recovering database after disk crash

2008-05-12 Thread Vic Simkus
During the initial ill-educated messing around I had set the zero_damaged_pages to yes, but I'm guessing that the end result is the same... Ill try it with the fresh copy of [the corrupt] data What kind of a database can't deal with a bit of random values injected into its sytem files anyways? :)

Re: [GENERAL] rounding problems

2008-05-12 Thread Sam Mason
On Mon, May 12, 2008 at 06:37:02PM -0400, Justin wrote: I guess i have not been very clear. lets take this select (9/10), (9/10)::numeric, (9::numeric/10::numeric), (9./10), (9*.1) With the given select statement i expected the results all to be same, especially sense it cast 4 of

Re: [GENERAL] How to create a function with multiple RefCursor OUT parameters

2008-05-12 Thread Chuck Bai
The following is a function from PosgreSQL documentation to return multiple cursors from a single function: CREATE FUNCTION myfunc(refcursor, refcursor) RETURNS SETOF refcursor AS $$ BEGIN OPEN $1 FOR SELECT * FROM table_1; RETURN NEXT $1; OPEN $2 FOR SELECT * FROM table_2; RETURN

Re: [GENERAL] rounding problems

2008-05-12 Thread Justin
thats what i'm trying to get a grasp on, what postgres is doing with calculation as it truncates or rounds the number when committing the records to the physical table. I just start digging into this as we are having problems where some fields in the database are precision of 2 and other go

Re: [GENERAL] rounding problems

2008-05-12 Thread Craig Ringer
Justin wrote: WE have several columns in table defined with numeric (20,10) thats is just insanity. Not necessarily. I have a few places where a monetary value is mulitiplied by a ratio quantity. For some of the historical data imported from another system the ratio can be irrational or at

Re: [GENERAL] rounding problems

2008-05-12 Thread Justin
Craig Ringer wrote: Justin wrote: WE have several columns in table defined with numeric (20,10) thats is just insanity. Not necessarily. I have a few places where a monetary value is mulitiplied by a ratio quantity. For some of the historical data imported from another system the

Re: [GENERAL] Server not listening

2008-05-12 Thread Josh Tolley
On Mon, May 12, 2008 at 4:53 PM, D Galen [EMAIL PROTECTED] wrote: If this isn't the right place to post this, please advise. I've spent a week trying to get PostgreSQL 8.3 to install correctly on WIN2K. Server will load I see the server processes loaded but none of them have any open