Re: [GENERAL] Oracle and Postgresql Play Nice Together on Same Computer?

2005-01-20 Thread Ian Barwick
On Thu, 20 Jan 2005 00:03:28 -0500, Troyston Campano
[EMAIL PROTECTED] wrote:
 
 Hello, 
 
 I am an Oracle DBA and I want do a Postgresql 'proof of concept' at the
 large corporation where I work to test the benefits of using Postgresql in
 our environment. I want to install Postgresql onto a production server
 that currently runs Oracle. Are there any problems with running Postgresql
 and Oracle on the same machine? I mean, I've heard that the way Sybase and
 DB2 UDB are architected to handle memory hurts Sybase when DB2 UDB is
 installed on the same machine as the Sybase Server (something about UDB
 eating up all the memory and not giving it back to Sybase). 
 
 Are there any issues running Postgresql and Oracle on the same
 machineanything special to know about memory, disk layout, and things like
 that? I just want to make sure the two engines play together on this same
 server. I had a hard time finding information about this via google. 

For testing purposes there shouldn't be any problems, at least in a
*NIX environment. PostgreSQL is very undemanding and compared to
Oracle is positively minuscule (at least as far as its installation
footprint goes). I've run PostgreSQL, MySQL, DB2 and Oracle on the
same development machine without any issues. Of course if another
application is in constant use on a production server PostgreSQL won't
perform as well as it could.

Ian Barwick

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [GENERAL] ECPG Segfaulting on EXEC SQL connect

2005-01-20 Thread Michael Meskes
On Wed, Jan 19, 2005 at 06:07:24PM +0100, Hans-Michael Stahl wrote:
 It is from a very large production example. I have to work a bit to trim 
 this down to a small example.  I'llt try to provide an example. I now 
 also remember that the problem *only* occurs with dynamically prepared 
 statements with cursors, static statements with cursors work w/o problems.

Okay, please let me know when you have a test case. I'd surely like to
fix that. :-)

  Go SF 49ers!
 
 What's that?

My favourite NFL team, that's professional american style football in the US. 

  Go Rhein Fire!
 
 And that?

My favourite and local NFLE team, that's professional (more or less)
american style football in Europe.

  Use PostgreSQL!
 
 Yes, when Embedded SQL works again :-)

Okay, let's work on that one. :-)

Michael
-- 
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: [EMAIL PROTECTED]
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [GENERAL] Unique Index

2005-01-20 Thread Dawid Kuroczko
On Thu, 20 Jan 2005 15:20:26 +1100, Alex [EMAIL PROTECTED] wrote:
 I actually just wanted to know if there is a way around this problem.
 Obviously it is implemented that way for whatever reason.

Well, if you really need it, partial indexes are your friends! :)

For clarity, let's say you have:
CREATE TABLE foo (
   a int,
   b int,
   c int,
);
And an INDEX:
CREATE UNIQUE INDEX foo_abc_index ON foo (a,b,c);

Now, you want to make sure a and b are UNIQUE, when c is null; just do:
CREATE UNIQUE INDEX foo_abN_index ON foo (a,b) WHERE c IS NULL;

Or even, to make b UNIQUE when a and c are null:
CREATE UNIQUE INDEX foo_NbN_index ON foo (b) WHERE a IS NULL AND c IS NULL;

You need to create such partial indexes for each set of columns
you want to be unique-with-null.

Don't worry about index bloat.  These additional indexes will be used
only when your main (foo_abc_index) is not used, so there won't be
any duplicate data in them.

Isn't PostgreSQL great? :)

   Regards,
  Dawid

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


[GENERAL] =?iso-8859-1?Q?Re:_[ADMIN]_Oracle_and_Postgresql_Play_Nice_Together_on_Same_Computer??=

2005-01-20 Thread simon

Troyston Campano [EMAIL PROTECTED] wrote on 20.01.2005,
06:03:28:
 I am an Oracle DBA and I want do a Postgresql 'proof of concept' at the
 large corporation where I work to test the benefits of using Postgresql in
 our environment. I want to install Postgresql onto a production server
 that currently runs Oracle. Are there any problems with running Postgresql
 and Oracle on the same machine? I mean, I've heard that the way Sybase and
 DB2 UDB are architected to handle memory hurts Sybase when DB2 UDB is
 installed on the same machine as the Sybase Server (something about UDB
 eating up all the memory and not giving it back to Sybase).
 
  
 
 Are there any issues running Postgresql and Oracle on the same
 machine.anything special to know about memory, disk layout, and things like
 that? I just want to make sure the two engines play together on this same
 server. I had a hard time finding information about this via google.
 

There should be no issues running both on the same machine. Running both
together at the same time isn't a good way of doing a benchmark
though...

I would question your intent slightly. Should it be a relative
comparison? Or should it be an assessment of what PostgreSQL is capable
of and whether that fits a sufficient number of your needs to make it
worth adopting?

There are many ways to structure a decision as to whether PostgreSQL is
suitable for your (business?) needs. Which structure you choose is
likely to prejudice your decision, one way or the other. i.e. if
capital acquisition costs are the decising factor, then PostgreSQL
would always win.

Best Regards, Simon Riggs

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread Bruno Almeida do Lago
I still opt for Slackware simplicity and stability. Nothing better than a
well configured Slackware box with XFS file system and PostgreSQL! =)

C Ya,
Bruno

 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ron Mayer
Sent: Wednesday, January 19, 2005 3:32 PM
To: Martijn van Oosterhout; pgsql-general@postgresql.org
Subject: Re: [GENERAL] Best Linux Distribution

When I had customers faced with this decision, we made the
recommendation based on which distro employs major contributors
of the software project in question.

For Postgresql's case, RedHat's employment of Tom made
our recommendation to use Red Hat.

Some of our clients are running .NET front ends, so we're
recommending Novel/SuSE for those.

It's a mix of superstition that the vendors platform is
may see earlier testing, along with rewarding the vendor
for supporting the project.

Ron

PS: All you open source vendors who employ important
developers -- Thank You - this contribution does not go unnoticed.



Martijn van Oosterhout wrote:
 No difference whatsoever from PostgreSQL's point of view. Use whichever
 distribution is easiest for you to administer. After all, there's no
 point installing Postgres on a machine you don't know how to maintain
 or tune :)
 
 Hope this helps,
 
 On Sat, Jan 08, 2005 at 11:14:00AM -0300, Esteban Kemp wrote:
 
I'm starting to develop a production enviroment with Postgres and
Tomcat, And I have to choose between some free linux distribution
like:

whitebox
RHEL
Fedora
Suse

Which is the better distribution in terms of postgres? if this has an
answer

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread Marco Colombo
On Wed, 19 Jan 2005, Joshua D. Drake wrote:
Martijn van Oosterhout wrote:
No difference whatsoever from PostgreSQL's point of view. Use whichever
distribution is easiest for you to administer. After all, there's no
point installing Postgres on a machine you don't know how to maintain
or tune :)
Actually there is a difference from PostgreSQL's point of view :)
Namely in filesystems. The default filesystem on whitebox, RHEL and
Fedora is EXT3 which really isn't that great.
 ^
Is there any evidence of the above claim? I've seen a link to a l-k
bug report about ext3, but apparently it was totally unconfirmed
(and a single bug does not mean a FS is not good - I remember XFS
being hammered heavily before being accepted into Linux).
I'm using ext3 cause all other FSes are simple add-ons in linux.
All of them struggled a lot before being able to meet linux high
quality standards and being accepted into mainstream. Ext3 was there
from the start. Of course that doesn't mean it fits PostgreSQL needs
better than other FSes.
.TM.
--
  /  /   /
 /  /   /   Marco Colombo
___/  ___  /   /  Technical Manager
   /  /   /  ESI s.r.l.
 _/ _/  _/ [EMAIL PROTECTED]
---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
 joining column's datatypes do not match


Re: [GENERAL] =?iso-8859-1?Q?Re:_[ADMIN]_Oracle_and_Postgresql_Play_Nice_Together_on_Same_Computer??=

2005-01-20 Thread Marco Colombo
On Thu, 20 Jan 2005 [EMAIL PROTECTED] wrote:
Troyston Campano [EMAIL PROTECTED] wrote on 20.01.2005,
06:03:28:
I am an Oracle DBA and I want do a Postgresql 'proof of concept' at the
large corporation where I work to test the benefits of using Postgresql in
our environment. I want to install Postgresql onto a production server
that currently runs Oracle. Are there any problems with running Postgresql
and Oracle on the same machine? I mean, I've heard that the way Sybase and
DB2 UDB are architected to handle memory hurts Sybase when DB2 UDB is
installed on the same machine as the Sybase Server (something about UDB
eating up all the memory and not giving it back to Sybase).

Are there any issues running Postgresql and Oracle on the same
machine.anything special to know about memory, disk layout, and things like
that? I just want to make sure the two engines play together on this same
server. I had a hard time finding information about this via google.
There should be no issues running both on the same machine. Running both
together at the same time isn't a good way of doing a benchmark
though...
I would question your intent slightly. Should it be a relative
comparison? Or should it be an assessment of what PostgreSQL is capable
of and whether that fits a sufficient number of your needs to make it
worth adopting?
There are many ways to structure a decision as to whether PostgreSQL is
suitable for your (business?) needs. Which structure you choose is
likely to prejudice your decision, one way or the other. i.e. if
capital acquisition costs are the decising factor, then PostgreSQL
would always win.
I may add that using the right tool for the right task should be
a priority. It's easy to underestimate the cost of continuosly
adapting your needs to the tool and not the opposite.
About Oracle I keep hearing success or horror stories. About PostgreSQL
mostly success stories, some unsuccess stories (it's good but we switched
back to MS SQL ), _very_ few horror stories. Last horror story was 
about data worth having but not backupping, a category existing only
in some manager's mind (and _deserving_ a horror story).

Note that I've never heard any unsuccess story about Oracle. I know 
some people that would tell one, if only they actually tried PostgreSQL
out - but that's my opinion, not thiers (yet).

IMHO, migrating from Oracle to PostgreSQL usually doesn't expose 
all PostgreSQL pros, and will expose some weaknesses or missing features.
Migrating from PostgreSQL to Oracle is what really makes PostgreSQL shine.
Too bad it happens so rarely. :-)

.TM.
--
  /  /   /
 /  /   /   Marco Colombo
___/  ___  /   /  Technical Manager
   /  /   /  ESI s.r.l.
 _/ _/  _/ [EMAIL PROTECTED]
---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread Abdul-Wahid Paterson
I think the filesystem you choose depends what you are looking for.
Ext3 is by far the most tested and most stable out the file systems
available. It is basically just ext2 with journalling stuck on top
(and a few other niceities). XFS may well be faster but is perhaps not
so well tested or as stable. My choise for stability would be ext3 and
for speed would be xfs.

As for the OS, it probably doesn't make much difference. My personal
choice though is gentoo. My reasons are.

1. The postgres server is compiled with optimised gcc flags.
2. Gentoo have many different versions of postgres available and is
easy to upgrade /change between versions. Looking at the versions
available now they have from
7.3.6 to 8.0. (8.0 is still marked as testing)

Regards,

Abdul-Wahid



On Thu, 20 Jan 2005 11:34:31 +0100 (CET), Marco Colombo
[EMAIL PROTECTED] wrote:
 On Wed, 19 Jan 2005, Joshua D. Drake wrote:
 
  Martijn van Oosterhout wrote:
 
  No difference whatsoever from PostgreSQL's point of view. Use whichever
  distribution is easiest for you to administer. After all, there's no
  point installing Postgres on a machine you don't know how to maintain
  or tune :)
 
  Actually there is a difference from PostgreSQL's point of view :)
  Namely in filesystems. The default filesystem on whitebox, RHEL and
  Fedora is EXT3 which really isn't that great.
   ^
 
 Is there any evidence of the above claim? I've seen a link to a l-k
 bug report about ext3, but apparently it was totally unconfirmed
 (and a single bug does not mean a FS is not good - I remember XFS
 being hammered heavily before being accepted into Linux).
 
 I'm using ext3 cause all other FSes are simple add-ons in linux.
 All of them struggled a lot before being able to meet linux high
 quality standards and being accepted into mainstream. Ext3 was there
 from the start. Of course that doesn't mean it fits PostgreSQL needs
 better than other FSes.
 
 .TM.
 --
/  /   /
   /  /   /  Marco Colombo
  ___/  ___  /   / Technical Manager
 /  /   / ESI s.r.l.
   _/ _/  _/[EMAIL PROTECTED]
 
 ---(end of broadcast)---
 TIP 9: the planner will ignore your desire to choose an index scan if your
   joining column's datatypes do not match


---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [GENERAL] Multiline plpython procedure

2005-01-20 Thread Martijn van Oosterhout
On Wed, Jan 19, 2005 at 07:06:49PM -0500, Frank D. Engel, Jr. wrote:
 Uh, does the Python doc specify platform line endings, or normal 
 (\n) line endings?  It sounded to me like it always wanted the 
 UNIX-style \n line endings, so that using those would result in 
 portability...

That's the problem, Python specifies platform line endings. See this
note:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66434
 When working between platforms, it is often necessary to convert the
 line endings on files for them to work, especially when it comes to
 code. Pass Unix Python code with \r and it goes nowhere. Same on Mac
 Python with \n. This code simply and easily fixes the problem.

Note, one of these links provides a possible solution:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/59867
 This code eliminates the need to convert line endings when moving .py
 modules between OSes. Put in your sitecustomize.py, anywhere on
 sys.path, and you'll be able to import Python modules with any of
 Unix, Mac, or Windows line endings, on any OS.

I don't understand how it works, but people claim it solves their
problem...

Hope this helps,
-- 
Martijn van Oosterhout   kleptog@svana.org   http://svana.org/kleptog/
 Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
 tool for doing 5% of the work and then sitting around waiting for someone
 else to do the other 95% so you can sue them.


pgpYc6QxjnxWp.pgp
Description: PGP signature


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread Vittorio
Alle 10:09, giovedì 20 gennaio 2005, Bruno Almeida do Lago ha scritto:
 I still opt for Slackware simplicity and stability. Nothing better than a
 well configured Slackware box with XFS file system and PostgreSQL! =)

 C Ya,
 Bruno

For a generic use of postgresql,  binary packages in any linux distribution 
are good and reliable. In some cases, i.e. in a production context where you 
have to optimize your postgresql,  the ability of configuring and compiling 
postgresql from sources is a must. This should make you use a more flexible 
distribution like slackware and gentoo with which you can prepare your linux 
box from scratch by compiling everything according to your needs (it isn't 
enough to have a binary linux distribituion installed and only postgresql 
compiled from sources).

Ciao
Vittorio


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [GENERAL] Unique Index

2005-01-20 Thread Martijn van Oosterhout
On Thu, Jan 20, 2005 at 04:32:37PM +0900, Michael Glaesemann wrote:
 
 On Jan 20, 2005, at 16:03, David Garamond wrote:
 
 Dann Corbit wrote:
 True, but the standard says nothing about the creation of an index, so
 you can make it behave in any way that you see fit.
 
 But I thought we are talking about unique _constraint_ here (which is 
 certainly regulated by the standard).
 
 They could conceivably be separated. The standard likewise doesn't say 
 anything about how the unique constraint is enforced. In PostgreSQL, a 
 unique index is used to enforce the constraint, but the unique index 
 is not intrinsically tied to the unique constraint.

Ofcourse, but then you'd have to create another UNIQUE index type just
to handle the constraint, so you could define two types of unique:

