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

Commit64caee7

Browse files
committed
Give the full syntax rules for subscripting and field selection in the
proper place, namely the syntax discussion of value expressions.
1 parentc58083a commit64caee7

File tree

1 file changed

+94
-20
lines changed

1 file changed

+94
-20
lines changed

‎doc/src/sgml/syntax.sgml

Lines changed: 94 additions & 20 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.86 2003/11/0409:55:39 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.87 2003/11/0419:18:15 tgl Exp $
33
-->
44

55
<chapter id="sql-syntax">
@@ -185,7 +185,7 @@ UPDATE "my_table" SET "a" = 5;
185185

186186
<para>
187187
Quoted identifiers can contain any character other than a double
188-
quote itself. To include a double quote, write two double quotes.
188+
quote itself.(To include a double quote, write two double quotes.)
189189
This allows constructing table or column names that would
190190
otherwise not be possible, such as ones containing spaces or
191191
ampersands. The length limitation still applies.
@@ -449,7 +449,7 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> )
449449
</indexterm>
450450

451451
<para>
452-
An operator is a sequence of up to <symbol>NAMEDATALEN</symbol>-1
452+
An operatornameis a sequence of up to <symbol>NAMEDATALEN</symbol>-1
453453
(63 by default) characters from the following list:
454454
<literallayout>
455455
+ - * / &lt; &gt; = ~ ! @ # % ^ &amp; | ` ?
@@ -855,6 +855,18 @@ SELECT 3 OPERATOR(pg_catalog.+) 4;
855855
</para>
856856
</listitem>
857857

858+
<listitem>
859+
<para>
860+
A subscripted expression.
861+
</para>
862+
</listitem>
863+
864+
<listitem>
865+
<para>
866+
A field selection expression.
867+
</para>
868+
</listitem>
869+
858870
<listitem>
859871
<para>
860872
An operator invocation.
@@ -928,31 +940,18 @@ SELECT 3 OPERATOR(pg_catalog.+) 4;
928940
<synopsis>
929941
<replaceable>correlation</replaceable>.<replaceable>columnname</replaceable>
930942
</synopsis>
931-
or
932-
<synopsis>
933-
<replaceable>correlation</replaceable>.<replaceable>columnname</replaceable>[<replaceable>subscript</replaceable>]
934-
</synopsis>
935-
(Here, the brackets <literal>[ ]</literal> are meant to appear literally.)
936943
</para>
937944

938945
<para>
939946
<replaceable>correlation</replaceable> is the name of a
940-
table (possibly qualified), or an alias for a table defined by means of a
941-
<literal>FROM</literal> clause, or
947+
table (possibly qualified with a schema name), or an alias for a table
948+
defined by means of a<literal>FROM</literal> clause, orone of
942949
the key words <literal>NEW</literal> or <literal>OLD</literal>.
943950
(<literal>NEW</literal> and <literal>OLD</literal> can only appear in rewrite rules,
944951
while other correlation names can be used in any SQL statement.)
945952
The correlation name and separating dot may be omitted if the column name
946953
is unique across all the tables being used in the current query. (See also <xref linkend="queries">.)
947954
</para>
948-
949-
<para>
950-
If <replaceable>column</replaceable> is of an array type, then the
951-
optional <replaceable>subscript</replaceable> selects a specific
952-
element or elements in the array. If no subscript is provided, then the
953-
whole array is selected. (See <xref linkend="arrays"> for more about
954-
arrays.)
955-
</para>
956955
</sect2>
957956

958957
<sect2>
@@ -995,6 +994,81 @@ CREATE FUNCTION dept(text) RETURNS dept
995994
</para>
996995
</sect2>
997996

997+
<sect2>
998+
<title>Subscripts</title>
999+
1000+
<indexterm>
1001+
<primary>subscript</primary>
1002+
</indexterm>
1003+
1004+
<para>
1005+
If an expression yields a value of an array type, then a specific
1006+
element of the array value can be extracted by writing
1007+
<synopsis>
1008+
<replaceable>expression</replaceable>[<replaceable>subscript</replaceable>]
1009+
</synopsis>
1010+
or multiple adjacent elements (an <quote>array slice</>) can be extracted
1011+
by writing
1012+
<synopsis>
1013+
<replaceable>expression</replaceable>[<replaceable>lower_subscript</replaceable>:<replaceable>upper_subscript</replaceable>]
1014+
</synopsis>
1015+
(Here, the brackets <literal>[ ]</literal> are meant to appear literally.)
1016+
Each <replaceable>subscript</replaceable> is itself an expression,
1017+
which must yield an integer value.
1018+
</para>
1019+
1020+
<para>
1021+
In general the array <replaceable>expression</replaceable> must be
1022+
parenthesized, but the parentheses may be omitted when the expression
1023+
to be subscripted is just a column reference or positional parameter.
1024+
Also, multiple subscripts can be concatenated when the original array
1025+
is multi-dimensional.
1026+
For example,
1027+
1028+
<programlisting>
1029+
mytable.arraycolumn[4]
1030+
mytable.two_d_column[17][34]
1031+
$1[10:42]
1032+
(arrayfunction(a,b))[42]
1033+
</programlisting>
1034+
1035+
The parentheses in the last example are required.
1036+
See <xref linkend="arrays"> for more about arrays.
1037+
</para>
1038+
</sect2>
1039+
1040+
<sect2>
1041+
<title>Field Selection</title>
1042+
1043+
<indexterm>
1044+
<primary>field selection</primary>
1045+
</indexterm>
1046+
1047+
<para>
1048+
If an expression yields a value of a composite type (row type), then a
1049+
specific field of the row can be extracted by writing
1050+
<synopsis>
1051+
<replaceable>expression</replaceable>.<replaceable>fieldname</replaceable>
1052+
</synopsis>
1053+
</para>
1054+
1055+
<para>
1056+
In general the row <replaceable>expression</replaceable> must be
1057+
parenthesized, but the parentheses may be omitted when the expression
1058+
to be selected from is just a table reference or positional parameter.
1059+
For example,
1060+
1061+
<programlisting>
1062+
mytable.mycolumn
1063+
$1.somecolumn
1064+
(rowfunction(a,b)).col3
1065+
</programlisting>
1066+
1067+
(Thus, a qualified column reference is actually just a special case
1068+
of the field selection syntax.)
1069+
</para>
1070+
</sect2>
1071+
9981072
<sect2>
9991073
<title>Operator Invocations</title>
10001074

@@ -1013,7 +1087,7 @@ CREATE FUNCTION dept(text) RETURNS dept
10131087
where the <replaceable>operator</replaceable> token follows the syntax
10141088
rules of <xref linkend="sql-syntax-operators">, or is one of the
10151089
key words <token>AND</token>, <token>OR</token>, and
1016-
<token>NOT</token>, or is a qualified operator name
1090+
<token>NOT</token>, or is a qualified operator name in the form
10171091
<synopsis>
10181092
<literal>OPERATOR(</><replaceable>schema</><literal>.</><replaceable>operatorname</><literal>)</>
10191093
</synopsis>
@@ -1078,7 +1152,7 @@ sqrt(2)
10781152
</synopsis>
10791153

10801154
where <replaceable>aggregate_name</replaceable> is a previously
1081-
defined aggregate (possiblya qualified name), and
1155+
defined aggregate (possiblyqualified with a schema name), and
10821156
<replaceable>expression</replaceable> is
10831157
any value expression that does not itself contain an aggregate
10841158
expression.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp