summaryrefslogtreecommitdiff
path: root/src/include/lib/stringinfo.h
diff options
context:
space:
mode:
authorRobert Haas2013-04-11 19:20:24 +0000
committerRobert Haas2013-04-11 19:20:24 +0000
commitef5409534ea854748a04388905334ae958ae0e66 (patch)
tree2804afa2b40c79900c61b18aacb1df13e3aa8178 /src/include/lib/stringinfo.h
parent8cbbdddac18d5aaf9546342291fa9a20de4deee8 (diff)
Avoid PG_TRY/PG_CATCH overhead if stringinfo is already large enough.copy_hack
Diffstat (limited to 'src/include/lib/stringinfo.h')
-rw-r--r--src/include/lib/stringinfo.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/include/lib/stringinfo.h b/src/include/lib/stringinfo.h
index ecb693fcc2..f795680777 100644
--- a/src/include/lib/stringinfo.h
+++ b/src/include/lib/stringinfo.h
@@ -153,4 +153,11 @@ extern void appendBinaryStringInfo(StringInfo str,
*/
extern void enlargeStringInfo(StringInfo str, int needed);
+/*------------------------
+ * isStringInfoLargeEnough
+ * Test whether a StringInfo's buffer can hold at least 'needed' more bytes.
+ */
+#define isStringInfoLargeEnough(str,needed) \
+ ((needed) < (str)->maxlen - ((str)->len + 1))
+
#endif /* STRINGINFO_H */