CREATE UNIQUE INDEX blah on (...)
CREATE POSTGRESQL_STRANGE_UNIQUE INDEX blah on  (...)

the former being used by CREATE CONSTRAINT. After all, we'd just be
incompatable with everyone else, no point using a standard keyword.

This is just more confusing when there are already perfectly workable
solutions to the problem as given. Don't use NULL when it's not
appropriate.

Hope this helps,
-- 
Martijn van Oosterhout   kleptog@svana.org   http://svana.org/kleptog/
 Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
 tool for doing 5% of the work and then sitting around waiting for someone
 else to do the other 95% so you can sue them.


pgpVmX5Ao4gHK.pgp
Description: PGP signature


Re: [GENERAL] Oracle and Postgresql Play Nice Together on Same Computer?

2005-01-20 Thread Troyston Campano
I guess what I am concerned about *is* running on a production server more
than a test server. Basically, I'd be taking a couple applications that are
running on the Oracle database instance, building a Postgresql instance, and
migrating them to that postgresql database instance. I'm just wondering
whether it's a bad idea to run them on the same server machine in a
production environment. (So instead of having 10 applications running on
Oracle on ServerComputerA...build a new postgresql instance on
ServerComputerA that lives along with Oracle and migrating 3 of the
applications to Postgresql.

Thank you for your time!

~ Troyston Campano ~

-Original Message-
From: Ian Barwick [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 20, 2005 3:07 AM
To: Troyston Campano
Cc: pgsql-admin@postgresql.org; pgsql-general@postgresql.org
Subject: Re: [GENERAL] Oracle and Postgresql Play Nice Together on Same
Computer?

On Thu, 20 Jan 2005 00:03:28 -0500, Troyston Campano
[EMAIL PROTECTED] wrote:
 
 Hello, 
 
 I am an Oracle DBA and I want do a Postgresql 'proof of concept' at the
 large corporation where I work to test the benefits of using Postgresql in
 our environment. I want to install Postgresql onto a production server
 that currently runs Oracle. Are there any problems with running Postgresql
 and Oracle on the same machine? I mean, I've heard that the way Sybase and
 DB2 UDB are architected to handle memory hurts Sybase when DB2 UDB is
 installed on the same machine as the Sybase Server (something about UDB
 eating up all the memory and not giving it back to Sybase). 
 
 Are there any issues running Postgresql and Oracle on the same
 machine.anything special to know about memory, disk layout, and things
like
 that? I just want to make sure the two engines play together on this same
 server. I had a hard time finding information about this via google. 

For testing purposes there shouldn't be any problems, at least in a
*NIX environment. PostgreSQL is very undemanding and compared to
Oracle is positively minuscule (at least as far as its installation
footprint goes). I've run PostgreSQL, MySQL, DB2 and Oracle on the
same development machine without any issues. Of course if another
application is in constant use on a production server PostgreSQL won't
perform as well as it could.

Ian Barwick


---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [GENERAL] [ADMIN] Oracle and Postgresql Play Nice Together on Same Computer?

2005-01-20 Thread Troyston Campano
Basically, we want to take 3 of the 10 applications running on Oracle, move
them to Postgresql on the same computer/server and just make sure it runs
about the same (really speed, memory usage, and space are the big issues).
I'm not concerned with how hard the migration will be and things like that.
The database is very low in complexity so the migration should be cake.

Thank you!

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 20, 2005 4:20 AM
To: Troyston Campano
Cc: pgsql-admin@postgresql.org; pgsql-general@postgresql.org
Subject: Re: [ADMIN] Oracle and Postgresql Play Nice Together on Same
Computer?


Troyston Campano [EMAIL PROTECTED] wrote on 20.01.2005,
06:03:28:
 I am an Oracle DBA and I want do a Postgresql 'proof of concept' at the
 large corporation where I work to test the benefits of using Postgresql in
 our environment. I want to install Postgresql onto a production server
 that currently runs Oracle. Are there any problems with running Postgresql
 and Oracle on the same machine? I mean, I've heard that the way Sybase and
 DB2 UDB are architected to handle memory hurts Sybase when DB2 UDB is
 installed on the same machine as the Sybase Server (something about UDB
 eating up all the memory and not giving it back to Sybase).
 
  
 
 Are there any issues running Postgresql and Oracle on the same
 machine.anything special to know about memory, disk layout, and things
like
 that? I just want to make sure the two engines play together on this same
 server. I had a hard time finding information about this via google.
 

There should be no issues running both on the same machine. Running both
together at the same time isn't a good way of doing a benchmark
though...

I would question your intent slightly. Should it be a relative
comparison? Or should it be an assessment of what PostgreSQL is capable
of and whether that fits a sufficient number of your needs to make it
worth adopting?

There are many ways to structure a decision as to whether PostgreSQL is
suitable for your (business?) needs. Which structure you choose is
likely to prejudice your decision, one way or the other. i.e. if
capital acquisition costs are the decising factor, then PostgreSQL
would always win.

Best Regards, Simon Riggs


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [GENERAL] Unique Index

2005-01-20 Thread Tom Lane
Greg Stark [EMAIL PROTECTED] writes:
 Tom Lane [EMAIL PROTECTED] writes:
 Direct your complaints to the ISO SQL standards committee.

 The SQL standard generally treats NULLs as a escape hatch for constraints.

Not for UNIQUE constraints.  SQL92 section 4.10 Integrity constraints:

 A unique constraint is satisfied if and only if no two rows in
 a table have the same non-null values in the unique columns. In
 addition, if the unique constraint was defined with PRIMARY KEY,
 then it requires that none of the values in the specified column or
 columns be the null value.

The short answer to this thread is that the OP is misusing nulls,
and should pick some non-null value to be his placeholder.

regards, tom lane

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


[GENERAL] Duplicate counting

2005-01-20 Thread Ji Nmec
Hello all,

I wrote a function which counts price of product from retail price and
discount. It works. But I need to count price with tax of same
product. The best way is to use counted price and add only a tax. I
would like to do by this way:

SELECT count_price(retail, discount) AS price, count_price_tax(price,
tax) FROM foo.

But PostgreSQL reports that price column doesn't exist. It doesn't
exist, but is counted by first calling count_price() function.

Is there some way how I shouldn't count these prices twice and use
just counted price?

-- 
Ji Nmec, ICQ: 114651500
www.menea.cz - www strnky a aplikace


---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


Re: [GENERAL] Debian Sarge, Postgres 7.4.6 + PAM

2005-01-20 Thread Bruno Lavoie
what should i put in /etc/pam.d/postgresql ?

i dont know how works pam, i'll read about it, but not enough time for
now, i added theses lines to /etc/pam.d/postgresql file:

authrequiredpam_unix.so nullok_secure
account requiredpam_unix.so


it works, auth via my unix users, is it the best way, the safest way?

thanks for help
Bruno

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [GENERAL] [ADMIN] Oracle and Postgresql Play Nice Together on Same Computer?

2005-01-20 Thread Alvaro Herrera
On Thu, Jan 20, 2005 at 08:03:42AM -0500, Troyston Campano wrote:
 Basically, we want to take 3 of the 10 applications running on Oracle, move
 them to Postgresql on the same computer/server and just make sure it runs
 about the same (really speed, memory usage, and space are the big issues).
 I'm not concerned with how hard the migration will be and things like that.

So you want Postgres to be a cheaper Oracle.  Hmm.  Maybe it will work,
but as Marco Colombo says, you are not going to see Postgres shining by
using that simplistic approach.  If you want that, maybe you should look
closely to see where you can find the rusty corner that needs to be
polished.

 The database is very low in complexity so the migration should be cake.

If you do things as simple as select count(*) from table, then you
will have to be careful to be really fair in your comparison; you could
misleadingly find that Postgres is much slower on that query.

-- 
Alvaro Herrera ([EMAIL PROTECTED])
Tulio: oh, para qué servirá este boton, Juan Carlos?
Policarpo: No, aléjense, no toquen la consola!
Juan Carlos: Lo apretaré una y otra vez.

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [GENERAL] Duplicate counting

2005-01-20 Thread Aaron Bingham
Ji Nmec wrote:
Hello all,
I wrote a function which counts price of product from retail price and
discount. It works. But I need to count price with tax of same
product. The best way is to use counted price and add only a tax. I
would like to do by this way:
SELECT count_price(retail, discount) AS price, count_price_tax(price,
tax) FROM foo.
But PostgreSQL reports that price column doesn't exist. It doesn't
exist, but is counted by first calling count_price() function.
Is there some way how I shouldn't count these prices twice and use
just counted price?
It's not quite clear to me what count_price and count_price_tax are 
supposed to do.  Does count_price_tax return the equivalent of 
price*(1.0+tax) (or maybe price*tax)?  If so, one way to do it is to use 
a sub-query like this:

SELECT price, count_price_tax(price, tax) FROM (SELECT 
count_price(retail, discount) AS price, tax FROM foo) AS bar;

--

Aaron Bingham
Application Developer
Cenix BioScience GmbH

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


[GENERAL] How to manually insert an UTF-8 character into an SQL statement?

2005-01-20 Thread Alban Hertroys
I'm trying to insert a record that contains an ô (o circumflex) into a 
table using the psql client.
I also tried with phppgadmin and pgadmin, but both can't do this. They 
insert a HTML entity and error out respectively. Not what I had in mind...

Supposedly I should be able to type:
INSERT INTO table (name) VALUES ('C\0x00f4te d''Azur');
but all I manage to achieve is inserting a capital 'C'...
It doesn't seem to matter to which encoding I set psql either.
What am I doing wrong?
Alban.
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread Frank D. Engel, Jr.
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
I think you forget the origins of the XFS filesystem.  XFS was 
originally created for SGI's IRIX operating system, and specifically 
designed for handling large files and filesystems at high speeds.  It 
is very fast, and quite well tested: it was in heavy use on IRIX 
systems before ever having been made available for Linux.

Check it out here:
http://oss.sgi.com/projects/xfs/
On Jan 20, 2005, at 7:23 AM, Abdul-Wahid Paterson wrote:
I think the filesystem you choose depends what you are looking for.
Ext3 is by far the most tested and most stable out the file systems
available. It is basically just ext2 with journalling stuck on top
(and a few other niceities). XFS may well be faster but is perhaps not
so well tested or as stable. My choise for stability would be ext3 and
for speed would be xfs.
As for the OS, it probably doesn't make much difference. My personal
choice though is gentoo. My reasons are.
1. The postgres server is compiled with optimised gcc flags.
2. Gentoo have many different versions of postgres available and is
easy to upgrade /change between versions. Looking at the versions
available now they have from
7.3.6 to 8.0. (8.0 is still marked as testing)
Regards,
Abdul-Wahid

On Thu, 20 Jan 2005 11:34:31 +0100 (CET), Marco Colombo
[EMAIL PROTECTED] wrote:
On Wed, 19 Jan 2005, Joshua D. Drake wrote:
Martijn van Oosterhout wrote:
No difference whatsoever from PostgreSQL's point of view. Use 
whichever
distribution is easiest for you to administer. After all, there's no
point installing Postgres on a machine you don't know how to 
maintain
or tune :)

Actually there is a difference from PostgreSQL's point of view :)
Namely in filesystems. The default filesystem on whitebox, RHEL and
Fedora is EXT3 which really isn't that great.
  ^
Is there any evidence of the above claim? I've seen a link to a l-k
bug report about ext3, but apparently it was totally unconfirmed
(and a single bug does not mean a FS is not good - I remember XFS
being hammered heavily before being accepted into Linux).
I'm using ext3 cause all other FSes are simple add-ons in linux.
All of them struggled a lot before being able to meet linux high
quality standards and being accepted into mainstream. Ext3 was there
from the start. Of course that doesn't mean it fits PostgreSQL needs
better than other FSes.
.TM.
--
   /  /   /
  /  /   /  Marco Colombo
 ___/  ___  /   / Technical Manager
/  /   / ESI s.r.l.
  _/ _/  _/[EMAIL PROTECTED]
---(end of 
broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if 
your
  joining column's datatypes do not match

---(end of 
broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org

- ---
Frank D. Engel, Jr.  [EMAIL PROTECTED]
$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep John 3:16
John 3:16 For God so loved the world, that he gave his only begotten 
Son, that whosoever believeth in him should not perish, but have 
everlasting life.
$
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFB77hE7aqtWrR9cZoRAqWDAJ90Ia0RaqdDydLBZ1qY87QlohuU4ACgkltP
FoATmnsg3CxK5TLiVtdcSAk=
=ck94
-END PGP SIGNATURE-

___
$0 Web Hosting with up to 120MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com
---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
 joining column's datatypes do not match


Re: [GENERAL] Unique Index

2005-01-20 Thread J. Greenlees
Tino Wildenhain wrote:
Hi,
Am Mittwoch, den 19.01.2005, 15:02 -0800 schrieb J. Greenlees:
Roman Neuhauser wrote:
# [EMAIL PROTECTED] / 2005-01-20 01:35:32 +1100:

i have a unique index on a table over multiple columns. If now one of 
the records has a null value in one of the indexed columns i can insert 
the same record multiple times.

Is this a problem within postgres or expected?

   In SQL, NULL means unknown value. How could you assert that two
   NULLs are equal?
which doesn't make mathematical sense.
mathwise null is an empty result.
so setting the logic up using the math logic, null values are always equal.

What kind of mathematics you are speaking?
For example you have infinity where infinity is never
equal to infinity.
Same with null. Which is unknown or undefined
So if x is undefined and y is undefined you cannot
assume x=y  - because if you assume this, then
they would not be undefined anymore.
q.e.d.
Regards
Tino

or null as in empty.
an empty result set is a null set, zero results.
declare a variable, but never assign a value, it has a default value of 
null from the declaration.
( basically any content of memory space allocated that was not actually 
empty is the content, but it's a null value to the app. )

--

only plain text format email accepted.
smaller file size, no virus transfer
no proprietary file formats.



smime.p7s
Description: S/MIME Cryptographic Signature


[GENERAL] connecting with a 8.0.0 client with ssl

2005-01-20 Thread Jackson Pauls
hi,

i'm trying to create a connection from a postgres 8.0.0 client to a
remote server running postgres 7.4.6 that requires ssl.

this connection worked on the client machine when connecting using a
7.4.6 postgres client, and still works when connecting from a 3rd
machine with 7.4.6. so i think that narrows it down to some change in
the new postgres 8.0.0 client.

client was configured with ./configure --with-openssl.

psql (lack of) output:

$ psql -U user -h remoteIP db
psql: [EMAIL PROTECTED]

php output:

Warning: pg_connect() [function.pg-connect]: Unable to connect to
PostgreSQL server: in ...

for each failed connection, the server log contains the line:

LOG:  could not initialize SSL connection: No SSL error reported

there is no root.crt file on the server, and no certificates present on
the client.

server tuns fedora core 1, openssl-0.9.7a-33.10 (rpm), client runs
fedora core 3, openssl-0.9.7a-40 (rpm).

i'm not sure where to go from here, any help appreciated.

cheers,

jackson


-- 
Play Alienballs at www.j.uklinux.net


---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [GENERAL] Samba not showing public share et al.

2005-01-20 Thread v . demartino2
DISMISS MY MESSAGE
Of course, it  was a slip of the tangue!
Sorry to bother this esteemed ng.

Vittorio


:-- Messaggio originale --
:Date: Thu, 20 Jan 2005 15:10:45 +0100
:From: [EMAIL PROTECTED]
:To: FreeBSD freebsd-questions@freebsd.org,
:   postgresql pgsql-general@postgresql.org
:Subject: Samba not showing public share et al.
:
:
:Server Box ():
:Pentium 3
:FreeBSD 5.3
:Samba 3.0.7
:connection to a windows 2000 LAN
:
:Samba on the freebsd side has the following smb.conf:
:
:
:[global]
:   workgroup = MYCO
:#
:   server string = VicBSD
:   load printers = no
:   log file = /var/log/samba/log.%m
:   log level = 1
:   max log size = 50
:   security = user
:nt acl support = no
:null passwords = yes
:  encrypt passwords = yes
:  smb passwd file = /usr/local/private/smbpasswd
:   wins server = 192.168.201.122 192.168.201.121
:
:[homes]
:read only=no
:[public]
:comment = %h Shared Public Directory
:   path = /home/public
:   force directory mode = 0777
:   force create mode = 0777
:   force group = nobody
:   force user = nobody
:   public = yes
:   writeable = yes
:   read only = no
:   browseable = yes
:-
:
:I gave /home/public permissions r,w,x for all the users and issued a 
'smbpassword
:-a -n nobody'.
:
:With this configuration I can easily and reliably connect to my home share
:providing a password.
:
:BUT, I and other users are unable to connect from our Win2k or XP Pro boxes
:directly to the public share. As a matter of fact windows:
:
:1) Shows all the shares including an 'invented' nobody share not defined
:elsewhere. This happens while I put browseable=yes only in the [public]
:section of smb.conf and not in each share.
:2) If we ask to connect to \\vicbsd\public I'm prompted for a userid and
:password. Only giving the 'nobody' userid is possible to connect to the
:share from within windows boxes. I mean not directly without being prompted.
:
:Why is that 1) and 2) and what should I do to connect without being prompted
:for userid and password?
:
:
:Ciao
:Vittorio
:
:
:
:
:___
:freebsd-questions@freebsd.org mailing list
:http://lists.freebsd.org/mailman/listinfo/freebsd-questions
:To unsubscribe, send any mail to [EMAIL PROTECTED]



