Re: [GENERAL] scripts in Postgres

2005-05-02 Thread Rolf Østvik
[EMAIL PROTECTED] ("Craig Bryden") wrote in news:[EMAIL PROTECTED]: > Hi Sean > > Thanks for that. Does psql work differently to pgAmin III's Query > program? I have tried exactly what you showed me below, and it did not > work. It seems like the script stops on first error, and the first > erro

Re: [GENERAL] unable to open editor.

2005-05-02 Thread Dinesh Pandey
In Solaris 10 with Postgres 8.0, I am getting only for " EDITOR". bash-2.05b$ echo $EDITOR /usr/dt/bin/dtpad bash-2.05b$ echo $VISUAL bash-2.05b$ bash-2.05b$ echo $PSQL_EDITOR bash-2.05b$ Thanks Dinesh Pandey -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Beha

Re: [GENERAL] [ANNOUNCE] IMPORTANT: two new PostgreSQL security problems

2005-05-02 Thread Tatsuo Ishii
> Two serious security errors have been found in PostgreSQL 7.3 and newer > releases. These errors at least allow an unprivileged database user to > crash the backend process, and may make it possible for an unprivileged > user to gain the privileges of a database superuser. > > We are currently

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 >> Which is why Vlad should use prepare() instead of prepare_cached(). > in our web application similar SQL queries (like load an object) > executed over and over again with high frequency. So it's very > desirable to use prepare_cached. I think we

[GENERAL] Security

2005-05-02 Thread Lei Sun
Hi All, I would like to find out some good sources or documentation for PostgreSQL hardening, and security tightening, especially on linux/unix environment. Thank you so much! Lei ---(end of broadcast)--- TIP 9: the planner will ignore your desire

Re: [Pgsqlrpms-hackers] Re: [GENERAL] 7.3.9 Install Question -

2005-05-02 Thread Devrim GUNDUZ
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, On Mon, 2 May 2005, Tom Lane wrote: # PGVERSION is:PGVERSION=7.4 --- Hmm. Apparently Devrim stuck the 7.4 initscript into the 7.3.9 RPMs. Not good :-( :-( AFAIR, it was an old issue, found by Simon. I rem

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 2, 2005, at 11:51 , Vlad wrote: in our web application similar SQL queries (like load an object) executed over and over again with high frequency. So it's very desirable to use prepare_cached. I think we are going to adjust our ORM (object relation mapper) to always use full path to referenc

Re: [GENERAL] DBmirror replication - replacement for DBMirror.pl

2005-05-02 Thread Peter Wilson
Just to add - the replacement for DBMirror.pl automatically works out the schema in use and will replicate using DBmirror from 7.x or from 8.x (table names all changed!). This is done transparently. I also wrote a short article at http://www.whitebeam.org/library/guide/TechNotes/replicate.rhtm

Re: [GENERAL] 7.3.9 Install Question - init.d/postgresql error?

2005-05-02 Thread Tom Lane
Dianne Chen <[EMAIL PROTECTED]> writes: > Let's verify the contents of the rpm file: > mkdir crap > cp postgresql-server-7.3.9-1PGDG.i686.rpm crap > cd crap > cat postgresql-server-7.3.9-1PGDG.i686.rpm | rpm2cpio | cpio -iumd > And now we have the file of concern right from the rpm file in a > d

Re: [GENERAL] 7.3.9 Install Question - init.d/postgresql error?

2005-05-02 Thread Dianne Chen
Hi Tom- Ok. I have checked. The /etc/rc.d/init.d directory was populated with the postgresql file after the postgresql-server-7.3.9-1PGDG.i686.rpm file was installed. Yes, I kept track of the differences as each rpm was installed. :) All rpm files were obtained from postgresql of course. Le

[GENERAL] PostgreSQL 8.0.2 and Tiger

2005-05-02 Thread Jonel Rienton
I just like to share that Postgres build and installed fine on my new Mac OS X Tiger using gcc-4.0 regards, Jonel ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [GENERAL] Tuning queries inside a function

