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

Commitee4ddac

Browse files
committed
Convert index-related tuple handling routines from char 'n'/' ' to bool
convention for isnull flags. Also, remove the useless InsertIndexResultreturn struct from index AM aminsert calls --- there is no reason forthe caller to know where in the index the tuple was inserted, and wewere wasting a palloc cycle per insert to deliver this uninterestingvalue (plus nontrivial complexity in some AMs).I forced initdb because of the change in the signature of the aminsertroutines, even though nothing really looks at those pg_proc entries...
1 parentfe7015f commitee4ddac

File tree

24 files changed

+289
-406
lines changed

24 files changed

+289
-406
lines changed

‎doc/src/sgml/indexam.sgml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/indexam.sgml,v 2.1 2005/02/13 03:04:15 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/indexam.sgml,v 2.2 2005/03/21 01:23:55 tgl Exp $
33
-->
44

55
<chapter id="indexam">
@@ -151,25 +151,26 @@ ambuild (Relation heapRelation,
151151

152152
<para>
153153
<programlisting>
154-
InsertIndexResult
154+
bool
155155
aminsert (Relation indexRelation,
156-
Datum *datums,
157-
char *nulls,
156+
Datum *values,
157+
bool *isnull,
158158
ItemPointer heap_tid,
159159
Relation heapRelation,
160160
bool check_uniqueness);
161161
</programlisting>
162-
Insert a new tuple into an existing index. The <literal>datums</> and
163-
<literal>nulls</> arrays give the key values to be indexed, and
162+
Insert a new tuple into an existing index. The <literal>values</> and
163+
<literal>isnull</> arrays give the key values to be indexed, and
164164
<literal>heap_tid</> is the TID to be indexed.
165165
If the access method supports unique indexes (its
166166
<structname>pg_am</>.<structfield>amcanunique</> flag is true) then
167167
<literal>check_uniqueness</> may be true, in which case the access method
168168
must verify that there is no conflicting row; this is the only situation in
169169
which the access method normally needs the <literal>heapRelation</>
170170
parameter. See <xref linkend="index-unique-checks"> for details.
171-
The result is a struct that must be pfree'd by the caller. (The result
172-
struct is really quite useless and should be removed...)
171+
The result is TRUE if an index entry was inserted, FALSE if not. (A FALSE
172+
result does not denote an error condition, but is used for cases such
173+
as an index AM refusing to index a NULL.)
173174
</para>
174175

175176
<para>

