473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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

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

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

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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Troy Hakala | last post by:
Is it possible to limit the query time in MySQL (3.x or 4.0)? For example, I'd like to have any query that takes more than a specified number of seconds just quit automatically. Seems dumb, but on...
3
by: Jim Geissman | last post by:
The C++ application calls the database to look up property data. One troublesome query is a function that returns a table, finding data which is assembled from four or five tables through a view...
1
by: Ayende Rahien | last post by:
I'm storing my data inside an XML file, the data is divided into several niches. I expect two things to happen during normal use of the application: A> Number of niches to grow. B> Amount of...
9
by: Steve Jorgensen | last post by:
First, an example - today, I wanted to print out the parameter values in a querydef object at a break point in the code for subsequent manual debugging of the query. In the past, I would have had...
25
by: Neil Ginsberg | last post by:
A while back I posted a message re. using an ADP file with a SQL Server back end as opposed to MDB file with linked tables, thinking that the ADP file would be less problematic. The input I got was...
5
by: Jamie Pittman via AccessMonster.com | last post by:
I have two tables with 5000 entries on them. One is based for regular time with several variables example (employee name, date,time in and out, code, customer, building) I have another table that...
12
by: strict9 | last post by:
Hello all, I'm writing several queries which need to do various string formating, including changing a phone number from (123) 456-7890. After some problem with data mismatches, I finally got it...
4
by: BradC | last post by:
We have a Windows 2000 web server (all patches up to date) that runs a variety of sites, most of which are straight HTML or ASP. We have recently added a couple of new ASP.NET sites that use...
3
by: myemail.an | last post by:
If I need to format how the content of a field is displayed, I can click ALT + ENTER from design view, and specify the format, for example, the number of decimal digits and so on. Is there a way...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.