Thread

  1. An INSERT can kill the PostgreSQL server

    Richi Plana <richip@mozcom.com> — 2000-05-28T17:01:06Z

    Your name		:	Richi Plana
    Your email address	:	richip@mozcom.com
    
    
    System Configuration
    ---------------------
      Architecture (example: Intel Pentium)  	:   Intel PentiumIII-500
    
      Operating System (example: Linux 2.0.26 ELF) 	:   Linux 2.2.15 ELF
    
      PostgreSQL version (example: PostgreSQL-6.5.1):   PostgreSQL-7.0
    
      Compiler used (example:  gcc 2.8.0)		:   gcc 2.91.66
    
    
    Please enter a FULL description of your problem:
    ------------------------------------------------
    While INSERTing a row into a TABLE, the backend would die and restart
    
    
    Please describe a way to repeat the problem.   Please try to provide a
    concise reproducible example, if at all possible: 
    ----------------------------------------------------------------------
    Table defs:
    
    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);
    
    Query:
    
    insert into routers values ('Cisco', '7206VXR', '72498595', '{"Butterflies",
    "Intehsoijfeijfjf"}', NULL, '10.2.3.4');
    
    
    If you know how this problem might be fixed, list the solution below:
    ---------------------------------------------------------------------
    
    -- 
    
    L   L Richi Plana, CCNA 8^)   ,-,-.     ,-,-.     ,-,-.     ,-,-.     ,-
    LL LL Systems Administrator  / / \ \   / / \ \   / / \ \   / / \ \   / /
    LLLLL Mosaic Communications, Inc. \ \ / /   \ \ / /   \ \ / /   \ \ / / 
    LLLLL mailto:richip@mozcom.com     `-'-'     `-'-'     `-'-'     `-'-' 
    
    
    
  2. Re: An INSERT can kill the PostgreSQL server

    Tom Lane <tgl@sss.pgh.pa.us> — 2000-05-28T17:25:28Z

    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');
    
    Hmm.  Looks like there is some kind of unpleasant interaction between
    the constant-expression simplifier and application of array-element
    length constraints.  Thanks for the report, I'll look into it today.
    
    If you are in a *big* hurry, I expect declaring rw_community as
    text[] would avoid the bug.
    
    			regards, tom lane
    
    
  3. Re: An INSERT can kill the PostgreSQL server

    Tom Lane <tgl@sss.pgh.pa.us> — 2000-05-28T17:47:10Z

    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