@@ -54,6 +54,7 @@ Datum gtsvector_picksplit(PG_FUNCTION_ARGS);
5454 GETBITBYTE(val,7) \
5555)
5656
57+ static int4 sizebitvec (BITVECP sign );
5758
5859Datum
5960gtsvector_in (PG_FUNCTION_ARGS )
@@ -64,13 +65,31 @@ gtsvector_in(PG_FUNCTION_ARGS)
6465 PG_RETURN_DATUM (0 );
6566}
6667
68+ #define SINGOUTSTR "%d true bits, %d false bits"
69+ #define ARROUTSTR "%d unique words"
70+ #define EXTRALEN ( 2*13 )
71+
72+ static int outbuf_maxlen = 0 ;
73+
6774Datum
6875gtsvector_out (PG_FUNCTION_ARGS )
6976{
70- ereport (ERROR ,
71- (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
72- errmsg ("gtsvector_out not implemented" )));
73- PG_RETURN_DATUM (0 );
77+ GISTTYPE * key = (GISTTYPE * ) DatumGetPointer (PG_DETOAST_DATUM (PG_GETARG_POINTER (0 )));
78+ char * outbuf ;
79+
80+ if ( outbuf_maxlen == 0 )
81+ outbuf_maxlen = 2 * EXTRALEN + Max ( strlen (SINGOUTSTR ), strlen (ARROUTSTR ) ) + 1 ;
82+ outbuf = palloc ( outbuf_maxlen );
83+
84+ if ( ISARRKEY (key ) )
85+ sprintf ( outbuf , ARROUTSTR , ARRNELEM (key ) );
86+ else {
87+ int cnttrue = ( ISALLTRUE (key ) ) ? SIGLENBIT : sizebitvec (GETSIGN (key ));
88+ sprintf ( outbuf , SINGOUTSTR , cnttrue , SIGLENBIT - cnttrue );
89+ }
90+
91+ PG_FREE_IF_COPY (key ,0 );
92+ PG_RETURN_POINTER (outbuf );
7493}
7594
7695static int
0 commit comments