Re: [GENERAL] Odd behavior in functions w/ anyarray & anyelement

2013-11-09 Thread David Johnston
Tom Lane-2 wrote > Furthermore, if there are positions declared anyarray > and others declared anyelement, the actual array type in the anyarray > positions must be an array whose elements are the same type appearing in > the anyelement positions. > > The last sentence is what I was saying

Re: [GENERAL] Odd behavior in functions w/ anyarray & anyelement

2013-11-09 Thread Tom Lane
David Johnston writes: > Tom Lane-2 wrote >> you do have one conceptual error: anyarray to anyelement is supposed >> to return the element type of the input array type. So when you pass >> TEXT[] to this function, the SQL parser decides that the expected >> result type is TEXT. > While this is

Re: [GENERAL] Odd behavior in functions w/ anyarray & anyelement

2013-11-09 Thread David Johnston
Tom Lane-2 wrote > you do have one conceptual error: anyarray to anyelement is supposed > to return the element type of the input array type. So when you pass > TEXT[] to this function, the SQL parser decides that the expected > result type is TEXT. While this is how it behaves in practice I di

Re: [GENERAL] Odd behavior in functions w/ anyarray & anyelement

2013-11-09 Thread Tom Lane
[ slowly catching up on vacation email ] Joshua Burns writes: > From that point I wrote a bunch of simply anyarray/element related > functions to better understand how these pseudo-types behave, which has > left me more confused than when I started. I think you would have been less confused if y

Re: [GENERAL] Odd behavior in functions w/ anyarray & anyelement

2013-09-11 Thread David Johnston
Joshua Burns wrote > DROP FUNCTION IF EXISTS anyar_anyel(anyarray); > CREATE OR REPLACE FUNCTION anyar_anyel(anyarray) RETURNS anyelement AS > $BODY$ > BEGIN > RETURN $1; > END; > $BODY$ LANGUAGE plpgsql; Similar to my comment on anyelement->anyarray: The original goal here is to

Re: [GENERAL] Odd behavior in functions w/ anyarray & anyelement

2013-09-11 Thread David Johnston
Joshua Burns wrote > CREATE OR REPLACE FUNCTION anyel_anyar(anyelement) RETURNS anyarray AS > $BODY$ > BEGIN > RETURN $1; > END; > $BODY$ LANGUAGE plpgsql; Two possible interpretations: 1) must return an array of whatever type is supplied; this is (apparently) the defined behavior