2015-01-19 14:27 GMT+01:00 Robert Haas <robertmh...@gmail.com>: > On Mon, Jan 19, 2015 at 2:59 AM, Pavel Stehule <pavel.steh...@gmail.com> > wrote: > >> I think you should just remove the WARNING, not change it to an error. > >> If somebody wants to quote the operator name to be able to continue > >> using it, I think that's OK. > > > > It looks so quoting doesn't help here > > > > + CREATE OPERATOR "=>" ( > > + leftarg = int8,<--><------>-- right unary > > + procedure = numeric_fac > > + ); > > + ERROR: syntax error at or near "(" > > + LINE 1: CREATE OPERATOR "=>" ( > > + ^ > > Well then the error check is just dead code. Either way, you don't need > it. >
yes, I removed it Regards Pavel > > -- > Robert Haas > EnterpriseDB: http://www.enterprisedb.com > The Enterprise PostgreSQL Company >
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml new file mode 100644 index 5e7b000..c33190e *** a/doc/src/sgml/func.sgml --- b/doc/src/sgml/func.sgml *************** SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1 *** 6785,6791 **** Create interval from years, months, weeks, days, hours, minutes and seconds fields </entry> ! <entry><literal>make_interval(days := 10)</literal></entry> <entry><literal>10 days</literal></entry> </row> --- 6785,6791 ---- Create interval from years, months, weeks, days, hours, minutes and seconds fields </entry> ! <entry><literal>make_interval(days => 10)</literal></entry> <entry><literal>10 days</literal></entry> </row> diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml new file mode 100644 index 4b81b08..d30db6a *** a/doc/src/sgml/syntax.sgml --- b/doc/src/sgml/syntax.sgml *************** SELECT concat_lower_or_upper('Hello', 'W *** 2599,2605 **** <literal>:=</literal> to separate it from the argument expression. For example: <screen> ! SELECT concat_lower_or_upper(a := 'Hello', b := 'World'); concat_lower_or_upper ----------------------- hello world --- 2599,2605 ---- <literal>:=</literal> to separate it from the argument expression. For example: <screen> ! SELECT concat_lower_or_upper(a => 'Hello', b => 'World'); concat_lower_or_upper ----------------------- hello world *************** SELECT concat_lower_or_upper(a := 'Hello *** 2610,2622 **** using named notation is that the arguments may be specified in any order, for example: <screen> ! SELECT concat_lower_or_upper(a := 'Hello', b := 'World', uppercase := true); concat_lower_or_upper ----------------------- HELLO WORLD (1 row) ! SELECT concat_lower_or_upper(a := 'Hello', uppercase := true, b := 'World'); concat_lower_or_upper ----------------------- HELLO WORLD --- 2610,2633 ---- using named notation is that the arguments may be specified in any order, for example: <screen> ! SELECT concat_lower_or_upper(a => 'Hello', b => 'World', uppercase => true); concat_lower_or_upper ----------------------- HELLO WORLD (1 row) ! SELECT concat_lower_or_upper(a => 'Hello', uppercase => true, b => 'World'); ! concat_lower_or_upper ! ----------------------- ! HELLO WORLD ! (1 row) ! </screen> ! </para> ! ! <para> ! Older syntax based on ":=" symbol is still supported: ! <screen> ! SELECT concat_lower_or_upper(a := 'Hello', uppercase := true, b := 'World'); concat_lower_or_upper ----------------------- HELLO WORLD *************** SELECT concat_lower_or_upper(a := 'Hello *** 2638,2644 **** already mentioned, named arguments cannot precede positional arguments. For example: <screen> ! SELECT concat_lower_or_upper('Hello', 'World', uppercase := true); concat_lower_or_upper ----------------------- HELLO WORLD --- 2649,2655 ---- already mentioned, named arguments cannot precede positional arguments. For example: <screen> ! SELECT concat_lower_or_upper('Hello', 'World', uppercase => true); concat_lower_or_upper ----------------------- HELLO WORLD diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml new file mode 100644 index f40504c..264e5ff *** a/doc/src/sgml/xfunc.sgml --- b/doc/src/sgml/xfunc.sgml *************** SELECT mleast(VARIADIC ARRAY[]::numeric[ *** 776,789 **** <literal>VARIADIC</>. For example, this will work: <screen> ! SELECT mleast(VARIADIC arr := ARRAY[10, -1, 5, 4.4]); </screen> but not these: <screen> ! SELECT mleast(arr := 10); ! SELECT mleast(arr := ARRAY[10, -1, 5, 4.4]); </screen> </para> </sect2> --- 776,789 ---- <literal>VARIADIC</>. For example, this will work: <screen> ! SELECT mleast(VARIADIC arr => ARRAY[10, -1, 5, 4.4]); </screen> but not these: <screen> ! SELECT mleast(arr => 10); ! SELECT mleast(arr => ARRAY[10, -1, 5, 4.4]); </screen> </para> </sect2> diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c new file mode 100644 index 2996019..e4327c2 *** a/src/backend/commands/operatorcmds.c --- b/src/backend/commands/operatorcmds.c *************** DefineOperator(List *names, List *parame *** 87,102 **** /* Convert list of names to a name and namespace */ oprNamespace = QualifiedNameGetCreationNamespace(names, &oprName); - /* - * The SQL standard committee has decided that => should be used for named - * parameters; therefore, a future release of PostgreSQL may disallow it - * as the name of a user-defined operator. - */ - if (strcmp(oprName, "=>") == 0) - ereport(WARNING, - (errmsg("=> is deprecated as an operator name"), - errdetail("This name may be disallowed altogether in future versions of PostgreSQL."))); - /* Check we have creation rights in target namespace */ aclresult = pg_namespace_aclcheck(oprNamespace, GetUserId(), ACL_CREATE); if (aclresult != ACLCHECK_OK) --- 87,92 ---- diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y new file mode 100644 index 36dac29..6a02dcc *** a/src/backend/parser/gram.y --- b/src/backend/parser/gram.y *************** static Node *makeRecursiveViewSelect(cha *** 531,537 **** */ %token <str> IDENT FCONST SCONST BCONST XCONST Op %token <ival> ICONST PARAM ! %token TYPECAST DOT_DOT COLON_EQUALS /* * If you want to make any keyword changes, update the keyword table in --- 531,537 ---- */ %token <str> IDENT FCONST SCONST BCONST XCONST Op %token <ival> ICONST PARAM ! %token TYPECAST DOT_DOT COLON_EQUALS EQUALS_GREATER /* * If you want to make any keyword changes, update the keyword table in *************** func_arg_expr: a_expr *** 12552,12557 **** --- 12552,12566 ---- { NamedArgExpr *na = makeNode(NamedArgExpr); na->name = $1; + na->arg = (Expr *) $3; + na->argnumber = -1; /* until determined */ + na->location = @1; + $$ = (Node *) na; + } + | param_name EQUALS_GREATER a_expr + { + NamedArgExpr *na = makeNode(NamedArgExpr); + na->name = $1; na->arg = (Expr *) $3; na->argnumber = -1; /* until determined */ na->location = @1; diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l new file mode 100644 index 21a6f30..743df71 *** a/src/backend/parser/scan.l --- b/src/backend/parser/scan.l *************** identifier {ident_start}{ident_cont}* *** 334,339 **** --- 334,340 ---- typecast "::" dot_dot \.\. colon_equals ":=" + equals_greater "=>" /* * "self" is the set of chars that should be returned as single-character *************** other . *** 808,813 **** --- 809,819 ---- return COLON_EQUALS; } + {equals_greater} { + SET_YYLLOC(); + return EQUALS_GREATER; + } + {self} { SET_YYLLOC(); return yytext[0]; diff --git a/src/test/regress/expected/create_operator.out b/src/test/regress/expected/create_operator.out new file mode 100644 index 2e6c764..3a216c2 *** a/src/test/regress/expected/create_operator.out --- b/src/test/regress/expected/create_operator.out *************** CREATE OPERATOR #%# ( *** 29,41 **** -- Test comments COMMENT ON OPERATOR ###### (int4, NONE) IS 'bad right unary'; ERROR: operator does not exist: integer ###### ! -- Show deprecated message. => is deprecated now CREATE OPERATOR => ( leftarg = int8, -- right unary procedure = numeric_fac ); ! WARNING: => is deprecated as an operator name ! DETAIL: This name may be disallowed altogether in future versions of PostgreSQL. -- Should fail. CREATE OPERATOR requires USAGE on SCHEMA BEGIN TRANSACTION; CREATE ROLE regress_rol_op1; --- 29,42 ---- -- Test comments COMMENT ON OPERATOR ###### (int4, NONE) IS 'bad right unary'; ERROR: operator does not exist: integer ###### ! -- => is disallowed now CREATE OPERATOR => ( leftarg = int8, -- right unary procedure = numeric_fac ); ! ERROR: syntax error at or near "=>" ! LINE 1: CREATE OPERATOR => ( ! ^ -- Should fail. CREATE OPERATOR requires USAGE on SCHEMA BEGIN TRANSACTION; CREATE ROLE regress_rol_op1; diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out new file mode 100644 index 27b2879..987b3ee *** a/src/test/regress/expected/polymorphism.out --- b/src/test/regress/expected/polymorphism.out *************** select dfunc('a'::text, 'b', flag := tru *** 1356,1361 **** --- 1356,1428 ---- a (1 row) + -- ansi/sql syntax + select dfunc(a => 1, b => 2); + dfunc + ------- + 1 + (1 row) + + select dfunc(a => 'a'::text, b => 'b'); + dfunc + ------- + a + (1 row) + + select dfunc(a => 'a'::text, b => 'b', flag => false); -- named notation + dfunc + ------- + b + (1 row) + + select dfunc(b => 'b'::text, a => 'a'); -- named notation with default + dfunc + ------- + a + (1 row) + + select dfunc(a => 'a'::text, flag => true); -- named notation with default + dfunc + ------- + a + (1 row) + + select dfunc(a => 'a'::text, flag => false); -- named notation with default + dfunc + ------- + + (1 row) + + select dfunc(b => 'b'::text, a => 'a', flag => true); -- named notation + dfunc + ------- + a + (1 row) + + select dfunc('a'::text, 'b', false); -- full positional notation + dfunc + ------- + b + (1 row) + + select dfunc('a'::text, 'b', flag => false); -- mixed notation + dfunc + ------- + b + (1 row) + + select dfunc('a'::text, 'b', true); -- full positional notation + dfunc + ------- + a + (1 row) + + select dfunc('a'::text, 'b', flag => true); -- mixed notation + dfunc + ------- + a + (1 row) + -- check reverse-listing of named-arg calls CREATE VIEW dfview AS SELECT q1, q2, diff --git a/src/test/regress/sql/create_operator.sql b/src/test/regress/sql/create_operator.sql new file mode 100644 index f7a372a..0e5d635 *** a/src/test/regress/sql/create_operator.sql --- b/src/test/regress/sql/create_operator.sql *************** CREATE OPERATOR #%# ( *** 35,41 **** -- Test comments COMMENT ON OPERATOR ###### (int4, NONE) IS 'bad right unary'; ! -- Show deprecated message. => is deprecated now CREATE OPERATOR => ( leftarg = int8, -- right unary procedure = numeric_fac --- 35,41 ---- -- Test comments COMMENT ON OPERATOR ###### (int4, NONE) IS 'bad right unary'; ! -- => is disallowed now CREATE OPERATOR => ( leftarg = int8, -- right unary procedure = numeric_fac diff --git a/src/test/regress/sql/polymorphism.sql b/src/test/regress/sql/polymorphism.sql new file mode 100644 index 3d8dd1e..72f6cb5 *** a/src/test/regress/sql/polymorphism.sql --- b/src/test/regress/sql/polymorphism.sql *************** select dfunc('a'::text, 'b', flag := fal *** 748,753 **** --- 748,769 ---- select dfunc('a'::text, 'b', true); -- full positional notation select dfunc('a'::text, 'b', flag := true); -- mixed notation + -- ansi/sql syntax + select dfunc(a => 1, b => 2); + select dfunc(a => 'a'::text, b => 'b'); + select dfunc(a => 'a'::text, b => 'b', flag => false); -- named notation + + select dfunc(b => 'b'::text, a => 'a'); -- named notation with default + select dfunc(a => 'a'::text, flag => true); -- named notation with default + select dfunc(a => 'a'::text, flag => false); -- named notation with default + select dfunc(b => 'b'::text, a => 'a', flag => true); -- named notation + + select dfunc('a'::text, 'b', false); -- full positional notation + select dfunc('a'::text, 'b', flag => false); -- mixed notation + select dfunc('a'::text, 'b', true); -- full positional notation + select dfunc('a'::text, 'b', flag => true); -- mixed notation + + -- check reverse-listing of named-arg calls CREATE VIEW dfview AS SELECT q1, q2,
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers