pgvector.git / summary / log / commit / refs
commit 62b411f94ce19eecf29bb9274339fe87b3428ee4
Author: Andrew Kane <andrew@ankane.org>
Date: Tue Apr 09 23:44:34 2024 +0000
Improved sparsevec input test [skip ci]
src/sparsevec.c | 6 ++++++
test/expected/sparsevec_input.out | 2 +-
test/sql/sparsevec_input.sql | 2 +-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/sparsevec.c b/src/sparsevec.c
index 335ebe06..7c1bd6d2 100644
--- a/src/sparsevec.c
+++ b/src/sparsevec.c
@@ -310,6 +310,9 @@ sparsevec_in(PG_FUNCTION_ARGS)
stringEnd++;
+ while (sparsevec_isspace(*stringEnd))
+ stringEnd++;
+
if (*stringEnd != '/')
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
@@ -318,6 +321,9 @@ sparsevec_in(PG_FUNCTION_ARGS)
stringEnd++;
+ while (sparsevec_isspace(*stringEnd))
+ stringEnd++;
+
/* Use similar logic as int2vectorin */
errno = 0;
pt = stringEnd;
diff --git a/test/expected/sparsevec_input.out b/test/expected/sparsevec_input.out
index b27d2050..79ee1fc2 100644
--- a/test/expected/sparsevec_input.out
+++ b/test/expected/sparsevec_input.out
@@ -4,7 +4,7 @@ SELECT '{1:1.5,3:3.5}/5'::sparsevec;
{1:1.5,3:3.5}/5
(1 row)
-SELECT ' { 1 : 1.5 , 3 : 3.5 }/5 '::sparsevec;
+SELECT ' { 1 : 1.5 , 3 : 3.5 } / 5 '::sparsevec;
sparsevec
-----------------
{1:1.5,3:3.5}/5
diff --git a/test/sql/sparsevec_input.sql b/test/sql/sparsevec_input.sql
index c85545d6..802348fc 100644
--- a/test/sql/sparsevec_input.sql
+++ b/test/sql/sparsevec_input.sql
@@ -1,5 +1,5 @@
SELECT '{1:1.5,3:3.5}/5'::sparsevec;
-SELECT ' { 1 : 1.5 , 3 : 3.5 }/5 '::sparsevec;
+SELECT ' { 1 : 1.5 , 3 : 3.5 } / 5 '::sparsevec;
SELECT ''::sparsevec;
SELECT '{'::sparsevec;
[parent: 82a17b81f52b]