http://www.postgresql.org/about/licence
The short of it:
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose, without fee, and without a written
agreement is hereby granted, provided that the above copyright notice
and this paragraph and the following two paragraphs appear in all
copies.
You need to include the original copyright, but other than that, you
are free to do what you want with it - for any purpose.