‎src/backend/access/common/heaptuple.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.98 2005/03/16 21:38:04 tgl Exp $
19+
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.99 2005/03/21 01:23:55 tgl Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -68,7 +68,7 @@ heap_compute_data_size(TupleDesc tupleDesc,
6868
* OLD API with char 'n'/' ' convention for indicating nulls
6969
* ----------------
7070
*/
71-
Size
71+
staticSize
7272
ComputeDataSize(TupleDesctupleDesc,
7373
Datum*values,
7474
char*nulls)
@@ -193,7 +193,7 @@ heap_fill_tuple(TupleDesc tupleDesc,
193193
* OLD API with char 'n'/' ' convention for indicating nulls
194194
* ----------------
195195
*/
196-
void
196+
staticvoid
197197
DataFill(char*data,
198198
TupleDesctupleDesc,
199199
Datum*values,

‎src/backend/access/common/indextuple.c

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.72 2004/12/31 21:59:07 pgsql Exp $
12+
* $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.73 2005/03/21 01:23:55 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -28,13 +28,13 @@
2828
*/
2929

3030
/* ----------------
31-
*index_formtuple
31+
*index_form_tuple
3232
* ----------------
3333
*/
3434
IndexTuple
35-
index_formtuple(TupleDesctupleDescriptor,
36-
Datum*value,
37-
char*null)
35+
index_form_tuple(TupleDesctupleDescriptor,
36+
Datum*values,
37+
bool*isnull)
3838
{
3939
char*tp;/* tuple pointer */
4040
IndexTupletuple;/* return tuple */
@@ -47,7 +47,7 @@ index_formtuple(TupleDesc tupleDescriptor,
4747
intnumberOfAttributes=tupleDescriptor->natts;
4848

4949
#ifdefTOAST_INDEX_HACK
50-
Datumuntoasted_value[INDEX_MAX_KEYS];
50+
Datumuntoasted_values[INDEX_MAX_KEYS];
5151
booluntoasted_free[INDEX_MAX_KEYS];
5252
#endif
5353

@@ -62,41 +62,41 @@ index_formtuple(TupleDesc tupleDescriptor,
6262
{
6363
Form_pg_attributeatt=tupleDescriptor->attrs[i];
6464

65-
untoasted_value[i]=value[i];
65+
untoasted_values[i]=values[i];
6666
untoasted_free[i]= false;
6767

6868
/* Do nothing if value is NULL or not of varlena type */
69-
if (null[i]!=' '||att->attlen!=-1)
69+
if (isnull[i]||att->attlen!=-1)
7070
continue;
7171

7272
/*
7373
* If value is stored EXTERNAL, must fetch it so we are not
7474
* depending on outside storage. This should be improved someday.
7575
*/
76-
if (VARATT_IS_EXTERNAL(value[i]))
76+
if (VARATT_IS_EXTERNAL(values[i]))
7777
{
78-
untoasted_value[i]=PointerGetDatum(
78+
untoasted_values[i]=PointerGetDatum(
7979
heap_tuple_fetch_attr(
80-
(varattrib*)DatumGetPointer(value[i])));
80+
(varattrib*)DatumGetPointer(values[i])));
8181
untoasted_free[i]= true;
8282
}
8383

8484
/*
8585
* If value is above size target, and is of a compressible
8686
* datatype, try to compress it in-line.
8787
*/
88-
if (VARATT_SIZE(untoasted_value[i])>TOAST_INDEX_TARGET&&
89-
!VARATT_IS_EXTENDED(untoasted_value[i])&&
88+
if (VARATT_SIZE(untoasted_values[i])>TOAST_INDEX_TARGET&&
89+
!VARATT_IS_EXTENDED(untoasted_values[i])&&
9090
(att->attstorage=='x'||att->attstorage=='m'))
9191
{
92-
Datumcvalue=toast_compress_datum(untoasted_value[i]);
92+
Datumcvalue=toast_compress_datum(untoasted_values[i]);
9393

9494
if (DatumGetPointer(cvalue)!=NULL)
9595
{
9696
/* successful compression */
9797
if (untoasted_free[i])
98-
pfree(DatumGetPointer(untoasted_value[i]));
99-
untoasted_value[i]=cvalue;
98+
pfree(DatumGetPointer(untoasted_values[i]));
99+
untoasted_values[i]=cvalue;
100100
untoasted_free[i]= true;
101101
}
102102
}
@@ -105,7 +105,7 @@ index_formtuple(TupleDesc tupleDescriptor,
105105

106106
for (i=0;i<numberOfAttributes;i++)
107107
{
108-
if (null[i]!=' ')
108+
if (isnull[i])
109109
{
110110
hasnull= true;
111111
break;
@@ -117,41 +117,42 @@ index_formtuple(TupleDesc tupleDescriptor,
117117

118118
hoff=IndexInfoFindDataOffset(infomask);
119119
#ifdefTOAST_INDEX_HACK
120-
size=hoff+ComputeDataSize(tupleDescriptor,untoasted_value,null);
120+
size=hoff+heap_compute_data_size(tupleDescriptor,
121+
untoasted_values,isnull);
121122
#else
122-
size=hoff+ComputeDataSize(tupleDescriptor,value,null);
123+
size=hoff+heap_compute_data_size(tupleDescriptor,
124+
values,isnull);
123125
#endif
124126
size=MAXALIGN(size);/* be conservative */
125127

126128
tp= (char*)palloc0(size);
127129
tuple= (IndexTuple)tp;
128130

129-
DataFill((char*)tp+hoff,
130-
tupleDescriptor,
131+
heap_fill_tuple(tupleDescriptor,
131132
#ifdefTOAST_INDEX_HACK
132-
untoasted_value,
133+
untoasted_values,
133134
#else
134-
value,
135+
values,
135136
#endif
136-
null,
137-
&tupmask,
138-
(hasnull ? (bits8*)tp+sizeof(*tuple) :NULL));
137+
isnull,
138+
(char*)tp+hoff,
139+
&tupmask,
140+
(hasnull ? (bits8*)tp+sizeof(*tuple) :NULL));
139141

140142
#ifdefTOAST_INDEX_HACK
141143
for (i=0;i<numberOfAttributes;i++)
142144
{
143145
if (untoasted_free[i])
144-
pfree(DatumGetPointer(untoasted_value[i]));
146+
pfree(DatumGetPointer(untoasted_values[i]));
145147
}
146148
#endif
147149

148150
/*
149-
* We do this becauseDataFill wants to initialize a "tupmask" which
150-
* is used for HeapTuples, but we want an indextuple infomask.The
151-
* only relevant info is the "has variable attributes" field. We have
152-
* already set the hasnull bit above.
151+
* We do this becauseheap_fill_tuple wants to initialize a "tupmask"
152+
*whichis used for HeapTuples, but we want an indextuple infomask.
153+
*Theonly relevant info is the "has variable attributes" field.
154+
*We havealready set the hasnull bit above.
153155
*/
154-
155156
if (tupmask&HEAP_HASVARWIDTH)
156157
infomask |=INDEX_VAR_MASK;
157158

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp