By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,776 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,776 IT Pros & Developers. It's quick & easy.

How to time several queries?

P: n/a
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

Nov 23 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
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

Nov 23 '05 #2

P: n/a
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 <ke*******@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


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

Nov 23 '05 #3

P: n/a
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

Nov 23 '05 #4

P: n/a
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 <ke*******@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


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

Nov 23 '05 #5

P: n/a

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

Nov 23 '05 #6

P: n/a

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

Nov 23 '05 #7

P: n/a
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/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 ma*******@postgresql.org)

Nov 23 '05 #8

P: n/a

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
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #9

P: n/a
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/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 ma*******@postgresql.org)

Nov 23 '05 #10

P: n/a

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
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.