aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/int8.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2010-11-19 22:13:11 -0500
committerRobert Haas <rhaas@postgresql.org>2010-11-19 22:13:11 -0500
commit4fc115b2e981f8c63165ca86a23215380a3fda66 (patch)
treefd2a51d0af0e2c3d2d3ce6d701c4402fef65c34e /src/backend/utils/adt/int8.c
parent0f61d4dd1b4f95832dcd81c9688dac56fd6b5687 (diff)
downloadpostgresql-4fc115b2e981f8c63165ca86a23215380a3fda66.tar.gz
postgresql-4fc115b2e981f8c63165ca86a23215380a3fda66.zip
Speed up conversion of signed integers to C strings.
A hand-coded implementation turns out to be much faster than calling printf(). In passing, add a few more regresion tests. Andres Freund, with assorted, mostly cosmetic changes.
Diffstat (limited to 'src/backend/utils/adt/int8.c')
-rw-r--r--src/backend/utils/adt/int8.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 894110d7a2c..91133f7741e 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -20,6 +20,7 @@
#include "funcapi.h"
#include "libpq/pqformat.h"
#include "utils/int8.h"
+#include "utils/builtins.h"
#define MAXINT8LEN 25
@@ -157,13 +158,10 @@ Datum
int8out(PG_FUNCTION_ARGS)
{
int64 val = PG_GETARG_INT64(0);
- char *result;
- int len;
char buf[MAXINT8LEN + 1];
+ char *result;
- if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, val)) < 0)
- elog(ERROR, "could not format int8");
-
+ pg_lltoa(val, buf);
result = pstrdup(buf);
PG_RETURN_CSTRING(result);
}