Skip to content

Commit 773358e

Browse files
committed
cleanup
1 parent 0a70b21 commit 773358e

File tree

5 files changed

+37
-43
lines changed

5 files changed

+37
-43
lines changed

doc/src/sgml/ref/create_index.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] <replaceable class=
151151
benefit from <firstterm>index-only scans</> by including certain
152152
columns in the index, the value of which would otherwise have to be
153153
obtained by reading the table's heap. Having these columns in the
154-
<literal>INCLUDING</> clause in some cases allows
154+
<literal>INCLUDING</> clause in some cases allows
155155
<productname>PostgreSQL</> to skip the heap read completely. This
156156
also allows <literal>UNIQUE</> indexes to be defined on one set of
157157
columns, which can include another set of column in the

doc/src/sgml/ref/create_table.sgml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
499499
primary key constraint defined for the table. (Otherwise it
500500
would just be the same constraint listed twice.)
501501
</para>
502+
502503
<para>
503504
Adding a unique constraint will automatically create a unique btree
504505
index on the column or group of columns used in the constraint.
@@ -510,13 +511,16 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
510511
See paragraph about <literal>INCLUDING</literal> in
511512
<xref linkend="SQL-CREATEINDEX"> for more information.
512513
</para>
514+
513515
</listitem>
514516
</varlistentry>
515517

516518
<varlistentry>
517519
<term><literal>PRIMARY KEY</> (column constraint)</term>
518520
<term><literal>PRIMARY KEY ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] )
519-
<optional>INCLUDING ( <replaceable class="PARAMETER">column_name</replaceable> [, ...])</optional></> (table constraint)</term> <listitem>
521+
<optional>INCLUDING ( <replaceable class="PARAMETER">column_name</replaceable> [, ...])</optional></> (table constraint)</term>
522+
523+
<listitem>
520524
<para>
521525
The <literal>PRIMARY KEY</> constraint specifies that a column or
522526
columns of a table can contain only unique (non-duplicate), nonnull

src/backend/access/common/indextuple.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,5 @@ index_truncate_tuple(Relation idxrel, IndexTuple olditup)
471471
itupdesc->natts = indnatts;
472472

473473
Assert(IndexTupleSize(newitup) <= IndexTupleSize(olditup));
474-
475474
return newitup;
476475
}

src/backend/access/index/genam.c

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -247,36 +247,33 @@ BuildIndexValueDescription(Relation indexRelation,
247247
appendStringInfo(&buf, "(%s)=(",
248248
pg_get_indexdef_columns(indexrelid, true));
249249

250-
for (i = 0; i < indnkeyatts; i++)
251-
{
252-
char *val;
253-
254-
if (isnull[i])
255-
val = "null";
256-
else
257-
{
258-
Oid foutoid;
259-
bool typisvarlena;
260-
/*
261-
* The provided data is not necessarily of the type stored in the
262-
* index; rather it is of the index opclass's input type. So look
263-
* at rd_opcintype not the index tupdesc.
264-
*
265-
* Note: this is a bit shaky for opclasses that have pseudotype
266-
* input types such as ANYARRAY or RECORD. Currently, the
267-
* typoutput functions associated with the pseudotypes will work
268-
* okay, but we might have to try harder in future.
269-
*/
270-
getTypeOutputInfo(indexRelation->rd_opcintype[i],
271-
&foutoid, &typisvarlena);
272-
val = OidOutputFunctionCall(foutoid, values[i]);
273-
}
250+
char *val;
274251

275-
if (i > 0)
276-
appendStringInfoString(&buf, ", ");
277-
appendStringInfoString(&buf, val);
252+
if (isnull[i])
253+
val = "null";
254+
else
255+
{
256+
Oid foutoid;
257+
bool typisvarlena;
258+
/*
259+
* The provided data is not necessarily of the type stored in the
260+
* index; rather it is of the index opclass's input type. So look
261+
* at rd_opcintype not the index tupdesc.
262+
*
263+
* Note: this is a bit shaky for opclasses that have pseudotype
264+
* input types such as ANYARRAY or RECORD. Currently, the
265+
* typoutput functions associated with the pseudotypes will work
266+
* okay, but we might have to try harder in future.
267+
*/
268+
getTypeOutputInfo(indexRelation->rd_opcintype[i],
269+
&foutoid, &typisvarlena);
270+
val = OidOutputFunctionCall(foutoid, values[i]);
278271
}
279272

273+
if (i > 0)
274+
appendStringInfoString(&buf, ", ");
275+
appendStringInfoString(&buf, val);
276+
280277
appendStringInfoChar(&buf, ')');
281278

282279
return buf.data;

src/backend/access/nbtree/nbtsort.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -628,25 +628,19 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, IndexTuple itup)
628628
* Truncate the tuple that we're going to insert
629629
* into the parent page as a downlink
630630
*/
631-
if (indnkeyatts < indnatts && P_ISLEAF(pageop))
632-
state->btps_minkey = index_truncate_tuple(wstate->index, itup);
633-
else
634-
state->btps_minkey = CopyIndexTuple(itup); }
635-
636-
/* Truncate nonkey attributes when inserting on nonleaf pages */
637-
if (wstate->index->rd_index->indnatts
638-
!= wstate->index->rd_index->indnkeyatts)
639-
{
640-
BTPageOpaque pageop = (BTPageOpaque) PageGetSpecialPointer(npage);
641-
642-
if (!P_ISLEAF(pageop))
631+
if (indnkeyatts != indnatts && P_ISLEAF(pageop))
643632
{
644-
itup = index_truncate_tuple(wstate->index, itup);
633+
state->btps_minkey = index_truncate_tuple(wstate->index, itup);
645634
itupsz = IndexTupleDSize(*itup);
646635
itupsz = MAXALIGN(itupsz);
647636
}
637+
else
638+
state->btps_minkey = CopyIndexTuple(itup);
648639
}
649640

641+
642+
643+
650644
/*
651645
* Add the new item into the current page.
652646
*/

0 commit comments

Comments
 (0)