Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
e4eb9104
Commit
e4eb9104
authored
Dec 18, 2000
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document the array_dims() function, and make some other small improvements
in the docs for arrays.
parent
1f159e56
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
18 deletions
+45
-18
doc/src/sgml/advanced.sgml
doc/src/sgml/advanced.sgml
+5
-4
doc/src/sgml/array.sgml
doc/src/sgml/array.sgml
+35
-7
doc/src/sgml/syntax.sgml
doc/src/sgml/syntax.sgml
+5
-7
No files found.
doc/src/sgml/advanced.sgml
View file @
e4eb9104
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.1
6 2000/09/29 20:21:33 petere
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.1
7 2000/12/18 23:39:37 tgl
Exp $
-->
-->
<chapter id="advanced">
<chapter id="advanced">
...
@@ -178,7 +178,7 @@ CREATE TABLE SAL_EMP (
...
@@ -178,7 +178,7 @@ CREATE TABLE SAL_EMP (
salary by quarter and a two-dimensional array of
salary by quarter and a two-dimensional array of
<firstterm>text</firstterm>
<firstterm>text</firstterm>
(schedule), which represents the employee's weekly
(schedule), which represents the employee's weekly
schedule. Now we do some <firstterm>INSERT
S
</firstterm>s;
schedule. Now we do some <firstterm>INSERT</firstterm>s;
note that when
note that when
appending to an array, we enclose the values within
appending to an array, we enclose the values within
braces and separate them by commas. If you know
braces and separate them by commas. If you know
...
@@ -239,8 +239,9 @@ SELECT SAL_EMP.pay_by_quarter[3] FROM SAL_EMP;
...
@@ -239,8 +239,9 @@ SELECT SAL_EMP.pay_by_quarter[3] FROM SAL_EMP;
</para>
</para>
<para>
<para>
We can also access arbitrary slices of an array, or
We can also access arbitrary slices of an array (subarrays)
subarrays. This query retrieves the first item on
by specifying both lower and upper bounds for
each subscript. This query retrieves the first item on
Bill's schedule for the first two days of the week.
Bill's schedule for the first two days of the week.
<programlisting>
<programlisting>
...
...
doc/src/sgml/array.sgml
View file @
e4eb9104
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/array.sgml,v 1.8 2000/12/18 23:39:37 tgl Exp $
-->
<Chapter Id="arrays">
<Chapter Id="arrays">
<Title>Arrays</Title>
<Title>Arrays</Title>
...
@@ -30,7 +34,7 @@ CREATE TABLE sal_emp (
...
@@ -30,7 +34,7 @@ CREATE TABLE sal_emp (
(pay_by_quarter), which represents the employee's
(pay_by_quarter), which represents the employee's
salary by quarter, and a two-dimensional array of <FirstTerm>text</FirstTerm>
salary by quarter, and a two-dimensional array of <FirstTerm>text</FirstTerm>
(schedule), which represents the employee's weekly
(schedule), which represents the employee's weekly
schedule. Now we do some <FirstTerm>INSERT
S
</FirstTerm>s; note that when
schedule. Now we do some <FirstTerm>INSERT</FirstTerm>s; note that when
appending to an array, we enclose the values within
appending to an array, we enclose the values within
braces and separate them by commas. If you know <FirstTerm>C</FirstTerm>,
braces and separate them by commas. If you know <FirstTerm>C</FirstTerm>,
this is not unlike the syntax for initializing structures.
this is not unlike the syntax for initializing structures.
...
@@ -82,9 +86,10 @@ SELECT pay_by_quarter[3] FROM sal_emp;
...
@@ -82,9 +86,10 @@ SELECT pay_by_quarter[3] FROM sal_emp;
</Para>
</Para>
<Para>
<Para>
We can also access arbitrary slices of an array, or
We can also access arbitrary
rectangular
slices of an array, or
subarrays. An array slice is denoted by writing
subarrays. An array slice is denoted by writing
"lower subscript : upper subscript" for one or more array
<replaceable>lower subscript</replaceable> <literal>:</literal>
<replaceable>upper subscript</replaceable> for one or more array
dimensions. This query retrieves the first item on
dimensions. This query retrieves the first item on
Bill's schedule for the first two days of the week:
Bill's schedule for the first two days of the week:
...
@@ -103,7 +108,11 @@ SELECT schedule[1:2][1:1] FROM sal_emp WHERE name = 'Bill';
...
@@ -103,7 +108,11 @@ SELECT schedule[1:2][1:1] FROM sal_emp WHERE name = 'Bill';
SELECT schedule[1:2][1] FROM sal_emp WHERE name = 'Bill';
SELECT schedule[1:2][1] FROM sal_emp WHERE name = 'Bill';
</ProgramListing>
</ProgramListing>
with the same result.
with the same result. An array subscripting operation is taken to
represent an array slice if any of the subscripts are written in
the form <replaceable>lower</replaceable> <literal>:</literal>
<replaceable>upper</replaceable>. A lower bound of 1 is assumed
for any subscript where only one value is specified.
</Para>
</Para>
<Para>
<Para>
...
@@ -114,7 +123,7 @@ UPDATE sal_emp SET pay_by_quarter = '{25000,25000,27000,27000}'
...
@@ -114,7 +123,7 @@ UPDATE sal_emp SET pay_by_quarter = '{25000,25000,27000,27000}'
WHERE name = 'Carol';
WHERE name = 'Carol';
</ProgramListing>
</ProgramListing>
or updated at a single e
ntry
:
or updated at a single e
lement
:
<ProgramListing>
<ProgramListing>
UPDATE sal_emp SET pay_by_quarter[4] = 15000
UPDATE sal_emp SET pay_by_quarter[4] = 15000
...
@@ -132,10 +141,11 @@ UPDATE sal_emp SET pay_by_quarter[1:2] = '{27000,27000}'
...
@@ -132,10 +141,11 @@ UPDATE sal_emp SET pay_by_quarter[1:2] = '{27000,27000}'
<Para>
<Para>
An array can be enlarged by assigning to an element adjacent to
An array can be enlarged by assigning to an element adjacent to
those already present, or by assigning to a slice that is adjacent
those already present, or by assigning to a slice that is adjacent
to or overlaps the data already present. Currently, this is only
to or overlaps the data already present.
allowed for one-dimensional arrays, not multidimensional arrays.
For example, if an array value currently has 4 elements, it will
For example, if an array value currently has 4 elements, it will
have five elements after an update that assigns to array[5].
have five elements after an update that assigns to array[5].
Currently, enlargement in this fashion is only
allowed for one-dimensional arrays, not multidimensional arrays.
</Para>
</Para>
<Para>
<Para>
...
@@ -160,4 +170,22 @@ CREATE TABLE tictactoe (
...
@@ -160,4 +170,22 @@ CREATE TABLE tictactoe (
number of dimensions.
number of dimensions.
</Para>
</Para>
<Para>
The current dimensions of any array value can be retrieved with
the <function>array_dims</function> function:
<ProgramListing>
SELECT array_dims(schedule) FROM sal_emp WHERE name = 'Carol';
array_dims
------------
[1:2][1:1]
(1 row)
</ProgramListing>
<function>array_dims</function> produces a <type>text</type> result,
which is convenient for people to read but perhaps not so convenient
for programs.
</Para>
</Chapter>
</Chapter>
doc/src/sgml/syntax.sgml
View file @
e4eb9104
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.2
8 2000/12/17 05:47:5
7 tgl Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.2
9 2000/12/18 23:39:3
7 tgl Exp $
-->
-->
<chapter id="syntax">
<chapter id="syntax">
...
@@ -555,12 +555,10 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> )
...
@@ -555,12 +555,10 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> )
</para>
</para>
<para>
<para>
Individual array elements can be placed between single-quote
Individual array elements can be placed between double-quote
marks to avoid ambiguity problems with respect to leading white space.
marks (<literal>"</literal>) to avoid ambiguity problems with respect to
Without quote marks, the array-value parser will skip white space.
white space.
Note that to write a quote mark inside a string literal that is to
Without quote marks, the array-value parser will skip leading white space.
become an array value, you must double the quote mark as described
previously.
</para>
</para>
</sect2>
</sect2>
</sect1>
</sect1>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment