forked from pganalyze/pg_query_go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vacuum_stmt.go
63 lines (53 loc) · 1.51 KB
/
vacuum_stmt.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
// Auto-generated from postgres/src/include/nodes/parsenodes.h - DO NOT EDIT
package pg_query
import "encoding/json"
/* ----------------------
* Vacuum and Analyze Statements
*
* Even though these are nominally two statements, it's convenient to use
* just one node type for both. Note that at least one of VACOPT_VACUUM
* and VACOPT_ANALYZE must be set in options.
* ----------------------
*/
type VacuumStmt struct {
Options int `json:"options"` /* OR of VacuumOption flags */
Relation *RangeVar `json:"relation"` /* single table to process, or NULL */
VaCols List `json:"va_cols"` /* list of column names, or NIL for all */
}
func (node VacuumStmt) MarshalJSON() ([]byte, error) {
type VacuumStmtMarshalAlias VacuumStmt
return json.Marshal(map[string]interface{}{
"VacuumStmt": (*VacuumStmtMarshalAlias)(&node),
})
}
func (node *VacuumStmt) UnmarshalJSON(input []byte) (err error) {
var fields map[string]json.RawMessage
err = json.Unmarshal(input, &fields)
if err != nil {
return
}
if fields["options"] != nil {
err = json.Unmarshal(fields["options"], &node.Options)
if err != nil {
return
}
}
if fields["relation"] != nil {
var nodePtr *Node
nodePtr, err = UnmarshalNodePtrJSON(fields["relation"])
if err != nil {
return
}
if nodePtr != nil && *nodePtr != nil {
val := (*nodePtr).(RangeVar)
node.Relation = &val
}
}
if fields["va_cols"] != nil {
node.VaCols.Items, err = UnmarshalNodeArrayJSON(fields["va_cols"])
if err != nil {
return
}
}
return
}