Re: [BUGS] Bug #838: SSL problems in 7.3

2002-12-14 Thread Bruce Momjian

I checked through the rest of the SSL code and caught a few more cases.

The strange part here is that COMMERROR is for cases where the client
might not exist, and obviously you are seeing that.  The problem is that
these errors can happen when the client _does_ exist too.  Not sure how
to handle that, but let me get this fix in now.

Attached patch applied to HEAD and 7.3.X.  Thanks.

---

Nathan Mueller wrote:
> Ok, I think I've gotten this figured out now.  I saw this comment in pqcomm.c,
> switched the ERROR logs to COMMERROR logs and it all works.  I've attached a
> patch to be-secure.c that fixes all my problems.  Hopefully this is the right fix.
> 
>   --Nate
> 
> /*
>  * Careful: an elog() that tries to write to the client would
>  * cause recursion to here, leading to stack overflow and core
>  * dump!  This message must go *only* to the postmaster log.
>  */
> 

[ Attachment, skipping... ]

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

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

Index: be-secure.c
===
RCS file: /cvsroot/pgsql-server/src/backend/libpq/be-secure.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -c -c -r1.18 -r1.19
*** be-secure.c 13 Dec 2002 05:51:29 -  1.18
--- be-secure.c 14 Dec 2002 18:39:14 -  1.19
***
*** 11,17 
   *
   *
   * IDENTIFICATION
!  *  $Header: /cvsroot/pgsql-server/src/backend/libpq/be-secure.c,v 1.18 
2002/12/13 05:51:29 momjian Exp $
   *
   *  Since the server static private key ($DataDir/server.key)
   *  will normally be stored unencrypted so that the database
--- 11,17 
   *
   *
   * IDENTIFICATION
!  *  $Header: /cvsroot/pgsql-server/src/backend/libpq/be-secure.c,v 1.19 
2002/12/14 18:39:14 momjian Exp $
   *
   *  Since the server static private key ($DataDir/server.key)
   *  will normally be stored unencrypted so that the database
***
*** 289,298 
break;
case SSL_ERROR_SYSCALL:
if (n == -1)
!   elog(ERROR, "SSL SYSCALL error: %s", 
strerror(errno));
break;
case SSL_ERROR_SSL:
!   elog(ERROR, "SSL error: %s", SSLerrmessage());
/* fall through */
case SSL_ERROR_ZERO_RETURN:
secure_close(port);
--- 289,298 
break;
case SSL_ERROR_SYSCALL:
if (n == -1)
!   elog(COMMERROR, "SSL SYSCALL error: %s", 
strerror(errno));
break;
case SSL_ERROR_SSL:
!   elog(COMMERROR, "SSL error: %s", SSLerrmessage());
/* fall through */
case SSL_ERROR_ZERO_RETURN:
secure_close(port);
***
*** 339,348 
break;
case SSL_ERROR_SYSCALL:
if (n == -1)
!   elog(ERROR, "SSL SYSCALL error: %s", 
strerror(errno));
break;
case SSL_ERROR_SSL:
!   elog(ERROR, "SSL error: %s", SSLerrmessage());
/* fall through */
case SSL_ERROR_ZERO_RETURN:
secure_close(port);
--- 339,348 
break;
case SSL_ERROR_SYSCALL:
if (n == -1)
!   elog(COMMERROR, "SSL SYSCALL error: %s", 
strerror(errno));
break;
case SSL_ERROR_SSL:
!   elog(COMMERROR, "SSL error: %s", SSLerrmessage());
/* fall through */
case SSL_ERROR_ZERO_RETURN:
secure_close(port);
***
*** 678,684 
!SSL_set_fd(port->ssl, port->sock) ||
SSL_accept(port->ssl) <= 0)
{
!   elog(ERROR, "failed to initialize SSL connection: %s", 
SSLerrmessage());
close_SSL(port);
return -1;
}
--- 678,684 
!SSL_set_fd(port->ssl, port->sock) ||
   

Re: [BUGS] postmaster segfaults when pg_hba.cof is missing

2002-12-14 Thread Bruce Momjian

Patch applied to HEAD and 7.3.X.  Thanks.

---



Neil Conway wrote:
> On Thu, 2002-12-12 at 13:13, Rudy Lippan wrote:
> > I know this is a broken install, but postmaster should not segfault when 
> > it can't find a file.
> > 
> > postgres@war PGDATA $ ../pgsql7.3/bin/postmaster
> > LOG:  load_hba: Unable to open authentication config file 
> > "/usr/local/PGDATA/pgsql7.3/pg_hba.conf": No such file or directory
> > Segmentation fault (core dumped)
> 
> Good catch. Here's a patch against CVS HEAD that fixes the problem.
> 
> The actual segfault was caused by a double pfree(), but ISTM that
> failing to find pg_hba.conf should be a fatal error anyway, so I
> increased the priority of the elog() from LOG to FATAL and refactored
> the code a little bit.
> 
> Bruce: unless anyone has an objection, please apply.
> 
> Thanks for the report.
> 
> Cheers,
> 
> Neil

[ Attachment, skipping... ]

> 
> ---(end of broadcast)---
> TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

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



[BUGS] Bug #848: Index on bigint column is unused in selects

2002-12-14 Thread pgsql-bugs
Peter Roozemaal ([EMAIL PROTECTED]) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
Index on bigint column is unused in selects

Long Description
PostgreSQL 7.2 will allways do a full table scan when the index field is a bigint. 
even with a "where bigkey = 99" clause.

CREATE TABLE test1 (
een bigint  PRIMARY KEY,
tweeint UNIQUE NOT NULL,
datatext);

peter=> explain select * from test1 where een > 0 and een < 1000;
NOTICE:  QUERY PLAN:
Seq Scan on test1  (cost=0.00..25.00 rows=5 width=44)
EXPLAIN

peter=> explain select * from test1 where een = 99;
NOTICE:  QUERY PLAN:
Seq Scan on test1  (cost=0.00..22.50 rows=1 width=44)
EXPLAIN

I expected two index scans here.

The same bug/feature is present in version 7.3

Sample Code
peter=> CREATE TABLE test1 (
een bigint  PRIMARY KEY,
tweeint UNIQUE NOT NULL,
datatext);

-- fill table with 10 rows -- 

peter=> explain select * from test1 where twee < 1000;
NOTICE:  QUERY PLAN:
Seq Scan on test1  (cost=0.00..22.50 rows=333 width=44)
EXPLAIN

peter=> explain select * from test1 where twee > 0 and twee < 1000;
NOTICE:  QUERY PLAN:
Index Scan using test1_twee_key on test1  (cost=0.00..17.08 rows=5 width=44)
EXPLAIN

peter=> explain select * from test1 where twee = 99;
NOTICE:  QUERY PLAN:
Index Scan using test1_twee_key on test1  (cost=0.00..4.82 rows=1 width=44)
EXPLAIN

peter=> explain select * from test1 where een > 0 and een < 1000;
NOTICE:  QUERY PLAN:
Seq Scan on test1  (cost=0.00..25.00 rows=5 width=44)
EXPLAIN

peter=> explain select * from test1 where een = 99;
NOTICE:  QUERY PLAN:
Seq Scan on test1  (cost=0.00..22.50 rows=1 width=44)
EXPLAIN

peter=> ANALYSE;
-- output --

peter=> explain select * from test1 where twee < 1000;
NOTICE:  QUERY PLAN:
Index Scan using test1_twee_key on test1  (cost=0.00..3.13 rows=10 width=99)
EXPLAIN 

No file was uploaded with this report


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly