Skip to content

Commit e926e3c

Browse files
committed
improved INSERT statement
1 parent e413225 commit e926e3c

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

doc/src/sgml/dump_stat.sgml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,30 @@
5151
The <literal>INSERT</> statement takes form of
5252
<screen>
5353
WITH upsert as (
54-
UPDATE pg_catalog.pg_statistic SET %s
55-
WHERE to_schema_qualified_relation(starelid) = relname
56-
AND to_attname(relname, staattnum) = attname
57-
AND to_atttype(relname, staattnum) = atttype
58-
AND stainherit = r.stainherit
54+
UPDATE pg_catalog.pg_statistic SET <replaceable class="PARAMETER">column_name</> = <replaceable class="PARAMETER">expression</> [, ...]
55+
WHERE to_schema_qualified_relation(starelid) = <replaceable class="PARAMETER">t_relname</>
56+
AND to_attname(<replaceable class="PARAMETER">t_relname</>, staattnum) = <replaceable class="PARAMETER">t_attname</>
57+
AND to_atttype(<replaceable class="PARAMETER">t_relname</>, staattnum) = <replaceable class="PARAMETER">t_atttype</>
58+
AND stainherit = <replaceable class="PARAMETER">t_stainherit</>
5959
RETURNING *)
6060
ins as (
61-
SELECT %s
61+
SELECT <replaceable class="PARAMETER">expression</> [, ...]
6262
WHERE NOT EXISTS (SELECT * FROM upsert)
63-
AND to_attnum(relname, attname) IS NOT NULL
64-
AND to_atttype(relname, attname) = atttype)
63+
AND to_attnum(<replaceable class="PARAMETER">t_relname</>, <replaceable class="PARAMETER">t_attname</>) IS NOT NULL
64+
AND to_atttype(<replaceable class="PARAMETER">t_relname</>, <replaceable class="PARAMETER">t_attname</>) = <replaceable class="PARAMETER">t_atttype</>)
6565
INSERT INTO pg_catalog.pg_statistic SELECT * FROM ins;
66+
67+
where <replaceable class="PARAMETER">expression</> can be one of:
68+
69+
array_in(<replaceable class="PARAMETER">array_text</>, <replaceable class="PARAMETER">type_name</>::regtype::oid, -1)
70+
<replaceable class="PARAMETER">value</>::<replaceable class="PARAMETER">type_name</>
6671
</screen>
6772
</para>
6873

6974
<para>
7075
Produced statements could be saved to a file, e.g.
7176
<screen>
72-
\COPY (select dump_statistic()) TO 'dump_stat.sql'
77+
test=# \COPY (select dump_statistic()) TO 'dump_stat.sql'
7378
</screen>
7479
</para>
7580
</listitem>

0 commit comments

Comments
 (0)