@@ -66,7 +66,7 @@ typedef struct
6666#define STATHDRSIZE (offsetof(TSVectorStat, data))
6767
6868static Datum tsvector_update_trigger (PG_FUNCTION_ARGS ,bool config_column );
69- static int tsvector_bsearch (TSVector tsin ,char * lexin ,int lexin_len );
69+ static int tsvector_bsearch (const TSVector tsv ,char * lexeme ,int lexeme_len );
7070
7171/*
7272 * Order: haspos, len, word, for all positions (pos, weight)
@@ -684,10 +684,12 @@ tsvector_to_array(PG_FUNCTION_ARGS)
684684{
685685TSVector tsin = PG_GETARG_TSVECTOR (0 );
686686WordEntry * arrin = ARRPTR (tsin );
687- Datum elements [ tsin -> size ] ;
687+ Datum * elements ;
688688int i ;
689689ArrayType * array ;
690690
691+ elements = palloc (tsin -> size * sizeof (Datum ));
692+
691693for (i = 0 ;i < tsin -> size ;i ++ )
692694{
693695elements [i ]= PointerGetDatum (
@@ -696,6 +698,8 @@ tsvector_to_array(PG_FUNCTION_ARGS)
696698}
697699
698700array = construct_array (elements ,tsin -> size ,TEXTOID ,-1 , false,'i' );
701+
702+ pfree (elements );
699703PG_FREE_IF_COPY (tsin ,0 );
700704PG_RETURN_POINTER (array );
701705}