---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


[GENERAL] Samba not showing public share et al.

2005-01-20 Thread v . demartino2
Server Box ():
Pentium 3
FreeBSD 5.3
Samba 3.0.7
connection to a windows 2000 LAN

Samba on the freebsd side has the following smb.conf:


[global]
   workgroup = MYCO
#
   server string = VicBSD
   load printers = no
   log file = /var/log/samba/log.%m
   log level = 1
   max log size = 50
   security = user
nt acl support = no
null passwords = yes
  encrypt passwords = yes
  smb passwd file = /usr/local/private/smbpasswd
   wins server = 192.168.201.122 192.168.201.121

[homes]
read only=no
[public]
comment = %h Shared Public Directory
   path = /home/public
   force directory mode = 0777
   force create mode = 0777
   force group = nobody
   force user = nobody
   public = yes
   writeable = yes
   read only = no
   browseable = yes
-

I gave /home/public permissions r,w,x for all the users and issued a 
'smbpassword
-a -n nobody'.

With this configuration I can easily and reliably connect to my home share
providing a password.

BUT, I and other users are unable to connect from our Win2k or XP Pro boxes
directly to the public share. As a matter of fact windows:

1) Shows all the shares including an 'invented' nobody share not defined
elsewhere. This happens while I put browseable=yes only in the [public]
section of smb.conf and not in each share.
2) If we ask to connect to \\vicbsd\public I'm prompted for a userid and
password. Only giving the 'nobody' userid is possible to connect to the
share from within windows boxes. I mean not directly without being prompted.

Why is that 1) and 2) and what should I do to connect without being prompted
for userid and password?


Ciao
Vittorio





---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [GENERAL] [ADMIN] Oracle and Postgresql Play Nice Together on Same Computer?

2005-01-20 Thread Marco Colombo
[ Cc: list cleaned a bit ]
On Thu, 20 Jan 2005, Alvaro Herrera wrote:
On Thu, Jan 20, 2005 at 08:03:42AM -0500, Troyston Campano wrote:
Basically, we want to take 3 of the 10 applications running on Oracle, move
them to Postgresql on the same computer/server and just make sure it runs
about the same (really speed, memory usage, and space are the big issues).
I'm not concerned with how hard the migration will be and things like that.
So you want Postgres to be a cheaper Oracle.  Hmm.  Maybe it will work,
but as Marco Colombo says, you are not going to see Postgres shining by
using that simplistic approach.  If you want that, maybe you should look
closely to see where you can find the rusty corner that needs to be
polished.
The database is very low in complexity so the migration should be cake.
If you do things as simple as select count(*) from table, then you
will have to be careful to be really fair in your comparison; you could
misleadingly find that Postgres is much slower on that query.
Yeah, that's precisely what I meant. The Oracle to PostgreSQL migration
is well worth considering a (partial) redesign.
Sometimes I happen to show some SQL queries I make (on PostgreSQL)
to an Oracle guy. Usually it goes like this:
1) hmm (ponders at the query)
2) ah!!! (realizes what the query does)
3) I didn't know you could do this! (excitement)
4) hmm (ponders again if that may work on Oracle as well)
5) no I can't do that in Oracle that way. I remember I did something
   like that in the past with other 3 SQL developers. We had to write
   a 300 lines long stored procedure, we got the locking right at the
   third reimplementation only (we don't know if we do need the locking,
   we asked our senior DBA but he was unsure as well, so we put it in,
   we don't think it hurts anyway).
Ok, point 5) has been exaggerated to joke level, but you get the idea.
.TM.
--
  /  /   /
 /  /   /   Marco Colombo
___/  ___  /   /  Technical Manager
   /  /   /  ESI s.r.l.
 _/ _/  _/ [EMAIL PROTECTED]
---(end of broadcast)---
TIP 6: Have you searched our list archives?
  http://archives.postgresql.org


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread Joshua D. Drake

 ^
Is there any evidence of the above claim? I've seen a link to a l-k
bug report about ext3, but apparently it was totally unconfirmed
(and a single bug does not mean a FS is not good - I remember XFS
being hammered heavily before being accepted into Linux).
EXT3 works. It is just dog slow and yes there is plenty of evidence
to EXT3s problems. Even from the author himself. Just review the kernel
threads and mailing lists. Note that a lot of the problem have been fixed.
I'm using ext3 cause all other FSes are simple add-ons in linux.All of 
them struggled a lot before being able to meet linux high
quality standards and being accepted into mainstream. Ext3 was there
from the start. Of course that doesn't mean it fits PostgreSQL needs
better than other FSes.

Well that isnt exactly true. EXT3 is a bolt on to EXT2 which was always
there. Reiser is also a long time kernel at least from 2.2. XFS is also
a long time Linux supporter and its inclusion into the main tree had
nothing to do with quality.
Just because something isn't in the main tree doesn't mean that the quality
is lacking. A lot of times it is just politics.
There is a reason that all major distributions supported XFS, Reiser and JFS
before RedHat and it has nothing to do with quality.
Sincerely,
Joshua D Drake

.TM.

--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - [EMAIL PROTECTED] - http://www.commandprompt.com
PostgreSQL Replicator -- production quality replication for PostgreSQL
begin:vcard
fn:Joshua Drake
n:Drake;Joshua
org:Command Prompt, Inc.
adr:;;PO Box 215 ;Cascade Locks;OR;97014;US
email;internet:[EMAIL PROTECTED]
title:Consultant
tel;work:503-667-4564
tel;fax:503-210-0334
x-mozilla-html:FALSE
url:http://www.commandprompt.com
version:2.1
end:vcard


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [GENERAL] How to manually insert an UTF-8 character into an SQL statement?

2005-01-20 Thread Martijn van Oosterhout
On Thu, Jan 20, 2005 at 02:48:40PM +0100, Alban Hertroys wrote:
 I'm trying to insert a record that contains an ô (o circumflex) into a 
 table using the psql client.
 I also tried with phppgadmin and pgadmin, but both can't do this. They 
 insert a HTML entity and error out respectively. Not what I had in mind...

My guess is that the \0x00 is being expanded to a null. If you want a
circumflex, why not just set the encoding to latin9 or whatever and
send it normally. Unicode characters don't have embedded nulls iirc so
that can't be a properly encoded character anyway...

 Supposedly I should be able to type:
 INSERT INTO table (name) VALUES ('C\0x00f4te d''Azur');
 but all I manage to achieve is inserting a capital 'C'...

Hope this helps,
-- 
Martijn van Oosterhout   kleptog@svana.org   http://svana.org/kleptog/
 Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
 tool for doing 5% of the work and then sitting around waiting for someone
 else to do the other 95% so you can sue them.


pgpiVovZgDxQO.pgp
Description: PGP signature


[GENERAL] Invalid message format error from JDBC driver

2005-01-20 Thread leon-pg
Hello, all. I have a query that runs perfectly when I run it from 
pgAdmin3, but bombs when I run it from ColdFusion using the JDBC 
driver. I'm using postgres 7.4. The query uses dblink(), which I assume 
is the source of the problem.

Can anyone provide me with any insight about why this would fail over 
JDBC? Thanks

select *
into cupahr_tblunit_20050120
from dblink('dbname=tafkan', '
select u.*, c1.className as Carnegie_Class, c2.className as 
Affiliation, c3.className as Level_of_Instruction

from tblunit u
	inner join tblClassType ct1 on ct1.clientID = 33 and ct1.classTypeName 
= ''Carnegie Class''
		left join tblLinkUnitClass l1 on l1.unitID = u.unitID and 
l1.classTypeID = ct1.classTypeID
		left join tblClass c1 on c1.classID = l1.classID
	inner join tblClassType ct2 on ct2.clientID = 33 and ct2.classTypeName 
= ''Affiliation''
		left join tblLinkUnitClass l2 on l2.unitID = u.unitID and 
l2.classTypeID = ct2.classTypeID
		left join tblClass c2 on c2.classID = l2.classID
	inner join tblClassType ct3 on ct3.clientID = 33 and ct3.classTypeName 
= ''Level of Instruction''
		left join tblLinkUnitClass l3 on l3.unitID = u.unitID and 
l3.classTypeID = ct3.classTypeID
		left join tblClass c3 on c3.classID = l3.classID
where u.clientid = 33


') as tblunit(
unitid int4,
  clientid int4,
  groupid int4,
  logoid int4,
  shortname varchar(50),
  unitname varchar(150),
  address1 varchar(100),
  address2 varchar(100),
  city varchar(50),
  state varchar(50),
  zip varchar(10),
  plus4 varchar(4),
  country varchar(50),
  phone varchar(50),
  fax varchar(50),
  o_iid int4,
  o_environmentid int4,
  o_itype int4,
  importunitid int4,
  importgroupid int4,
  membertype char(10),
  membertypeid int4,
  isgroupsummary bool,
  lastupdate timestamp,
  Carnegie_Class varchar(250),
  Affiliation varchar(250),
  Level_of_Instruction varchar(250)
)
---(end of broadcast)---
TIP 6: Have you searched our list archives?
  http://archives.postgresql.org


Re: [GENERAL] [ADMIN] Oracle and Postgresql Play Nice Together on Same Computer?

2005-01-20 Thread troyston campano
I'm not really too concerned about the migration aspect at all. If
need be, we might even throw in some new applications into the
postgresql database. What we're really concerned about is any issues
that may come from running postgresql and oracle on the same box. Do
they play nice together...or does one hog memory in a way that
prevents the other engine from operating correctly? I'm worried more
about things like that.

thank you again for your time!

~ Troyston ~


On Thu, 20 Jan 2005 15:22:33 +0100 (CET), Marco Colombo
[EMAIL PROTECTED] wrote:
 [ Cc: list cleaned a bit ]
 
 On Thu, 20 Jan 2005, Alvaro Herrera wrote:
 
  On Thu, Jan 20, 2005 at 08:03:42AM -0500, Troyston Campano wrote:
  Basically, we want to take 3 of the 10 applications running on Oracle, move
  them to Postgresql on the same computer/server and just make sure it runs
  about the same (really speed, memory usage, and space are the big issues).
  I'm not concerned with how hard the migration will be and things like that.
 
  So you want Postgres to be a cheaper Oracle.  Hmm.  Maybe it will work,
  but as Marco Colombo says, you are not going to see Postgres shining by
  using that simplistic approach.  If you want that, maybe you should look
  closely to see where you can find the rusty corner that needs to be
  polished.
 
  The database is very low in complexity so the migration should be cake.
 
  If you do things as simple as select count(*) from table, then you
  will have to be careful to be really fair in your comparison; you could
  misleadingly find that Postgres is much slower on that query.
 
 Yeah, that's precisely what I meant. The Oracle to PostgreSQL migration
 is well worth considering a (partial) redesign.
 
 Sometimes I happen to show some SQL queries I make (on PostgreSQL)
 to an Oracle guy. Usually it goes like this:
 
 1) hmm (ponders at the query)
 2) ah!!! (realizes what the query does)
 3) I didn't know you could do this! (excitement)
 4) hmm (ponders again if that may work on Oracle as well)
 5) no I can't do that in Oracle that way. I remember I did something
like that in the past with other 3 SQL developers. We had to write
a 300 lines long stored procedure, we got the locking right at the
third reimplementation only (we don't know if we do need the locking,
we asked our senior DBA but he was unsure as well, so we put it in,
we don't think it hurts anyway).
 
 Ok, point 5) has been exaggerated to joke level, but you get the idea.
 
 .TM.
 --
   /  /   /
  /  /   /  Marco Colombo
 ___/  ___  /   / Technical Manager
/  /   / ESI s.r.l.
  _/ _/  _/[EMAIL PROTECTED]
 
 ---(end of broadcast)---
 TIP 6: Have you searched our list archives?
 
   http://archives.postgresql.org


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [GENERAL] Unique Index

2005-01-20 Thread Greg Stark
Tom Lane [EMAIL PROTECTED] writes:

 Greg Stark [EMAIL PROTECTED] writes:
  Tom Lane [EMAIL PROTECTED] writes:
  Direct your complaints to the ISO SQL standards committee.
 
  The SQL standard generally treats NULLs as a escape hatch for constraints.

Huh? I thought I was agreeing with you. By escape hatch I meant that having
a NULL value in the indexed column allowed multiple records with otherwise
identical values because the NULL compared unequal. Ie, that the unique index
doesn't apply to the record with NULL columns.


 Not for UNIQUE constraints.  SQL92 section 4.10 Integrity constraints:
 
  A unique constraint is satisfied if and only if no two rows in
  a table have the same non-null values in the unique columns. 

That's ambiguous. Does it mean no two rows have all non-null columns that are
all identical? Or does it mean no two rows have columns that excluding any
null columns are identical.

It actually sounds more like the latter to me which would mean Postgres's
interpretation is wrong.


 The short answer to this thread is that the OP is misusing nulls,
 and should pick some non-null value to be his placeholder.

We're in violent agreement.


-- 
greg


---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [GENERAL] Unique Index

2005-01-20 Thread Tom Lane
Greg Stark [EMAIL PROTECTED] writes:
 Tom Lane [EMAIL PROTECTED] writes:
 Not for UNIQUE constraints.  SQL92 section 4.10 Integrity constraints:
 
 A unique constraint is satisfied if and only if no two rows in
 a table have the same non-null values in the unique columns. 

 That's ambiguous. Does it mean no two rows have all non-null columns that are
 all identical? Or does it mean no two rows have columns that excluding any
 null columns are identical.

OK, try the more formal definition in 8.9 unique predicate

 2) If there are no two rows in T such that the value of each column
in one row is non-null and is equal to the value of the cor-
responding column in the other row according to Subclause 8.2,
comparison predicate, then the result of the unique predi-
cate is true; otherwise, the result of the unique predicate
is false.

(11.7 defines the UNIQUE constraint in terms of the unique predicate)

regards, tom lane

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [GENERAL] Unique Index

2005-01-20 Thread Greg Stark
Dawid Kuroczko [EMAIL PROTECTED] writes:

 Don't worry about index bloat.  These additional indexes will be used
 only when your main (foo_abc_index) is not used, so there won't be
 any duplicate data in them.

The main index will have _all_ the tuples in them, even where some of the
columns are NULL, so this will in fact use extra space. It will also cause
extra i/o on every update of a record with NULL in one of the columns.

To minimize the extra space you could make it

Dawid Kuroczko [EMAIL PROTECTED] writes:

 CREATE UNIQUE INDEX foo_ab_index ON foo (a,b) WHERE c IS NULL AND a is NOT 
NULL and b IS NOT NULL;
 CREATE UNIQUE INDEX foo_ac_index ON foo (a,c) WHERE b IS NULL AND a is NOT 
NULL and c IS NOT NULL;
 CREATE UNIQUE INDEX foo_bc_index ON foo (b,c) WHERE a IS NULL AND b is NOT 
NULL and c IS NOT NULL;
 CREATE UNIQUE INDEX foo_a_index ON foo (a)   WHERE a IS NOT NULL AND b IS NULL 
and c is NULL;
 CREATE UNIQUE INDEX foo_b_index ON foo (b)   WHERE b IS NOT NULL AND a IS NULL 
and c is NULL;
 CREATE UNIQUE INDEX foo_c_index ON foo (c)   WHERE c IS NOT NULL AND a IS NULL 
and b is NULL;

To avoid indexing the same tuples in multiple indexes.

None of this will prevent you from inserting multiple null,null,null records
though.


-- 
greg


---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [GENERAL] [ADMIN] Oracle and Postgresql Play Nice Together on Same Computer?

2005-01-20 Thread Frank D. Engel, Jr.
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Does anyone know if there could be a shared memory issue here?
If there is, then one of the two (postgres or oracle) would simply 
refuse to start (it would quit with an error, I'd assume).  If this 
happens, you would need to either decrease the number of shared memory 
resources one database or the other is asking for, or increase the 
number of shared memory resources made available by the kernel (the 
exact process depends on your operating system; I forget if you named 
the one you are using or not).

Otherwise, there shouldn't be a problem, as long as your server 
hardware has the resources to handle both at the same time (disk space, 
memory/CPU power, etc.)

On Jan 20, 2005, at 10:50 AM, troyston campano wrote:
I'm not really too concerned about the migration aspect at all. If
need be, we might even throw in some new applications into the
postgresql database. What we're really concerned about is any issues
that may come from running postgresql and oracle on the same box. Do
they play nice together...or does one hog memory in a way that
prevents the other engine from operating correctly? I'm worried more
about things like that.
thank you again for your time!
~ Troyston ~
On Thu, 20 Jan 2005 15:22:33 +0100 (CET), Marco Colombo
[EMAIL PROTECTED] wrote:
[ Cc: list cleaned a bit ]
On Thu, 20 Jan 2005, Alvaro Herrera wrote:
On Thu, Jan 20, 2005 at 08:03:42AM -0500, Troyston Campano wrote:
Basically, we want to take 3 of the 10 applications running on 
Oracle, move
them to Postgresql on the same computer/server and just make sure 
it runs
about the same (really speed, memory usage, and space are the big 
issues).
I'm not concerned with how hard the migration will be and things 
like that.
So you want Postgres to be a cheaper Oracle.  Hmm.  Maybe it will 
work,
but as Marco Colombo says, you are not going to see Postgres shining 
by
using that simplistic approach.  If you want that, maybe you should 
look
closely to see where you can find the rusty corner that needs to be
polished.

The database is very low in complexity so the migration should be 
cake.
If you do things as simple as select count(*) from table, then you
will have to be careful to be really fair in your comparison; you 
could
misleadingly find that Postgres is much slower on that query.
Yeah, that's precisely what I meant. The Oracle to PostgreSQL 
migration
is well worth considering a (partial) redesign.

Sometimes I happen to show some SQL queries I make (on PostgreSQL)
to an Oracle guy. Usually it goes like this:
1) hmm (ponders at the query)
2) ah!!! (realizes what the query does)
3) I didn't know you could do this! (excitement)
4) hmm (ponders again if that may work on Oracle as well)
5) no I can't do that in Oracle that way. I remember I did something
   like that in the past with other 3 SQL developers. We had to write
   a 300 lines long stored procedure, we got the locking right at the
   third reimplementation only (we don't know if we do need the 
locking,
   we asked our senior DBA but he was unsure as well, so we put it in,
   we don't think it hurts anyway).

Ok, point 5) has been exaggerated to joke level, but you get the idea.
.TM.
--
  /  /   /
 /  /   /  Marco Colombo
___/  ___  /   / Technical Manager
   /  /   / ESI s.r.l.
 _/ _/  _/[EMAIL PROTECTED]
---(end of 
broadcast)---
TIP 6: Have you searched our list archives?

  http://archives.postgresql.org
