pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aroon Pahwa <aroon@loopt.com>
To: pgsql-general@postgresql.org
To: pgsql-sql@postgresql.org
Subject: valid query runs forever?
Date: Fri, 05 Oct 2007 14:33:20 -0700
Message-ID: <4706ADA0.9030507@loopt.com> (raw)

I'm having a strange issue with postgres...I think.

I have the following query:

GRANT SELECT ON 'tablename' TO 'username';

As far as I can tell, thats a valid query.  It works fine when I run it 
under the psql command line interface and executed against a remote db.

When I try and run the same query in pg-Admin from the same machine to 
the same remote db, however, the query never terminates.  It just runs 
forever.  I've let it run for about a half hour before.  psql returns 
almost immediately.

I've run into the same kind of behavior when attempting to execute a 
stored procedure from code.  The specific instance looked something like 
this in C# .NET using the Npgsql data provider:

using (NpgsqlConnection conn = new NpgsqlConnection(connString))
using (NpgsqlCommand command = new pgsqlCommand("Function(:a,:b)", conn))
{
	conn.Open();
	command.CommandType = CommandType.StoredProcedure;
	command.Parameters.Add("a", DbType.Double).Value = this.a;
	command.Parameters.Add("b", DbType.Double).Value = this.b;
	result = command.ExecuteScalar();
}

In this case, the user specified in the connection string has SELECT 
rights on the appropriate table but did not have EXECUTE rights on the 
stored proc.  The code would block at 'command.ExecuteScalar();' 
forever.  Granting execute rights resolved the issue and everything 
returned as expected.  I've reproduced the same issue using the pgODBC 
driver as well.  The code looks almost exactly the same.

Has anyone else encountered these issues?  In the former case, I don't 
understand why the query would fail.  Using the explain option from the 
title bar (ie. F7) gave a syntax error at a random character in the 
query. Usually character 9 (the 'L' in "SELECT") but sometimes a 
different one.  In the latter case I at least expected postgres to 
return some kind of error.  Any insights into this would be helpful!

BTW, specs of the machine I'm running postgres on and other details:

Win2k3 Server x64
AMD Opeteron 2GHz
loads of RAM
postgres 8.2
no firewalls of any kind on either box involved
the latter issue was running in a multithreaded/concurrent access 
environment but I don't have any issues with queries when the user has 
all the necessary rights even under enormous load and I consistently 
have issues on the very first query when I would expect a permissions error.

Also, not sure if this fit in the general mailing list or just the sql 
mailing list. Sorry if this is off topic in general.

Thanks,
Aroon



Message-ID: <4706ADA0.9030507@loopt.com>
Permalink:  ../4706ADA0.9030507@loopt.com/
Also on:    postgresql.org/message-id/4706ADA0.9030507@loopt.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: aroon@loopt.com, pgsql-general@postgresql.org
  Subject: Re: valid query runs forever?
  In-Reply-To: <4706ADA0.9030507@loopt.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox