Re: An INSERT can kill the PostgreSQL server

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richi Plana <richip@mozcom.com>
Cc: pgsql-bugs@postgresql.org
Date: 2000-05-28T17:47:10Z
Lists: pgsql-bugs
Richi Plana <richip@mozcom.com> writes:
> create table devices (brand varchar(30), model varchar(30), serial
> varchar(30), ro_community varchar(50)[], rw_community varchar(50)[], primary
> key (brand, model, serial));

> create table routers (lo_address inet) inherits (devices);

> insert into routers values ('Cisco', '7206VXR', '72498595', '{"Butterflies",
> "Intehsoijfeijfjf"}', NULL, '10.2.3.4');

Ah, I see it: it's the NULL array value that is causing the problem.
6.5 parser didn't really handle the NULL properly, but 7.0's does:
it tries to apply array_map() to the NULL to ensure it's coerced to
50-chars-per-item length limit.  Which means array_map had better be
NULL-proof.

This patch is applied for 7.0.1, but if you need a fix now:

*** src/backend/utils/adt/arrayfuncs.c~	Wed Jan 26 00:57:12 2000
--- src/backend/utils/adt/arrayfuncs.c	Sun May 28 13:43:34 2000
***************
*** 1308,1313 ****
--- 1308,1317 ----
  	char	   *s;
  	char	   *p;
  	va_list		ap;
+ 
+ 	/* Need to guard against NULL input array */
+ 	if (v == NULL)
+ 		return NULL;
  
  	/* Large objects not yet supported */
  	if (ARR_IS_LO(v) == true)



			regards, tom lane