---(end of 
broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html

- ---
Frank D. Engel, Jr.  [EMAIL PROTECTED]
$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep John 3:16
John 3:16 For God so loved the world, that he gave his only begotten 
Son, that whosoever believeth in him should not perish, but have 
everlasting life.
$
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFB79ef7aqtWrR9cZoRAvdMAJwKW+dptxX+zPv5Ql1XUbzPDZGvywCaAqpN
ghnwgW9m1Qtcb/QBqWzpGf0=
=d65G
-END PGP SIGNATURE-

___
$0 Web Hosting with up to 120MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly


Re: [GENERAL] Unique Index

2005-01-20 Thread Frank D. Engel, Jr.
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
I'm sure this won't work for some reason, but something similar might; 
why not create a unique index on a constant where all three are null; 
something along these lines (in addition to the others):

CREATE UNIQUE INDEX foo_trio_index ON foo (1) WHERE c IS NULL AND a IS 
NULL and b IS NULL;

On Jan 20, 2005, at 10:57 AM, Greg Stark wrote:
Dawid Kuroczko [EMAIL PROTECTED] writes:
Don't worry about index bloat.  These additional indexes will be 
used
only when your main (foo_abc_index) is not used, so there won't be
any duplicate data in them.
The main index will have _all_ the tuples in them, even where some of 
the
columns are NULL, so this will in fact use extra space. It will also 
cause
extra i/o on every update of a record with NULL in one of the columns.

To minimize the extra space you could make it
Dawid Kuroczko [EMAIL PROTECTED] writes:
 CREATE UNIQUE INDEX foo_ab_index ON foo (a,b) WHERE c IS NULL AND a 
is NOT NULL and b IS NOT NULL;
 CREATE UNIQUE INDEX foo_ac_index ON foo (a,c) WHERE b IS NULL AND a 
is NOT NULL and c IS NOT NULL;
 CREATE UNIQUE INDEX foo_bc_index ON foo (b,c) WHERE a IS NULL AND b 
is NOT NULL and c IS NOT NULL;
 CREATE UNIQUE INDEX foo_a_index ON foo (a)   WHERE a IS NOT NULL AND 
b IS NULL and c is NULL;
 CREATE UNIQUE INDEX foo_b_index ON foo (b)   WHERE b IS NOT NULL AND 
a IS NULL and c is NULL;
 CREATE UNIQUE INDEX foo_c_index ON foo (c)   WHERE c IS NOT NULL AND 
a IS NULL and b is NULL;

To avoid indexing the same tuples in multiple indexes.
None of this will prevent you from inserting multiple null,null,null 
records
though.

--
greg
---(end of 
broadcast)---
TIP 4: Don't 'kill -9' the postmaster


- ---
Frank D. Engel, Jr.  [EMAIL PROTECTED]
$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep John 3:16
John 3:16 For God so loved the world, that he gave his only begotten 
Son, that whosoever believeth in him should not perish, but have 
everlasting life.
$
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFB79hL7aqtWrR9cZoRAglUAJ9sT3SypLYDZhx6Dkysfr7aLHQttwCeNLs8
/J4jFlWMLcMMxbQ3/nj55eA=
=4Bbe
-END PGP SIGNATURE-

___
$0 Web Hosting with up to 120MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly


Re: [GENERAL] Re: [ADMIN] Oracle and Postgresql Play Nice Together on Same Computer

2005-01-20 Thread Alex Turner
It depends how you have your Oracle instance configured.  If you have
it set up so that the total SGA and UGA ammount consume around 80%-90%
of total available memory, then this is obviously only going to leave
postgress with 20% or less of the total available memory.  Postgres is
also designed to take advantage of the file caching behaviour of the
OS.  The OS however is probably going to prioritize Oracle running
memory over cached file pages, and therefore I would think that
running the two together is a less than optimal configuration.  If you
are going to do it, I would make sure that you at least reduce the SGA
for Oracle down below 40% of the box's total RAM so you give
postgresql enough space to work in.  Even doing this, there is a
chance that the OS will try to cache the Oracle Tablespace files if
they are small enough, duplicating the buffering effort that Oracle is
doing, and also reducing the amount of memory for Postgresql file
cache.

All in all, I would personaly be very wary of running both together if
you are planning on doing any benchmarking.

Alex Turner
NetEconomist


On Thu, 20 Jan 2005 10:20:02 +0100, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 
 Troyston Campano [EMAIL PROTECTED] wrote on 20.01.2005,
 06:03:28:
  I am an Oracle DBA and I want do a Postgresql 'proof of concept' at the
  large corporation where I work to test the benefits of using Postgresql in
  our environment. I want to install Postgresql onto a production server
  that currently runs Oracle. Are there any problems with running Postgresql
  and Oracle on the same machine? I mean, I've heard that the way Sybase and
  DB2 UDB are architected to handle memory hurts Sybase when DB2 UDB is
  installed on the same machine as the Sybase Server (something about UDB
  eating up all the memory and not giving it back to Sybase).
 
 
 
  Are there any issues running Postgresql and Oracle on the same
  machine.anything special to know about memory, disk layout, and things like
  that? I just want to make sure the two engines play together on this same
  server. I had a hard time finding information about this via google.
 
 
 There should be no issues running both on the same machine. Running both
 together at the same time isn't a good way of doing a benchmark
 though...
 
 I would question your intent slightly. Should it be a relative
 comparison? Or should it be an assessment of what PostgreSQL is capable
 of and whether that fits a sufficient number of your needs to make it
 worth adopting?
 
 There are many ways to structure a decision as to whether PostgreSQL is
 suitable for your (business?) needs. Which structure you choose is
 likely to prejudice your decision, one way or the other. i.e. if
 capital acquisition costs are the decising factor, then PostgreSQL
 would always win.
 
 Best Regards, Simon Riggs
 
 ---(end of broadcast)---
 TIP 8: explain analyze is your friend


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [GENERAL] Unique Index

2005-01-20 Thread Scott Marlowe
On Wed, 2005-01-19 at 22:20, Alex wrote:

 
 Maybe there could be an option in the creation of the index to indicate 
 on how to use NULL values.
 
 How do other DBMS handle this?

http://troels.arvin.dk/db/rdbms/

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


Re: [GENERAL] Oracle and Postgresql Play Nice Together on Same

2005-01-20 Thread Scott Marlowe
On Wed, 2005-01-19 at 23:03, Troyston Campano wrote:
 Hello, 
 
 I am an Oracle DBA and I want do a Postgresql proof of concept at
 the large corporation where I work to test the benefits of using
 Postgresql in our environment. I want to install Postgresql onto a
 production server that currently runs Oracle. Are there any problems
 with running Postgresql and Oracle on the same machine? I mean, Ive
 heard that the way Sybase and DB2 UDB are architected to handle memory
 hurts Sybase when DB2 UDB is installed on the same machine as the
 Sybase Server (something about UDB eating up all the memory and not
 giving it back to Sybase).
 
  
 
 Are there any issues running Postgresql and Oracle on the same
 machineanything special to know about memory, disk layout, and things
 like that? I just want to make sure the two engines play together on
 this same server. I had a hard time finding information about this via
 google.


The only issue you're likely to face is the one you've already
mentioned, that Oracle may be configured to use most of the memory on
the machine, and PostgreSQL, in general, relies on the OS to do the
caching for it. Since there might not be much free / cache memory on the
machine, PostgreSQL may run a bit slower than it would were it the only
thing on the machine.

However, you can always do a benchmark with Oracle running, then shut
down oracle for a few minutes and see if PostgreSQL runs any faster with
the extra memory being used by the OS to cache the dataset.

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [ADMIN] [GENERAL] Oracle and Postgresql Play Nice Together on

2005-01-20 Thread Scott Marlowe
On Thu, 2005-01-20 at 06:58, Troyston Campano wrote:
 I guess what I am concerned about *is* running on a production server more
 than a test server. Basically, I'd be taking a couple applications that are
 running on the Oracle database instance, building a Postgresql instance, and
 migrating them to that postgresql database instance. I'm just wondering
 whether it's a bad idea to run them on the same server machine in a
 production environment. (So instead of having 10 applications running on
 Oracle on ServerComputerA...build a new postgresql instance on
 ServerComputerA that lives along with Oracle and migrating 3 of the
 applications to Postgresql.

Have you got a spare machine you can do the testing on at first?  That
will allow you to throw big nasty queries at the server and tune it
first, before putting postgresql on the production box.

I'd recommend reading the tuning document from varlena:

http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html

And experimenting with various settings on a test box first.  My first
PostgreSQL server way back when was running 6.5.2 or so on my P-II-300
workstation with 128 Megs of ram sitting under my desk, and it ran quite
well, well enough we used it as our development / staging server for
almost a year. 

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [GENERAL] connecting with a 8.0.0 client with ssl

2005-01-20 Thread Jackson Pauls
On Thu, 2005-01-20 at 14:14 +, Jackson Pauls wrote:

 i'm trying to create a connection from a postgres 8.0.0 client to a
 remote server running postgres 7.4.6 that requires ssl.
 
 this connection worked on the client machine when connecting using a
 7.4.6 postgres client, and still works when connecting from a 3rd
 machine with 7.4.6. so i think that narrows it down to some change in
 the new postgres 8.0.0 client.
 
 client was configured with ./configure --with-openssl.
 
 psql (lack of) output:
 
 $ psql -U user -h remoteIP db
 psql: [EMAIL PROTECTED]
 
 php output:
 
 Warning: pg_connect() [function.pg-connect]: Unable to connect to
 PostgreSQL server: in ...
 
 for each failed connection, the server log contains the line:
 
 LOG:  could not initialize SSL connection: No SSL error reported
 
 there is no root.crt file on the server, and no certificates present on
 the client.
 
 server tuns fedora core 1, openssl-0.9.7a-33.10 (rpm), client runs
 fedora core 3, openssl-0.9.7a-40 (rpm).

... adding to my own post. i just noticed errors aren't being reported
in psql in the 8.0.0 client (connected to a local 8.0.0 server):

db= select 'a' + 1;
db=

but do appear in the local server log: 'ERROR:  invalid input syntax for
integer: a'

i'm using the default settings for error reporting and logging. 

is there is a way to reinstate error messages in psql? it might be
trying to tell me something useful when i'm trying to connect to the
remote server.

cheers,

j

-- 
Play Alienballs at www.j.uklinux.net


---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [GENERAL] Unique Index

2005-01-20 Thread Greg Stark
Frank D. Engel, Jr. [EMAIL PROTECTED] writes:

 I'm sure this won't work for some reason, but something similar might; why not
 create a unique index on a constant where all three are null; something along
 these lines (in addition to the others):
 
 CREATE UNIQUE INDEX foo_trio_index ON foo (1) WHERE c IS NULL AND a IS NULL 
 and
 b IS NULL;
 

Huh. Hadn't thought of creating an index on a constant. It works if you put an
extra set of parentheses in:

CREATE UNIQUE INDEX foo_abc_index ON foo ((1)) WHERE ...


-- 
greg


---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


[GENERAL] Postgresql Security Pen Test

2005-01-20 Thread troyston campano
Are there any 'pen tests' that one could run that checks the security
of your Postgresql instance? I don't think postgresql has any default
accounts except for 'postgres' but maybe something that scans for
blank passwords and things like that.

thanks!

~ Troyston Campano ~

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


[GENERAL] Client's variables

2005-01-20 Thread fryk
Hi,

How to set such variable after (during?) client connection (PHP)?

I want to use it in view - so view could depends on it:

If I could set client's variable i.e. MY_VAR='hello' then I could do
something like this:

CREATE VIEW my_view AS SELECT * FROM pg_tables WHERE tablename ~* (SELECT
MY_VAR FROM ???)

Cheers!
___
fryk



---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


Re: [GENERAL] Unique Index

2005-01-20 Thread Dann Corbit
It is clear to me that only allowing a single null value will not
violate the explanation below.

It would be equally true that allowing multiple null values would not
violate it.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tom Lane
Sent: Thursday, January 20, 2005 8:03 AM
To: Greg Stark
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Unique Index 

Greg Stark [EMAIL PROTECTED] writes:
 Tom Lane [EMAIL PROTECTED] writes:
 Not for UNIQUE constraints.  SQL92 section 4.10 Integrity
constraints:
 
 A unique constraint is satisfied if and only if no two rows in
 a table have the same non-null values in the unique columns. 

 That's ambiguous. Does it mean no two rows have all non-null columns
that are
 all identical? Or does it mean no two rows have columns that excluding
any
 null columns are identical.

OK, try the more formal definition in 8.9 unique predicate

 2) If there are no two rows in T such that the value of each
column
in one row is non-null and is equal to the value of the cor-
responding column in the other row according to Subclause
8.2,
comparison predicate, then the result of the unique
predi-
cate is true; otherwise, the result of the unique
predicate
is false.

(11.7 defines the UNIQUE constraint in terms of the unique predicate)

regards, tom lane

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [GENERAL] Client's variables

2005-01-20 Thread Marek Lewczuk
fryk napisa(a):
Hi,
How to set such variable after (during?) client connection (PHP)?
I want to use it in view - so view could depends on it:
If I could set client's variable i.e. MY_VAR='hello' then I could do
something like this:
CREATE VIEW my_view AS SELECT * FROM pg_tables WHERE tablename ~* (SELECT
MY_VAR FROM ???)
You have (at least) two choices. First is to use temporary table, where 
you can store anything you wish and it will be visible and available for 
current connection/session.

Read more: 
http://www.postgresql.org/docs/8.0/interactive/sql-createtable.html

Another solution is to use plperl - this is more flexible then the first 
one. plperl supports global values - go to:
http://www.postgresql.org/docs/8.0/interactive/plperl-global.html
and see examples set_var and get_var.

You decide what is the best solution for your needs.
In Polish:
Masz dwa wyjcia. Pierwszy wykorzysta tablice tymczasow, w ktrej 
moesz trzyma co chcesz. Bdzie ona widoczna tylko dla jednego 
uytkownika w obecnej sesji/poczeniu. Zobacz wicej:
http://www.postgresql.org/docs/8.0/interactive/sql-createtable.html

Drugie rozwizanie to skorzysta z plperl'a - to jest bardziej 
elastyczne rozwizanie. Plperl posiada moliwo tworzenia globalnych 
zmiennych. Zobacz wicej:
http://www.postgresql.org/docs/8.0/interactive/plperl-global.html
Masz tam przykadowe funkcje, ktre moesz miao wykorzysta.

Sam zdecyduj co jest lepszym rozwizaniem w Twojej aplikacji.
ML

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [GENERAL] Unique Index

2005-01-20 Thread Stephan Szabo

On Thu, 20 Jan 2005, Dann Corbit wrote:

 It is clear to me that only allowing a single null value will not
 violate the explanation below.

Given two rows in T with one column each
(NULL), (NULL)

Find two rows such that the value of each column in one row is non-null
and equal to the value of the corresponding column in the other row
according to 8.2. If there are no such rows the unique predicate returns
true (ie the constraint is satisfied).


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [GENERAL] Unique Index

2005-01-20 Thread Dann Corbit
Would the constraint not be satisfied if each combination (including
NULL) were not also forced to be unique?

I maintain that the constraint is still satisfied.

So, it is satisfied if I stuff thousands of NULL values in there.

And it is satisfied if I only allow a single NULL value.

With multiple columns, it might be set such that each combination must
be unique, like binary counting.

Let me also state that I agree: allowing null values in a unique index
is ludicrous.  But if it is allowed, I think forcing the combinations to
be single valued makes more sense than allowing any number of them.

-Original Message-
From: Stephan Szabo [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 20, 2005 11:14 AM
To: Dann Corbit
Cc: Tom Lane; Greg Stark; pgsql-general@postgresql.org
Subject: Re: [GENERAL] Unique Index 


On Thu, 20 Jan 2005, Dann Corbit wrote:

 It is clear to me that only allowing a single null value will not
 violate the explanation below.

Given two rows in T with one column each
(NULL), (NULL)

Find two rows such that the value of each column in one row is non-null
and equal to the value of the corresponding column in the other row
according to 8.2. If there are no such rows the unique predicate returns
true (ie the constraint is satisfied).


---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [GENERAL] Unique Index

2005-01-20 Thread Frank D. Engel, Jr.
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Huh?
... the value of EACH COLUMN in one row is NOT NULL and IS EQUAL to ...
In order for values to be equal in SQL, neither one can be null.  For 
this condition to hold, it is more than clear that at least one row 
must contain *NO* *NULL* *VALUES* (that means zero columns in that row 
may contain null values).  Since *ALL* columns in the other row must be 
EQUAL to the corresponding column in that row, none of them can be null 
either.  Therefore, the uniqueness predicate evaluates to false, and 
each of the two rows is considered unique compared to the other as soon 
as any null value shows up in either row.

There is *no* ambiguity here!
On Jan 20, 2005, at 1:55 PM, Dann Corbit wrote:
It is clear to me that only allowing a single null value will not
violate the explanation below.
It would be equally true that allowing multiple null values would not
violate it.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tom Lane
Sent: Thursday, January 20, 2005 8:03 AM
To: Greg Stark
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Unique Index
Greg Stark [EMAIL PROTECTED] writes:
Tom Lane [EMAIL PROTECTED] writes:
Not for UNIQUE constraints.  SQL92 section 4.10 Integrity
constraints:
A unique constraint is satisfied if and only if no two rows in
a table have the same non-null values in the unique columns.

That's ambiguous. Does it mean no two rows have all non-null columns
that are
all identical? Or does it mean no two rows have columns that excluding
any
null columns are identical.
OK, try the more formal definition in 8.9 unique predicate
 2) If there are no two rows in T such that the value of each
column
in one row is non-null and is equal to the value of the 
cor-
responding column in the other row according to Subclause
8.2,
comparison predicate, then the result of the unique
predi-
cate is true; otherwise, the result of the unique
predicate
is false.

(11.7 defines the UNIQUE constraint in terms of the unique predicate)
regards, tom lane
---(end of 
broadcast)---
TIP 1: subscribe and unsubscribe commands go to 
[EMAIL PROTECTED]

---(end of 
broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html

- ---
Frank D. Engel, Jr.  [EMAIL PROTECTED]
$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep John 3:16
John 3:16 For God so loved the world, that he gave his only begotten 
Son, that whosoever believeth in him should not perish, but have 
everlasting life.
$
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFB8AX07aqtWrR9cZoRAlu+AJ0YCv6VEID7MR5BHOf6rRl+gyPeLgCghImV
Um7r0pyp2vfsCVArSOkswMM=
=kzpI
-END PGP SIGNATURE-

___
$0 Web Hosting with up to 120MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly


Re: [GENERAL] Unique Index

2005-01-20 Thread Greg Stark
Dann Corbit [EMAIL PROTECTED] writes:

 Would the constraint not be satisfied if each combination (including
 NULL) were not also forced to be unique?
 
 I maintain that the constraint is still satisfied.
 
 So, it is satisfied if I stuff thousands of NULL values in there.
 
 And it is satisfied if I only allow a single NULL value.

You're misreading it. It's not a question of what you allow, it's a question
of what's in the table. The database *must* allow anything in the table that
would satisfy the constraint.

Of course the constraint is satisfied if there's only one NULL value. But the
constraint is also satisfied if there are more than one. So the database has
to allow you to do either of these since there's no constraint that they
violate.

 Let me also state that I agree: allowing null values in a unique index
 is ludicrous.  But if it is allowed, I think forcing the combinations to
 be single valued makes more sense than allowing any number of them.

In fact allowing NULLs in columns involved in a unique constraint is an
optional feature of the SQL standard. But if it's allowed it is required to be
done the way Postgres does it.

Perhaps you're just thinking of primary keys (which, btw, are *not* allowed to
be nullable according to the spec). NULLs are much more likely in a situation
where it's not a key field, just a bit of incidental data that we know should
be unique.

Consider for example a user table where there's a phone number field. Now not
all users enter a phone number, but when they do we want to make sure it's
unique. Does it make sense to restrict the database to a single user with an
unknown phone number?

Or consider a product database. Some products have ISBNs, namely books, but
not all do. If the product has an ISBN then it really ought to be unique, no
other product should have the same ISBN. But any number of products can be
non-books and not have an ISBN.



-- 
greg


---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [GENERAL] Unique Index

2005-01-20 Thread Stephan Szabo
On Thu, 20 Jan 2005, Dann Corbit wrote:

 Would the constraint not be satisfied if each combination (including
 NULL) were not also forced to be unique?

The constraint would be satisfied, however cases that the constraint is
satisfied for would not be allowed.  The case I gave below is one for
which I argue the constraint is satisfied because the search condition is
true.  The definition above would appear to not allow that case and as
such appears to be contrary to the definition of the constraint.

 Let me also state that I agree: allowing null values in a unique index
 is ludicrous.  But if it is allowed, I think forcing the combinations to
 be single valued makes more sense than allowing any number of them.

I think that'd be better termed a DISTINCT index to use SQL terminology.

 On Thu, 20 Jan 2005, Dann Corbit wrote:

  It is clear to me that only allowing a single null value will not
  violate the explanation below.

 Given two rows in T with one column each
 (NULL), (NULL)

 Find two rows such that the value of each column in one row is non-null
 and equal to the value of the corresponding column in the other row
 according to 8.2. If there are no such rows the unique predicate returns
 true (ie the constraint is satisfied).


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [GENERAL] Unique Index

2005-01-20 Thread Dann Corbit
Yes.
I was wrong.

Sorry about the noise.

-Original Message-
From: Stephan Szabo [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 20, 2005 12:01 PM
To: Dann Corbit
Cc: Tom Lane; Greg Stark; pgsql-general@postgresql.org
Subject: RE: [GENERAL] Unique Index 

On Thu, 20 Jan 2005, Dann Corbit wrote:

 Would the constraint not be satisfied if each combination (including
 NULL) were not also forced to be unique?

The constraint would be satisfied, however cases that the constraint is
satisfied for would not be allowed.  The case I gave below is one for
which I argue the constraint is satisfied because the search condition
is
true.  The definition above would appear to not allow that case and as
such appears to be contrary to the definition of the constraint.

 Let me also state that I agree: allowing null values in a unique index
 is ludicrous.  But if it is allowed, I think forcing the combinations
to
 be single valued makes more sense than allowing any number of them.

I think that'd be better termed a DISTINCT index to use SQL terminology.

 On Thu, 20 Jan 2005, Dann Corbit wrote:

  It is clear to me that only allowing a single null value will not
  violate the explanation below.

 Given two rows in T with one column each
 (NULL), (NULL)

 Find two rows such that the value of each column in one row is
non-null
 and equal to the value of the corresponding column in the other row
 according to 8.2. If there are no such rows the unique predicate
returns
 true (ie the constraint is satisfied).


---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [GENERAL] Unique Index

2005-01-20 Thread Tino Wildenhain
Am Donnerstag, den 20.01.2005, 06:09 -0800 schrieb J. Greenlees:
 Tino Wildenhain wrote:
  Hi,
  
  Am Mittwoch, den 19.01.2005, 15:02 -0800 schrieb J. Greenlees:
  
 Roman Neuhauser wrote:
 
 # [EMAIL PROTECTED] / 2005-01-20 01:35:32 +1100:
 
 
 i have a unique index on a table over multiple columns. If now one of 
 the records has a null value in one of the indexed columns i can insert 
 the same record multiple times.
 
 Is this a problem within postgres or expected?
 
 
 In SQL, NULL means unknown value. How could you assert that two
 NULLs are equal?
 
 
 which doesn't make mathematical sense.
 mathwise null is an empty result.
 so setting the logic up using the math logic, null values are always equal.
  
  
  What kind of mathematics you are speaking?
  For example you have infinity where infinity is never
  equal to infinity.
  Same with null. Which is unknown or undefined
  So if x is undefined and y is undefined you cannot
  assume x=y  - because if you assume this, then
  they would not be undefined anymore.
  
  q.e.d.
  
  Regards
  Tino
  
  
 or null as in empty.
 an empty result set is a null set, zero results.
 declare a variable, but never assign a value, it has a default value of 
 null from the declaration.
 ( basically any content of memory space allocated that was not actually 
 empty is the content, but it's a null value to the app. )

No. Empty result set is just a set without elements. zero-length
list or tuple or whatever your programming language uses :-)

[] != null/undefined/None  


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [GENERAL] Client's variables

2005-01-20 Thread Richard Huxton
Marek Lewczuk wrote:
fryk napisa(a):
Hi,
How to set such variable after (during?) client connection (PHP)?
I want to use it in view - so view could depends on it:
If I could set client's variable i.e. MY_VAR='hello' then I could do
something like this:
CREATE VIEW my_view AS SELECT * FROM pg_tables WHERE tablename ~* (SELECT
MY_VAR FROM ???)

You have (at least) two choices. First is to use temporary table, where 
you can store anything you wish and it will be visible and available for 
current connection/session.

Read more: 
http://www.postgresql.org/docs/8.0/interactive/sql-createtable.html

Another solution is to use plperl - this is more flexible then the first 
one. plperl supports global values - go to:
http://www.postgresql.org/docs/8.0/interactive/plperl-global.html
and see examples set_var and get_var.
Or, in the attached file, I've used pltcl. Again, it uses global 
variables to store session data. If you know TCL you may be able to 
improve on these functions since I more or less cut and paste these 
together.

--
  Richard Huxton
  Archonet Ltd
-- app_session(VARNAME, VALUE)
--	Defines a text variable and sets its value.
--	If you try to set the same VARNAME twice in one session, an error is returned.
--	If VALUE is null, just returns the value.
--
CREATE OR REPLACE FUNCTION app_session(text, text) RETURNS text AS '
	upvar app_sess_vars a
	if {![ argisnull 2 ]} {
		if {[ info exists a($1) ]} {
			elog ERROR app_session(): Already set var $1 this session
		}
		set a($1) $2
	}

return $a($1)
' LANGUAGE pltcl;


-- app_session(VARNAME)
--	Returns the value of VARNAME (if set) or UNDEFINED
--	NOTE - this function is marked IMMUTABLE - do not use as a DEFAULT source 
--  in a table definition
--
CREATE OR REPLACE FUNCTION app_session(text) RETURNS text AS '
	upvar app_sess_vars a
	if {![ info exists a($1) ]} {
		return UNDEFINED
	}

return $a($1)
' LANGUAGE pltcl IMMUTABLE;

-- app_session_int(VARNAME)
--	Returns the value of VARNAME (if set) or 0
--	NOTE - this function is marked IMMUTABLE - do not use as a DEFAULT source 
--  in a table definition
--
CREATE OR REPLACE FUNCTION app_session_int(text) RETURNS int4 AS '
	upvar app_sess_vars a
	if {![ info exists a($1) ]} {
		return 0
	}

return $a($1)
' LANGUAGE pltcl IMMUTABLE;

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [GENERAL] How to manually insert an UTF-8 character into an SQL statement?

2005-01-20 Thread Ian Barwick
On Thu, 20 Jan 2005 14:48:40 +0100, Alban Hertroys
[EMAIL PROTECTED] wrote:
 I'm trying to insert a record that contains an ô (o circumflex) into a
 table using the psql client.
 I also tried with phppgadmin and pgadmin, but both can't do this. They
 insert a HTML entity and error out respectively. Not what I had in mind...
 
 Supposedly I should be able to type:
 INSERT INTO table (name) VALUES ('C\0x00f4te d''Azur');
 but all I manage to achieve is inserting a capital 'C'...
 
 It doesn't seem to matter to which encoding I set psql either.
 What am I doing wrong?

For a start, 0x00F4 does not represent valid UTF-8; you want 0xC3B4.

AFAIK you can insert this using two different methods in psql:

  \set myvalue '\'C\0xc3\0xb4te d\'\'Azur\''
  INSERT INTO table (name) VALUES (:myvalue);

in 8.0 also: 

  \set myvalue '$$C\0xc3\0xb4te d\'Azur$$' 

or:

INSERT INTO table (name) values
('C'||encode(decode('c3b4','hex'),'escape')||'te d''Azur');

Ian Barwick

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


[GENERAL] Data format and display

2005-01-20 Thread Josué Maldonado
Hello list,
I have a table that contains this raw data:
 epr_procode | epr_tipo | epr_mes | epr_valor |  zert_title
-+--+-+---+--
 00C188  | VTA  | 200309  | 2116. | Venta
 00C188  | CTO  | 200309  | 1600.0700 | Costo
 00C188  | VTA  | 200311  | 3450. | Venta
 00C188  | CTO  | 200311  | 2687.4200 | Costo
I need to display it this way:
TITULO   |200309|200310   |200311 |200312
-+--+-+---+--
Venta|2116. |0.   |3450.  |0.
Costo|1600.0700 |0.   |2687.4200  |0.   
Notice I must display the missing 200310 and 200312 empty data since 
users retrieves the info in four months based data set, of course that 
data does not exist since there were no trans in those months. Any idea 
or suggestion to get it done in Postgresql.

Thanks in advance

--
Sinceramente,
Josué Maldonado.
Las palabras de aliento después de la censura son como el sol tras el 
aguacero.

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [GENERAL] Data format and display

2005-01-20 Thread Steve Crawford
 I have a table that contains this raw data:

   epr_procode | epr_tipo | epr_mes | epr_valor |  zert_title
 -+--+-+---+
-- 00C188  | VTA  | 200309  | 2116. | Venta
   00C188  | CTO  | 200309  | 1600.0700 | Costo
   00C188  | VTA  | 200311  | 3450. | Venta
   00C188  | CTO  | 200311  | 2687.4200 | Costo

 I need to display it this way:

 TITULO |200309|200310   |200311 |200312
 -+--+-+---+
-- Venta|2116. |0.   |3450.  |0.
 Costo  |1600.0700 |0.   |2687.4200  |0.


 Notice I must display the missing 200310 and 200312 empty data
 since users retrieves the info in four months based data set, of
 course that data does not exist since there were no trans in those
 months. Any idea or suggestion to get it done in Postgresql.

Here's one way:

select
  zert_title as TITULO, 
  sum(case when epr_mes=200309 then epr_valor else 0 end) as 200309,
  sum(case when epr_mes=200310 then epr_valor else 0 end) as 200310,
  sum(case when epr_mes=200311 then epr_valor else 0 end) as 200311,
  sum(case when epr_mes=200312 then epr_valor else 0 end) as 200312
  group by 1;

Cheers,
Steve


---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


[GENERAL] PLPHP

2005-01-20 Thread Oluwatope Akinniyi
Hi,

Do we have a Windows version of plPHP?

Best regards.

Tope.
-- 


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [GENERAL] Data format and display

2005-01-20 Thread Josué Maldonado
Hello Steve,
El 20/01/2005 5:20 PM, Steve Crawford en su mensaje escribio:
select
  zert_title as TITULO, 
  sum(case when epr_mes=200309 then epr_valor else 0 end) as 200309,
  sum(case when epr_mes=200310 then epr_valor else 0 end) as 200310,
  sum(case when epr_mes=200311 then epr_valor else 0 end) as 200311,
  sum(case when epr_mes=200312 then epr_valor else 0 end) as 200312
  group by 1;
That works ok, but start and end month are variables, user can choose them.
Thanks,
--
Sinceramente,
Josué Maldonado.
Los estupidos adolecentes son los que se reunen por las noches a 
consumir drogas y a planear los ilicitos.

---(end of broadcast)---
TIP 6: Have you searched our list archives?
  http://archives.postgresql.org


[GENERAL] Dynamic column name troubles

2005-01-20 Thread mstory


I have a table that gets a column added to it for every insert on another table.
 the general form of these columns are g_c_i_avg where i is the unique
identifyer for the insert that caused the column to be added. I need to use this
column to calculate a new value for another column in the same table on an
update to that column.  I can find the altered column, and even build a text
string for it: something like column := ''NEW.g_c_'' || 7 || ''_avg'';

but then i can't use the double precision value for that column.  Any help would
be appreciated.

matt

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread David Garamond
Joshua D. Drake wrote:
Well that isnt exactly true. EXT3 is a bolt on to EXT2 which was always
there. Reiser is also a long time kernel at least from 2.2. 
I remember first using reiser3 by patching early 2.4 kernels. IIRC, 
reiser was not in linus tree until 2.4.7 or so (not sure which release) 
and it went in after a great debate/controversy.

So I don't think reiser is available in 2.2.
XFS is also
a long time Linux supporter and its inclusion into the main tree had
nothing to do with quality.
--
dave
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread mstory
Does it have to be linux?  I've never had as much success with PostGresql on
linux as i have on FreeBSD 5.3

matt

Quoting David Garamond [EMAIL PROTECTED]:

 Joshua D. Drake wrote:
  Well that isnt exactly true. EXT3 is a bolt on to EXT2 which was always
  there. Reiser is also a long time kernel at least from 2.2. 
 
 I remember first using reiser3 by patching early 2.4 kernels. IIRC, 
 reiser was not in linus tree until 2.4.7 or so (not sure which release) 
 and it went in after a great debate/controversy.
 
 So I don't think reiser is available in 2.2.
 
  XFS is also
  a long time Linux supporter and its inclusion into the main tree had
  nothing to do with quality.
 
 --
 dave
 
 ---(end of broadcast)---
 TIP 3: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly
 



---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [GENERAL] PLPHP

2005-01-20 Thread Joshua D. Drake
Oluwatope Akinniyi wrote:
Hi,
Do we have a Windows version of plPHP?
 

No not currently.
Sincerely,
Joshua D. Drake

Best regards.
Tope.
 


--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - [EMAIL PROTECTED] - http://www.commandprompt.com
PostgreSQL Replicator -- production quality replication for PostgreSQL
begin:vcard
fn:Joshua Drake
n:Drake;Joshua
org:Command Prompt, Inc.
adr:;;PO Box 215 ;Cascade Locks;OR;97014;US
email;internet:[EMAIL PROTECTED]
title:Consultant
tel;work:503-667-4564
tel;fax:503-210-0334
x-mozilla-html:FALSE
url:http://www.commandprompt.com
version:2.1
end:vcard


---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread Joshua D. Drake
David Garamond wrote:
Joshua D. Drake wrote:
Well that isnt exactly true. EXT3 is a bolt on to EXT2 which was always
there. Reiser is also a long time kernel at least from 2.2. 

I remember first using reiser3 by patching early 2.4 kernels. IIRC, 
reiser was not in linus tree until 2.4.7 or so (not sure which 
release) and it went in after a great debate/controversy.

So I don't think reiser is available in 2.2.
O.k. did some research and it appears that Reiser may have been 
available as of 2.4.1:

http://en.wikipedia.org/wiki/ReiserFS
Which was still along time ago :) and considering how borked the Linus 
tree was in 2.4 until about 2.4.18 which was
18 months after release... I think still matches my not always a 
technical reason comment in this thread ;)

