8181/* Write a character-string (possibly NULL) field */
8282#define WRITE_STRING_FIELD (fldname ) \
8383(appendStringInfo(str, " :" CppAsString(fldname) " "), \
84- _outToken (str, node->fldname))
84+ outToken (str, node->fldname))
8585
8686/* Write a parse location field (actually same as INT case) */
8787#define WRITE_LOCATION_FIELD (fldname ) \
9595/* Write a bitmapset field */
9696#define WRITE_BITMAPSET_FIELD (fldname ) \
9797(appendStringInfo(str, " :" CppAsString(fldname) " "), \
98- _outBitmapset (str, node->fldname))
98+ outBitmapset (str, node->fldname))
9999
100100
101101#define booltostr (x ) ((x) ? "true" : "false")
102102
103103
104104/*
105- *_outToken
105+ *outToken
106106 * Convert an ordinary string (eg, an identifier) into a form that
107107 * will be decoded back to a plain token by read.c's functions.
108108 *
109109 * If a null or empty string is given, it is encoded as "<>".
110110 */
111- static void
112- _outToken (StringInfo str ,const char * s )
111+ void
112+ outToken (StringInfo str ,const char * s )
113113{
114114if (s == NULL || * s == '\0' )
115115{
@@ -140,13 +140,6 @@ _outToken(StringInfo str, const char *s)
140140}
141141}
142142
143- /* for use by extensions which define extensible nodes */
144- void
145- outToken (StringInfo str ,const char * s )
146- {
147- _outToken (str ,s );
148- }
149-
150143static void
151144_outList (StringInfo str ,const List * node )
152145{
@@ -185,13 +178,13 @@ _outList(StringInfo str, const List *node)
185178}
186179
187180/*
188- *_outBitmapset -
181+ *outBitmapset -
189182 * converts a bitmap set of integers
190183 *
191184 * Note: the output format is "(b int int ...)", similar to an integer List.
192185 */
193- static void
194- _outBitmapset (StringInfo str ,const Bitmapset * bms )
186+ void
187+ outBitmapset (StringInfo str ,const Bitmapset * bms )
195188{
196189int x ;
197190
@@ -203,13 +196,6 @@ _outBitmapset(StringInfo str, const Bitmapset *bms)
203196appendStringInfoChar (str ,')' );
204197}
205198
206- /* for use by extensions which define extensible nodes */
207- void
208- outBitmapset (StringInfo str ,const Bitmapset * bms )
209- {
210- _outBitmapset (str ,bms );
211- }
212-
213199/*
214200 * Print the value of a Datum given its type.
215201 */
@@ -632,7 +618,7 @@ _outCustomScan(StringInfo str, const CustomScan *node)
632618WRITE_BITMAPSET_FIELD (custom_relids );
633619/* CustomName is a key to lookup CustomScanMethods */
634620appendStringInfoString (str ," :methods " );
635- _outToken (str ,node -> methods -> CustomName );
621+ outToken (str ,node -> methods -> CustomName );
636622}
637623
638624static void
@@ -1196,7 +1182,7 @@ _outBoolExpr(StringInfo str, const BoolExpr *node)
11961182break ;
11971183}
11981184appendStringInfoString (str ," :boolop " );
1199- _outToken (str ,opstr );
1185+ outToken (str ,opstr );
12001186
12011187WRITE_NODE_FIELD (args );
12021188WRITE_LOCATION_FIELD (location );
@@ -1609,14 +1595,14 @@ _outPathInfo(StringInfo str, const Path *node)
16091595{
16101596WRITE_ENUM_FIELD (pathtype ,NodeTag );
16111597appendStringInfoString (str ," :parent_relids " );
1612- _outBitmapset (str ,node -> parent -> relids );
1598+ outBitmapset (str ,node -> parent -> relids );
16131599if (node -> pathtarget != node -> parent -> reltarget )
16141600WRITE_NODE_FIELD (pathtarget );
16151601appendStringInfoString (str ," :required_outer " );
16161602if (node -> param_info )
1617- _outBitmapset (str ,node -> param_info -> ppi_req_outer );
1603+ outBitmapset (str ,node -> param_info -> ppi_req_outer );
16181604else
1619- _outBitmapset (str ,NULL );
1605+ outBitmapset (str ,NULL );
16201606WRITE_BOOL_FIELD (parallel_aware );
16211607WRITE_BOOL_FIELD (parallel_safe );
16221608WRITE_INT_FIELD (parallel_workers );
@@ -1740,7 +1726,7 @@ _outCustomPath(StringInfo str, const CustomPath *node)
17401726WRITE_NODE_FIELD (custom_paths );
17411727WRITE_NODE_FIELD (custom_private );
17421728appendStringInfoString (str ," :methods " );
1743- _outToken (str ,node -> methods -> CustomName );
1729+ outToken (str ,node -> methods -> CustomName );
17441730}
17451731
17461732static void
@@ -2994,12 +2980,12 @@ _outValue(StringInfo str, const Value *value)
29942980case T_String :
29952981
29962982/*
2997- * We use_outToken to provide escaping of the string's content,
2983+ * We useoutToken to provide escaping of the string's content,
29982984 * but we don't want it to do anything with an empty string.
29992985 */
30002986appendStringInfoChar (str ,'"' );
30012987if (value -> val .str [0 ]!= '\0' )
3002- _outToken (str ,value -> val .str );
2988+ outToken (str ,value -> val .str );
30032989appendStringInfoChar (str ,'"' );
30042990break ;
30052991case T_BitString :
@@ -3895,3 +3881,18 @@ nodeToString(const void *obj)
38953881outNode (& str ,obj );
38963882return str .data ;
38973883}
3884+
3885+ /*
3886+ * bmsToString -
3887+ * returns the ascii representation of the Bitmapset as a palloc'd string
3888+ */
3889+ char *
3890+ bmsToString (const Bitmapset * bms )
3891+ {
3892+ StringInfoData str ;
3893+
3894+ /* see stringinfo.h for an explanation of this maneuver */
3895+ initStringInfo (& str );
3896+ outBitmapset (& str ,bms );
3897+ return str .data ;
3898+ }