Skip to content

Commit 317215f

Browse files
committed
Clean up CREATE TYPE/OPERATOR/AGGREGATE productions, so that parser
will not accept types named with operator names or vice versa.
1 parent 4ce226e commit 317215f

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

src/backend/parser/gram.y

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.211 2000/12/03 14:50:54 thomas Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.212 2000/12/22 07:07:58 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHOR DATE MAJOR EVENT
@@ -161,7 +161,7 @@ static void doNegateFloat(Value *v);
161161
%type <str> TriggerEvents
162162
%type <value> TriggerFuncArg
163163

164-
%type <str> relation_name, copy_file_name, copy_delimiter, copy_null, def_name,
164+
%type <str> relation_name, copy_file_name, copy_delimiter, copy_null,
165165
database_name, access_method_clause, access_method, attr_name,
166166
class, index_name, name, func_name, file_name
167167

@@ -206,7 +206,7 @@ static void doNegateFloat(Value *v);
206206
opt_with_copy, index_opt_unique, opt_verbose, opt_analyze
207207
%type <boolean> opt_cursor
208208

209-
%type <ival> copy_dirn, def_type, direction, reindex_type, drop_type,
209+
%type <ival> copy_dirn, direction, reindex_type, drop_type,
210210
opt_column, event, comment_type, comment_cl,
211211
comment_ag, comment_fn, comment_op, comment_tg
212212

@@ -1635,7 +1635,7 @@ IntegerOnly: Iconst
16351635
*****************************************************************************/
16361636

16371637
CreatePLangStmt: CREATE PLangTrusted opt_procedural LANGUAGE Sconst
1638-
HANDLER def_name LANCOMPILER Sconst
1638+
HANDLER func_name LANCOMPILER Sconst
16391639
{
16401640
CreatePLangStmt *n = makeNode(CreatePLangStmt);
16411641
n->plname = $5;
@@ -1854,29 +1854,34 @@ DropTrigStmt: DROP TRIGGER name ON relation_name
18541854
/*****************************************************************************
18551855
*
18561856
* QUERY :
1857-
* define (type,operator,aggregate)
1857+
* define (aggregate,operator,type)
18581858
*
18591859
*****************************************************************************/
18601860

1861-
DefineStmt: CREATE def_type def_name definition
1861+
DefineStmt: CREATE AGGREGATE func_name definition
18621862
{
18631863
DefineStmt *n = makeNode(DefineStmt);
1864-
n->defType = $2;
1864+
n->defType = AGGREGATE;
1865+
n->defname = $3;
1866+
n->definition = $4;
1867+
$$ = (Node *)n;
1868+
}
1869+
| CREATE OPERATOR all_Op definition
1870+
{
1871+
DefineStmt *n = makeNode(DefineStmt);
1872+
n->defType = OPERATOR;
1873+
n->defname = $3;
1874+
n->definition = $4;
1875+
$$ = (Node *)n;
1876+
}
1877+
| CREATE TYPE_P name definition
1878+
{
1879+
DefineStmt *n = makeNode(DefineStmt);
1880+
n->defType = TYPE_P;
18651881
n->defname = $3;
18661882
n->definition = $4;
18671883
$$ = (Node *)n;
18681884
}
1869-
;
1870-
1871-
def_type: OPERATOR { $$ = OPERATOR; }
1872-
| TYPE_P { $$ = TYPE_P; }
1873-
| AGGREGATE { $$ = AGGREGATE; }
1874-
;
1875-
1876-
def_name: PROCEDURE { $$ = "procedure"; }
1877-
| JOIN { $$ = "join"; }
1878-
| all_Op { $$ = $1; }
1879-
| ColId { $$ = $1; }
18801885
;
18811886

18821887
definition: '(' def_list ')' { $$ = $2; }
@@ -1886,24 +1891,18 @@ def_list: def_elem { $$ = makeList1($1); }
18861891
| def_list ',' def_elem { $$ = lappend($1, $3); }
18871892
;
18881893

1889-
def_elem: def_name '=' def_arg
1894+
def_elem: ColLabel '=' def_arg
18901895
{
18911896
$$ = makeNode(DefElem);
18921897
$$->defname = $1;
18931898
$$->arg = (Node *)$3;
18941899
}
1895-
| def_name
1900+
| ColLabel
18961901
{
18971902
$$ = makeNode(DefElem);
18981903
$$->defname = $1;
18991904
$$->arg = (Node *)NULL;
19001905
}
1901-
| DEFAULT '=' def_arg
1902-
{
1903-
$$ = makeNode(DefElem);
1904-
$$->defname = "default";
1905-
$$->arg = (Node *)$3;
1906-
}
19071906
;
19081907

19091908
def_arg: func_return { $$ = (Node *)$1; }
@@ -2538,7 +2537,7 @@ RemoveFuncStmt: DROP FUNCTION func_name func_args
25382537
}
25392538
;
25402539

2541-
RemoveAggrStmt: DROP AGGREGATE name aggr_argtype
2540+
RemoveAggrStmt: DROP AGGREGATE func_name aggr_argtype
25422541
{
25432542
RemoveAggrStmt *n = makeNode(RemoveAggrStmt);
25442543
n->aggname = $3;
@@ -5498,6 +5497,7 @@ TokenId: ABSOLUTE { $$ = "absolute"; }
54985497
| PRIOR { $$ = "prior"; }
54995498
| PRIVILEGES { $$ = "privileges"; }
55005499
| PROCEDURAL { $$ = "procedural"; }
5500+
| PROCEDURE { $$ = "procedure"; }
55015501
| READ { $$ = "read"; }
55025502
| REINDEX { $$ = "reindex"; }
55035503
| RELATIVE { $$ = "relative"; }
@@ -5644,7 +5644,6 @@ ColLabel: ColId { $$ = $1; }
56445644
| POSITION { $$ = "position"; }
56455645
| PRECISION { $$ = "precision"; }
56465646
| PRIMARY { $$ = "primary"; }
5647-
| PROCEDURE { $$ = "procedure"; }
56485647
| PUBLIC { $$ = "public"; }
56495648
| REFERENCES { $$ = "references"; }
56505649
| RESET { $$ = "reset"; }

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy