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

Commit0e9d75c

Browse files
Jan WieckJan Wieck
Jan Wieck
authored and
Jan Wieck
committed
Added NUMERIC data type with many builtin funcitons, operators
and aggregates.Jan
1 parent6059c5a commit0e9d75c

File tree

10 files changed

+4955
-1056
lines changed

10 files changed

+4955
-1056
lines changed

‎src/backend/parser/gram.c

Lines changed: 1052 additions & 1025 deletions
Large diffs are not rendered by default.

‎src/backend/parser/gram.y

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.40 1998/12/18 09:10:32 vadim Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.41 1998/12/30 19:56:28 wieck Exp $
1414
*
1515
* HISTORY
1616
* AUTHORDATEMAJOR EVENT
@@ -46,6 +46,7 @@
4646
#include "utils/elog.h"
4747
#include "access/xact.h"
4848
#include "storage/lmgr.h"
49+
#include "utils/numeric.h"
4950

5051
#ifdef MULTIBYTE
5152
#include "mb/pg_wchar.h"
@@ -229,7 +230,8 @@ Oidparam_type(int t); /* used in parse_expr.c */
229230
%type <str>generic, numeric, character, datetime
230231
%type <str>extract_arg
231232
%type <str>opt_charset, opt_collate
232-
%type <str>opt_float, opt_numeric, opt_decimal
233+
%type <str>opt_float
234+
%type <ival>opt_numeric, opt_decimal
233235
%type <boolean>opt_varying, opt_timezone
234236

235237
%type <ival>Iconst
@@ -3018,8 +3020,7 @@ generic: IDENT{ $$ = $1; }
30183020

30193021
/* SQL92 numeric data types
30203022
* Check FLOAT() precision limits assuming IEEE floating types.
3021-
* Provide rudimentary DECIMAL() and NUMERIC() implementations
3022-
* by checking parameters and making sure they match what is possible with INTEGER.
3023+
* Provide real DECIMAL() and NUMERIC() implementations now - Jan 1998-12-30
30233024
* - thomas 1997-09-18
30243025
*/
30253026
Numeric: FLOAT opt_float
@@ -3036,14 +3037,14 @@ Numeric: FLOAT opt_float
30363037
| DECIMAL opt_decimal
30373038
{
30383039
$$ = makeNode(TypeName);
3039-
$$->name = xlateSqlType("integer");
3040+
$$->name = xlateSqlType("numeric");
30403041
$$->typmod = -1;
30413042
}
30423043
| NUMERIC opt_numeric
30433044
{
30443045
$$ = makeNode(TypeName);
3045-
$$->name = xlateSqlType("integer");
3046-
$$->typmod =-1;
3046+
$$->name = xlateSqlType("numeric");
3047+
$$->typmod =$2;
30473048
}
30483049
;
30493050

@@ -3052,7 +3053,7 @@ numeric: FLOAT
30523053
| DOUBLE PRECISION
30533054
{$$ = xlateSqlType("float8"); }
30543055
| DECIMAL
3055-
{$$ = xlateSqlType("decimal"); }
3056+
{$$ = xlateSqlType("numeric"); }
30563057
| NUMERIC
30573058
{$$ = xlateSqlType("numeric"); }
30583059
;
@@ -3076,42 +3077,55 @@ opt_float: '(' Iconst ')'
30763077

30773078
opt_numeric: '(' Iconst ',' Iconst ')'
30783079
{
3079-
if ($2 != 9)
3080-
elog(ERROR,"NUMERIC precision %d must be 9",$2);
3081-
if ($4 != 0)
3082-
elog(ERROR,"NUMERIC scale %d must be zero",$4);
3080+
if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
3081+
elog(ERROR,"NUMERIC precision %d must be beween 1 and %d",
3082+
$2, NUMERIC_MAX_PRECISION);
3083+
if ($4 < 0 || $4 > $2)
3084+
elog(ERROR,"NUMERIC scale %d must be between 0 and precision %d",
3085+
$4,$2);
3086+
3087+
$$ = (($2 << 16) | $4) + VARHDRSZ;
30833088
}
30843089
| '(' Iconst ')'
30853090
{
3086-
if ($2 != 9)
3087-
elog(ERROR,"NUMERIC precision %d must be 9",$2);
3091+
if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
3092+
elog(ERROR,"NUMERIC precision %d must be beween 1 and %d",
3093+
$2, NUMERIC_MAX_PRECISION);
3094+
3095+
$$ = ($2 << 16) + VARHDRSZ;
30883096
}
30893097
| /*EMPTY*/
30903098
{
3091-
$$ =NULL;
3099+
$$ =((NUMERIC_DEFAULT_PRECISION << 16) | NUMERIC_DEFAULT_SCALE) + VARHDRSZ;
30923100
}
30933101
;
30943102

30953103
opt_decimal: '(' Iconst ',' Iconst ')'
30963104
{
3097-
if ($2 > 9)
3098-
elog(ERROR,"DECIMAL precision %d exceeds implementation limit of 9",$2);
3099-
if ($4 != 0)
3100-
elog(ERROR,"DECIMAL scale %d must be zero",$4);
3101-
$$ = NULL;
3105+
if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
3106+
elog(ERROR,"DECIMAL precision %d must be beween 1 and %d",
3107+
$2, NUMERIC_MAX_PRECISION);
3108+
if ($4 < 0 || $4 > $2)
3109+
elog(ERROR,"DECIMAL scale %d must be between 0 and precision %d",
3110+
$4,$2);
3111+
3112+
$$ = (($2 << 16) | $4) + VARHDRSZ;
31023113
}
31033114
| '(' Iconst ')'
31043115
{
3105-
if ($2 > 9)
3106-
elog(ERROR,"DECIMAL precision %d exceeds implementation limit of 9",$2);
3107-
$$ = NULL;
3116+
if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
3117+
elog(ERROR,"DECIMAL precision %d must be beween 1 and %d",
3118+
$2, NUMERIC_MAX_PRECISION);
3119+
3120+
$$ = ($2 << 16) + VARHDRSZ;
31083121
}
31093122
| /*EMPTY*/
31103123
{
3111-
$$ =NULL;
3124+
$$ =((NUMERIC_DEFAULT_PRECISION << 16) | NUMERIC_DEFAULT_SCALE) + VARHDRSZ;
31123125
}
31133126
;
31143127

3128+
31153129
/* SQL92 character data types
31163130
* The following implements CHAR() and VARCHAR().
31173131
* We do it here instead of the 'Generic' production

‎src/backend/utils/adt/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for utils/adt
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.20 1998/10/22 20:40:44 momjian Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.21 1998/12/30 19:56:29 wieck Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -20,7 +20,7 @@ endif
2020
OBJS = acl.o arrayfuncs.o arrayutils.o bool.o cash.o char.o chunk.o\
2121
date.o datetime.o datum.o dt.o filename.o float.o\
2222
geo_ops.o geo_selfuncs.o int.o int8.o like.o\
23-
misc.o nabstime.o name.o not_in.o numutils.o\
23+
misc.o nabstime.o name.o not_in.onumeric.onumutils.o\
2424
oid.o oracle_compat.o\
2525
regexp.o regproc.o ruleutils.o selfuncs.o sets.o\
2626
tid.o timestamp.o varchar.o varlena.o version.o\

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp