2008-05-12 08:00:54 +08:00
|
|
|
/*
|
2009-03-16 06:05:17 +08:00
|
|
|
* $PostgreSQL: pgsql/contrib/hstore/hstore.h,v 1.7 2009/03/15 22:05:17 tgl Exp $
|
2008-05-12 08:00:54 +08:00
|
|
|
*/
|
2006-09-06 02:00:58 +08:00
|
|
|
#ifndef __HSTORE_H__
|
|
|
|
#define __HSTORE_H__
|
|
|
|
|
2008-05-12 08:00:54 +08:00
|
|
|
#include "fmgr.h"
|
2006-09-06 02:00:58 +08:00
|
|
|
|
|
|
|
|
2006-10-04 08:30:14 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint16 keylen;
|
|
|
|
uint16 vallen;
|
|
|
|
uint32
|
|
|
|
valisnull:1,
|
|
|
|
pos:31;
|
|
|
|
} HEntry;
|
|
|
|
|
2009-03-16 06:05:17 +08:00
|
|
|
/* these are determined by the sizes of the keylen and vallen fields */
|
|
|
|
/* in struct HEntry and struct Pairs */
|
|
|
|
#define HSTORE_MAX_KEY_LEN 65535
|
|
|
|
#define HSTORE_MAX_VALUE_LEN 65535
|
|
|
|
|
2006-10-04 08:30:14 +08:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2007-03-01 06:44:38 +08:00
|
|
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
2006-10-04 08:30:14 +08:00
|
|
|
int4 size;
|
|
|
|
char data[1];
|
|
|
|
} HStore;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2007-03-01 06:44:38 +08:00
|
|
|
#define HSHRDSIZE (VARHDRSZ + sizeof(int4))
|
2006-09-06 02:00:58 +08:00
|
|
|
#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-09-06 02:00:58 +08:00
|
|
|
|
|
|
|
|
2006-10-04 08:30:14 +08:00
|
|
|
#define PG_GETARG_HS(x) ((HStore*)PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2006-10-04 08:30:14 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char *key;
|
|
|
|
char *val;
|
|
|
|
uint16 keylen;
|
|
|
|
uint16 vallen;
|
|
|
|
bool isnull;
|
|
|
|
bool needfree;
|
|
|
|
} Pairs;
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2006-10-04 08:30:14 +08:00
|
|
|
int comparePairs(const void *a, const void *b);
|
|
|
|
int uniquePairs(Pairs * a, int4 l, int4 *buflen);
|
2006-09-06 02:00:58 +08:00
|
|
|
|
2009-03-16 06:05:17 +08:00
|
|
|
size_t hstoreCheckKeyLen(size_t len);
|
|
|
|
size_t hstoreCheckValLen(size_t len);
|
|
|
|
|
2007-11-16 05:14:46 +08:00
|
|
|
#define HStoreContainsStrategyNumber 7
|
|
|
|
#define HStoreExistsStrategyNumber 9
|
2007-03-14 22:21:53 +08:00
|
|
|
|
2008-05-12 08:00:54 +08:00
|
|
|
#endif /* __HSTORE_H__ */
|