postgresql/contrib/hstore/hstore.h

57 lines
1.1 KiB
C
Raw Normal View History

#ifndef __HSTORE_H__
#define __HSTORE_H__
#include "postgres.h"
#include "funcapi.h"
#include "access/gist.h"
#include "access/itup.h"
#include "utils/elog.h"
#include "utils/palloc.h"
#include "utils/builtins.h"
#include "storage/bufpage.h"
2006-10-04 08:30:14 +08:00
typedef struct
{
uint16 keylen;
uint16 vallen;
uint32
valisnull:1,
pos:31;
} HEntry;
typedef struct
{
int32 vl_len_; /* varlena header (do not touch directly!) */
2006-10-04 08:30:14 +08:00
int4 size;
char data[1];
} HStore;
#define HSHRDSIZE (VARHDRSZ + sizeof(int4))
#define CALCDATASIZE(x, lenstr) ( (x) * sizeof(HEntry) + HSHRDSIZE + (lenstr) )
2006-10-04 08:30:14 +08:00
#define ARRPTR(x) ( (HEntry*) ( (char*)(x) + HSHRDSIZE ) )
#define STRPTR(x) ( (char*)(x) + HSHRDSIZE + ( sizeof(HEntry) * ((HStore*)x)->size ) )
2006-10-04 08:30:14 +08:00
#define PG_GETARG_HS(x) ((HStore*)PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))
2006-10-04 08:30:14 +08:00
typedef struct
{
char *key;
char *val;
uint16 keylen;
uint16 vallen;
bool isnull;
bool needfree;
} Pairs;
2006-10-04 08:30:14 +08:00
int comparePairs(const void *a, const void *b);
int uniquePairs(Pairs * a, int4 l, int4 *buflen);
#define HStoreContainsStrategyNumber 7
#define HStoreExistsStrategyNumber 9
#endif