dbTalk Databases Forums  

How to time several queries?

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss How to time several queries? in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
nd02tsk@student.hig.se
 
Posts: n/a

Default How to time several queries? - 10-18-2004 , 07:20 AM






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


---------------------------(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


Reply With Quote
  #2  
Old   
Ken Tozier
 
Posts: n/a

Default Superuser log-in through a web interface? - 10-30-2004 , 07:35 PM






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";
}
}
}
?>


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


Reply With Quote
  #3  
Old   
Kevin Barnard
 
Posts: n/a

Default Re: Superuser log-in through a web interface? - 10-31-2004 , 12:29 AM



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 (AT) comcast (DOT) net> wrote:
Quote:
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

---------------------------(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



Reply With Quote
  #4  
Old   
Ken Tozier
 
Posts: n/a

Default Re: Superuser log-in through a web interface? - 10-31-2004 , 04:24 AM




On Oct 31, 2004, at 1:29 AM, Kevin Barnard wrote:

Quote:
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.


---------------------------(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



Reply With Quote
  #5  
Old   
Vinko Vrsalovic
 
Posts: n/a

Default Re: Superuser log-in through a web interface? - 10-31-2004 , 11:40 AM



On Sun, Oct 31, 2004 at 05:24:34AM -0500, Ken Tozier wrote:
Quote:
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/i...ntication.html

HTH,
--
Vinko Vrsalovic <el[|-@-|]vinko.cl>

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
  #6  
Old   
Ken Tozier
 
Posts: n/a

Default Re: Superuser log-in through a web interface? - 10-31-2004 , 01:52 PM




On Oct 31, 2004, at 12:40 PM, Vinko Vrsalovic wrote:

Quote:
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


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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.