2005-05-02 Thread Tom Lane
"Joshua D. Drake" <[EMAIL PROTECTED]> writes: > Mike Nolan wrote: >> That part I get, but I cannot seem to get an 'explain select' to return >> the explain output inside a function. > Oh interesting. Hmmm. Alvaro can you think of a way to execute the > result into a variable and return it as

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Vlad
> > The docs for prepare_cached() are littered with "Don't do this unless > > you understand the implications" warnings, as well as some kludges to > > differentiate different cases. > > Which is why Vlad should use prepare() instead of prepare_cached(). in our web application similar SQL queries

Re: [GENERAL] Tuning queries inside a function

2005-05-02 Thread Joshua D. Drake
Mike Nolan wrote: Mike Nolan wrote: select * from foo('bar','debug') But how do I do that inside a pl/pgsql function? 'select into' doesn't seem to work properly. You would have to code it. For example: IF $2 = ''debug'' THEN: That part I get, but I cannot seem to get an 'explain select' to

Re: [GENERAL] Tuning queries inside a function

2005-05-02 Thread Mike Nolan
> Mike Nolan wrote: > >>select * from foo('bar','debug') > > > > > > But how do I do that inside a pl/pgsql function? 'select into' doesn't > > seem to work properly. > > > You would have to code it. For example: > > IF $2 = ''debug'' THEN: That part I get, but I cannot seem to get an 'expla

Re: [GENERAL] Using pgcrypto with AES-256 bits?

2005-05-02 Thread Marko Kreen
On 5/1/05, Stas Oskin <[EMAIL PROTECTED]> wrote: > I tried the pgcrypto contrib module with the AES default encryption. It > works pretty nice, but I understand that it's using 128 bit key strength. Is > there any built-in support for the 256 bit key strength? Or it should be > used via external li

Re: [GENERAL] Persistent Connections in Webserver Environment

2005-05-02 Thread Hannes Dorbath
On 02.05.2005 18:33, Marco Colombo wrote: #1 Golden Rule for optimizing: - Don't. (Expecially when it causes _real_ troubles elsewhere.) hmm.. :/ I'll do some more meaningful testing on server load this night.. Thanks so far! ---(end of broadcast)---

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 2, 2005, at 09:34 , Tom Lane wrote: I think you could demonstrate that if the spec is "make it look like the original query was retyped as source each time", then *every* DDL change in the database potentially requires invalidating every cached plan. I don't find that a desirable spec. I

Re: [GENERAL] 7.3.9 Install Question - init.d/postgresql error?

2005-05-02 Thread Tom Lane
Dianne Chen <[EMAIL PROTECTED]> writes: > I have just installed postgresql 7.3.9 into a RHEL3.0 > environment. > there, the script then cats the contents of the > PG_VERSION file and compares it to the script variable > $PGVERSION, which is set to 7.4 in the very first line > of the script.

Re: [GENERAL] Tuning queries inside a function

2005-05-02 Thread Joshua D. Drake
Mike Nolan wrote: select * from foo('bar','debug') But how do I do that inside a pl/pgsql function? 'select into' doesn't seem to work properly. You would have to code it. For example: IF $2 = ''debug'' THEN: I would have to check be able to include a timestamp at the beginning of each notice

Re: [GENERAL] Persistent Connections in Webserver Environment

2005-05-02 Thread Marco Colombo
On Mon, 2005-05-02 at 17:32 +0200, Hannes Dorbath wrote: > On 02.05.2005 16:41, Marco Colombo wrote: > > > Have you measured the real gain in using persistent connections at all? > > As simple as possible: > > require_once('Benchmark/Timer.php'); > $timer =& new Benchmark_Timer(); > $timer->sta

[GENERAL] 7.3.9 Install Question - init.d/postgresql error?

