|
#define | HENTRY_ISFIRST 0x80000000 |
|
#define | HENTRY_ISNULL 0x40000000 |
|
#define | HENTRY_POSMASK 0x3FFFFFFF |
|
#define | HSE_ISFIRST(he_) (((he_).entry & HENTRY_ISFIRST) != 0) |
|
#define | HSE_ISNULL(he_) (((he_).entry & HENTRY_ISNULL) != 0) |
|
#define | HSE_ENDPOS(he_) ((he_).entry & HENTRY_POSMASK) |
|
#define | HSE_OFF(he_) (HSE_ISFIRST(he_) ? 0 : HSE_ENDPOS((&(he_))[-1])) |
|
#define | HSE_LEN(he_) |
|
#define | HSTORE_MAX_KEY_LEN 0x3FFFFFFF |
|
#define | HSTORE_MAX_VALUE_LEN 0x3FFFFFFF |
|
#define | HS_FLAG_NEWVERSION 0x80000000 |
|
#define | HS_COUNT(hsp_) ((hsp_)->size_ & 0x0FFFFFFF) |
|
#define | HS_SETCOUNT(hsp_, c_) ((hsp_)->size_ = (c_) | HS_FLAG_NEWVERSION) |
|
#define | HSHRDSIZE (sizeof(HStore)) |
|
#define | CALCDATASIZE(x, lenstr) ( (x) * 2 * sizeof(HEntry) + HSHRDSIZE + (lenstr) ) |
|
#define | ARRPTR(x) ( (HEntry*) ( (HStore*)(x) + 1 ) ) |
|
#define | STRPTR(x) ( (char*)(ARRPTR(x) + HS_COUNT((HStore*)(x)) * 2) ) |
|
#define | HSTORE_KEY(arr_, str_, i_) ((str_) + HSE_OFF((arr_)[2*(i_)])) |
|
#define | HSTORE_VAL(arr_, str_, i_) ((str_) + HSE_OFF((arr_)[2*(i_)+1])) |
|
#define | HSTORE_KEYLEN(arr_, i_) (HSE_LEN((arr_)[2*(i_)])) |
|
#define | HSTORE_VALLEN(arr_, i_) (HSE_LEN((arr_)[2*(i_)+1])) |
|
#define | HSTORE_VALISNULL(arr_, i_) (HSE_ISNULL((arr_)[2*(i_)+1])) |
|
#define | HS_COPYITEM(dent_, dbuf_, dptr_, sptr_, klen_, vlen_, vnull_) |
|
#define | HS_ADDITEM(dent_, dbuf_, dptr_, pair_) |
|
#define | HS_FINALIZE(hsp_, count_, buf_, ptr_) |
|
#define | HS_FIXSIZE(hsp_, count_) |
|
#define | DatumGetHStoreP(d) hstoreUpgrade(d) |
|
#define | PG_GETARG_HSTORE_P(x) DatumGetHStoreP(PG_GETARG_DATUM(x)) |
|
#define | HStoreContainsStrategyNumber 7 |
|
#define | HStoreExistsStrategyNumber 9 |
|
#define | HStoreExistsAnyStrategyNumber 10 |
|
#define | HStoreExistsAllStrategyNumber 11 |
|
#define | HStoreOldContainsStrategyNumber 13 /* backwards compatibility */ |
|
#define | HSTORE_POLLUTE_NAMESPACE 1 |
|
#define | HSTORE_POLLUTE(newname_, oldname_) |
|
Definition at line 73 of file hstore_op.c.
74{
76 bool *key_nulls;
77 int key_count;
79 int bufsiz;
82
84
85 if (key_count == 0)
86 {
87 *npairs = 0;
88 return NULL;
89 }
90
91
92
93
94
95
96
97
100 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
101 errmsg(
"number of pairs (%d) exceeds the maximum allowed (%d)",
103
105
106 for (
i = 0,
j = 0;
i < key_count;
i++)
107 {
109 {
112 key_pairs[
j].
val = NULL;
117 }
118 }
119
121
122 return key_pairs;
123}
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define hstoreUniquePairs
References a, deconstruct_array_builtin(), ereport, errcode(), errmsg(), ERROR, hstoreUniquePairs, i, Pairs::isnull, j, Pairs::key, Pairs::keylen, MaxAllocSize, Pairs::needfree, palloc(), Pairs::val, Pairs::vallen, VARDATA, VARHDRSZ, and VARSIZE.
Referenced by hstore_delete_array(), hstore_exists_all(), hstore_exists_any(), and hstore_slice_to_hstore().
PGDLLEXPORT int hstoreFindKey |
( |
HStore * |
hs, |
|
|
int * |
lowbound, |
|
|
char * |
key, |
|
|
int |
keylen |
|
) |
| |
Definition at line 36 of file hstore_op.c.
37{
39 int stopLow = lowbound ? *lowbound : 0;
41 int stopMiddle;
43
44 while (stopLow < stopHigh)
45 {
47
48 stopMiddle = stopLow + (stopHigh - stopLow) / 2;
49
52 else
54
56 {
57 if (lowbound)
58 *lowbound = stopMiddle + 1;
59 return stopMiddle;
60 }
62 stopLow = stopMiddle + 1;
63 else
64 stopHigh = stopMiddle;
65 }
66
67 if (lowbound)
68 *lowbound = stopLow;
69 return -1;
70}
Datum difference(PG_FUNCTION_ARGS)
#define HSTORE_KEY(arr_, str_, i_)
#define HSTORE_KEYLEN(arr_, i_)
References ARRPTR, difference(), HS_COUNT, HSTORE_KEY, HSTORE_KEYLEN, sort-test::key, and STRPTR.
Referenced by hstore_contains(), hstore_defined(), hstore_exists(), hstore_exists_all(), hstore_exists_any(), hstore_fetchval(), hstore_populate_record(), hstore_slice_to_array(), hstore_slice_to_hstore(), and hstore_subscript_fetch().
Definition at line 445 of file hstore_io.c.
446{
449 char *ptr;
453
458
459 if (pcount == 0)
460 return out;
461
464
465 for (
i = 0;
i < pcount;
i++)
467
469
470 return out;
471}
#define HS_FINALIZE(hsp_, count_, buf_, ptr_)
#define HS_ADDITEM(dent_, dbuf_, dptr_, pair_)
#define HS_SETCOUNT(hsp_, c_)
#define SET_VARSIZE(PTR, len)
References ARRPTR, buf, CALCDATASIZE, HS_ADDITEM, HS_FINALIZE, HS_SETCOUNT, i, len, palloc(), SET_VARSIZE, and STRPTR.
Referenced by hstore_from_array(), hstore_from_arrays(), hstore_from_record(), hstore_from_text(), hstore_in(), and hstore_recv().
Definition at line 356 of file hstore_io.c.
357{
360
361 *buflen = 0;
362 if (l < 2)
363 {
364 if (l == 1)
365 *buflen =
a->keylen + ((
a->isnull) ? 0 :
a->vallen);
366 return l;
367 }
368
370
371
372
373
374
378 {
380 memcmp(ptr->
key,
res->key,
res->keylen) == 0)
381 {
383 {
386 }
387 }
388 else
389 {
390 *buflen +=
res->keylen + ((
res->isnull) ? 0 :
res->vallen);
394 }
395
396 ptr++;
397 }
398
399 *buflen +=
res->keylen + ((
res->isnull) ? 0 :
res->vallen);
401}
static void PGresult * res
static int comparePairs(const void *a, const void *b)
void pfree(void *pointer)
#define qsort(a, b, c, d)
References a, comparePairs(), Pairs::key, Pairs::keylen, Pairs::needfree, pfree(), qsort, res, and Pairs::val.
Referenced by hstore_from_array(), hstore_from_arrays(), hstore_from_record(), hstore_in(), and hstore_recv().
Definition at line 236 of file hstore_compat.c.
237{
239 int valid_new;
240 int valid_old;
241
242
244 return hs;
245
246
249
250 if (hs->
size_ == 0 ||
252 {
255 return hs;
256 }
257
260
261 if (!valid_old || hs->
size_ == 0)
262 {
263 if (valid_new)
264 {
265
266
267
270 return hs;
271 }
272 else
273 {
274 elog(
ERROR,
"invalid hstore value found");
275 }
276 }
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300 if (valid_new)
301 {
302#ifdef HSTORE_IS_HSTORE_NEW
303 elog(
WARNING,
"ambiguous hstore value resolved as hstore-new");
304
305
306
307
310 return hs;
311#else
312 elog(
WARNING,
"ambiguous hstore value resolved as hstore-old");
313#endif
314 }
315
316
317
318
319 {
320 int count = hs->
size_;
324
325 for (
i = 0;
i < count; ++
i)
326 {
331
332 if (isnull)
333 vallen = 0;
334
338 }
339
340 if (count)
344 }
345
346 return hs;
347}
#define PG_DETOAST_DATUM_COPY(datum)
#define PG_DETOAST_DATUM(datum)
#define HS_FIXSIZE(hsp_, count_)
#define HS_FLAG_NEWVERSION
static int hstoreValidOldFormat(HStore *hs)
static int hstoreValidNewFormat(HStore *hs)
static Pointer DatumGetPointer(Datum X)
References ARRPTR, DatumGetPointer(), elog, HEntry::entry, ERROR, HENTRY_ISFIRST, HENTRY_ISNULL, HENTRY_POSMASK, HS_COUNT, HS_FIXSIZE, HS_FLAG_NEWVERSION, HS_SETCOUNT, HSE_ISFIRST, hstoreValidNewFormat(), hstoreValidOldFormat(), i, HOldEntry::keylen, PG_DETOAST_DATUM, PG_DETOAST_DATUM_COPY, HOldEntry::pos, HStore::size_, HOldEntry::valisnull, HOldEntry::vallen, VARSIZE, and WARNING.