summaryrefslogtreecommitdiff
path: root/src/backend/commands/define.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/define.c')
-rw-r--r--src/backend/commands/define.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c
index 889ddd0f440..20d2a61de47 100644
--- a/src/backend/commands/define.c
+++ b/src/backend/commands/define.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.76 2002/04/15 05:22:03 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.77 2002/05/22 21:40:55 tgl Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
@@ -37,6 +37,7 @@
#include "commands/defrem.h"
#include "parser/parse_type.h"
+#include "utils/int8.h"
/*
@@ -115,6 +116,34 @@ defGetNumeric(DefElem *def)
}
/*
+ * Extract an int64 value from a DefElem.
+ */
+int64
+defGetInt64(DefElem *def)
+{
+ if (def->arg == NULL)
+ elog(ERROR, "Define: \"%s\" requires a numeric value",
+ def->defname);
+ switch (nodeTag(def->arg))
+ {
+ case T_Integer:
+ return (int64) intVal(def->arg);
+ case T_Float:
+ /*
+ * Values too large for int4 will be represented as Float
+ * constants by the lexer. Accept these if they are valid int8
+ * strings.
+ */
+ return DatumGetInt64(DirectFunctionCall1(int8in,
+ CStringGetDatum(strVal(def->arg))));
+ default:
+ elog(ERROR, "Define: \"%s\" requires a numeric value",
+ def->defname);
+ }
+ return 0; /* keep compiler quiet */
+}
+
+/*
* Extract a possibly-qualified name (as a List of Strings) from a DefElem.
*/
List *