forked from pganalyze/pg_query_go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
partition_bound_spec.go
79 lines (64 loc) · 1.96 KB
/
partition_bound_spec.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
71
72
73
74
75
76
77
78
79
// Auto-generated from postgres/src/include/nodes/parsenodes.h - DO NOT EDIT
package pg_query
import "encoding/json"
/*
* PartitionBoundSpec - a partition bound specification
*
* This represents the portion of the partition key space assigned to a
* particular partition. These are stored on disk in pg_class.relpartbound.
*/
type PartitionBoundSpec struct {
Strategy byte `json:"strategy"` /* see PARTITION_STRATEGY codes above */
/* Partitioning info for LIST strategy: */
Listdatums List `json:"listdatums"` /* List of Consts (or A_Consts in raw tree) */
/* Partitioning info for RANGE strategy: */
Lowerdatums List `json:"lowerdatums"` /* List of PartitionRangeDatums */
Upperdatums List `json:"upperdatums"` /* List of PartitionRangeDatums */
Location int `json:"location"` /* token location, or -1 if unknown */
}
func (node PartitionBoundSpec) MarshalJSON() ([]byte, error) {
type PartitionBoundSpecMarshalAlias PartitionBoundSpec
return json.Marshal(map[string]interface{}{
"PartitionBoundSpec": (*PartitionBoundSpecMarshalAlias)(&node),
})
}
func (node *PartitionBoundSpec) UnmarshalJSON(input []byte) (err error) {
var fields map[string]json.RawMessage
err = json.Unmarshal(input, &fields)
if err != nil {
return
}
if fields["strategy"] != nil {
var strVal string
err = json.Unmarshal(fields["strategy"], &strVal)
node.Strategy = strVal[0]
if err != nil {
return
}
}
if fields["listdatums"] != nil {
node.Listdatums.Items, err = UnmarshalNodeArrayJSON(fields["listdatums"])
if err != nil {
return
}
}
if fields["lowerdatums"] != nil {
node.Lowerdatums.Items, err = UnmarshalNodeArrayJSON(fields["lowerdatums"])
if err != nil {
return
}
}
if fields["upperdatums"] != nil {
node.Upperdatums.Items, err = UnmarshalNodeArrayJSON(fields["upperdatums"])
if err != nil {
return
}
}
if fields["location"] != nil {
err = json.Unmarshal(fields["location"], &node.Location)
if err != nil {
return
}
}
return
}