2005-05-02 Thread Dianne Chen
Hi! I have just installed postgresql 7.3.9 into a RHEL3.0 environment. The install went fine. I went to start the postgresql server in the "service configuration" box, and that went well. The problem happened when I went to restart the server. I got the bad error: An old version of the database f

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 1, 2005, at 23:16 , Steve Atkins wrote: Isn't this behaving as documented? prepare_cached() is supposed to return the original statement handle when you pass it the same string a second time. Yes. The docs for prepare_cached() are littered with "Don't do this unless you understand the implic

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Tom Lane
David Wheeler <[EMAIL PROTECTED]> writes: > On May 1, 2005, at 21:30 , Neil Conway wrote: >> An alternative would be to flush dependent plans when the schema >> search path is changed. In effect this would mean flushing *all* >> prepared plans whenever the search path changes: we could perhaps

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 1, 2005, at 21:30 , Neil Conway wrote: An alternative would be to flush dependent plans when the schema search path is changed. In effect this would mean flushing *all* prepared plans whenever the search path changes: we could perhaps keep plans that only contain explicit namespace ref

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 2, 2005, at 06:40 , Andrew Dunstan wrote: I am not sure this is reasonably fixable. Invalidating the cache is not a pleasant solution - the query might not be affected by the change in search path at all. I'd be inclined to say that this is just a limitation of prepare_cached() which s

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 2, 2005, at 06:36 , Vlad wrote: as I understood Tom's message, he's not advising dbd::pg driver to rely on the fact that earlier prepared query is still valid. That's not going to change. It's your responsibility, as the programmer, to know when you need to expire the cache: $dbh->do("SET

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 2, 2005, at 06:14 , Neil Conway wrote: I'm not sure I quite follow you -- in some future version of the backend in which prepared queries are invalidated, this would be invisible to the client. The client wouldn't need to explicitly check for the "liveness" of the prepared query, they

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 1, 2005, at 22:44 , Tom Lane wrote: I am not claiming that the backend handles all these cases nicely today: it certainly doesn't. But we understand in principle how to fix these problems by invalidating plans inside the backend. I don't see how the DBD::Pg driver can hope to deal with any

Re: [GENERAL] Persistent Connections in Webserver Environment

2005-05-02 Thread Hannes Dorbath
On 02.05.2005 17:41, Scott Marlowe wrote: But if the average PHP script takes 50 milliseconds to start up and 100 milliseconds to run, then either one is still pretty much noise. Yeah, _IF_ :) Our scripts reside precompiled in a bytecode cache so there just isn't much start up time ;) I just repl

Re: [GENERAL] Persistent Connections in Webserver Environment

2005-05-02 Thread Scott Marlowe
On Mon, 2005-05-02 at 10:32, Hannes Dorbath wrote: > On 02.05.2005 16:41, Marco Colombo wrote: > > > Have you measured the real gain in using persistent connections at all? > > As simple as possible: > > require_once('Benchmark/Timer.php'); > $timer =& new Benchmark_Timer(); > $timer->start();

Re: [GENERAL] Persistent Connections in Webserver Environment

2005-05-02 Thread Hannes Dorbath
On 02.05.2005 17:32, Hannes Dorbath wrote: $q = "SELECT u.login FROM users WHERE u.user_id = 1;"; Sorry, it should read: $q = "SELECT u.login FROM users u WHERE u.user_id = 1;"; I accidently removed the "u" after users while removing line breaks to make it shorter to post here. --

Re: [GENERAL] Persistent Connections in Webserver Environment

2005-05-02 Thread Hannes Dorbath
On 02.05.2005 16:41, Marco Colombo wrote: Have you measured the real gain in using persistent connections at all? As simple as possible: start(); pg_pconnect('host=myhost dbname=database user=user'); pg_query("SET search_path TO myschema;"); $q = "SELECT u.login FROM users WHERE u.user_id = 1;"; $q

Re: [GENERAL] Persistent Connections in Webserver Environment

2005-05-02 Thread Hannes Dorbath
On 02.05.2005 16:41, Marco Colombo wrote: Have you measured the real gain in using persistent connections at all? I measured it about one year ago on a linux box. Swichting from multi-user-pg_connect to single-user-pg_pconnect was a big improvment on that box -- 50% and more on pages with just 1-

Re: [GENERAL] unable to open editor.

2005-05-02 Thread Michael Fuhr
On Mon, May 02, 2005 at 06:06:46PM +0530, Dinesh Pandey wrote: > > In Solaris 10 with Postgres 8.0, I am getting this error and unable to open > editor. > > testdb=# \e test.sql > > ttdt_open failed: TT_ERR_PROCID The process id passed is not valid. This looks like a ToolTalk error. What edit

Re: [GENERAL] Persistent Connections in Webserver Environment

2005-05-02 Thread Marco Colombo
On Mon, 2005-05-02 at 14:45 +0200, Hannes Dorbath wrote: > Hi, > as the subject says I need some advice on setting up connection handling > to PG in a webserver environment. It's a typical dual Xeon FreeBSD box > running Apache2 with mod_php5 and PG 8. About 20 different applications > (ecommerc

Re: [GENERAL] Persistent Connections in Webserver Environment

2005-05-02 Thread Hannes Dorbath
Hm. That would work, but there are so many data-altering queries, it's a lot of work :/ I'm dreaming of a simple proxy that securely holds a pool of su-connections and uses: SET SESSION AUTHORIZATION $foo; $query; RESET SESSION AUTHORIZATION; It would just have to filter queries that contain "S

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Andrew Dunstan
Andrew Dunstan wrote: Vlad wrote: i.e. the following perl code won't work correctly with DBD::Pg 1.40+ $dbh->do("SET search_path TO one"); my $sth1 = $dbh->prepare_cached("SELECT * FROM test WHERE item = ?"); $sth1->execute("one"); $dbh->do("set search_path to two"); my $sth2 = $dbh->prepare_cach

Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Vlad
On 5/2/05, Neil Conway <[EMAIL PROTECTED]> wrote: > I'm not sure I quite follow you -- in some future version of the backend > in which prepared queries are invalidated, this would be invisible to > the client. The client wouldn't need to explicitly check for the > "liveness" of the prepared query,

