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

Commit1bd22f5

Browse files
committed
Disallow dollar sign in operator names, instead allow it as a non-first
character in identifiers. The first change eliminates the current needto put spaces around parameter references, as in "x<=$2". The secondchange improves compatibility with Oracle and some other RDBMSes. Thiswas discussed and agreed to back in January, but did not get done.
1 parent8902aaa commit1bd22f5

File tree

4 files changed

+44
-39
lines changed

4 files changed

+44
-39
lines changed

‎doc/src/sgml/release.sgml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.193 2003/06/17 23:12:36 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.194 2003/06/19 23:22:40 tgl Exp $
33
-->
44

55
<appendix id="release">
@@ -24,6 +24,8 @@ CDATA means the content is "SGML-free", so you can write without
2424
worries about funny characters.
2525
-->
2626
<literallayout><![CDATA[
27+
Dollar sign ($) is no longer allowed in operator names
28+
Dollar sign ($) can be a non-first character in identifiers
2729
Precision in FLOAT(p) is now interpreted as bits, not decimal digits
2830
Functional indexes have been generalized into expressional indexes
2931
CHAR(n) to TEXT conversion automatically strips trailing blanks

‎doc/src/sgml/syntax.sgml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.78 2003/06/06 15:04:01 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.79 2003/06/19 23:22:40 tgl Exp $
33
-->
44

55
<chapter id="sql-syntax">
@@ -109,10 +109,15 @@ INSERT INTO MY_TABLE VALUES (3, 'hi there');
109109
(<literal>a</literal>-<literal>z</literal>, but also letters with
110110
diacritical marks and non-Latin letters) or an underscore
111111
(<literal>_</literal>). Subsequent characters in an identifier or
112-
key word can be letters, digits
113-
(<literal>0</literal>-<literal>9</literal>), or underscores,
114-
although the SQL standard will not define a key word that contains
115-
digits or starts or ends with an underscore.
112+
key word can be letters, underscores, digits
113+
(<literal>0</literal>-<literal>9</literal>), or dollar signs
114+
(<literal>$</>). Note that dollar signs are not allowed in identifiers
115+
according to the letter of the SQL standard, so their use may render
116+
applications less portable.
117+
The SQL standard will not define a key word that contains
118+
digits or starts or ends with an underscore, so identifiers of this
119+
form are safe against possible conflict with future extensions of the
120+
standard.
116121
</para>
117122

118123
<para>
@@ -478,18 +483,11 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> )
478483
An operator is a sequence of up to <symbol>NAMEDATALEN</symbol>-1
479484
(63 by default) characters from the following list:
480485
<literallayout>
481-
+ - * / &lt; &gt; = ~ ! @ # % ^ &amp; | ` ? $
486+
+ - * / &lt; &gt; = ~ ! @ # % ^ &amp; | ` ?
482487
</literallayout>
483488

484489
There are a few restrictions on operator names, however:
485490
<itemizedlist>
486-
<listitem>
487-
<para>
488-
<literal>$</> (dollar) cannot be a single-character operator, although it
489-
can be part of a multiple-character operator name.
490-
</para>
491-
</listitem>
492-
493491
<listitem>
494492
<para>
495493
<literal>--</literal> and <literal>/*</literal> cannot appear
@@ -503,7 +501,7 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> )
503501
A multiple-character operator name cannot end in <literal>+</> or <literal>-</>,
504502
unless the name also contains at least one of these characters:
505503
<literallayout>
506-
~ ! @ # % ^ &amp; | ` ? $
504+
~ ! @ # % ^ &amp; | ` ?
507505
</literallayout>
508506
For example, <literal>@-</literal> is an allowed operator name,
509507
but <literal>*-</literal> is not. This restriction allows
@@ -539,9 +537,9 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> )
539537
<listitem>
540538
<para>
541539
A dollar sign (<literal>$</literal>) followed by digits is used
542-
to representthe positionalparameters in the body of a function
540+
to representa positionalparameter in the body of a function
543541
definition or a prepared statement. In other contexts the
544-
dollar sign may be part of anoperator name.
542+
dollar sign may be part of anidentifier.
545543
</para>
546544
</listitem>
547545

@@ -965,9 +963,12 @@ SELECT 3 OPERATOR(pg_catalog.+) 4;
965963
<title>Positional Parameters</title>
966964

967965
<para>
968-
A positional parameter reference is used to indicate aparameter
966+
A positional parameter reference is used to indicate avalue
969967
that is supplied externally to an SQL statement. Parameters are
970-
used in SQL function definitions and in prepared queries.
968+
used in SQL function definitions and in prepared queries. Some
969+
client libraries also support specifying data values separately
970+
from the SQL command string, in which case parameters are used to
971+
refer to the out-of-line data values.
971972
The form of a parameter reference is:
972973
<synopsis>
973974
$<replaceable>number</replaceable>

‎src/backend/parser/scan.l

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.107 2003/05/2922:30:02 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.108 2003/06/19 23:22:40 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -174,10 +174,10 @@ xcstop\*+\/
174174
xcinside[^*/]+
175175

176176
digit[0-9]
177-
letter[\200-\377_A-Za-z]
178-
letter_or_digit[\200-\377_A-Za-z0-9]
177+
ident_start[A-Za-z\200-\377_]
178+
ident_cont[A-Za-z\200-\377_0-9\$]
179179

180-
identifier{letter}{letter_or_digit}*
180+
identifier{ident_start}{ident_cont}*
181181

182182
typecast"::"
183183

@@ -191,8 +191,8 @@ typecast"::"
191191
* If you change either set, adjust the character lists appearing in the
192192
* rule for "operator"!
193193
*/
194-
self[,()\[\].;$\:\+\-\*\/\%\^\<\>\=]
195-
op_chars[\~\!\@\#\^\&\|\`\?\$\+\-\*\/\%\<\>\=]
194+
self[,()\[\].;\:\+\-\*\/\%\^\<\>\=]
195+
op_chars[\~\!\@\#\^\&\|\`\?\+\-\*\/\%\<\>\=]
196196
operator{op_chars}+
197197

198198
/* we no longer allow unary minus in numbers.
@@ -461,7 +461,7 @@ other.
461461

462462
for (ic = nchars-2; ic >=0; ic--)
463463
{
464-
if (strchr("~!@#^&|`?$%", yytext[ic]))
464+
if (strchr("~!@#^&|`?%", yytext[ic]))
465465
break;
466466
}
467467
if (ic >=0)
@@ -480,7 +480,7 @@ other.
480480
* that the "self" rule would have.
481481
*/
482482
if (nchars ==1 &&
483-
strchr(",()[].;$:+-*/%^<>=", yytext[0]))
483+
strchr(",()[].;:+-*/%^<>=", yytext[0]))
484484
return yytext[0];
485485
}
486486

‎src/pl/plpgsql/src/scan.l

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* procedural language
55
*
66
* IDENTIFICATION
7-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.27 2003/06/17 04:35:03 tgl Exp $
7+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.28 2003/06/19 23:22:40 tgl Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -72,12 +72,14 @@ intplpgsql_SpaceScanned = 0;
7272
%xIN_STRINGIN_COMMENT
7373

7474
digit[0-9]
75-
letter[\200-\377_A-Za-z]
76-
letter_or_digit[\200-\377_A-Za-z0-9]
75+
ident_start[A-Za-z\200-\377_]
76+
ident_cont[A-Za-z\200-\377_0-9\$]
7777

7878
quoted_ident(\"[^\"]*\")+
7979

80-
identifier({letter}{letter_or_digit}*|{quoted_ident})
80+
identifier({ident_start}{ident_cont}*|{quoted_ident})
81+
82+
param\${digit}+
8183

8284
space[\t\n\r\f]
8385

@@ -197,28 +199,28 @@ dump{ return O_DUMP;}
197199
{identifier}{space}*\.{space}*{identifier}{space}*%ROWTYPE{
198200
plpgsql_error_lineno =plpgsql_scanner_lineno();
199201
returnplpgsql_parse_dblwordrowtype(yytext); }
200-
\${digit}+{
202+
{param}{
201203
plpgsql_error_lineno =plpgsql_scanner_lineno();
202204
returnplpgsql_parse_word(yytext); }
203-
\${digit}+{space}*\.{space}*{identifier}{
205+
{param}{space}*\.{space}*{identifier}{
204206
plpgsql_error_lineno =plpgsql_scanner_lineno();
205207
returnplpgsql_parse_dblword(yytext); }
206-
\${digit}+{space}*\.{space}*{identifier}{space}*\.{space}*{identifier}{
208+
{param}{space}*\.{space}*{identifier}{space}*\.{space}*{identifier}{
207209
plpgsql_error_lineno =plpgsql_scanner_lineno();
208210
returnplpgsql_parse_tripword(yytext); }
209-
\${digit}+{space}*%TYPE{
211+
{param}{space}*%TYPE{
210212
plpgsql_error_lineno =plpgsql_scanner_lineno();
211213
returnplpgsql_parse_wordtype(yytext); }
212-
\${digit}+{space}*\.{space}*{identifier}{space}*%TYPE{
214+
{param}{space}*\.{space}*{identifier}{space}*%TYPE{
213215
plpgsql_error_lineno =plpgsql_scanner_lineno();
214216
returnplpgsql_parse_dblwordtype(yytext); }
215-
\${digit}+{space}*\.{space}*{identifier}{space}*\.{space}*{identifier}{space}*%TYPE{
217+
{param}{space}*\.{space}*{identifier}{space}*\.{space}*{identifier}{space}*%TYPE{
216218
plpgsql_error_lineno =plpgsql_scanner_lineno();
217219
returnplpgsql_parse_tripwordtype(yytext); }
218-
\${digit}+{space}*%ROWTYPE{
220+
{param}{space}*%ROWTYPE{
219221
plpgsql_error_lineno =plpgsql_scanner_lineno();
220222
returnplpgsql_parse_wordrowtype(yytext); }
221-
\${digit}+{space}*\.{space}*{identifier}{space}*%ROWTYPE{
223+
{param}{space}*\.{space}*{identifier}{space}*%ROWTYPE{
222224
plpgsql_error_lineno =plpgsql_scanner_lineno();
223225
returnplpgsql_parse_dblwordrowtype(yytext); }
224226

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp