/src/postgres/src/include/access/valid.h
Line | Count | Source (jump to first uncovered line) |
1 | | /*------------------------------------------------------------------------- |
2 | | * |
3 | | * valid.h |
4 | | * POSTGRES tuple qualification validity definitions. |
5 | | * |
6 | | * |
7 | | * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group |
8 | | * Portions Copyright (c) 1994, Regents of the University of California |
9 | | * |
10 | | * src/include/access/valid.h |
11 | | * |
12 | | *------------------------------------------------------------------------- |
13 | | */ |
14 | | #ifndef VALID_H |
15 | | #define VALID_H |
16 | | |
17 | | #include "access/htup.h" |
18 | | #include "access/htup_details.h" |
19 | | #include "access/skey.h" |
20 | | #include "access/tupdesc.h" |
21 | | |
22 | | /* |
23 | | * HeapKeyTest |
24 | | * |
25 | | * Test a heap tuple to see if it satisfies a scan key. |
26 | | */ |
27 | | static inline bool |
28 | | HeapKeyTest(HeapTuple tuple, TupleDesc tupdesc, int nkeys, ScanKey keys) |
29 | 0 | { |
30 | 0 | int cur_nkeys = nkeys; |
31 | 0 | ScanKey cur_key = keys; |
32 | |
|
33 | 0 | for (; cur_nkeys--; cur_key++) |
34 | 0 | { |
35 | 0 | Datum atp; |
36 | 0 | bool isnull; |
37 | 0 | Datum test; |
38 | |
|
39 | 0 | if (cur_key->sk_flags & SK_ISNULL) |
40 | 0 | return false; |
41 | | |
42 | 0 | atp = heap_getattr(tuple, cur_key->sk_attno, tupdesc, &isnull); |
43 | |
|
44 | 0 | if (isnull) |
45 | 0 | return false; |
46 | | |
47 | 0 | test = FunctionCall2Coll(&cur_key->sk_func, |
48 | 0 | cur_key->sk_collation, |
49 | 0 | atp, cur_key->sk_argument); |
50 | |
|
51 | 0 | if (!DatumGetBool(test)) |
52 | 0 | return false; |
53 | 0 | } |
54 | | |
55 | 0 | return true; |
56 | 0 | } |
57 | | |
58 | | #endif /* VALID_H */ |