Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita349733

Browse files
author
Thomas G. Lockhart
committed
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.
1 parent1b992b4 commita349733

File tree

14 files changed

+639
-196
lines changed

14 files changed

+639
-196
lines changed

‎src/backend/commands/define.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.38 2000/01/26 05:56:13 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.39 2000/04/07 13:39:24 thomas Exp $
1414
*
1515
* DESCRIPTION
1616
* The "DefineFoo" routines take the parse tree and pick out the
@@ -377,24 +377,22 @@ DefineOperator(char *oprName,
377377

378378
if (!strcasecmp(defel->defname,"leftarg"))
379379
{
380-
/* see gram.y, must be setof */
381-
if (nodeTag(defel->arg)==T_TypeName)
380+
if ((nodeTag(defel->arg)==T_TypeName)
381+
&& (((TypeName*)defel->arg)->setof))
382382
elog(ERROR,"setof type not implemented for leftarg");
383383

384-
if (nodeTag(defel->arg)==T_String)
385-
typeName1=defGetString(defel);
386-
else
384+
typeName1=defGetString(defel);
385+
if (typeName1==NULL)
387386
elog(ERROR,"type for leftarg is malformed.");
388387
}
389388
elseif (!strcasecmp(defel->defname,"rightarg"))
390389
{
391-
/* see gram.y, must be setof */
392-
if (nodeTag(defel->arg)==T_TypeName)
390+
if ((nodeTag(defel->arg)==T_TypeName)
391+
&& (((TypeName*)defel->arg)->setof))
393392
elog(ERROR,"setof type not implemented for rightarg");
394393

395-
if (nodeTag(defel->arg)==T_String)
396-
typeName2=defGetString(defel);
397-
else
394+
typeName2=defGetString(defel);
395+
if (typeName2==NULL)
398396
elog(ERROR,"type for rightarg is malformed.");
399397
}
400398
elseif (!strcasecmp(defel->defname,"procedure"))
@@ -700,9 +698,19 @@ DefineType(char *typeName, List *parameters)
700698
staticchar*
701699
defGetString(DefElem*def)
702700
{
703-
if (nodeTag(def->arg)!=T_String)
701+
char*string;
702+
703+
if (nodeTag(def->arg)==T_String)
704+
string=strVal(def->arg);
705+
elseif (nodeTag(def->arg)==T_TypeName)
706+
string= ((TypeName*)def->arg)->name;
707+
else
708+
string=NULL;
709+
#if0
704710
elog(ERROR,"Define: \"%s\" = what?",def->defname);
705-
returnstrVal(def->arg);
711+
#endif
712+
713+
returnstring;
706714
}
707715

708716
staticdouble

‎src/backend/commands/variable.c

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.32 2000/03/17 05:29:04 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.33 2000/04/07 13:39:24 thomas Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -93,6 +93,9 @@ static bool parse_max_expr_depth(char *);
9393
staticboolshow_XactIsoLevel(void);
9494
staticboolreset_XactIsoLevel(void);
9595
staticboolparse_XactIsoLevel(char*);
96+
staticboolparse_random_seed(char*);
97+
staticboolshow_random_seed(void);
98+
staticboolreset_random_seed(void);
9699

97100
/*
98101
* get_token
@@ -1066,6 +1069,41 @@ reset_pg_options(void)
10661069
}
10671070

10681071

1072+
/*
1073+
* Random number seed
1074+
*/
1075+
staticbool
1076+
parse_random_seed(char*value)
1077+
{
1078+
doubleseed=0;
1079+
1080+
if (value==NULL)
1081+
reset_random_seed();
1082+
else
1083+
{
1084+
sscanf(value,"%lf",&seed);
1085+
setseed(&seed);
1086+
}
1087+
return (TRUE);
1088+
}
1089+
1090+
staticbool
1091+
show_random_seed(void)
1092+
{
1093+
elog(NOTICE,"Seed for random number generator is not known");
1094+
return (TRUE);
1095+
}
1096+
1097+
staticbool
1098+
reset_random_seed(void)
1099+
{
1100+
doubleseed=0.5;
1101+
1102+
setseed(&seed);
1103+
return (TRUE);
1104+
}
1105+
1106+
10691107
/*-----------------------------------------------------------------------*/
10701108

10711109
staticstructVariableParsers
@@ -1155,6 +1193,9 @@ static struct VariableParsers
11551193
{
11561194
"pg_options",parse_pg_options,show_pg_options,reset_pg_options
11571195
},
1196+
{
1197+
"seed",parse_random_seed,show_random_seed,reset_random_seed
1198+
},
11581199
{
11591200
NULL,NULL,NULL,NULL
11601201
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp