[GENERAL] pl/pgsql loop thru columns names

2009-08-18 Thread Dilyan Berkovski
Hi All, I have a nasty table with many repeating columns of the kind port_ts_{i}_, where {i} is from 0 to 31, and could be 3 different words. I have made a pl/pgsql function that checks those columns from port_ts_1_status to port_ts_31_status and counts something, however this is nasty and ugl

[GENERAL] question about /etc/init.d/postgresql in PGDG

2009-08-18 Thread Scott Marlowe
In the init script from the PGDG rpms there's this block of code: PGDATA=/var/lib/pgsql/data if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base/template1" ] then echo "Using old-style directory structure" else PGDATA=/var/lib/pgsql/data fi Is it just me, or is the else extra no

Re: [GENERAL] Idle processes chewing up CPU?

2009-08-18 Thread Brendan Hill
Hi Craig, thanks for the analysis. If I attach a debugger on the runaway child process, will this halt execution for all the other child processes (ie. freeze the server)? And, can I attach Visual Studio C++ 2008, or is there a recommended debugger for Windows debugging? Given the reliability of t

Re: [GENERAL] Idle processes chewing up CPU?

2009-08-18 Thread Craig Ringer
On 19/08/2009 12:31 PM, Brendan Hill wrote: Hi Craig/Tom, I've managed to trap the full stack trace this time The common part of those traces is: > ntdll.dll!KiFastSystemCallRet > WS2_32.dll!WSARecv+0x65 > WSOCK32.dll!recv+0x31 > LIBEAY32.dll!BIO_sock_should_retry+0x57 > postgres.exe!my_soc

Re: [GENERAL] Idle processes chewing up CPU?

2009-08-18 Thread Brendan Hill
Hi Craig/Tom, I've managed to trap the full stack trace this time - 2 processes chewing up 25% each (1 core each on a quad core server), while SELECT * FROM pg_stat_activity revealed they were . I also confirmed that the two runaway processes were started by a developer remotely connecting pgAdmin

Re: [GENERAL] 2 versions of Postgres on the same machine

2009-08-18 Thread Sachin Srivastava
On 08/18/2009 10:34 PM, Devrim GÜNDÜZ wrote: On Tue, 2009-08-18 at 02:16 -0700, wstrzalka wrote: Is there any clever way to install parallel version of PG using yum or other way (without compilation please :D ) There is no way to do it with RPMS :( Install one of the versions usi

Re: [GENERAL] Function Logging

2009-08-18 Thread Craig Ringer
On 18/08/2009 9:26 PM, Adrian Klaver wrote: On Monday 17 August 2009 8:50:09 pm Andrew Bartley wrote: So the information i have thus far is that, I am not easily able to log the statements from a function. Does anyone know why it was removed... that is it 7.2 logged this information. Thanks Ag

Re: [GENERAL] text type has no default operator class for GIN?

2009-08-18 Thread Tom Lane
Sam Mason writes: > On Tue, Aug 18, 2009 at 03:50:47PM -0600, Bob Gobeille wrote: >>> CREATE INDEX "ufile_name_search" ON "public"."uploadtree" USING GIN >>> ("ufile_name"); >>> ERROR: data type text has no default operator class for access method >>> "gin" > Not sure if understand very well mys

Re: [GENERAL] text type has no default operator class for GIN?

2009-08-18 Thread Sam Mason
On Tue, Aug 18, 2009 at 03:50:47PM -0600, Bob Gobeille wrote: > On Aug 18, 2009, at 3:46 PM, Gobeille, Robert wrote: > >CREATE INDEX "ufile_name_search" ON "public"."uploadtree" USING GIN > >("ufile_name"); > > > >ERROR: data type text has no default operator class for access method > >"gin" > >HI

Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-18 Thread Adam Rich
Andre, See this PHP page: http://www.php.net/manual/en/function.pg-last-notice.php Andre Lopes wrote: Hi, I'm developing a function with some checks, for example... to check if the e-mail is valid or not. If the e-mail is not valid I put a line with RAISE NOTICE 'E-mail not valid'. I n

Re: [GENERAL] text type has no default operator class for GIN?

2009-08-18 Thread Bob Gobeille
On Aug 18, 2009, at 3:46 PM, Gobeille, Robert wrote: CREATE INDEX "ufile_name_search" ON "public"."uploadtree" USING GIN ("ufile_name"); ERROR: data type text has no default operator class for access method "gin" HINT: You must specify an operator class for the index or define a default oper

[GENERAL] text type has no default operator class for GIN?

2009-08-18 Thread Bob Gobeille
CREATE INDEX "ufile_name_search" ON "public"."uploadtree" USING GIN ("ufile_name"); ERROR: data type text has no default operator class for access method "gin" HINT: You must specify an operator class for the index or define a default operator class for the data type. This is on a new 8

Re: [GENERAL] Access Control System - Design

2009-08-18 Thread John R Pierce
Andre Lopes wrote: Hi, I need to implement a "Access Control System", but I don't have any clue of what it is the ideal system... I will try to explain my problem... I have 4 levels of users in my web application, "Super Administrator", "Administrator", "Manager" and "Worker". The database

Re: [GENERAL] index "pg_authid_rolname_index" is not a btree

2009-08-18 Thread Alvaro Herrera
Andrus Moor wrote: > Hard disk containing PostgreSql 8.1 database on Windows crashes and > there was no new > backup copy. > > I installed 8.1.9 to new computer and copied data directory from > crashed disk to it. > data directory contains a lot of files with a lot of data. > > Trying to connect

Re: [GENERAL] Any justification for sequence table vs. native sequences?

2009-08-18 Thread Tom Lane
Bill Moran writes: > And yes, it's pretty much guaranteed to be slower than built in sequences, > with > blocking when multiple threads want a sequence all at the same time. It's also going to create a vacuum bottleneck unless the insert rate is quite low, because each ID assignment will create

Re: [GENERAL] PL/PGSQL: why IF test the whole condition before failing or not?

2009-08-18 Thread Tom Lane
Suporte PK writes: > IF TG_OP = 'UPDATE' AND OLD.field != NEW.field THEN > ... > The question is: if the trigger was not fired by an UPDATE event, > shouldn't it make the first test and then ignore the rest of the condition? No. This is a very very common error. The behavior is not as short-ci

[GENERAL] PL/PGSQL: why IF test the whole condition before failing or not?

2009-08-18 Thread Suporte PK
Hi list, I'm having trouble with - believe me! - the IF operator on a PL/PGSQL function used by a trigger. I'm using one unique function to process the three triggers events (delete, update and insert), but when I reference OLD or NEW on a IF CONDITION, I get an error even when testing BEFOR

[GENERAL] Access Control System - Design

2009-08-18 Thread Andre Lopes
Hi, I need to implement a "Access Control System", but I don't have any clue of what it is the ideal system... I will try to explain my problem... I have 4 levels of users in my web application, "Super Administrator", "Administrator", "Manager" and "Worker". The database have data from more than

Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-18 Thread Scott Marlowe
On Tue, Aug 18, 2009 at 10:57 AM, Andre Lopes wrote: > Hi, > > I'm developing a function with some checks, for example... to check if the > e-mail is valid or not. > > If the e-mail is not valid I put a line with RAISE NOTICE 'E-mail not > valid'. > > I need to know if it is possible to show this R

Re: [GENERAL] Any justification for sequence table vs. native sequences?

2009-08-18 Thread Bill Moran
Doug Gorley wrote: > > I just stumbled across this table in a database > developed by a collegue: > > > field_name | next_value | lock > +-+ > id_alert| 500010 | FREE > id_page | 500087 | FREE > id_group| 500021 | FREE > > > These "i

Re: [GENERAL] Any justification for sequence table vs. native sequences?

2009-08-18 Thread Stuart McGraw
On 08/18/2009 01:14 PM, Doug Gorley wrote: I just stumbled across this table in a database developed by a collegue: field_name | next_value | lock +-+ id_alert| 500010 | FREE id_page | 500087 | FREE id_group| 500021 | FREE These "id

[GENERAL] Any justification for sequence table vs. native sequences?

2009-08-18 Thread Doug Gorley
I just stumbled across this table in a database developed by a collegue: field_name | next_value | lock +-+ id_alert| 500010 | FREE id_page | 500087 | FREE id_group| 500021 | FREE These "id_" fields correspond to the primary keys on

[GENERAL] Fwd: PQgetlength vs. octet_length()

2009-08-18 Thread Michael Clark
On Tue, Aug 18, 2009 at 1:48 PM, Greg Stark wrote: > On Tue, Aug 18, 2009 at 6:39 PM, Michael Clark > wrote: > > But it seems pretty crazy that a 140meg bit of data goes to 1.3 gigs. > Does > > that seem a bit excessive? > > From what you posted earlier it looked like it was turning into about >

Re: [GENERAL] Unit conversion database (was: multiple paramters in aggregate function)

2009-08-18 Thread Alban Hertroys
Hello all, Inspired by the original discussion on aggregating quantities of different units I made a start at a unit conversion database and the result is here: http://solfertje.student.utwente.nl/documents/units.sql This is not a complete implementation, I just thought I'd show you what

Re: [GENERAL] PQgetlength vs. octet_length()

2009-08-18 Thread Greg Stark
On Tue, Aug 18, 2009 at 6:39 PM, Michael Clark wrote: > But it seems pretty crazy that a 140meg bit of data goes to 1.3 gigs.  Does > that seem a bit excessive? From what you posted earlier it looked like it was turning into about 500M which sounds about right. Presumably either libpq or your code

[GENERAL] PQgetlength vs. octet_length()

2009-08-18 Thread Michael Clark
This thread was originally posted (incorrectly by me) to the hackers mailing list. Moving the discussion to the gerenal. Hi Greg, That is what Pierre pointed out, and you are both right. I am using the text mode. But it seems pretty crazy that a 140meg bit of data goes to 1.3 gigs. Does that

Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-18 Thread Randal L. Schwartz
> "Andre" == Andre Lopes writes: Andre> I'm developing a function with some checks, for example... to check if the Andre> e-mail is valid or not. How are you hoping to do this? The regex to validate an email address syntactically is pretty large: http://ex-parrot.com/~pdw/Mail-RFC822-Ad

Re: [GENERAL] 2 versions of Postgres on the same machine

2009-08-18 Thread Devrim GÜNDÜZ
On Tue, 2009-08-18 at 02:16 -0700, wstrzalka wrote: >Is there any clever way to install parallel version of PG using yum > or other way (without compilation please :D ) There is no way to do it with RPMS :( Install one of the versions using yum, and compile the other please. -- Devrim GÜNDÜZ,

[GENERAL] Postgre RAISE NOTICE and PHP

2009-08-18 Thread Andre Lopes
Hi, I'm developing a function with some checks, for example... to check if the e-mail is valid or not. If the e-mail is not valid I put a line with RAISE NOTICE 'E-mail not valid'. I need to know if it is possible to show this RAISE NOTICE when I run this function from PHP. Best Regards, André

Re: [GENERAL] comparing NEW and OLD (any good this way?)

2009-08-18 Thread Daniel Verite
Sam Mason wrote: > > You're intentionally assuming that row(null) IS NULL evaluating to true > > implies that row(null) can be replaced by NULL. As discussed upthread, this > > is not the case. > > But you've still not said how is this useful! To me, IS NULL applied to rows, as a test of

Re: [GENERAL] Configuration Question

2009-08-18 Thread Tom Lane
Terry Lee Tucker writes: > Is there a way to get hold of an environment variable such that it can be > referenced in postgresql.conf? No, but you could perhaps set that GUC on the postmaster command line instead. postmaster ... --dynamic_library_path="$SOURCE:$$libdir"

Re: [GENERAL] Configuration Question

2009-08-18 Thread Terry Lee Tucker
On Tuesday 18 August 2009 09:28, Martin Gainty wrote: > v8.3 FAQ_Solaris > > To point it to the right location, set the > LD_LIBRARY_PATH environment variable, e.g., > > LD_LIBRARY_PATH=/usr/sfw/lib:/opt/sfw/lib:/usr/local/lib > export LD_LIBRARY_PATH > > and restart configure. You will al

Re: [GENERAL] Configuration Question

2009-08-18 Thread Martin Gainty
v8.3 FAQ_Solaris To point it to the right location, set the LD_LIBRARY_PATH environment variable, e.g., LD_LIBRARY_PATH=/usr/sfw/lib:/opt/sfw/lib:/usr/local/lib export LD_LIBRARY_PATH and restart configure. You will also have to keep this setting whenever you run any of the installed P

Re: [GENERAL] Function Logging

2009-08-18 Thread Adrian Klaver
On Monday 17 August 2009 8:50:09 pm Andrew Bartley wrote: > So the information i have thus far is that, I am not easily able to log the > statements from a function. > > Does anyone know why it was removed... that is it 7.2 logged this > information. > > Thanks Again > > Andrew Bartley > You are g

Re: [GENERAL] design, plpgsql and sql injection in dynamically generated sql

2009-08-18 Thread Pavel Stehule
2009/8/18 Ivan Sergio Borgonovo : > On Tue, 18 Aug 2009 12:38:49 +0200 > Pavel Stehule wrote: > >> some unsafe function: > > I suspected something similar. > > I think many would appreciate if you put these examples here > http://www.okbob.blogspot.com/2008/06/execute-using-feature-in-postgresql-8

Re: [GENERAL] Best database model for canvassing (and analysing) opinion

2009-08-18 Thread Sam Mason
On Tue, Aug 18, 2009 at 05:24:52AM -0700, John R Pierce wrote: > Sam Mason wrote: > > SELECT course, date, COUNT(*) > > FROM application_preferred_date > > GROUP BY course, date; > > the problem as stated is more complex than that. A student could, in > theory, pick several different courses

Re: [GENERAL] There are procedures in Postgres 8.3?

2009-08-18 Thread Pavel Stehule
2009/8/18 Andre Lopes : > Hi, > > I have some functions developed in postgres to work as a procedure. But now > I see in the Postgres Studio that we have the option to create a > procedure... So my question? there are procedures in Postgres 8.3? If yes, > what the correct syntax to write procedures

[GENERAL] index "pg_authid_rolname_index" is not a btree

2009-08-18 Thread Andrus Moor
Hard disk containing PostgreSql 8.1 database on Windows crashes and there was no new backup copy. I installed 8.1.9 to new computer and copied data directory from crashed disk to it. data directory contains a lot of files with a lot of data. Trying to connect to template0 or any other databas

Re: [GENERAL] There are procedures in Postgres 8.3?

2009-08-18 Thread Sam Mason
On Tue, Aug 18, 2009 at 12:48:49PM +0100, Andre Lopes wrote: > I have some functions developed in postgres to work as a procedure. But now > I see in the Postgres Studio that we have the option to create a > procedure... Really, I've never noticed them! If you're asking about EnterpriseDB specific

Re: [GENERAL] Best database model for canvassing (and analysing) opinion

2009-08-18 Thread John R Pierce
Sam Mason wrote: SELECT course, date, COUNT(*) FROM application_preferred_date GROUP BY course, date; Hope that gives you some ideas! the problem as stated is more complex than that. A student could, in theory, pick several different courses on the same dates on the assumption that

[GENERAL] There are procedures in Postgres 8.3?

2009-08-18 Thread Andre Lopes
Hi, I have some functions developed in postgres to work as a procedure. But now I see in the Postgres Studio that we have the option to create a procedure... So my question? there are procedures in Postgres 8.3? If yes, what the correct syntax to write procedures in Postgres 8.3? Best Regards, An

Re: [GENERAL] multiple paramters in aggregate function

2009-08-18 Thread Alban Hertroys
On 18 Aug 2009, at 6:51, Sim Zacks wrote: That would be true if all units were always convertible to mm, but we have volume also, we also have feet etc.. So that the easiest and How did you plan on solving that in your multiple-argument aggregate? Fake their value by adding 0? That's no diff

Re: [GENERAL] Best database model for canvassing (and analysing) opinion

2009-08-18 Thread Sam Mason
On Tue, Aug 18, 2009 at 08:58:12AM +, Sebastian Tennant wrote: > Perhaps the simplest model is a database table 'application_forms' which > includes two text columns; 'course' and 'preferred_dates' with entries that > look like this: > > course: "Drama" > prefered_dates: "Sat_22Aug09

Re: [GENERAL] design, plpgsql and sql injection in dynamically generated sql

2009-08-18 Thread Ivan Sergio Borgonovo
On Tue, 18 Aug 2009 12:38:49 +0200 Pavel Stehule wrote: > some unsafe function: I suspected something similar. I think many would appreciate if you put these examples here http://www.okbob.blogspot.com/2008/06/execute-using-feature-in-postgresql-84.html and substitute the int example there with

Re: [GENERAL] 2 versions of Postgres on the same machine

2009-08-18 Thread Sam Mason
On Tue, Aug 18, 2009 at 02:16:20AM -0700, wstrzalka wrote: >I need to have 8.3 & 8.4 installed on the same machine (for > pg_migrator). As I'm not Linux guru I used to install/update Postgres > using yum from PGDG. If you could use Debian or something based on it (e.g. Ubuntu) then this is how

Re: [GENERAL] comparing NEW and OLD (any good this way?)

2009-08-18 Thread Sam Mason
On Tue, Aug 18, 2009 at 10:32:35AM +0200, Daniel Verite wrote: > Sam Mason wrote: > > I've just realized another case where it's not consistent; why does the > > following return true: > > > > SELECT row(null) IS NULL; > > > > and yet the following false: > > > > SELECT row(row(null)) IS NUL

Re: [GENERAL] design, plpgsql and sql injection in dynamically generated sql

2009-08-18 Thread Pavel Stehule
2009/8/18 Ivan Sergio Borgonovo : > On Mon, 17 Aug 2009 12:48:21 +0200 > Pavel Stehule wrote: > >> Hello >> >> I am not sure, if it's possible for you. PostgreSQL 8.4 has EXECUTE >> USING clause, it is 100% safe. > > Sorry I don't get it. > > How can I use USING safely when the substitution involv

[GENERAL] Configuration Question

2009-08-18 Thread Terry Lee Tucker
Greetings: Is there a way to get hold of an environment variable such that it can be referenced in postgresql.conf? In particular, I'd like to be able to point dynamic_library_path to an environment variable defined at the system level as in dynamic_library_path = '$SOURCE:$libdir'. master=# s

Re: [GENERAL] design, plpgsql and sql injection in dynamically generated sql

2009-08-18 Thread Ivan Sergio Borgonovo
On Mon, 17 Aug 2009 12:48:21 +0200 Pavel Stehule wrote: > Hello > > I am not sure, if it's possible for you. PostgreSQL 8.4 has EXECUTE > USING clause, it is 100% safe. Sorry I don't get it. How can I use USING safely when the substitution involves a table name? The examples I've seen just in

Re: [GENERAL] psql command line editor

2009-08-18 Thread Jasen Betts
On 2009-08-17, Bob Gobeille wrote: > I use PSQL to set my editor to vi. This works as expected in psql, \e > brings up vi and I edit away. > > Is there any way to set my psql command line editor to also use vi > (just like I do with "set -o vi" in bash)? > I can't find this in the docs. psql

Re: [GENERAL] 2 versions of Postgres on the same machine

2009-08-18 Thread John R Pierce
wstrzalka wrote: Hi This is probably more like linux question but strictly related to PG so I hope somebody can help me. I need to have 8.3 & 8.4 installed on the same machine (for pg_migrator). As I'm not Linux guru I used to install/update Postgres using yum from PGDG. Is there any

[GENERAL] 2 versions of Postgres on the same machine

2009-08-18 Thread wstrzalka
Hi This is probably more like linux question but strictly related to PG so I hope somebody can help me. I need to have 8.3 & 8.4 installed on the same machine (for pg_migrator). As I'm not Linux guru I used to install/update Postgres using yum from PGDG. Is there any clever way to insta

[GENERAL] Best database model for canvassing (and analysing) opinion

2009-08-18 Thread Sebastian Tennant
Hi all, A school wants to offer a number of short courses on a number of different dates. Students apply online for a single course at a time and choose one or more dates (from a list) which would suit them. Once the application period is over which course is taught when is decided soley on the b

Re: [GENERAL] comparing NEW and OLD (any good this way?)

2009-08-18 Thread Daniel Verite
Sam Mason wrote: > I've just realized another case where it's not consistent; why does the > following return true: > > SELECT row(null) IS NULL; > > and yet the following false: > > SELECT row(row(null)) IS NULL; You're intentionally assuming that row(null) IS NULL evaluating to t