I believe the int2vectorin function should handle invalid input more cleanly.

Current behavior:

-- Correct input format:
SELECT '1 2 3'::int2vector;
 int2vector
------------
 1 2 3
(1 row)

-- Three variations on incorrect input format
SELECT '1not 2really_an 3int2vector'::int2vector;
 int2vector
------------
 1 2 3
(1 row)

SELECT '1,2,3'::int2vector;
 int2vector
------------
 1
(1 row)

SELECT '1, 2,3'::int2vector;
 int2vector
------------
 1 2
(1 row)

-- What other types do:
SELECT '1,2'::oid;
ERROR:  invalid input syntax for type oid: "1,2"


Behavior after attached patch:

-- Correct input format:
SELECT '1 2 3'::int2vector;
 int2vector
------------
 1 2 3
(1 row)

-- Three variations on incorrect input format
SELECT '1not 2really_an 3int2vector'::int2vector;
ERROR:  invalid input for int2vector: "1not 2really_an 3int2vector"

SELECT '1,2,3'::int2vector;
ERROR:  invalid input for int2vector: "1,2,3"

SELECT '1, 2,3'::int2vector;
ERROR:  invalid input for int2vector: "1, 2,3"

-- What other types do:
SELECT '1,2'::oid;
ERROR:  invalid input syntax for type oid: "1,2"

Regards,
  Caleb

Attachment: int2vector.patch
Description: int2vector.patch

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to