Thread

  1. Re: atttypmod of 0

    Zeugswetter Andreas <andreas.zeugswetter@telecom.at> — 1998-02-05T17:23:59Z

       This  time  it's during the parser (gdb told me). varcharin()
        is called with a atttypmod of  0  causing  a  palloc()  of  0
        bytes.  How should a VARCHAR type whithout a specified length
        behave? Is this type 1 character or a  variable  size  up  to
        4096?
    
    I thought we fixed this on Feb 3. look at
    parse_expr.c line 104: it should read: 
                                    if (con->typename != NULL)
    !                                       result = parser_typecast(val,
    con->typename, -1);
                                    else
    
    I think all funcs calling with atttypmod = 0 are allways wrong, should
    be -1.
    or a number > 0 (or 4 if atttypmod includes the VARHDRSZ don't know) 
    
    Andreas
    
    
  2. Re: [HACKERS] Re: atttypmod of 0

    Bruce Momjian <maillist@candle.pha.pa.us> — 1998-02-05T17:41:44Z

    > 
    >    This  time  it's during the parser (gdb told me). varcharin()
    >     is called with a atttypmod of  0  causing  a  palloc()  of  0
    >     bytes.  How should a VARCHAR type whithout a specified length
    >     behave? Is this type 1 character or a  variable  size  up  to
    >     4096?
    > 
    > I thought we fixed this on Feb 3. look at
    > parse_expr.c line 104: it should read: 
    >                                 if (con->typename != NULL)
    > !                                       result = parser_typecast(val,
    > con->typename, -1);
    >                                 else
    > 
    > I think all funcs calling with atttypmod = 0 are allways wrong, should
    > be -1.
    > or a number > 0 (or 4 if atttypmod includes the VARHDRSZ don't know) 
    > 
    > Andreas
    > 
    > 
    
    Yes, we did, but now I fixed varcharin, and bpcharin to test for
    atttypmod of 0 and do the right thing, I think.  If we need to make the
    default atttypmod value -1, then we can change it back.  Let me know if
    the current fix does not work.
    
    Should I make atttypmod default to -1?
    
    -- 
    Bruce Momjian
    maillist@candle.pha.pa.us
    
    
  3. Re: [HACKERS] Re: atttypmod of 0

    Bruce Momjian <maillist@candle.pha.pa.us> — 1998-02-05T17:57:21Z

    > 
    >    This  time  it's during the parser (gdb told me). varcharin()
    >     is called with a atttypmod of  0  causing  a  palloc()  of  0
    >     bytes.  How should a VARCHAR type whithout a specified length
    >     behave? Is this type 1 character or a  variable  size  up  to
    >     4096?
    > 
    > I thought we fixed this on Feb 3. look at
    > parse_expr.c line 104: it should read: 
    >                                 if (con->typename != NULL)
    > !                                       result = parser_typecast(val,
    > con->typename, -1);
    >                                 else
    > 
    > I think all funcs calling with atttypmod = 0 are allways wrong, should
    > be -1.
    > or a number > 0 (or 4 if atttypmod includes the VARHDRSZ don't know) 
    
    It does include the VARHDRSZ.
    
    -- 
    Bruce Momjian
    maillist@candle.pha.pa.us
    
    
  4. Re: [HACKERS] Re: atttypmod of 0

    Jan Wieck <jwieck@debis.com> — 1998-02-05T18:19:37Z

    > 
    > > 
    > >    This  time  it's during the parser (gdb told me). varcharin()
    > >     is called with a atttypmod of  0  causing  a  palloc()  of  0
    > >     bytes.  How should a VARCHAR type whithout a specified length
    > >     behave? Is this type 1 character or a  variable  size  up  to
    > >     4096?
    > > 
    > > I thought we fixed this on Feb 3. look at
    > > parse_expr.c line 104: it should read: 
    > >                                 if (con->typename != NULL)
    > > !                                       result = parser_typecast(val,
    > > con->typename, -1);
    > >                                 else
    > > 
    > > I think all funcs calling with atttypmod = 0 are allways wrong, should
    > > be -1.
    > > or a number > 0 (or 4 if atttypmod includes the VARHDRSZ don't know) 
    > 
    > It does include the VARHDRSZ.
    
        So the right check would be "atttypmod > 4" instead of "> 0"
        But fixing all the other places to use one and the same
        value (0 or -1) would be a good idea.
    
    > 
    > -- 
    > Bruce Momjian
    > maillist@candle.pha.pa.us
    > 
    > 
    
    
    Until later, Jan
    
    
    -- 
    
    #======================================================================#
    # It's easier to get forgiveness for being wrong than for being right. #
    # Let's break this rule - forgive me.                                  #
    #======================================== jwieck@debis.com (Jan Wieck) #
    
    
    
  5. Re: [HACKERS] Re: atttypmod of 0

    Bruce Momjian <maillist@candle.pha.pa.us> — 1998-02-05T18:47:34Z

    > > It does include the VARHDRSZ.
    > 
    >     So the right check would be "atttypmod > 4" instead of "> 0"
    >     But fixing all the other places to use one and the same
    >     value (0 or -1) would be a good idea.
    > 
    
    I already have.  0 is the default, but I can change it.
    
    -- 
    Bruce Momjian
    maillist@candle.pha.pa.us