Re: [GENERAL] Python DB-API 2.0 oddity (was: I receieved an example of

2005-05-02 Thread Marco Colombo
On Mon, 2005-05-02 at 11:56 +0200, Karsten Hilbert wrote: > > The key is getting the "cursor". Once you have a cursor you can do > > inserts, > > updates and deletes, like > Huh ? Pardon me ? Doing inserts, updates and deletes via a > cursor ? The PostgreSQL documentation clearly says that the

Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Julian Mehnle
Vlad [EMAIL PROTECTED] wrote: > ok, since there is no gurantee that server-side prepared query is > still active, pergaps postgresql interface library provide way to > check if a prepared before query still alive prior runing exec, so > that dbd::pg driver can make sure it's still there, right befo

[GENERAL] DBmirror replication - replacement for DBMirror.pl

2005-05-02 Thread Peter Wilson
Not sure whether this is any use to anyone, or whether this is the right list to post to but... I've just released a C++ implementation of the DBMirror.pl script as part of Whitebeam (http://www.whitebeam.org). We had *real* performance issues with the Perl implementation replicating large fiel

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Andrew Dunstan
Vlad wrote: i.e. the following perl code won't work correctly with DBD::Pg 1.40+ $dbh->do("SET search_path TO one"); my $sth1 = $dbh->prepare_cached("SELECT * FROM test WHERE item = ?"); $sth1->execute("one"); $dbh->do("set search_path to two"); my $sth2 = $dbh->prepare_cached("SELECT * FROM test

Re: [GENERAL] Persistent Connections in Webserver Environment

2005-05-02 Thread Sean Davis
I have only a few connections, but I just connect with the equivalent of your "apache" user. My database is pretty much query-only with a few exceptions that are not "sensitive". But for you, could you just write a stored function to do the transaction and write the audit trail for data-alter

Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Neil Conway
Vlad wrote: ok, since there is no gurantee that server-side prepared query is still active, pergaps postgresql interface library provide way to check if a prepared before query still alive prior runing exec I'm not sure I quite follow you -- in some future version of the backend in which prepared

Re: [GENERAL] scripts in Postgres

2005-05-02 Thread Sean Davis
Craig, I think that pgAdmin III submits each block of SQL as a single block, so if something has an error, it will rollback the entire query. Someone might correct me on this, but I think it is the case (I don't use pgAdmin III). I don't know what OS you are using, but you can use shell script

Re: [GENERAL] scripts in Postgres

2005-05-02 Thread Tino Wildenhain
Am Montag, den 02.05.2005, 14:05 +0200 schrieb Craig Bryden: > Hi > > Thanks for the reply. Since I don't intend using any of the interfaces at > the moment, How would I write the script below in SQL then. > Please keep in mind that I will be sending this script to other people to > run and that i

Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Vlad
ok, since there is no gurantee that server-side prepared query is still active, pergaps postgresql interface library provide way to check if a prepared before query still alive prior runing exec, so that dbd::pg driver can make sure it's still there, right before executing? If there is no such fun

Re: [GENERAL] scripts in Postgres

2005-05-02 Thread Craig Bryden
Hi Sean Thanks for that. Does psql work differently to pgAmin III's Query program? I have tried exactly what you showed me below, and it did not work. It seems like the script stops on first error, and the first error is that the table does not exist. Thanks Craig - Original Message - F

[GENERAL] unable to open editor.

2005-05-02 Thread Dinesh Pandey
In Solaris 10 with Postgres 8.0, I am getting this error and unable to open editor.   testdb=# \e test.sql ttdt_open failed: TT_ERR_PROCID   The process id passed is not valid.     Thanks  

[GENERAL] Persistent Connections in Webserver Environment

2005-05-02 Thread Hannes Dorbath
Hi, as the subject says I need some advice on setting up connection handling to PG in a webserver environment. It's a typical dual Xeon FreeBSD box running Apache2 with mod_php5 and PG 8. About 20 different applications (ecommerce systems) will be running on this box. Each app resides in it's o

Re: [GENERAL] scripts in Postgres

2005-05-02 Thread Sean Davis
DROP TABLE tb_messages; CREATE TABLE tb_messages ( ); That should do it. Save that as a text file, for example 'test.sql', from an editor. Then, start up psql: psql databasename and type at the psql prompt (where test.sql is in the current directory): \i test.sql Sean - Original Messag

Re: [GENERAL] scripts in Postgres

2005-05-02 Thread Craig Bryden
Hi Thanks for the reply. Since I don't intend using any of the interfaces at the moment, How would I write the script below in SQL then. Please keep in mind that I will be sending this script to other people to run and that it needs to be totally automated. Thanks Craig - Original Message --

Re: [GENERAL] scripts in Postgres

2005-05-02 Thread Sean Davis
Yes, pl/pgsql needs to be written as a function. If you want to "script" things, that is done in SQL or via one of the interfaces for perl, python, java, etc. You can just do the DROP TABLE, ignore the error message if the table doesn't exist, and then create the table. The documenation is qu

Re: [GENERAL] Python DB-API 2.0 oddity (was: I receieved an example of

2005-05-02 Thread Marco Colombo
On Mon, 2005-05-02 at 11:56 +0200, Karsten Hilbert wrote: > A note on what I think is a strangeness in the Python DB-API 2.0. > Please correct me if I am wrong. > > (Note that I am not trying to throw off the OP but simply use > his example to point out an oddity about that API. The point > is to

[GENERAL] scripts in Postgres

2005-05-02 Thread Craig Bryden
Hi I am fairly new to Postgres and am struggling to understand one concept. If I wish to use pl/pgsql, must it be in a function? An example of where I would not want it to be in a function is: I have a CREATE TABLE statement that I want to execute. But the script must first check for the existenc

[GENERAL] Python DB-API 2.0 oddity (was: I receieved an example of Rekall script)

2005-05-02 Thread Karsten Hilbert
A note on what I think is a strangeness in the Python DB-API 2.0. Please correct me if I am wrong. (Note that I am not trying to throw off the OP but simply use his example to point out an oddity about that API. The point is to make sure it *is* an oddity so I can raise it with the appropriate for

Re: [GENERAL] Function call identification

2005-05-02 Thread Thomas Hallgren
Vishal Kashyap @ [SaiHertz] wrote: Dear all, I was wondering if their exist any function in Plpgsql functions that would allow me to identify which functions has called what function. To make it simple suppose I have a function func_1 ,func_2 and func_3 Now func_1 calls function func_2 for some

[GENERAL] Function call identification

2005-05-02 Thread Vishal Kashyap @ [SaiHertz]
Dear all, I was wondering if their exist any function in Plpgsql functions that would allow me to identify which functions has called what function. To make it simple suppose I have a function func_1 ,func_2 and func_3 Now func_1 calls function func_2 for some reason and it gives the results a