Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd8c61c9

Browse files
committed
Add debugging aid "bmsToString(Bitmapset *bms)".
This function has no direct callers at present, but it's convenient formanual use in a debugger, rather than having to inspect memory and dobit-counting in your head.In passing, get rid of useless outBitmapset() wrapper around_outBitmapset(); let's just export the function that does the work.Likewise for outToken().Ashutosh Bapat, tweaked a bit by meDiscussion: <CAFjFpRdiht8e1HTVirbubr4YzaON5iZTzFJjq909y4sU8M_6eA@mail.gmail.com>
1 parent5225c66 commitd8c61c9

File tree

2 files changed

+34
-32
lines changed

2 files changed

+34
-32
lines changed

‎src/backend/nodes/outfuncs.c

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
/* Write a character-string (possibly NULL) field */
8282
#defineWRITE_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
#defineWRITE_LOCATION_FIELD(fldname) \
@@ -95,21 +95,21 @@
9595
/* Write a bitmapset field */
9696
#defineWRITE_BITMAPSET_FIELD(fldname) \
9797
(appendStringInfo(str, " :" CppAsString(fldname) " "), \
98-
_outBitmapset(str, node->fldname))
98+
outBitmapset(str, node->fldname))
9999

100100

101101
#definebooltostr(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-
staticvoid
112-
_outToken(StringInfostr,constchar*s)
111+
void
112+
outToken(StringInfostr,constchar*s)
113113
{
114114
if (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(StringInfostr,constchar*s)
146-
{
147-
_outToken(str,s);
148-
}
149-
150143
staticvoid
151144
_outList(StringInfostr,constList*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-
staticvoid
194-
_outBitmapset(StringInfostr,constBitmapset*bms)
186+
void
187+
outBitmapset(StringInfostr,constBitmapset*bms)
195188
{
196189
intx;
197190

@@ -203,13 +196,6 @@ _outBitmapset(StringInfo str, const Bitmapset *bms)
203196
appendStringInfoChar(str,')');
204197
}
205198

206-
/* for use by extensions which define extensible nodes */
207-
void
208-
outBitmapset(StringInfostr,constBitmapset*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)
632618
WRITE_BITMAPSET_FIELD(custom_relids);
633619
/* CustomName is a key to lookup CustomScanMethods */
634620
appendStringInfoString(str," :methods ");
635-
_outToken(str,node->methods->CustomName);
621+
outToken(str,node->methods->CustomName);
636622
}
637623

638624
staticvoid
@@ -1196,7 +1182,7 @@ _outBoolExpr(StringInfo str, const BoolExpr *node)
11961182
break;
11971183
}
11981184
appendStringInfoString(str," :boolop ");
1199-
_outToken(str,opstr);
1185+
outToken(str,opstr);
12001186

12011187
WRITE_NODE_FIELD(args);
12021188
WRITE_LOCATION_FIELD(location);
@@ -1609,14 +1595,14 @@ _outPathInfo(StringInfo str, const Path *node)
16091595
{
16101596
WRITE_ENUM_FIELD(pathtype,NodeTag);
16111597
appendStringInfoString(str," :parent_relids ");
1612-
_outBitmapset(str,node->parent->relids);
1598+
outBitmapset(str,node->parent->relids);
16131599
if (node->pathtarget!=node->parent->reltarget)
16141600
WRITE_NODE_FIELD(pathtarget);
16151601
appendStringInfoString(str," :required_outer ");
16161602
if (node->param_info)
1617-
_outBitmapset(str,node->param_info->ppi_req_outer);
1603+
outBitmapset(str,node->param_info->ppi_req_outer);
16181604
else
1619-
_outBitmapset(str,NULL);
1605+
outBitmapset(str,NULL);
16201606
WRITE_BOOL_FIELD(parallel_aware);
16211607
WRITE_BOOL_FIELD(parallel_safe);
16221608
WRITE_INT_FIELD(parallel_workers);
@@ -1740,7 +1726,7 @@ _outCustomPath(StringInfo str, const CustomPath *node)
17401726
WRITE_NODE_FIELD(custom_paths);
17411727
WRITE_NODE_FIELD(custom_private);
17421728
appendStringInfoString(str," :methods ");
1743-
_outToken(str,node->methods->CustomName);
1729+
outToken(str,node->methods->CustomName);
17441730
}
17451731

17461732
staticvoid
@@ -2994,12 +2980,12 @@ _outValue(StringInfo str, const Value *value)
29942980
caseT_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
*/
30002986
appendStringInfoChar(str,'"');
30012987
if (value->val.str[0]!='\0')
3002-
_outToken(str,value->val.str);
2988+
outToken(str,value->val.str);
30032989
appendStringInfoChar(str,'"');
30042990
break;
30052991
caseT_BitString:
@@ -3895,3 +3881,18 @@ nodeToString(const void *obj)
38953881
outNode(&str,obj);
38963882
returnstr.data;
38973883
}
3884+
3885+
/*
3886+
* bmsToString -
3887+
* returns the ascii representation of the Bitmapset as a palloc'd string
3888+
*/
3889+
char*
3890+
bmsToString(constBitmapset*bms)
3891+
{
3892+
StringInfoDatastr;
3893+
3894+
/* see stringinfo.h for an explanation of this maneuver */
3895+
initStringInfo(&str);
3896+
outBitmapset(&str,bms);
3897+
returnstr.data;
3898+
}

‎src/include/nodes/nodes.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,16 +551,17 @@ extern PGDLLIMPORT Node *newNodeMacroHolder;
551551
/*
552552
* nodes/{outfuncs.c,print.c}
553553
*/
554-
externchar*nodeToString(constvoid*obj);
555-
556554
structBitmapset;/* not to include bitmapset.h here */
557555
structStringInfoData;/* not to include stringinfo.h here */
556+
558557
externvoidoutNode(structStringInfoData*str,constvoid*obj);
559558
externvoidoutToken(structStringInfoData*str,constchar*s);
560559
externvoidoutBitmapset(structStringInfoData*str,
561560
conststructBitmapset*bms);
562561
externvoidoutDatum(structStringInfoData*str,uintptr_tvalue,
563562
inttyplen,booltypbyval);
563+
externchar*nodeToString(constvoid*obj);
564+
externchar*bmsToString(conststructBitmapset*bms);
564565

565566
/*
566567
* nodes/{readfuncs.c,read.c}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp