Header And Logo

PostgreSQL
| The world's most advanced open source database.

valid.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * valid.h
00004  *    POSTGRES tuple qualification validity definitions.
00005  *
00006  *
00007  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00008  * Portions Copyright (c) 1994, Regents of the University of California
00009  *
00010  * src/include/access/valid.h
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef VALID_H
00015 #define VALID_H
00016 
00017 /*
00018  *      HeapKeyTest
00019  *
00020  *      Test a heap tuple to see if it satisfies a scan key.
00021  */
00022 #define HeapKeyTest(tuple, \
00023                     tupdesc, \
00024                     nkeys, \
00025                     keys, \
00026                     result) \
00027 do \
00028 { \
00029     /* Use underscores to protect the variables passed in as parameters */ \
00030     int         __cur_nkeys = (nkeys); \
00031     ScanKey     __cur_keys = (keys); \
00032  \
00033     (result) = true; /* may change */ \
00034     for (; __cur_nkeys--; __cur_keys++) \
00035     { \
00036         Datum   __atp; \
00037         bool    __isnull; \
00038         Datum   __test; \
00039  \
00040         if (__cur_keys->sk_flags & SK_ISNULL) \
00041         { \
00042             (result) = false; \
00043             break; \
00044         } \
00045  \
00046         __atp = heap_getattr((tuple), \
00047                              __cur_keys->sk_attno, \
00048                              (tupdesc), \
00049                              &__isnull); \
00050  \
00051         if (__isnull) \
00052         { \
00053             (result) = false; \
00054             break; \
00055         } \
00056  \
00057         __test = FunctionCall2Coll(&__cur_keys->sk_func, \
00058                                    __cur_keys->sk_collation, \
00059                                    __atp, __cur_keys->sk_argument); \
00060  \
00061         if (!DatumGetBool(__test)) \
00062         { \
00063             (result) = false; \
00064             break; \
00065         } \
00066     } \
00067 } while (0)
00068 
00069 #endif   /* VALID_H */