~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to contrib/hstore/hstore_io.c

Tags: upstream-8.4.0
ImportĀ upstreamĀ versionĀ 8.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $PostgreSQL: pgsql/contrib/hstore/hstore_io.c,v 1.10 2009/04/02 17:57:05 teodor Exp $
 
2
 * $PostgreSQL: pgsql/contrib/hstore/hstore_io.c,v 1.11 2009/06/11 14:48:51 momjian Exp $
3
3
 */
4
4
#include "postgres.h"
5
5
 
20
20
        Pairs      *pairs;
21
21
        int                     pcur;
22
22
        int                     plen;
23
 
}       HSParser;
 
23
} HSParser;
24
24
 
25
25
#define RESIZEPRSBUF \
26
26
do { \
41
41
#define GV_WAITESCESCIN 4
42
42
 
43
43
static bool
44
 
get_val(HSParser * state, bool ignoreeq, bool *escaped)
 
44
get_val(HSParser *state, bool ignoreeq, bool *escaped)
45
45
{
46
46
        int                     st = GV_WAITVAL;
47
47
 
165
165
 
166
166
 
167
167
static void
168
 
parse_hstore(HSParser * state)
 
168
parse_hstore(HSParser *state)
169
169
{
170
170
        int                     st = WKEY;
171
171
        bool            escaped = false;
287
287
}
288
288
 
289
289
int
290
 
uniquePairs(Pairs * a, int4 l, int4 *buflen)
 
290
uniquePairs(Pairs *a, int4 l, int4 *buflen)
291
291
{
292
292
        Pairs      *ptr,
293
293
                           *res;
328
328
}
329
329
 
330
330
static void
331
 
freeHSParse(HSParser * state)
 
331
freeHSParse(HSParser *state)
332
332
{
333
333
        int                     i;
334
334
 
447
447
        HStore     *in = PG_GETARG_HS(0);
448
448
        int                     buflen,
449
449
                                i,
450
 
                                nnulls=0;
 
450
                                nnulls = 0;
451
451
        char       *out,
452
452
                           *ptr;
453
453
        char       *base = STRPTR(in);
465
465
                if (entries[i].valisnull)
466
466
                        nnulls++;
467
467
 
468
 
        buflen = (4 /* " */ + 2 /* => */ ) * ( in->size - nnulls ) +
469
 
                ( 2 /* " */ + 2 /* => */ + 4 /* NULL */ ) * nnulls  +
470
 
                2 /* ,  */ * ( in->size - 1 ) +
471
 
                2 /* esc */ * (VARSIZE(in) - CALCDATASIZE(in->size, 0)) + 
472
 
                1 /* \0 */;
 
468
        buflen = (4 /* " */ + 2 /* => */ ) * (in->size - nnulls) +
 
469
                (2 /* " */ + 2 /* => */ + 4 /* NULL */ ) * nnulls +
 
470
                2 /* ,  */ * (in->size - 1) +
 
471
                2 /* esc */ * (VARSIZE(in) - CALCDATASIZE(in->size, 0)) +
 
472
                1 /* \0 */ ;
473
473
 
474
474
        out = ptr = palloc(buflen);
475
475
        for (i = 0; i < in->size; i++)