Обсуждение: How to time several queries?
Hello I know it is possible to time isolated queries through the settting of the \timing option in psql. This makes PgSQL report the time it took to perform one operation. I would like to know how one can get a time summary of many operations, if it is at all possible. Thank you. Tim
Hello all, I'm trying to create a php form for logging in to postgress with different level passwords and my first test with a superuser isn't working unless I specify a database name. I would like to allow superusers to log in without specifying a database so they can create new users, databases etc from a web interface. Does anyone see what I'm doing wrong in the following example? Thanks for any help, Ken --------------------------------------------- I defined a super user like so CREATE USER user_name CREATEUSER PASSWORD 'password' Try to log in through a web form like so: User: user_name Password: password but the connection always fails unless I specify a database. Relevant PHP: <?php function LogInUser() { if (isset($_POST['user_name']) && isset($_POST['password'])) { $user = $_POST['user_name']; $password = $_POST['password']; $conn_string = "user=".$user." password=".$password." host=localhost port=5432"; $conn = pg_connect($conn_string); if ($conn) { echo "login succeeded"; } } } ?>
You have a conceptual error. When connecting you are connecting "to a database". With out the database you are not connecting to anything hence the failure. Typically to do what you are trying to do you would connect to the database template1 unless a database is specified. If you have another DB you can connect to that and do your create commands there are well. On Sat, 30 Oct 2004 20:35:50 -0400, Ken Tozier <kentozier@comcast.net> wrote: > Hello all, > > I'm trying to create a php form for logging in to postgress with > different level passwords and my first test with a superuser isn't > working unless I specify a database name. I would like to allow > superusers to log in without specifying a database so they can create > new users, databases etc from a web interface. Does anyone see what I'm > doing wrong in the following example? > > Thanks for any help, > > Ken > > --------------------------------------------- > I defined a super user like so > > CREATE USER user_name CREATEUSER PASSWORD 'password' > > Try to log in through a web form like so: > > User: user_name > Password: password > > but the connection always fails unless I specify a database. > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster >
On Oct 31, 2004, at 1:29 AM, Kevin Barnard wrote: > You have a conceptual error. When connecting you are connecting "to a > database". With out the database you are not connecting to anything > hence the failure. That explains it, thanks. Another pesky problem I've run into is that I can enter literally anything into the user name and password fields of my php form and it still logs in. What's up with that? Is there some way find out the user for a given connection? I tried to use pg_user and pg_shadow but neither of them registered as valid functions in the PHP code.
On Sun, Oct 31, 2004 at 05:24:34AM -0500, Ken Tozier wrote: > > On Oct 31, 2004, at 1:29 AM, Kevin Barnard wrote: > > >You have a conceptual error. When connecting you are connecting "to a > >database". With out the database you are not connecting to anything > >hence the failure. > > That explains it, thanks. > > Another pesky problem I've run into is that I can enter literally > anything into the user name and password fields of my php form and it > still logs in. What's up with that? Is there some way find out the user > for a given connection? This is probably because pg_hba.conf settings. By default, it trusts connections from localhost, which means that any connection being made from localhost (which is the case when the web server and database are running in the same machine) will be accepted regardless of user and password. You should change these lines in pg_hba.conf local all all trust # IPv4-style local connections: host all all 127.0.0.1/32 trust and change 'trust' to your preferred auth method (password, md5, etc.) Check out the docs for authentication methods at http://www.postgresql.org/docs/7.4/interactive/client-authentication.html HTH, -- Vinko Vrsalovic <el[|-@-|]vinko.cl>
On Oct 31, 2004, at 12:40 PM, Vinko Vrsalovic wrote: > <snip> > This is probably because pg_hba.conf settings. By default, it trusts > connections from localhost, which means that any connection being made > from localhost (which is the case when the web server and database are > running in the same machine) will be accepted regardless of user and > password. > > You should change these lines in pg_hba.conf > > local all all trust > # IPv4-style local connections: > host all all 127.0.0.1/32 trust > > and change 'trust' to your preferred auth method (password, md5, etc.) > > Check out the docs for authentication methods at > http://www.postgresql.org/docs/7.4/interactive/client- > authentication.html Thanks Vinko that did the trick. Ken