Sincerely,
Joshua D. Drake


XFS is also
a long time Linux supporter and its inclusion into the main tree had
nothing to do with quality.

--
dave
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly

--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - [EMAIL PROTECTED] - http://www.commandprompt.com
PostgreSQL Replicator -- production quality replication for PostgreSQL
begin:vcard
fn:Joshua Drake
n:Drake;Joshua
org:Command Prompt, Inc.
adr:;;PO Box 215 ;Cascade Locks;OR;97014;US
email;internet:[EMAIL PROTECTED]
title:Consultant
tel;work:503-667-4564
tel;fax:503-210-0334
x-mozilla-html:FALSE
url:http://www.commandprompt.com
version:2.1
end:vcard


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread Joshua D. Drake
[EMAIL PROTECTED] wrote:
Does it have to be linux?  I've never had as much success with PostGresql on
linux as i have on FreeBSD 5.3
 

For XFS? I don't think you are going to have with FreeBSD and XFS.
If IIRC (some freebsd person please chime in) that is one thing
that Linux has over FreeBSD which is its filesystems support.
Sincerely,
Joshua D. Drake

matt
Quoting David Garamond [EMAIL PROTECTED]:
 

Joshua D. Drake wrote:
   

Well that isnt exactly true. EXT3 is a bolt on to EXT2 which was always
there. Reiser is also a long time kernel at least from 2.2. 
 

I remember first using reiser3 by patching early 2.4 kernels. IIRC, 
reiser was not in linus tree until 2.4.7 or so (not sure which release) 
and it went in after a great debate/controversy.

So I don't think reiser is available in 2.2.
   

XFS is also
a long time Linux supporter and its inclusion into the main tree had
nothing to do with quality.
 

--
dave
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly
   


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly
 


--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - [EMAIL PROTECTED] - http://www.commandprompt.com
PostgreSQL Replicator -- production quality replication for PostgreSQL
begin:vcard
fn:Joshua Drake
n:Drake;Joshua
org:Command Prompt, Inc.
adr:;;PO Box 215 ;Cascade Locks;OR;97014;US
email;internet:[EMAIL PROTECTED]
title:Consultant
tel;work:503-667-4564
tel;fax:503-210-0334
x-mozilla-html:FALSE
url:http://www.commandprompt.com
version:2.1
end:vcard


---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


[GENERAL] Shared memory and Mac OS X

2005-01-20 Thread Wes
The problem with not being able to set shmmax and shmall in a startup script
in Mac OS X is not that you are setting them too late in the boot process.
It is that you can set them only once.  In fact, you can set them from a
terminal window after booting and logging in - as long as they haven't
already been set.

If you comment out the sysctl's for shmall and shmmax in /etc/rc, reboot,
then log in and bring up a terminal window, you will see that they are set
to -1.  You can then set them to whatever you want (as root of course).
However, if you try to set the value again, the first value remains set.

Unfortunately, this doesn't help much, as Apple's default /etc/rc sets
values.  If you comment out these, you can set the values in a startup
script, but you're still screwed when the next update re-enables the
settings in /etc/rc, which are set before SystemStarter is called.  I guess
the best you can do is have a startup script that notifies you if the values
are wrong.

Wes



---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [GENERAL] cron backup

2005-01-20 Thread Vittorio De Martino
Alle 14:38, martedì 18 gennaio 2005, Lonni J Friedman ha scritto:
 On Tue, 18 Jan 2005 11:12:34 +0100, [EMAIL PROTECTED]

 [EMAIL PROTECTED] wrote:
  At office we have a Win2k LAN to which my freebsd postgresql server box
  is connected via Samba. On this box I have a script, called 'crono',
  which is dealt by /usr/bin/cron every working day's  night at 1 am.  As
  you can see below this crono script vacuums all the DBs and dumps mydb to
  a samba share.
 
  ##crono file
  vacuumdb -a -U victor
  pg_dump --create --format=c -O -Uvictor --file=/root/my_dump/mydb.sql.gz
  mydb
  ##
 
  Now if I execute the script by hand as root it all works smoothly but
  cron fails frequently to start or complete the execution of the script
  even though in the cron log I see that it starts it regularly as root at
  1 am.
 
  The fact is that I don't have any other clue on what is going wrong
  because of the poor log.
 
  What logs shoiuld I enable in the postgresql.conf configuration file to
  trace what's going on with the vacuumdb and  pg_dump commands?

 Normally cronjob output is sent to the email address of its owner.  Is
 root receiving any email output from this cronjob?  Also, you should
 add the -z and -f switches to vacuumdb.

 If I had to guess on your probem above, i'd say it could be a $PATH
 issue, since you're not specifying the path for vacuumdb.

You were right! The only problem was the absence of the directories of the 
command vacuumdb and pg_dump. I added the Iusr/local/bin/ prefic to both and 
now it all works smoothly.

Thanks
Vittorio

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [GENERAL] Error al Subir base de datos

2005-01-20 Thread alexandre::aldeia digital
Hi,
You need to create you database with an enconding like LATIN1:
createdb -E latin1 mydb

Alexandre
Juan Jose Siles Salinas wrote:
Cuando subo la base de datos con pg_restore -d mydb  mydb.tar 
restablece toda la informacion pero los acentos y ñ muestran caracteres 
en otra codificacion como puedo solucionar esto

__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


[GENERAL] how to connect postgresql database

2005-01-20 Thread sudheer raghav
hi,
   am new to Perl.
 How to connect postgresql database with perl ? here
is the Perl code follows:
  #!/usr/bin/perl
  use CGI qw(:standard);
  use DBI;
  use strict;

  print Content-type: text/html\n\n;
  use CGI::Carp qw/fatalsToBrowser/;
  $query = new CGI;
  print $query-header;

$dbh = DBI-connect(dbi:Pg:dbname=test, postgres,
, {AutoCommit = 1, Rais
eError = 1});

if($query-param(submit) eq save) {
$sth = $dbh-prepare(SELECT ip_add from firewall
where $source_add ='10.0.0.10');
} else {
 print error;
 }

if(!defined($sth)) {
print ERROR: Unable to execute database query:
$DBI::errstr\n;
exit;
}
 $sth-execute;


$sth-finish;

print $query-start_html(FIREWALL);

