@@ -66,7 +66,7 @@ typedef struct
66
66
#define STATHDRSIZE (offsetof(TSVectorStat, data))
67
67
68
68
static 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 );
70
70
71
71
/*
72
72
* Order: haspos, len, word, for all positions (pos, weight)
@@ -684,10 +684,12 @@ tsvector_to_array(PG_FUNCTION_ARGS)
684
684
{
685
685
TSVector tsin = PG_GETARG_TSVECTOR (0 );
686
686
WordEntry * arrin = ARRPTR (tsin );
687
- Datum elements [ tsin -> size ] ;
687
+ Datum * elements ;
688
688
int i ;
689
689
ArrayType * array ;
690
690
691
+ elements = palloc (tsin -> size * sizeof (Datum ));
692
+
691
693
for (i = 0 ;i < tsin -> size ;i ++ )
692
694
{
693
695
elements [i ]= PointerGetDatum (
@@ -696,6 +698,8 @@ tsvector_to_array(PG_FUNCTION_ARGS)
696
698
}
697
699
698
700
array = construct_array (elements ,tsin -> size ,TEXTOID ,-1 , false,'i' );
701
+
702
+ pfree (elements );
699
703
PG_FREE_IF_COPY (tsin ,0 );
700
704
PG_RETURN_POINTER (array );
701
705
}