When does PQstatus() update?

Started by Richi Planaover 27 years ago3 messagesgeneral
Jump to latest
#1Richi Plana
richip@mozcom.com

Hi,

Just wondering when the result of the function PQstatus() gets updated?
Can I expect it to be updated while connected even without performing any
transactions/communications with the backend?

I tried PQexec()'ing a "BEGIN TRANSACTION" on a dead backend and
immediately checked PQstatus() as well as PQresultStatus(). PQstatus()
returned a CONNECTION_OK while PQresultStatus() returned
PGRES_FATAL_ERROR. I tried it again on the same dead-connection backend a
couple of seconds later and got a CONNECTION_BAD fro PQstatus() and a
PGRES_NONFATAL_ERROR from PQresultStatus().

L L Richi Plana 8^) ,-,-. ,-,-. ,-,-. ,-,-. ,-
LL LL Systems Administrator / / \ \ / / \ \ / / \ \ / / \ \ / /
LLLLL Mosaic Communications, Inc. \ \ / / \ \ / / \ \ / / \ \ / /
LLLLL mailto:richip@mozcom.com `-'-' `-'-' `-'-' `-'-'
------------------------------------------------------------------------
P G P Key available at http://www2.mozcom.com/~richip/richip.asc
Tired of Spam? Join this CAUCE! http://www.cauce.org/

#2Giovanni Floridia
gfloridia@provider.com.br
In reply to: Richi Plana (#1)
Subselect question

Hi,

I have some trouble with subselects. (Version 6.3).

If I try

Select name, address from costumers where cod_costumer in (
Select cod_costumer from logins where total_usage > 0);

It take lots of time (really I din't wait till the end).

But if I manualy split in
Select cod_costumer from logins where total_usage > 0;
getting
( 1, 9, 15, 18 , 40)
and then use
Select name, address from costumers where cod_costumer in ( 1, 9,
15, 18 , 40);

All is OK.

Is this type of subselect suported ?

Thanks
Giovanni Floridia

#3Jackson, DeJuan
djackson@cpsgroup.com
In reply to: Giovanni Floridia (#2)
RE: [GENERAL] Subselect question

Hi,

I have some trouble with subselects. (Version 6.3).

If I try

Select name, address from costumers where cod_costumer in (
Select cod_costumer from logins where total_usage > 0);

It take lots of time (really I din't wait till the end).

But if I manualy split in
Select cod_costumer from logins where total_usage > 0;
getting
( 1, 9, 15, 18 , 40)
and then use
Select name, address from costumers where cod_costumer in ( 1, 9,
15, 18 , 40);

All is OK.

Is this type of subselect suported ?

Thanks
Giovanni Floridia

Yes it's supported, but the subselect will be executed for each row of
the main select.
This should be a faster select (but not as fast as your second one).
Select name, address from costumers where EXISTS(Select 1 from logins
where total_usage > 0 AND logins.cod_customer = customers.cod_customer);
-DEJ