aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorThomas G. Lockhart <lockhart@fourpalms.org>2000-04-07 13:40:45 +0000
committerThomas G. Lockhart <lockhart@fourpalms.org>2000-04-07 13:40:45 +0000
commita349733bbbeaca5aa5b0b3520963b01a455c9ff8 (patch)
tree75b3222de81890c5fafb91eee0b0f920716d6df4 /src/backend/commands
parent1b992b468bc5fef62f5a1470f382c70311e9d162 (diff)
downloadpostgresql-a349733bbbeaca5aa5b0b3520963b01a455c9ff8.tar.gz
postgresql-a349733bbbeaca5aa5b0b3520963b01a455c9ff8.zip
Add transcendental math functions (sine, cosine, etc)
Add a random number generator and seed setter (random(), SET SEED) Fix up the interval*float8 math to carry partial months into the time field. Add float8*interval so we have symmetry in the available math. Fix the parser and define.c to accept SQL92 types as field arguments. Fix the parser to accept SQL92 types for CREATE TYPE, etc. This is necessary to allow... Bit/varbit support in contrib/bit cleaned up to compile and load cleanly. Still needs some work before final release. Implement the "SOME" keyword as a synonym for "ANY" per SQL92. Implement ascii(text), ichar(int4), repeat(text,int4) to help support the ODBC driver. Enable the TRUNCATE() function mapping in the ODBC driver.
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/define.c34
-rw-r--r--src/backend/commands/variable.c43
2 files changed, 63 insertions, 14 deletions
diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c
index cd69f079113..2090076f2e4 100644
--- a/src/backend/commands/define.c
+++ b/src/backend/commands/define.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.38 2000/01/26 05:56:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.39 2000/04/07 13:39:24 thomas Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
@@ -377,24 +377,22 @@ DefineOperator(char *oprName,
if (!strcasecmp(defel->defname, "leftarg"))
{
- /* see gram.y, must be setof */
- if (nodeTag(defel->arg) == T_TypeName)
+ if ((nodeTag(defel->arg) == T_TypeName)
+ && (((TypeName *)defel->arg)->setof))
elog(ERROR, "setof type not implemented for leftarg");
- if (nodeTag(defel->arg) == T_String)
- typeName1 = defGetString(defel);
- else
+ typeName1 = defGetString(defel);
+ if (typeName1 == NULL)
elog(ERROR, "type for leftarg is malformed.");
}
else if (!strcasecmp(defel->defname, "rightarg"))
{
- /* see gram.y, must be setof */
- if (nodeTag(defel->arg) == T_TypeName)
+ if ((nodeTag(defel->arg) == T_TypeName)
+ && (((TypeName *)defel->arg)->setof))
elog(ERROR, "setof type not implemented for rightarg");
- if (nodeTag(defel->arg) == T_String)
- typeName2 = defGetString(defel);
- else
+ typeName2 = defGetString(defel);
+ if (typeName2 == NULL)
elog(ERROR, "type for rightarg is malformed.");
}
else if (!strcasecmp(defel->defname, "procedure"))
@@ -700,9 +698,19 @@ DefineType(char *typeName, List *parameters)
static char *
defGetString(DefElem *def)
{
- if (nodeTag(def->arg) != T_String)
+ char *string;
+
+ if (nodeTag(def->arg) == T_String)
+ string = strVal(def->arg);
+ else if (nodeTag(def->arg) == T_TypeName)
+ string = ((TypeName *)def->arg)->name;
+ else
+ string = NULL;
+#if 0
elog(ERROR, "Define: \"%s\" = what?", def->defname);
- return strVal(def->arg);
+#endif
+
+ return string;
}
static double
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 482b9a23ae0..6432d3c2b8f 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.32 2000/03/17 05:29:04 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.33 2000/04/07 13:39:24 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -93,6 +93,9 @@ static bool parse_max_expr_depth(char *);
static bool show_XactIsoLevel(void);
static bool reset_XactIsoLevel(void);
static bool parse_XactIsoLevel(char *);
+static bool parse_random_seed(char *);
+static bool show_random_seed(void);
+static bool reset_random_seed(void);
/*
* get_token
@@ -1066,6 +1069,41 @@ reset_pg_options(void)
}
+/*
+ * Random number seed
+ */
+static bool
+parse_random_seed(char *value)
+{
+ double seed = 0;
+
+ if (value == NULL)
+ reset_random_seed();
+ else
+ {
+ sscanf(value, "%lf", &seed);
+ setseed(&seed);
+ }
+ return (TRUE);
+}
+
+static bool
+show_random_seed(void)
+{
+ elog(NOTICE, "Seed for random number generator is not known");
+ return (TRUE);
+}
+
+static bool
+reset_random_seed(void)
+{
+ double seed = 0.5;
+
+ setseed(&seed);
+ return (TRUE);
+}
+
+
/*-----------------------------------------------------------------------*/
static struct VariableParsers
@@ -1156,6 +1194,9 @@ static struct VariableParsers
"pg_options", parse_pg_options, show_pg_options, reset_pg_options
},
{
+ "seed", parse_random_seed, show_random_seed, reset_random_seed
+ },
+ {
NULL, NULL, NULL, NULL
}
};