print EOF;
   HTML
   BODY
   print centerH1FIREWALL/H1/center\n;
   print IP Adress:;
 print $query-popup_menu(-name='IP Adress',

-Values=['10.0.0.1','10.0.0.2','10.0.0.3','10.0.0.4',10.0.0.5,10.0.0.6],
);

   print Source IP Adress:;
   print $query-textfield('numeric');
   print Destination IP Adress:;
   print $query-textfield('Dest');
   print $query-radio_group(-name='Disable Enable',
   -Values=['Disable','Enable'],
   );


   print Pcenter$query-submit('Action','save');

   print
$query-submit('Action','cancel')/center/P;
   /BODY
   /HTML
EOF
print $query-end_html;
$dbh-disconnect;
exit(0);


=
Y.SUDHEER RAGHAV+919440521140



__ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com 

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [GENERAL] PostgreSQL 8 on windows very slow

2005-01-20 Thread lol
I've runned your test: 3304 ms (7200 rpm hard disk, pentium3 1Ghz).


---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [GENERAL] cron backup

2005-01-20 Thread Vittorio De Martino
Alle 14:38, martedì 18 gennaio 2005, Lonni J Friedman ha scritto:
 On Tue, 18 Jan 2005 11:12:34 +0100, [EMAIL PROTECTED]

 [EMAIL PROTECTED] wrote:
  At office we have a Win2k LAN to which my freebsd postgresql server box
  is connected via Samba. On this box I have a script, called 'crono',
  which is dealt by /usr/bin/cron every working day's  night at 1 am.  As
  you can see below this crono script vacuums all the DBs and dumps mydb to
  a samba share.
 
  ##crono file
  vacuumdb -a -U victor
  pg_dump --create --format=c -O -Uvictor --file=/root/my_dump/mydb.sql.gz
  mydb
  ##
 
  Now if I execute the script by hand as root it all works smoothly but
  cron fails frequently to start or complete the execution of the script
  even though in the cron log I see that it starts it regularly as root at
  1 am.
 
  The fact is that I don't have any other clue on what is going wrong
  because of the poor log.
 
  What logs shoiuld I enable in the postgresql.conf configuration file to
  trace what's going on with the vacuumdb and  pg_dump commands?

 Normally cronjob output is sent to the email address of its owner.  Is
 root receiving any email output from this cronjob?  Also, you should
 add the -z and -f switches to vacuumdb.

 If I had to guess on your probem above, i'd say it could be a $PATH
 issue, since you're not specifying the path for vacuumdb.

Lonni, you were right! The only problem was the absence of the directories of 
the 
command vacuumdb and pg_dump. I added the Iusr/local/bin/ prefic to both and 
now it all works smoothly.

Thanks
Vittorio

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [GENERAL] Multiline plpython procedure

2005-01-20 Thread Marco Colombo
On Wed, 19 Jan 2005, Martijn van Oosterhout wrote:
On Wed, Jan 19, 2005 at 12:20:23PM +0100, Marco Colombo wrote:
I think you're missing that vendors define what a 'text file' is on their
platform, not Guido. Guido just says that a Python program is a text file,
which is a very sound decision, since it makes perfectlty sense to be able
to edit it with native tools (text editors which do not support alien
textfile formats).
Sure, some text editors don't. Some text editors do. But the C compiler
accepts programs in any of these formats. And consider multiple
machines working off the same file server. There is no standard text
format and everyone should just get along.
Exaclty. Or, one could say: the standard text format is the one the
platform you are running on dictates. Which is what python does.
Multiple machine from a file server had better to agree on what a text
file is. Or do runtime conversions. Or let the server do that.
The issue affects _any_ text file (this email to name one) not only
python programs. [aside note: for e-mail there actually is a well
defined on the wire format, and applications are expected to make
the conversion when needed]
The C standard explicitly defines \r and \n as whitespace, thus neatly
avoiding the entire issue. Many other languages do the same. The fact
is the python is the odd one out.
You're missing the point. The C source file is not a text file, it's
a binary sequence of bytes (which is quite unfortunate, you may
d/l a .c file and be not able to see/read it on your platform, while
the C compliler groks it happily). There's no _line_ separator in C.
If you've ever heard of obfuscated-C contexts, you know that you
can write a complete C program that actually does something in one
line, since C uses a _statements_ separator (';') and not a line
separator. So C is precisely an example of what you should not do:
use a binary file as source, pretending it's a text file. This may
actually make sense, historically, but definitely it's against
python attitude. Python source files are, like it or not, well formed
text file, and the parser even requires correct indentation.
Be very picky in what you accept... after all, you're a _formal_
language. You already put a thousand requirements (a whole grammar)
in what you receive, why not adding also a few ones that force an
improved readability. Think of how hard it is for newbies to spot
a missing ; in C. Compare to how easy is to spot a missing line
break (actually, I think any newbie gets line breaking naturally
right from the start). Having the source of your programs be
line-oriented (opposed to statement oriented) is big win for a 
language designer. And correclty indended from the start is even
better.
You may not agree with the last statements, but that's the python
way, a design (and general attitude) decision. There's no point
in sending a bug report about it.

Be liberal in what you receive. After, what's the benefit of having
python source that's not runnable on every computer. Without
conversion.
Python source of course is runnable on every computer, provided that
the source file is a real text file for that platform.
If you downloaded any text file (not just python source files) by
the _wrong_ mean (e.g. FTP binary mode from a Unix server) on Windows
you'll have problems in handling it. You cannot view it (notepad)
you - very likely - cannot print it. (Yeah your insert favorite 3rd
party editor may be able perform both operations, but that's not the
point). Are you expecting your python interpreter on windows to be able
to handle it? Why? It's not a text file, it's binary garbage, the same
you see with notepad or on your printer when you try and print it.
See the point? (It's subtle: python somehow requires a program to be
human readable, and that means it has to be a text file, correctly
formatted for the platform).
I can see only two ways to address the issue:
- convert the string that represents the python program to a correct
  multi-line string (according to the rules of the platform we're
  running on) before we pass it to the python interpreter;
- explicitly set one format as the right one for our purpose
  (embedded python in PostgreSQL), and have the python interpreter
  we use comply, no matter of the platform we're running on.
Of course, setting the rule:
- python scripts should be correctly formatted multi-line strings
  according to _server_ platform,
will work as well, but places extra burden on the clients (and/or users).
Note that an option or env. variable like:
$ python -T dos file.py
$ export PYTHONTEXTFORMAT=dos
$ python file.py
would be great to have, of course (and that can be suggested).
.TM.
--
  /  /   /
 /  /   /   Marco Colombo
___/  ___  /   /  Technical Manager
   /  /   /  ESI s.r.l.
 _/ _/  _/ [EMAIL PROTECTED]
---(end of 

[GENERAL] Thank you

2005-01-20 Thread Vikram Singh
My friend started a small e-learning company and asked
me to develop the IT solution. The company is now 5
years old and postgresql has been in use for the last
4 years. In the past 4 years NOT ONCE has postgresql
crashed on us. We have had times when the server
utilization was at 100% and swap was being used as
memory but postgresql kept going. 

Today, we have a quite a few high profile clients
(fortune 50) with hundreds of their employees using
our system to keep their skills updated. We are
excited about the 8.0 release and will be upgrading
soon. I would like to thank the postgresql team for
delivering a rock solid DBMS. 



__ 
Do you Yahoo!? 
All your favorites on one personal page – Try My Yahoo!
http://my.yahoo.com 

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


Re: [GENERAL] pg_restore

2005-01-20 Thread Niederland
More Info:
If I perform a backup of my database with PGAdmin3.  I can restore
the database via the command line pg_restore.  It seems as if the
backup created with pg_restore when issued from a winXP command prompt
does not create a file that the pg_restore can read... At least for the
file types Compress and Tar.  Which I need to use since my database
contains blobs.

One other item:  Issuing an pg_restore -C -d myDB myDB.backup
Did not create the database myDB and complained that the database did
not exist.  I had to first create the database and then the pg_restore
functioned correctly (without -C option).


---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


[GENERAL] Calculating a moving average

2005-01-20 Thread Vanole, Mike
Title: Message



Hi,

I need to calculate 
a moving average and I would like to do it with SQL, or a Pg function built for 
this purpose. I'm on Pg 7.4. Is this possible in Pg without abunch of self 
joins, or is there a funtion available? 

Thanks,
Mike


[GENERAL] Would a wiki help newbies?

2005-01-20 Thread Chris Travers
Hi all;
I have recently contributed a wiki to another open source project 
(SQL-Ledger) and have received a fair bit of positive feedback and 
assistance in getting it going.  After reading a lot of the discussion 
on Slashdot concerning the 8.0 release, it occurred to me that a wiki 
might be a good mechanism for newbie support and topics which are 
outside the PostgreSQL documentation umbrella (general database 
management concepts, etc.)

All the documentation on the site would be BSD-style licensed.  If you 
want to see what I have in mind, check out the other wiki I contributed: 
http://www.metatrontech.com/sql-ledger-wiki/

The site will not be branded with my company information except in a 
contributed by bit, and in the domain name.

Do people think that this would be helpful?
Best Wishes,
Chris Travers
Metatron Technology Consulting
begin:vcard
fn:Chris Travers
n:Travers;Chris
email;internet:[EMAIL PROTECTED]
x-mozilla-html:FALSE
version:2.1
end:vcard


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [GENERAL] pg_restore

2005-01-20 Thread Niederland
I am having the same problem:
System: the released Postgres 8.0, winXP
Install performed an initDB.  Tryed all types of backup/restore
combinations, see below:

Using:
pg_dump --format=t --blobs myDB  DBFile
pg_restore --create -dbname=crm DBFile

Resulted in:
pg_restore: [archiver] unsupported version (1.13) in file header

NOTE:  File was created from pg_dump
and then tried as an input to pg_restore.  File was not viewed or
modified
in any way.

*
Using:
pg_dump --format=t --blobs myDB  DBFile

Resulted in:
pg_dump: [custom archiver] WARNING: ftell mismatch with expected
position -- ftell used


Using:
pg_dump --format=t --blobs myDB  DBFile

Resulted in:
pg_dump: large-object output is not supported for plain-text dump files
pg_dump: Use a different output format.
***

Tom Lane wrote:
 Cesar Schneider [EMAIL PROTECTED] writes:
  When I execute pg_restore I get this error:
  pg_restore: [archiver] unsupported version (1.13) in file header

 There is no 1.13; you have a corrupt dump file.  Personally I'd bet
 money that you ran it through a Windows newline conversion (LF to
CR/LF).

   regards, tom lane

 ---(end of
broadcast)---
 TIP 5: Have you checked our extensive FAQ?
 
http://www.postgresql.org/docs/faqs/FAQ.html


---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [GENERAL] Will someone please be a vote taker.

2005-01-20 Thread Wayne Brown [EMAIL PROTECTED]
Mike Cox wrote:

 PostgreSQL 8.0 will be released on Wednesday, Jan 19, 2005.  As of
 today, there were 775 people who said they would like a PostgreSQL
 newsgroup in a web poll.  See the results here:

 http://www.postgresql.org/community/survey.36 .

 PostgreSQL 8.0 is a milestone release.  It features native Windows
 support, nested transactions, and point in time recovery. These
 features are new, and many users will have questions.  With the
 publicity the new version will recieve on slashdot.org, and other
 computer news sites such as zdnet, it would be nice to have a
 PostgreSQL group for those 775 people who took part in the poll.

 New PostgreSQL users who discover PostgreSQL through the media
 coverage would also benefit tremendously.

Didn't you hear the news? There shall be no vote. There are already a
series of working PGSQL groups in the PGSQL hierarchy. A Big 8 group
would be redundant.

(besides, Firebired and MySQL are better)


---(end of broadcast)---
TIP 8: explain analyze is your friend


[GENERAL] SELECT * variant idea, is there something like this...

2005-01-20 Thread Matthew Smith



Hi 


Often I find myself 
working in a query where I need to select one or two fields fromsource 
table A
as renamed objects ( 
usually to prevent name duplication with other selected fields from another 
joined
source table B ) and 
then to also select all the remaining fields from source table 
A

I end up having to 
type out every field name from the underlying tables in the SELECT 
clause,
which is remedial 
and dull, and adds to code maintenance, as everytime I add a new field to 
the
table structure, I 
have to re-editthe queries as well.

In this situation I 
cant help but think it would be great to have something like the "all 
fields" *  keyword token 
as perthe 
SELECT * sql command, that would add into the select field list any fields 
that have not been specifically referenced yet
eg SELECT 
**
or  SELECT 



A visual example of 
what I mean


Table 
Fields

A 
job
A 
description
A 
amount

B 
job
Bsub-item 

Bamount 



The sql 
command 


 SELECT A.*, 
B.*
 FROM A, 
B
 
WHERE A.Job = B.Job

results in all 
fields, but some have to be renamed to prevent duplicated names ( Job and Amount 
fields )

 
Job 
table A
 
Description 
table A
 
Amount 
 table A
 
Job_1 
table B
 
Sub_Item 
table B
 
Amount_1 
table B

 
so I end up doing 
something like this

 SELECT 
A.job, A.description, A.amount AS total_amount, B.*
 
FROM A, B
 
WHERE A.Job = B.Job

typing out all the 
field names from table A ( which can be a lot more than this simple example !!! 
)
this results in the 
following data struture ( field names )

 
Job
 
Description
 
Total_Amount 
( manually renamed Table A's Amount field. To prevent clash with 
Table B's Amount field )
 
Job_1 
( Table B's Job field, auto renamed to prevent clash with earlier 
inclusion of Table A's Job field )
 
Sub_Item
 
Amount

but if I then add 
any new fields to Table A, the 2nd query will never pick them up, as the SELECT 
clause is restrictive in its coding ( I did not use the * token to get all 
fields )



What I see as being 
usefull is something like this


 SELECT 
A.amount AS total_amount, A.** , B.*
 
FROM A, B
 
WHERE A.Job = B.Job

this results in the 
following data struture ( field names )


 
Total_Amount 
( manually renamed Table A's Amount field. To prevent clash with 
Table B's Amount field ) 
Job 
auto included by the A.** in the select 
clause
 
Description 
 
auto included by the A.** in the select 
clause
 
Job_1 
( Table B's Job field, auto renamed to prevent clash with earlier 
inclusion of Table A's Job field )
 
Sub_Item
 
Amount

Note Table A field 
Amount is not added in automatically by the "Select A.**" code as this field has 
already been referenced manually by
the "Select A.amount 
AS total_amount"code


Does something like 
this already exist,
is there a way 
around the problem
or would this make a 
useful additional feature ?

Thanks 


Matthew Smith




Re: [GENERAL] Dynamic column name troubles

2005-01-20 Thread Greg Stark

[EMAIL PROTECTED] writes:

 I have a table that gets a column added to it for every insert on another 
 table.

I think you're going to run into a lot of problems with something like that.
Perhaps you should describe the original problem you're trying to solve and
people would be able to suggest another approach.


-- 
greg


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [GENERAL] Shared memory and Mac OS X

2005-01-20 Thread Jonel Rienton
have you tried using /etc/sysctl.conf and saving the shmax value there?

On Thu, 20 Jan 2005 21:51:02 -0600, Wes wrote
 The problem with not being able to set shmmax and shmall in a 
 startup script in Mac OS X is not that you are setting them too late 
 in the boot process. It is that you can set them only once.  In fact,
  you can set them from a terminal window after booting and logging 
 in - as long as they haven't already been set.
 
 If you comment out the sysctl's for shmall and shmmax in /etc/rc,
  reboot, then log in and bring up a terminal window, you will see 
 that they are set to -1.  You can then set them to whatever you want 
 (as root of course). However, if you try to set the value again, the 
 first value remains set.
 
 Unfortunately, this doesn't help much, as Apple's default /etc/rc 
 sets values.  If you comment out these, you can set the values in a startup
 script, but you're still screwed when the next update re-enables the
 settings in /etc/rc, which are set before SystemStarter is called. 
  I guess the best you can do is have a startup script that notifies 
 you if the values are wrong.
 
 Wes
 
 ---(end of broadcast)---
 TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


--
Jonel Rienton
http://jonel.road14.com


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [GENERAL] Shared memory and Mac OS X

2005-01-20 Thread Wes
On 1/20/05 10:27 PM, Jonel Rienton [EMAIL PROTECTED] wrote:

 have you tried using /etc/sysctl.conf and saving the shmax value there?

Unfortunately, the -p parameter does not appear to be valid, nor does
'strings -a' show 'conf' in the binary (unlike the RedHat sysctl).

Wes



---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [GENERAL] Calculating a moving average

2005-01-20 Thread Dann Corbit
Title: Message








Why not use a cursor?



P.S.

A moving average will look much better if
you Hahn the tails.


To do a normal 7 point moving average, you take (x[i]+ x[i+1]+ x[i+2]+ x[i+3]+ x[i+4]+
x[i+5]+ x[i+6])/7 as point xprime[i] and (y[i]+ y[i+1]+ y[i+2]+ y[i+3]+ y[i+4]+
y[i+5]+ y[i+6])/7 as point yprime[i].



But when you start let x[0], y[0] be the
first point, and then average the next 2 for the second point until you
get to 7 and then do the same thing in the other end. Otherwise, you get
a very strange looking curve.



IMO-YMMV









From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of Vanole, Mike
Sent: Wednesday, January 19, 2005
1:34 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Calculating a
moving average







Hi,











I need to calculate a moving average and I would like to do
it with SQL, or a Pg function built for this purpose. I'm on Pg 7.4. Is this
possible in Pg without abunch of self joins, or is there a funtion
available? 











Thanks,





Mike










Re: [GENERAL] Calculating a moving average

2005-01-20 Thread Jim C. Nasby
Also, if you don't need an exact moving average, you might consider a
weighted mean. Something like:

mean = mean * 0.9 + new_value * 0.1

Much easier to maintain than a moving average.

On Thu, Jan 20, 2005 at 08:40:24PM -0800, Dann Corbit wrote:
 Why not use a cursor?
 
  
 
 P.S.
 
 A moving average will look much better if you Hahn the tails.
 
 
 To do a normal 7 point moving average, you take (x[i]+ x[i+1]+ x[i+2]+
 x[i+3]+ x[i+4]+ x[i+5]+ x[i+6])/7 as point xprime[i] and (y[i]+ y[i+1]+
 y[i+2]+ y[i+3]+ y[i+4]+ y[i+5]+ y[i+6])/7 as point yprime[i].
 
  
 
 But when you start let x[0], y[0] be the first point, and then average
 the next 2 for the second point... until you get to 7 and then do the
 same thing in the other end.  Otherwise, you get a very strange looking
 curve.
 
  
 
 IMO-YMMV
 
 
 
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Vanole, Mike
 Sent: Wednesday, January 19, 2005 1:34 PM
 To: pgsql-general@postgresql.org
 Subject: [GENERAL] Calculating a moving average
 
  
 
 Hi,
 
  
 
 I need to calculate a moving average and I would like to do it with SQL,
 or a Pg function built for this purpose. I'm on Pg 7.4. Is this possible
 in Pg without a bunch of self joins, or is there a funtion available? 
 
  
 
 Thanks,
 
 Mike
 

-- 
Jim C. Nasby, Database Consultant   [EMAIL PROTECTED] 
Give your computer some brain candy! www.distributed.net Team #1828

Windows: Where do you want to go today?
Linux: Where do you want to go tomorrow?
FreeBSD: Are you guys coming, or what?

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


[GENERAL] [ADMIN] Help in Replication

2005-01-20 Thread Lakshmi Narayanan
Thanks in advance,

I have a situation where i have to make my client synchronize their entries 
made in the database locally with the database in the server and viceversa.
Is there any stable application on this.  I use postgresql 7.4.1 version

Lakshmi Narayanan

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread Andrew L. Gould
On Thursday 20 January 2005 09:20 pm, Joshua D. Drake wrote:
 [EMAIL PROTECTED] wrote:
 Does it have to be linux?  I've never had as much success with
  PostGresql on linux as i have on FreeBSD 5.3

 For XFS? I don't think you are going to have with FreeBSD and XFS.
 If IIRC (some freebsd person please chime in) that is one thing
 that Linux has over FreeBSD which is its filesystems support.

 Sincerely,

 Joshua D. Drake

I don't think he was referring to the filesystem issue as much as the 
original question as to which Linux distribution would be best.

I was running PostgreSQL on Linux until just before the 2.4 kernel was 
released.  I tried it on FreeBSD because my uncompressed backup files 
were larger than 2GB.  I've been running PostgreSQL on FreeBSD 4* ever 
since; and I could not be more pleased.  Although the 2.4 kernel 
increased the maximum file size, I never looked back.  (Actually, I 
have been looking back at Linux -- but only at the request of the IS 
Dept.  They have a few staff that run Linux at home; but aren't 
comfortable with FreeBSD.  At the point that they support Linux 
officially, they would like me to change operating systems.)

Andrew Gould

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread Quinton Delpeche
On Friday 21 January 2005 07:40, Andrew L. Gould wrote:

We are running a 200 user system off a SUN Fire v40z using SuSE Linux 9.2 for 
AMD64.

On average we process a JSP page in 300 ms, country wide and have 
approximately 300 tables with over 3 000 000 records in the PostgresQL DB.

I would recommend that you look at any Linux distro that supports 64 Bit 
architecture... ...32 bit machines just don't cope so well. :)

Initially we running this off a Win 2000 server running MS-SQL but we could 
only support 20 concurrent connections... ...if we were lucky.

I then converted the DB to PostgresQL and moved this to a Dual PIV running 
Linux and managed to push the concurrent connections up to 50.

We now can support more then 300 concurrent connections and the server keeps 
smiling.

The machine is a quad processor with 8GB of RAM which does not really compare 
with the PIV as it is in a league of its own, but if you look at the query 
response and page response on a case-by-case basis, you will see that the 64 
bit architecture is normally 2 to 3 times faster then a 32 bit machine.

Q
-- 
Quinton Delpeche
Internal Systems Developer
Softline VIP

Telephone: +27 12 420 7000
Direct:+27 12 420 7007
Facsimile: +27 12 420 7344

http://www.vippayroll.co.za/

Hier liegt ein Mann ganz obnegleich;
Im Leibe dick, an Suden reich.
Wir haben ihn in das Grab gesteckt, Here lies a man with sundry flaws
Weil es uns dunkt er sei verreckt.  And numerous Sins upon his head;
We buried him today because
As far as we can tell, he's dead.
-- PDQ Bach's epitaph, as requested by his cousin Betty
   Sue Bach and written by the local doggerel catcher;
   The Definitive Biography of PDQ Bach, Peter
   Schickele


pgpg79jlTNF2C.pgp
Description: PGP signature


Re: [GENERAL] Calculating a moving average

2005-01-20 Thread Greg Stark
Vanole, Mike [EMAIL PROTECTED] writes:

 I need to calculate a moving average and I would like to do it with SQL,
 or a Pg function built for this purpose. I'm on Pg 7.4. Is this possible
 in Pg without a bunch of self joins, or is there a funtion available? 

Unfortunately moving averages fall into a class of functions, called analytic
functions (at least that's what Oracle calls them) that are inherently hard to
model efficiently in SQL. Postgres doesn't have any special support for this
set of functions, so you're stuck doing it the inefficient ways that standard
SQL allows.

I think this is even hard to implement correctly using Postgres's extremely
extensible function support. Even if you implemented it in Perl or Python I
don't think there's any way to allocate a temporary static storage area for a
given call site. So your moving average function would behave strangely if you
called it twice in a given query.

But if you can work within that caveat it should be straightforward to
implement it efficiently in Perl or Python. Alternatively you can write a
plpgsql function to calculate the specific moving average you need that does
the select itself.

-- 
greg


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [GENERAL] Multiline plpython procedure

2005-01-20 Thread Greg Stark

Marco Colombo [EMAIL PROTECTED] writes:

 Exaclty. Or, one could say: the standard text format is the one the
 platform you are running on dictates. Which is what python does.

Egads. So the set of valid Python programs is different depending on what
platform you're on? That's just, uhm, insane. So essentially Python isn't a
single language, it's a set of languages, Python-NL, Python-NLCR, Python-CR,
(and in theory others).

So if I generate a database with a Python-CRNL function on windows, then
pg_dump it and load it on Unix the function won't run because it's the wrong
language, Unix only supports Python-NL.

I don't think it's reasonable for pg_dump to think about converting data from
one language to another. It's important for pg_dump to restore an identical
database. Having it start with special case data conversation from one flavour
to another seems too dangerous.


Incidentally, are we sure we've diagnosed this correctly? I'm discussing this
with some Python developers and they're expressing skepticism. One just tried
a quick test with a Python program containing a mixture of all three newline
flavours and it ran fine.


-- 
greg


---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread Jason C. Wells
--On Saturday, January 08, 2005 11:14 AM -0300 Esteban Kemp 
[EMAIL PROTECTED] wrote:

I'm starting to develop a production enviroment with Postgres and Tomcat,
And I have to choose between some free linux distribution like:
whitebox
RHEL
Fedora
Suse
Which is the better distribution in terms of postgres? if this has an
answer
Have you considered something other than linux?  Try FreeBSD.  I think one 
of FreeBSD's active developers is also a PostgreSQL developer.  (Fournier 
IIRC)  FreeBSD is great software and it shares the BSD license with 
PostgreSQL.

Later,
Jason C. Wells
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [GENERAL] Calculating a moving average

2005-01-20 Thread Jim C. Nasby
On Fri, Jan 21, 2005 at 12:53:45AM -0500, Greg Stark wrote:
 Vanole, Mike [EMAIL PROTECTED] writes:
 
  I need to calculate a moving average and I would like to do it with SQL,
  or a Pg function built for this purpose. I'm on Pg 7.4. Is this possible
  in Pg without a bunch of self joins, or is there a funtion available? 
 
 Unfortunately moving averages fall into a class of functions, called analytic
 functions (at least that's what Oracle calls them) that are inherently hard to
 model efficiently in SQL. Postgres doesn't have any special support for this
 set of functions, so you're stuck doing it the inefficient ways that standard
 SQL allows.
 
 I think this is even hard to implement correctly using Postgres's extremely
 extensible function support. Even if you implemented it in Perl or Python I
 don't think there's any way to allocate a temporary static storage area for a
 given call site. So your moving average function would behave strangely if you
 called it twice in a given query.
 
 But if you can work within that caveat it should be straightforward to
 implement it efficiently in Perl or Python. Alternatively you can write a
 plpgsql function to calculate the specific moving average you need that does
 the select itself.

If you're feeling adventurous, you might look at Oracle's documentation
on their analytic functions and see if you can come up with something
generic for PostgreSQL. Even if you only do a moving average function it
would be a good start.
-- 
Jim C. Nasby, Database Consultant   [EMAIL PROTECTED] 
Give your computer some brain candy! www.distributed.net Team #1828

Windows: Where do you want to go today?
Linux: Where do you want to go tomorrow?
FreeBSD: Are you guys coming, or what?

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [GENERAL] Multiline plpython procedure

2005-01-20 Thread Tom Lane
Greg Stark [EMAIL PROTECTED] writes:
 Egads. So the set of valid Python programs is different depending on what
 platform you're on? That's just, uhm, insane.

No quibble here.

 Incidentally, are we sure we've diagnosed this correctly? I'm discussing this
 with some Python developers and they're expressing skepticism. One just tried
 a quick test with a Python program containing a mixture of all three newline
 flavours and it ran fine.

He tried reading 'em from files, using Python's text-format-converting
file reader, no?  See the test case posted up-thread, which demonstrates
that feeding a string directly to PyExec (or whatever its called)
produces newline-sensitive results.

regards, tom lane

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [GENERAL] Calculating a moving average

2005-01-20 Thread Greg Stark
Jim C. Nasby [EMAIL PROTECTED] writes:

 If you're feeling adventurous, you might look at Oracle's documentation
 on their analytic functions and see if you can come up with something
 generic for PostgreSQL. 

I think the hard part of doing even a simple implementation is precisely the
point I raised about doing it in Perl or Python. Somehow you have to allocate
a static storage area specific to the call site. It's sort of like an
aggregate function call except of course that you're going to return a datum
for every record.

For a fuller implementation there are a lot more details. If I understand
correctly in Oracle you get to specify an ORDER BY clause and the equivalent
of a GROUP BY clause in the analytic function call. I think each call site can
even have its own order and grouping.

 Even if you only do a moving average function it would be a good start.

Actually my pet one would be a rank function. So you could do something like
return the top 3 scoring players from each team. Currently the suggested way
to do it is by using an aggregate function to gather up the data in an array.

-- 
greg


---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [GENERAL] Calculating a moving average

2005-01-20 Thread Dann Corbit
If someone wanted to put arbitrary aggregates into PostgreSQL, I would
suggest something akin to the RED BRICK API, or better yet, the ATLAS
API:
http://magna.cs.ucla.edu/atlas/

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [GENERAL] Multiline plpython procedure

2005-01-20 Thread Stuart Bishop
Tom Lane wrote:
Greg Stark [EMAIL PROTECTED] writes:
Egads. So the set of valid Python programs is different depending on what
platform you're on? That's just, uhm, insane.

No quibble here.

Incidentally, are we sure we've diagnosed this correctly? I'm discussing this
with some Python developers and they're expressing skepticism. One just tried
a quick test with a Python program containing a mixture of all three newline
flavours and it ran fine.

He tried reading 'em from files, using Python's text-format-converting
file reader, no?  See the test case posted up-thread, which demonstrates
that feeding a string directly to PyExec (or whatever its called)
produces newline-sensitive results.
This is currently being discussed on python-dev:
http://mail.python.org/pipermail/python-dev/2005-January/051203.html
It looks like my earlier concerns were unwarrented - current consensus 
seems to be to transform line endings in the string to the 
one-true-format expected by Python's guts:

http://mail.python.org/pipermail/python-dev/2005-January/051214.html
--
Stuart Bishop [EMAIL PROTECTED]
http://www.stuartbishop.net/
---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [GENERAL] Best Linux Distribution

2005-01-20 Thread Stuart Bishop
Esteban Kemp wrote:
I'm starting to develop a production enviroment with Postgres and 
Tomcat, And I have to choose between some free linux distribution like:
 
whitebox
RHEL
Fedora
Suse
 
Which is the better distribution in terms of postgres? if this has an answer
If you are looking for boxes to run PostgreSQL, you may want to add 
Ubuntu to your list. Ubuntu is free to use and supported, and commercial 
support available too. We use PostgreSQL internally, including on a 
monster box with 12GB of RAM, and have a vested interest in ensuring it 
works well. http://www.ubuntulinux.org

If you need Java on the boxes running PostgreSQL, that will probably be 
the decisive factor - Java licencing makes it difficult for free 
distributions to provide easy installation and support.

--
Stuart Bishop [EMAIL PROTECTED]   http://www.canonical.com/
Canonical Ltd.  http://www.ubuntulinux.com/
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
  http://www.postgresql.org/docs/faq