1. Fixed error with empty array ( '{}' ),

test data changed to include such data
2. Test a dimension of an array ( we support only one-dimension)

Oleg Bartunov
This commit is contained in:
Bruce Momjian 2001-08-04 19:35:32 +00:00
parent f8683e8a9c
commit f368c94fd6
2 changed files with 36 additions and 21 deletions

View File

@ -36,7 +36,8 @@
#define ARRPTR(x) ( (int4 *) ARR_DATA_PTR(x) ) #define ARRPTR(x) ( (int4 *) ARR_DATA_PTR(x) )
#define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x)) #define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
#define ARRISNULL(x) ( (x) ? ( ( ARR_NDIM(x) == NDIM ) ? ( ( ARRNELEMS( x ) ) ? 0 : 1 ) : 1 ) : 1 ) #define ARRISNULL(x) ( (x) ? ( ( ARR_NDIM(x) == NDIM ) ? ( ( ARRNELEMS( x ) ) ? 0 : 1 ) : ( ( ARR_NDIM(x) ) ? (elog(ERROR,"Array is not one-dimentional: %d dimentions", ARR_NDIM(x)),1) : 1 ) ) : 1 )
#define ARRISVOID(x) ( (x) ? ( ( ARR_NDIM(x) == NDIM ) ? ( ( ARRNELEMS( x ) ) ? 0 : 1 ) : 1 ) : 0 )
#define SORT(x) \ #define SORT(x) \
do { \ do { \
@ -300,15 +301,16 @@ g_int_compress(PG_FUNCTION_ARGS)
if (ARRISNULL(r)) if (ARRISNULL(r))
{ {
#ifdef GIST_DEBUG if ( ARRISVOID(r) ) {
elog(NOTICE, "COMP IN: NULL"); ArrayType *out = new_intArrayType( 0 );
#endif gistentryinit(*retval, PointerGetDatum(out),
if (r) entry->rel, entry->page, entry->offset, VARSIZE(out), FALSE);
if (r != (ArrayType *) DatumGetPointer(entry->key)) } else {
pfree(r); gistentryinit(*retval, (Datum) 0, entry->rel, entry->page, entry->offset,
gistentryinit(*retval, (Datum) 0, entry->rel, entry->page, entry->offset,
0, FALSE); 0, FALSE);
}
if (r) pfree(r);
PG_RETURN_POINTER(retval); PG_RETURN_POINTER(retval);
} }
@ -371,14 +373,20 @@ g_int_decompress(PG_FUNCTION_ARGS)
else else
in = NULL; in = NULL;
if (entry->bytes < ARR_OVERHEAD(NDIM) || ARRISNULL(in)) if (ARRISNULL(in))
{ {
retval = palloc(sizeof(GISTENTRY)); retval = palloc(sizeof(GISTENTRY));
if ( ARRISVOID(in) ) {
r = new_intArrayType( 0 );
gistentryinit(*retval, PointerGetDatum(r),
entry->rel, entry->page, entry->offset, VARSIZE(r), FALSE);
} else {
gistentryinit(*retval, (Datum) 0, entry->rel, entry->page, entry->offset, 0, FALSE);
}
if (in) if (in)
if (in != (ArrayType *) DatumGetPointer(entry->key)) if (in != (ArrayType *) DatumGetPointer(entry->key))
pfree(in); pfree(in);
gistentryinit(*retval, (Datum) 0, entry->rel, entry->page, entry->offset, 0, FALSE);
#ifdef GIST_DEBUG #ifdef GIST_DEBUG
elog(NOTICE, "DECOMP IN: NULL"); elog(NOTICE, "DECOMP IN: NULL");
#endif #endif
@ -1137,10 +1145,17 @@ g_intbig_compress(PG_FUNCTION_ARGS)
if (ARRISNULL(in)) if (ARRISNULL(in))
{ {
if ( ARRISVOID(in) ) {
r = new_intArrayType( SIGLENINT );
gistentryinit(*retval, PointerGetDatum(r),
entry->rel, entry->page, entry->offset, VARSIZE(r), FALSE);
} else {
gistentryinit(*retval, (Datum) 0, entry->rel, entry->page, entry->offset,
0, FALSE);
}
if (in) if (in)
if (in != (ArrayType *) DatumGetPointer(entry->key)) if (in != (ArrayType *) DatumGetPointer(entry->key))
pfree(in); pfree(in);
gistentryinit(*retval, (Datum) 0, entry->rel, entry->page, entry->offset, 0, FALSE);
PG_RETURN_POINTER (retval); PG_RETURN_POINTER (retval);
} }

View File

@ -4,7 +4,7 @@
{79,83,16,63,32} {79,83,16,63,32}
{52,41,61,79,94,87} {52,41,61,79,94,87}
{76,59,39,36,21} {76,59,39,36,21}
\N {}
{41,79,76,96,3} {41,79,76,96,3}
{25,59,5,96,32} {25,59,5,96,32}
{92,58,12,57} {92,58,12,57}
@ -57,7 +57,7 @@
{58,1,39,48} {58,1,39,48}
{78,36,70,92} {78,36,70,92}
{43,3,22,95,51} {43,3,22,95,51}
\N {}
{88,64,25,64,86} {88,64,25,64,86}
{34,6,49,90,25} {34,6,49,90,25}
{86,35,13,22} {86,35,13,22}
@ -76,12 +76,12 @@
{89,11,67,55,73} {89,11,67,55,73}
{78,39,84,63,62,45} {78,39,84,63,62,45}
{50,63,8} {50,63,8}
\N {}
{96,36,58,65,96} {96,36,58,65,96}
{59,86,41,30} {59,86,41,30}
{90,60,39,47,19} {90,60,39,47,19}
{70,100,73,99} {70,100,73,99}
\N {}
{85,14,39} {85,14,39}
{76,53} {76,53}
{96,38,52,13,87,85} {96,38,52,13,87,85}
@ -95,7 +95,7 @@
{84,93,36,95,34,69} {84,93,36,95,34,69}
{66,25,5,40} {66,25,5,40}
{77,6,57,42} {77,6,57,42}
\N {}
{88,81,85,37,12} {88,81,85,37,12}
{56,73,38} {56,73,38}
{70,70,6,19} {70,70,6,19}
@ -176,7 +176,7 @@
{31,48} {31,48}
{28,35,18} {28,35,18}
{77,55,100,73,57,62} {77,55,100,73,57,62}
\N {}
{14,59,53} {14,59,53}
{98,3} {98,3}
{13,56} {13,56}
@ -188,7 +188,7 @@
{41,76,39,84,32} {41,76,39,84,32}
{94,66,47} {94,66,47}
{55,28} {55,28}
\N {}
{94,65,59,20} {94,65,59,20}
{55,50,56,14,58} {55,50,56,14,58}
{14,94,52,25,69,95} {14,94,52,25,69,95}
@ -203,7 +203,7 @@
{46,69} {46,69}
{35,54} {35,54}
{36,79,54} {36,79,54}
\N {}
{63,78} {63,78}
{12,86,52,29,60,30} {12,86,52,29,60,30}
{29,27,58,86,42,62} {29,27,58,86,42,62}
@ -215,7 +215,7 @@
{14,85,14,26,3} {14,85,14,26,3}
{46,71,10,16} {46,71,10,16}
{30,63} {30,63}
\N {}
{91,30,56} {91,30,56}
{46,36,68,91,36,88} {46,36,68,91,36,88}
{24,61} {24,61}