forked from pganalyze/pg_query_go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
varatt_external.go
70 lines (59 loc) · 2.01 KB
/
varatt_external.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Auto-generated from postgres/src/include/postgres.h - DO NOT EDIT
package pg_query
import "encoding/json"
/*
* struct varatt_external is a traditional "TOAST pointer", that is, the
* information needed to fetch a Datum stored out-of-line in a TOAST table.
* The data is compressed if and only if va_extsize < va_rawsize - VARHDRSZ.
* This struct must not contain any padding, because we sometimes compare
* these pointers using memcmp.
*
* Note that this information is stored unaligned within actual tuples, so
* you need to memcpy from the tuple into a local struct variable before
* you can look at these fields! (The reason we use memcmp is to avoid
* having to do that just to detect equality of two TOAST pointers...)
*/
type varatt_external struct {
VaRawsize int32 `json:"va_rawsize"` /* Original data size (includes header) */
VaExtsize int32 `json:"va_extsize"` /* External saved size (doesn't) */
VaValueid Oid `json:"va_valueid"` /* Unique ID of value within TOAST table */
VaToastrelid Oid `json:"va_toastrelid"` /* RelID of TOAST table containing it */
}
func (node varatt_external) MarshalJSON() ([]byte, error) {
type varatt_externalMarshalAlias varatt_external
return json.Marshal(map[string]interface{}{
"varatt_external": (*varatt_externalMarshalAlias)(&node),
})
}
func (node *varatt_external) UnmarshalJSON(input []byte) (err error) {
var fields map[string]json.RawMessage
err = json.Unmarshal(input, &fields)
if err != nil {
return
}
if fields["va_rawsize"] != nil {
err = json.Unmarshal(fields["va_rawsize"], &node.VaRawsize)
if err != nil {
return
}
}
if fields["va_extsize"] != nil {
err = json.Unmarshal(fields["va_extsize"], &node.VaExtsize)
if err != nil {
return
}
}
if fields["va_valueid"] != nil {
err = json.Unmarshal(fields["va_valueid"], &node.VaValueid)
if err != nil {
return
}
}
if fields["va_toastrelid"] != nil {
err = json.Unmarshal(fields["va_toastrelid"], &node.VaToastrelid)
if err != nil {
return
}
}
return
}