7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.10 1997/09/08 21:44:07 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.11 1997/12/04 23:20:32 thomas Exp $
11
11
*
12
12
* NOTES
13
13
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -67,6 +67,70 @@ _outIntList(StringInfo str, List *list)
67
67
appendStringInfo (str , ")" );
68
68
}
69
69
70
+ static void
71
+ _outCreateStmt (StringInfo str , CreateStmt * node )
72
+ {
73
+ char buf [500 ];
74
+
75
+ sprintf (buf , "CREATE" );
76
+ appendStringInfo (str , buf );
77
+
78
+ sprintf (buf , " :relname %s" , node -> relname );
79
+ appendStringInfo (str , buf );
80
+ appendStringInfo (str , " :columns" );
81
+ _outNode (str , node -> tableElts );
82
+ } /* _outCreateStmt() */
83
+
84
+ static void
85
+ _outIndexStmt (StringInfo str , IndexStmt * node )
86
+ {
87
+ char buf [500 ];
88
+
89
+ sprintf (buf , "INDEX" );
90
+ appendStringInfo (str , buf );
91
+
92
+ sprintf (buf , " :idxname %s" , node -> idxname );
93
+ appendStringInfo (str , buf );
94
+ sprintf (buf , " :relname %s" , node -> relname );
95
+ appendStringInfo (str , buf );
96
+ sprintf (buf , " :method %s" , node -> accessMethod );
97
+ appendStringInfo (str , buf );
98
+ sprintf (buf , " :unique %s" , (node -> unique ? "y" : "n" ));
99
+ appendStringInfo (str , buf );
100
+ appendStringInfo (str , " :columns" );
101
+ _outNode (str , node -> indexParams );
102
+ } /* _outIndexStmt() */
103
+
104
+ static void
105
+ _outColumnDef (StringInfo str , ColumnDef * node )
106
+ {
107
+ char buf [500 ];
108
+
109
+ sprintf (buf , "COLUMNDEF" );
110
+ appendStringInfo (str , buf );
111
+
112
+ sprintf (buf , " :colname %s" , node -> colname );
113
+ appendStringInfo (str , buf );
114
+ appendStringInfo (str , " :typename" );
115
+ _outNode (str , node -> typename );
116
+ } /* _outColumnDef() */
117
+
118
+ static void
119
+ _outIndexElem (StringInfo str , IndexElem * node )
120
+ {
121
+ char buf [500 ];
122
+
123
+ sprintf (buf , "INDEXELEM" );
124
+ appendStringInfo (str , buf );
125
+
126
+ sprintf (buf , " :name %s" , node -> name );
127
+ appendStringInfo (str , buf );
128
+ sprintf (buf , " :class %s" , node -> class );
129
+ appendStringInfo (str , buf );
130
+ appendStringInfo (str , " :tname" );
131
+ _outNode (str , node -> tname );
132
+ } /* _outIndexElem() */
133
+
70
134
static void
71
135
_outQuery (StringInfo str , Query * node )
72
136
{
@@ -77,14 +141,41 @@ _outQuery(StringInfo str, Query *node)
77
141
78
142
sprintf (buf , " :command %d" , node -> commandType );
79
143
appendStringInfo (str , buf );
80
- if (node -> utilityStmt &&
81
- nodeTag (node -> utilityStmt ) == T_NotifyStmt )
82
- sprintf (buf , " :utility %s" ,
83
- ((NotifyStmt * ) (node -> utilityStmt ))-> relname );
144
+ if (node -> utilityStmt )
145
+ {
146
+ switch (nodeTag (node -> utilityStmt ))
147
+ {
148
+ case T_CreateStmt :
149
+ sprintf (buf , " :create %s" ,
150
+ ((CreateStmt * ) (node -> utilityStmt ))-> relname );
151
+ appendStringInfo (str , buf );
152
+ _outNode (str , node -> utilityStmt );
153
+ break ;
154
+
155
+ case T_IndexStmt :
156
+ sprintf (buf , " :index %s on %s" ,
157
+ ((IndexStmt * ) (node -> utilityStmt ))-> idxname ,
158
+ ((IndexStmt * ) (node -> utilityStmt ))-> relname );
159
+ appendStringInfo (str , buf );
160
+ _outNode (str , node -> utilityStmt );
161
+ break ;
162
+
163
+ case T_NotifyStmt :
164
+ sprintf (buf , " :utility %s" ,
165
+ ((NotifyStmt * ) (node -> utilityStmt ))-> relname );
166
+ appendStringInfo (str , buf );
167
+ break ;
168
+
169
+ default :
170
+ sprintf (buf , " :utility ?" );
171
+ appendStringInfo (str , buf );
172
+ }
173
+ }
84
174
else
175
+ {
85
176
/* use "" to designate */
86
- sprintf ( buf , " :utility \"\"" );
87
- appendStringInfo ( str , buf );
177
+ appendStringInfo ( str , " :utility \"\"" );
178
+ }
88
179
89
180
sprintf (buf , " :resrel %d" , node -> resultRelation );
90
181
appendStringInfo (str , buf );
@@ -1527,6 +1618,20 @@ _outNode(StringInfo str, void *obj)
1527
1618
appendStringInfo (str , "{" );
1528
1619
switch (nodeTag (obj ))
1529
1620
{
1621
+ case T_CreateStmt :
1622
+ _outCreateStmt (str , obj );
1623
+ break ;
1624
+ case T_IndexStmt :
1625
+ _outIndexStmt (str , obj );
1626
+ break ;
1627
+
1628
+ case T_ColumnDef :
1629
+ _outColumnDef (str , obj );
1630
+ break ;
1631
+ case T_IndexElem :
1632
+ _outIndexElem (str , obj );
1633
+ break ;
1634
+
1530
1635
case T_Query :
1531
1636
_outQuery (str , obj );
1532
1637
break ;
0 commit comments