]> granicus.if.org Git - postgresql/blob - src/include/utils/datum.h
Massive commit to run PGINDENT on all *.c and *.h files.
[postgresql] / src / include / utils / datum.h
1 /*-------------------------------------------------------------------------
2  *
3  * datum.h--
4  *        POSTGRES abstract data type datum representation definitions.
5  *
6  *
7  * Copyright (c) 1994, Regents of the University of California
8  *
9  * $Id: datum.h,v 1.3 1997/09/07 05:02:17 momjian Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef DATUM_H
14 #define DATUM_H
15
16
17 /*--------------------------------------------------------
18  * SOME NOT VERY PORTABLE ROUTINES ???
19  *--------------------------------------------------------
20  *
21  * In the implementation of the next routines we assume the following:
22  *
23  * A) if a type is "byVal" then all the information is stored in the
24  * Datum itself (i.e. no pointers involved!). In this case the
25  * length of the type is always greater than zero and less than
26  * "sizeof(Datum)"
27  * B) if a type is not "byVal" and it has a fixed length, then
28  * the "Datum" always contain a pointer to a stream of bytes.
29  * The number of significant bytes are always equal to the length of thr
30  * type.
31  * C) if a type is not "byVal" and is of variable length (i.e. it has
32  * length == -1) then "Datum" always points to a "struct varlena".
33  * This varlena structure has information about the actual length of this
34  * particular instance of the type and about its value.
35  */
36
37 /*---------------
38  * datumGetSize
39  * find the "real" length of a datum
40  */
41 extern Size             datumGetSize(Datum value, Oid type, bool byVal, Size len);
42
43 /*---------------
44  * datumCopy
45  * make a copy of a datum.
46  */
47 extern Datum    datumCopy(Datum value, Oid type, bool byVal, Size len);
48
49 /*---------------
50  * datumFree
51  * free space that *might* have been palloced by "datumCopy"
52  */
53 extern void             datumFree(Datum value, Oid type, bool byVal, Size len);
54
55 /*---------------
56  * datumIsEqual
57  * return true if thwo datums are equal, false otherwise.
58  * XXX : See comments in the code for restrictions!
59  */
60 extern bool
61 datumIsEqual(Datum value1, Datum value2, Oid type,
62                          bool byVal, Size len);
63
64 #endif                                                  /* DATUM_H */