mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-15 17:16:56 +08:00
Fixed casting [skip ci]
This commit is contained in:
@@ -363,7 +363,7 @@ array_to_intvec(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
ArrayType *array = PG_GETARG_ARRAYTYPE_P(0);
|
ArrayType *array = PG_GETARG_ARRAYTYPE_P(0);
|
||||||
int32 typmod = PG_GETARG_INT32(1);
|
int32 typmod = PG_GETARG_INT32(1);
|
||||||
Vector *result;
|
IntVector *result;
|
||||||
int16 typlen;
|
int16 typlen;
|
||||||
bool typbyval;
|
bool typbyval;
|
||||||
char typalign;
|
char typalign;
|
||||||
@@ -386,7 +386,7 @@ array_to_intvec(PG_FUNCTION_ARGS)
|
|||||||
CheckDim(nelemsp);
|
CheckDim(nelemsp);
|
||||||
CheckExpectedDim(typmod, nelemsp);
|
CheckExpectedDim(typmod, nelemsp);
|
||||||
|
|
||||||
result = InitVector(nelemsp);
|
result = InitIntVector(nelemsp);
|
||||||
|
|
||||||
if (ARR_ELEMTYPE(array) == INT4OID)
|
if (ARR_ELEMTYPE(array) == INT4OID)
|
||||||
{
|
{
|
||||||
@@ -609,10 +609,10 @@ intvec_cmp_internal(IntVector * a, IntVector * b)
|
|||||||
/* Check values before dimensions to be consistent with Postgres arrays */
|
/* Check values before dimensions to be consistent with Postgres arrays */
|
||||||
for (int i = 0; i < dim; i++)
|
for (int i = 0; i < dim; i++)
|
||||||
{
|
{
|
||||||
if (a->x[i] < b->x[i])
|
if ((int) a->x[i] < (int) b->x[i])
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (a->x[i] > b->x[i])
|
if ((int) a->x[i] > (int) b->x[i])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ for (1 .. 50)
|
|||||||
$actual = $node->safe_psql("postgres", "SELECT halfvec_cmp(v::halfvec, '$query'::real[]::halfvec) FROM tst");
|
$actual = $node->safe_psql("postgres", "SELECT halfvec_cmp(v::halfvec, '$query'::real[]::halfvec) FROM tst");
|
||||||
is($expected, $actual);
|
is($expected, $actual);
|
||||||
|
|
||||||
|
# Test intvec
|
||||||
|
$actual = $node->safe_psql("postgres", "SELECT intvec_cmp(v::int[]::intvec, '$query'::int[]::intvec) FROM tst");
|
||||||
|
is($expected, $actual);
|
||||||
|
|
||||||
# Test sparsevec
|
# Test sparsevec
|
||||||
$actual = $node->safe_psql("postgres", "SELECT sparsevec_cmp(v::vector::sparsevec, '$query'::real[]::vector::sparsevec) FROM tst");
|
$actual = $node->safe_psql("postgres", "SELECT sparsevec_cmp(v::vector::sparsevec, '$query'::real[]::vector::sparsevec) FROM tst");
|
||||||
is($expected, $actual);
|
is($expected, $actual);
|
||||||
|
|||||||
Reference in New Issue
Block a user