forked from pganalyze/pg_query_go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
into_clause.go
95 lines (81 loc) · 2.45 KB
/
into_clause.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Auto-generated from postgres/src/include/nodes/primnodes.h - DO NOT EDIT
package pg_query
import "encoding/json"
/*
* IntoClause - target information for SELECT INTO, CREATE TABLE AS, and
* CREATE MATERIALIZED VIEW
*
* For CREATE MATERIALIZED VIEW, viewQuery is the parsed-but-not-rewritten
* SELECT Query for the view; otherwise it's NULL. (Although it's actually
* Query*, we declare it as Node* to avoid a forward reference.)
*/
type IntoClause struct {
Rel *RangeVar `json:"rel"` /* target relation name */
ColNames List `json:"colNames"` /* column names to assign, or NIL */
Options List `json:"options"` /* options from WITH clause */
OnCommit OnCommitAction `json:"onCommit"` /* what do we do at COMMIT? */
TableSpaceName *string `json:"tableSpaceName"` /* table space to use, or NULL */
ViewQuery Node `json:"viewQuery"` /* materialized view's SELECT query */
SkipData bool `json:"skipData"` /* true for WITH NO DATA */
}
func (node IntoClause) MarshalJSON() ([]byte, error) {
type IntoClauseMarshalAlias IntoClause
return json.Marshal(map[string]interface{}{
"IntoClause": (*IntoClauseMarshalAlias)(&node),
})
}
func (node *IntoClause) UnmarshalJSON(input []byte) (err error) {
var fields map[string]json.RawMessage
err = json.Unmarshal(input, &fields)
if err != nil {
return
}
if fields["rel"] != nil {
var nodePtr *Node
nodePtr, err = UnmarshalNodePtrJSON(fields["rel"])
if err != nil {
return
}
if nodePtr != nil && *nodePtr != nil {
val := (*nodePtr).(RangeVar)
node.Rel = &val
}
}
if fields["colNames"] != nil {
node.ColNames.Items, err = UnmarshalNodeArrayJSON(fields["colNames"])
if err != nil {
return
}
}
if fields["options"] != nil {
node.Options.Items, err = UnmarshalNodeArrayJSON(fields["options"])
if err != nil {
return
}
}
if fields["onCommit"] != nil {
err = json.Unmarshal(fields["onCommit"], &node.OnCommit)
if err != nil {
return
}
}
if fields["tableSpaceName"] != nil {
err = json.Unmarshal(fields["tableSpaceName"], &node.TableSpaceName)
if err != nil {
return
}
}
if fields["viewQuery"] != nil {
node.ViewQuery, err = UnmarshalNodeJSON(fields["viewQuery"])
if err != nil {
return
}
}
if fields["skipData"] != nil {
err = json.Unmarshal(fields["skipData"], &node.SkipData)
if err != nil {
return
}
}
return
}