mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Add debugging aid "bmsToString(Bitmapset *bms)".
This function has no direct callers at present, but it's convenient for manual use in a debugger, rather than having to inspect memory and do bit-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 me Discussion: <CAFjFpRdiht8e1HTVirbubr4YzaON5iZTzFJjq909y4sU8M_6eA@mail.gmail.com>
This commit is contained in:
parent
5225c66336
commit
d8c61c9765
@ -81,7 +81,7 @@
|
|||||||
/* Write a character-string (possibly NULL) field */
|
/* Write a character-string (possibly NULL) field */
|
||||||
#define WRITE_STRING_FIELD(fldname) \
|
#define WRITE_STRING_FIELD(fldname) \
|
||||||
(appendStringInfo(str, " :" CppAsString(fldname) " "), \
|
(appendStringInfo(str, " :" CppAsString(fldname) " "), \
|
||||||
_outToken(str, node->fldname))
|
outToken(str, node->fldname))
|
||||||
|
|
||||||
/* Write a parse location field (actually same as INT case) */
|
/* Write a parse location field (actually same as INT case) */
|
||||||
#define WRITE_LOCATION_FIELD(fldname) \
|
#define WRITE_LOCATION_FIELD(fldname) \
|
||||||
@ -95,21 +95,21 @@
|
|||||||
/* Write a bitmapset field */
|
/* Write a bitmapset field */
|
||||||
#define WRITE_BITMAPSET_FIELD(fldname) \
|
#define WRITE_BITMAPSET_FIELD(fldname) \
|
||||||
(appendStringInfo(str, " :" CppAsString(fldname) " "), \
|
(appendStringInfo(str, " :" CppAsString(fldname) " "), \
|
||||||
_outBitmapset(str, node->fldname))
|
outBitmapset(str, node->fldname))
|
||||||
|
|
||||||
|
|
||||||
#define booltostr(x) ((x) ? "true" : "false")
|
#define booltostr(x) ((x) ? "true" : "false")
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _outToken
|
* outToken
|
||||||
* Convert an ordinary string (eg, an identifier) into a form that
|
* Convert an ordinary string (eg, an identifier) into a form that
|
||||||
* will be decoded back to a plain token by read.c's functions.
|
* will be decoded back to a plain token by read.c's functions.
|
||||||
*
|
*
|
||||||
* If a null or empty string is given, it is encoded as "<>".
|
* If a null or empty string is given, it is encoded as "<>".
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
_outToken(StringInfo str, const char *s)
|
outToken(StringInfo str, const char *s)
|
||||||
{
|
{
|
||||||
if (s == NULL || *s == '\0')
|
if (s == NULL || *s == '\0')
|
||||||
{
|
{
|
||||||
@ -140,13 +140,6 @@ _outToken(StringInfo str, const char *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for use by extensions which define extensible nodes */
|
|
||||||
void
|
|
||||||
outToken(StringInfo str, const char *s)
|
|
||||||
{
|
|
||||||
_outToken(str, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_outList(StringInfo str, const List *node)
|
_outList(StringInfo str, const List *node)
|
||||||
{
|
{
|
||||||
@ -185,13 +178,13 @@ _outList(StringInfo str, const List *node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _outBitmapset -
|
* outBitmapset -
|
||||||
* converts a bitmap set of integers
|
* converts a bitmap set of integers
|
||||||
*
|
*
|
||||||
* Note: the output format is "(b int int ...)", similar to an integer List.
|
* Note: the output format is "(b int int ...)", similar to an integer List.
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
_outBitmapset(StringInfo str, const Bitmapset *bms)
|
outBitmapset(StringInfo str, const Bitmapset *bms)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
@ -203,13 +196,6 @@ _outBitmapset(StringInfo str, const Bitmapset *bms)
|
|||||||
appendStringInfoChar(str, ')');
|
appendStringInfoChar(str, ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for use by extensions which define extensible nodes */
|
|
||||||
void
|
|
||||||
outBitmapset(StringInfo str, const Bitmapset *bms)
|
|
||||||
{
|
|
||||||
_outBitmapset(str, bms);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print the value of a Datum given its type.
|
* Print the value of a Datum given its type.
|
||||||
*/
|
*/
|
||||||
@ -632,7 +618,7 @@ _outCustomScan(StringInfo str, const CustomScan *node)
|
|||||||
WRITE_BITMAPSET_FIELD(custom_relids);
|
WRITE_BITMAPSET_FIELD(custom_relids);
|
||||||
/* CustomName is a key to lookup CustomScanMethods */
|
/* CustomName is a key to lookup CustomScanMethods */
|
||||||
appendStringInfoString(str, " :methods ");
|
appendStringInfoString(str, " :methods ");
|
||||||
_outToken(str, node->methods->CustomName);
|
outToken(str, node->methods->CustomName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1196,7 +1182,7 @@ _outBoolExpr(StringInfo str, const BoolExpr *node)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
appendStringInfoString(str, " :boolop ");
|
appendStringInfoString(str, " :boolop ");
|
||||||
_outToken(str, opstr);
|
outToken(str, opstr);
|
||||||
|
|
||||||
WRITE_NODE_FIELD(args);
|
WRITE_NODE_FIELD(args);
|
||||||
WRITE_LOCATION_FIELD(location);
|
WRITE_LOCATION_FIELD(location);
|
||||||
@ -1609,14 +1595,14 @@ _outPathInfo(StringInfo str, const Path *node)
|
|||||||
{
|
{
|
||||||
WRITE_ENUM_FIELD(pathtype, NodeTag);
|
WRITE_ENUM_FIELD(pathtype, NodeTag);
|
||||||
appendStringInfoString(str, " :parent_relids ");
|
appendStringInfoString(str, " :parent_relids ");
|
||||||
_outBitmapset(str, node->parent->relids);
|
outBitmapset(str, node->parent->relids);
|
||||||
if (node->pathtarget != node->parent->reltarget)
|
if (node->pathtarget != node->parent->reltarget)
|
||||||
WRITE_NODE_FIELD(pathtarget);
|
WRITE_NODE_FIELD(pathtarget);
|
||||||
appendStringInfoString(str, " :required_outer ");
|
appendStringInfoString(str, " :required_outer ");
|
||||||
if (node->param_info)
|
if (node->param_info)
|
||||||
_outBitmapset(str, node->param_info->ppi_req_outer);
|
outBitmapset(str, node->param_info->ppi_req_outer);
|
||||||
else
|
else
|
||||||
_outBitmapset(str, NULL);
|
outBitmapset(str, NULL);
|
||||||
WRITE_BOOL_FIELD(parallel_aware);
|
WRITE_BOOL_FIELD(parallel_aware);
|
||||||
WRITE_BOOL_FIELD(parallel_safe);
|
WRITE_BOOL_FIELD(parallel_safe);
|
||||||
WRITE_INT_FIELD(parallel_workers);
|
WRITE_INT_FIELD(parallel_workers);
|
||||||
@ -1740,7 +1726,7 @@ _outCustomPath(StringInfo str, const CustomPath *node)
|
|||||||
WRITE_NODE_FIELD(custom_paths);
|
WRITE_NODE_FIELD(custom_paths);
|
||||||
WRITE_NODE_FIELD(custom_private);
|
WRITE_NODE_FIELD(custom_private);
|
||||||
appendStringInfoString(str, " :methods ");
|
appendStringInfoString(str, " :methods ");
|
||||||
_outToken(str, node->methods->CustomName);
|
outToken(str, node->methods->CustomName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2994,12 +2980,12 @@ _outValue(StringInfo str, const Value *value)
|
|||||||
case T_String:
|
case T_String:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We use _outToken to provide escaping of the string's content,
|
* We use outToken to provide escaping of the string's content,
|
||||||
* but we don't want it to do anything with an empty string.
|
* but we don't want it to do anything with an empty string.
|
||||||
*/
|
*/
|
||||||
appendStringInfoChar(str, '"');
|
appendStringInfoChar(str, '"');
|
||||||
if (value->val.str[0] != '\0')
|
if (value->val.str[0] != '\0')
|
||||||
_outToken(str, value->val.str);
|
outToken(str, value->val.str);
|
||||||
appendStringInfoChar(str, '"');
|
appendStringInfoChar(str, '"');
|
||||||
break;
|
break;
|
||||||
case T_BitString:
|
case T_BitString:
|
||||||
@ -3895,3 +3881,18 @@ nodeToString(const void *obj)
|
|||||||
outNode(&str, obj);
|
outNode(&str, obj);
|
||||||
return str.data;
|
return str.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* bmsToString -
|
||||||
|
* returns the ascii representation of the Bitmapset as a palloc'd string
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
bmsToString(const Bitmapset *bms)
|
||||||
|
{
|
||||||
|
StringInfoData str;
|
||||||
|
|
||||||
|
/* see stringinfo.h for an explanation of this maneuver */
|
||||||
|
initStringInfo(&str);
|
||||||
|
outBitmapset(&str, bms);
|
||||||
|
return str.data;
|
||||||
|
}
|
||||||
|
@ -551,16 +551,17 @@ extern PGDLLIMPORT Node *newNodeMacroHolder;
|
|||||||
/*
|
/*
|
||||||
* nodes/{outfuncs.c,print.c}
|
* nodes/{outfuncs.c,print.c}
|
||||||
*/
|
*/
|
||||||
extern char *nodeToString(const void *obj);
|
|
||||||
|
|
||||||
struct Bitmapset; /* not to include bitmapset.h here */
|
struct Bitmapset; /* not to include bitmapset.h here */
|
||||||
struct StringInfoData; /* not to include stringinfo.h here */
|
struct StringInfoData; /* not to include stringinfo.h here */
|
||||||
|
|
||||||
extern void outNode(struct StringInfoData *str, const void *obj);
|
extern void outNode(struct StringInfoData *str, const void *obj);
|
||||||
extern void outToken(struct StringInfoData *str, const char *s);
|
extern void outToken(struct StringInfoData *str, const char *s);
|
||||||
extern void outBitmapset(struct StringInfoData *str,
|
extern void outBitmapset(struct StringInfoData *str,
|
||||||
const struct Bitmapset *bms);
|
const struct Bitmapset *bms);
|
||||||
extern void outDatum(struct StringInfoData *str, uintptr_t value,
|
extern void outDatum(struct StringInfoData *str, uintptr_t value,
|
||||||
int typlen, bool typbyval);
|
int typlen, bool typbyval);
|
||||||
|
extern char *nodeToString(const void *obj);
|
||||||
|
extern char *bmsToString(const struct Bitmapset *bms);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nodes/{readfuncs.c,read.c}
|
* nodes/{readfuncs.c,read.c}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user