From 7ee9e86b10e9120f2f672c7051f6d734f858a457 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 11 Jun 2023 12:00:04 -0700 Subject: [PATCH] Improved error message for invalid input syntax --- src/vector.c | 4 ++-- test/expected/input.out | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vector.c b/src/vector.c index 4bab837..1e568c8 100644 --- a/src/vector.c +++ b/src/vector.c @@ -194,7 +194,7 @@ vector_in(PG_FUNCTION_ARGS) if (stringEnd == pt) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type vector: \"%s\"", pt))); + errmsg("invalid input syntax for type vector: \"%s\"", lit))); while (vector_isspace(*stringEnd)) stringEnd++; @@ -202,7 +202,7 @@ vector_in(PG_FUNCTION_ARGS) if (*stringEnd != '\0' && *stringEnd != ']') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type vector: \"%s\"", pt))); + errmsg("invalid input syntax for type vector: \"%s\"", lit))); pt = strtok(NULL, ","); } diff --git a/test/expected/input.out b/test/expected/input.out index d2cb1c6..3925447 100644 --- a/test/expected/input.out +++ b/test/expected/input.out @@ -23,7 +23,7 @@ SELECT '[1.23456]'::vector; (1 row) SELECT '[hello,1]'::vector; -ERROR: invalid input syntax for type vector: "hello" +ERROR: invalid input syntax for type vector: "[hello,1]" LINE 1: SELECT '[hello,1]'::vector; ^ SELECT '[NaN,1]'::vector; @@ -62,7 +62,7 @@ ERROR: vector must have at least 1 dimension LINE 1: SELECT '[]'::vector; ^ SELECT '[1,]'::vector; -ERROR: invalid input syntax for type vector: "]" +ERROR: invalid input syntax for type vector: "[1,]" LINE 1: SELECT '[1,]'::vector; ^ SELECT '[1,2,3]'::vector(2);