Thread

  1. Misleading Error Message

    Kristofer Munn <kmunn@munn.com> — 1999-05-16T04:10:12Z

    Hi all.  Was working tonight and ran into the following error.  Doing a
    union between two selects (to get around the lack of outer joins - hint
    hint), I was getting the error:
    
            ERROR: Each UNION clause must have the same number of columns
    
    Upon examining the SQL statement in question, I verified that it did,
    indeed, have the same number of columns.  After some fiddling, I found the
    actual problem was that I was doing an ORDER BY on a column which was not
    being included in the two select statements.  Unfortunately, the error
    message wasn't pointing at that.
    
    I'm not sure if this is just a simple change or implies other problems
    with the parser but I thought I'd toss it out onto the pile.
    
    Cya...
    
    - K
    
    Kristofer Munn * http://www.munn.com/~kmunn/ * ICQ# 352499 * AIM: KrMunn 
    
    
    
    
  2. Re: [HACKERS] Misleading Error Message

    Bruce Momjian <maillist@candle.pha.pa.us> — 1999-05-16T05:25:59Z

    > Hi all.  Was working tonight and ran into the following error.  Doing a
    > union between two selects (to get around the lack of outer joins - hint
    > hint), I was getting the error:
    > 
    >         ERROR: Each UNION clause must have the same number of columns
    > 
    > Upon examining the SQL statement in question, I verified that it did,
    > indeed, have the same number of columns.  After some fiddling, I found the
    > actual problem was that I was doing an ORDER BY on a column which was not
    > being included in the two select statements.  Unfortunately, the error
    > message wasn't pointing at that.
    > 
    > I'm not sure if this is just a simple change or implies other problems
    > with the parser but I thought I'd toss it out onto the pile.
    
    Tom Lane discovered it a few days ago in relation to INSERT INTO table
    SELECT * FROM TABLE ORDER BY col1, and col1 was not in the select target
    list.  It shows an error.  We are looking at solutions.
    
    -- 
      Bruce Momjian                        |  http://www.op.net/~candle
      maillist@candle.pha.pa.us            |  (610) 853-3000
      +  If your life is a hard drive,     |  830 Blythe Avenue
      +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
    
    
  3. Re: [HACKERS] Misleading Error Message

    Jan Wieck <jwieck@debis.com> — 1999-05-17T08:27:26Z

    >
    > > Hi all.  Was working tonight and ran into the following error.  Doing a
    > > union between two selects (to get around the lack of outer joins - hint
    > > hint), I was getting the error:
    > >
    > >         ERROR: Each UNION clause must have the same number of columns
    > >
    > > Upon examining the SQL statement in question, I verified that it did,
    > > indeed, have the same number of columns.  After some fiddling, I found the
    > > actual problem was that I was doing an ORDER BY on a column which was not
    > > being included in the two select statements.  Unfortunately, the error
    > > message wasn't pointing at that.
    > >
    > > I'm not sure if this is just a simple change or implies other problems
    > > with the parser but I thought I'd toss it out onto the pile.
    >
    > Tom Lane discovered it a few days ago in relation to INSERT INTO table
    > SELECT * FROM TABLE ORDER BY col1, and col1 was not in the select target
    > list.  It shows an error.  We are looking at solutions.
    
        This  might  also  interfere with latest changes I did in the
        rewrite system. Parser and rewriter now add  junk  attributes
        to  the  targetlist.   I  think the problem is that the union
        code (where the check is done)  doesn't  recognize  that  the
        unequal  length of the targetlists is due to junk attributes.
    
    
    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) #
    
    
    
    
  4. Re: [HACKERS] Misleading Error Message

    Bruce Momjian <maillist@candle.pha.pa.us> — 1999-05-17T18:22:27Z

    > >
    > > > Hi all.  Was working tonight and ran into the following error.  Doing a
    > > > union between two selects (to get around the lack of outer joins - hint
    > > > hint), I was getting the error:
    > > >
    > > >         ERROR: Each UNION clause must have the same number of columns
    > > >
    > > > Upon examining the SQL statement in question, I verified that it did,
    > > > indeed, have the same number of columns.  After some fiddling, I found the
    > > > actual problem was that I was doing an ORDER BY on a column which was not
    > > > being included in the two select statements.  Unfortunately, the error
    > > > message wasn't pointing at that.
    > > >
    > > > I'm not sure if this is just a simple change or implies other problems
    > > > with the parser but I thought I'd toss it out onto the pile.
    > >
    > > Tom Lane discovered it a few days ago in relation to INSERT INTO table
    > > SELECT * FROM TABLE ORDER BY col1, and col1 was not in the select target
    > > list.  It shows an error.  We are looking at solutions.
    > 
    >     This  might  also  interfere with latest changes I did in the
    >     rewrite system. Parser and rewriter now add  junk  attributes
    >     to  the  targetlist.   I  think the problem is that the union
    >     code (where the check is done)  doesn't  recognize  that  the
    >     unequal  length of the targetlists is due to junk attributes.
    
    I have added code to the parser and rewrite checks to skip counting of
    resjunk nodes in checking for UNION length equality.  This should fix
    the problem.
    
    -- 
      Bruce Momjian                        |  http://www.op.net/~candle
      maillist@candle.pha.pa.us            |  (610) 853-3000
      +  If your life is a hard drive,     |  830 Blythe Avenue
      +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
    
    
  5. Re: [HACKERS] Misleading Error Message

    Bruce Momjian <maillist@candle.pha.pa.us> — 1999-05-17T18:23:00Z

    > Hi all.  Was working tonight and ran into the following error.  Doing a
    > union between two selects (to get around the lack of outer joins - hint
    > hint), I was getting the error:
    > 
    >         ERROR: Each UNION clause must have the same number of columns
    > 
    > Upon examining the SQL statement in question, I verified that it did,
    > indeed, have the same number of columns.  After some fiddling, I found the
    > actual problem was that I was doing an ORDER BY on a column which was not
    > being included in the two select statements.  Unfortunately, the error
    > message wasn't pointing at that.
    > 
    > I'm not sure if this is just a simple change or implies other problems
    > with the parser but I thought I'd toss it out onto the pile.
    
    
    This now fixed.
    
    -- 
      Bruce Momjian                        |  http://www.op.net/~candle
      maillist@candle.pha.pa.us            |  (610) 853-3000
      +  If your life is a hard drive,     |  830 Blythe Avenue
      +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026