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

Commit48165ec

Browse files
committed
Latest round of fmgr updates. All functions with bool,char, or int2
inputs have been converted to newstyle. This should go a long way towardsfixing our portability problems with platforms where char and shortparameters are passed differently from int-width parameters. Stillmore to do for the Alpha port however.
1 parentc61db5b commit48165ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2175
-2008
lines changed

‎src/backend/access/hash/hashfunc.c

Lines changed: 100 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.25 2000/04/12 17:14:44 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.26 2000/06/05 07:28:35 tgl Exp $
1212
*
1313
* NOTES
1414
* These functions are stored in pg_amproc.For each operator class
@@ -21,190 +21,183 @@
2121

2222
#include"access/hash.h"
2323

24-
uint32
25-
hashint2(int16key)
24+
Datum
25+
hashint2(PG_FUNCTION_ARGS)
2626
{
27-
return (uint32) ~key;
27+
PG_RETURN_UINT32((uint32) ~PG_GETARG_INT16(0));
2828
}
2929

30-
uint32
31-
hashint4(uint32key)
30+
Datum
31+
hashint4(PG_FUNCTION_ARGS)
3232
{
33-
return ~key;
33+
PG_RETURN_UINT32(~PG_GETARG_UINT32(0));
3434
}
3535

36-
uint32
37-
hashint8(int64*key)
36+
Datum
37+
hashint8(PG_FUNCTION_ARGS)
3838
{
39-
return ~((uint32)*key);
39+
/* we just use the low 32 bits... */
40+
PG_RETURN_UINT32(~((uint32)PG_GETARG_INT64(0)));
4041
}
4142

4243
/* Hash function from Chris Torek. */
43-
uint32
44-
hashfloat4(float32keyp)
44+
Datum
45+
hashfloat4(PG_FUNCTION_ARGS)
4546
{
46-
intlen;
47+
float4key=PG_GETARG_FLOAT4(0);
48+
char*kp= (char*)&key;
49+
intlen=sizeof(key);
4750
intloop;
4851
uint32h;
49-
char*kp= (char*)keyp;
50-
51-
len=sizeof(float32data);
5252

5353
#defineHASH4a h = (h << 5) - h + *kp++;
5454
#defineHASH4b h = (h << 5) + h + *kp++;
5555
#defineHASH4 HASH4b
5656

57-
5857
h=0;
59-
if (len>0)
60-
{
61-
loop= (len+8-1) >>3;
58+
/*
59+
* This is a tad silly, given that we expect len = 4, but a smart
60+
* compiler should be able to eliminate the redundant code...
61+
*/
62+
loop= (len+8-1) >>3;
6263

63-
switch (len& (8-1))
64-
{
65-
case0:
66-
do
67-
{/* All fall throughs */
68-
HASH4;
69-
case7:
70-
HASH4;
71-
case6:
72-
HASH4;
73-
case5:
74-
HASH4;
75-
case4:
76-
HASH4;
77-
case3:
78-
HASH4;
79-
case2:
80-
HASH4;
81-
case1:
82-
HASH4;
83-
}while (--loop);
84-
}
64+
switch (len& (8-1))
65+
{
66+
case0:
67+
do
68+
{/* All fall throughs */
69+
HASH4;
70+
case7:
71+
HASH4;
72+
case6:
73+
HASH4;
74+
case5:
75+
HASH4;
76+
case4:
77+
HASH4;
78+
case3:
79+
HASH4;
80+
case2:
81+
HASH4;
82+
case1:
83+
HASH4;
84+
}while (--loop);
8585
}
86-
returnh;
86+
PG_RETURN_UINT32(h);
8787
}
8888

89-
90-
uint32
91-
hashfloat8(float64keyp)
89+
Datum
90+
hashfloat8(PG_FUNCTION_ARGS)
9291
{
93-
intlen;
92+
float8key=PG_GETARG_FLOAT8(0);
93+
char*kp= (char*)&key;
94+
intlen=sizeof(key);
9495
intloop;
9596
uint32h;
96-
char*kp= (char*)keyp;
97-
98-
len=sizeof(float64data);
9997

10098
#defineHASH4a h = (h << 5) - h + *kp++;
10199
#defineHASH4b h = (h << 5) + h + *kp++;
102100
#defineHASH4 HASH4b
103101

104-
105102
h=0;
106-
if (len>0)
107-
{
108-
loop= (len+8-1) >>3;
103+
/*
104+
* This is a tad silly, given that we expect len = 8, but a smart
105+
* compiler should be able to eliminate the redundant code...
106+
*/
107+
loop= (len+8-1) >>3;
109108

110-
switch (len& (8-1))
111-
{
112-
case0:
113-
do
114-
{/* All fall throughs */
115-
HASH4;
116-
case7:
117-
HASH4;
118-
case6:
119-
HASH4;
120-
case5:
121-
HASH4;
122-
case4:
123-
HASH4;
124-
case3:
125-
HASH4;
126-
case2:
127-
HASH4;
128-
case1:
129-
HASH4;
130-
}while (--loop);
131-
}
109+
switch (len& (8-1))
110+
{
111+
case0:
112+
do
113+
{/* All fall throughs */
114+
HASH4;
115+
case7:
116+
HASH4;
117+
case6:
118+
HASH4;
119+
case5:
120+
HASH4;
121+
case4:
122+
HASH4;
123+
case3:
124+
HASH4;
125+
case2:
126+
HASH4;
127+
case1:
128+
HASH4;
129+
}while (--loop);
132130
}
133-
returnh;
131+
PG_RETURN_UINT32(h);
134132
}
135133

136-
137-
uint32
138-
hashoid(Oidkey)
134+
Datum
135+
hashoid(PG_FUNCTION_ARGS)
139136
{
140-
return (uint32)~key;
137+
PG_RETURN_UINT32(~(uint32)PG_GETARG_OID(0));
141138
}
142139

143-
uint32
144-
hashoidvector(Oid*key)
140+
Datum
141+
hashoidvector(PG_FUNCTION_ARGS)
145142
{
143+
Oid*key= (Oid*)PG_GETARG_POINTER(0);
146144
inti;
147145
uint32result=0;
148146

149147
for (i=INDEX_MAX_KEYS;--i >=0;)
150148
result= (result <<1) ^ (~(uint32)key[i]);
151-
returnresult;
149+
PG_RETURN_UINT32(result);
152150
}
153151

154152
/*
155153
* Note: hashint2vector currently can't be used as a user hash table
156154
* hash function, because it has no pg_proc entry.We only need it
157155
* for catcache indexing.
158156
*/
159-
uint32
160-
hashint2vector(int16*key)
157+
Datum
158+
hashint2vector(PG_FUNCTION_ARGS)
161159
{
160+
int16*key= (int16*)PG_GETARG_POINTER(0);
162161
inti;
163162
uint32result=0;
164163

165164
for (i=INDEX_MAX_KEYS;--i >=0;)
166165
result= (result <<1) ^ (~(uint32)key[i]);
167-
returnresult;
166+
PG_RETURN_UINT32(result);
168167
}
169168

170169

171170
#definePRIME137
172171
#definePRIME21048583
173172

174-
uint32
175-
hashchar(charkey)
173+
Datum
174+
hashchar(PG_FUNCTION_ARGS)
176175
{
177176
uint32h;
178177

179178
/* Convert char to integer */
180-
h= (key-' ');
179+
h= (PG_GETARG_CHAR(0)-' ');
181180
h %=PRIME2;
182181

183-
returnh;
182+
PG_RETURN_UINT32(h);
184183
}
185184

186-
187-
uint32
188-
hashname(NameData*n)
185+
Datum
186+
hashname(PG_FUNCTION_ARGS)
189187
{
188+
char*key=NameStr(*PG_GETARG_NAME(0));
189+
intlen=NAMEDATALEN;
190190
uint32h;
191-
intlen;
192-
char*key;
193-
194-
key=NameStr(*n);
195191

196192
h=0;
197-
len=NAMEDATALEN;
198193
/* Convert string to integer */
199194
while (len--)
200195
h=h*PRIME1 ^ (*key++-' ');
201196
h %=PRIME2;
202197

203-
returnh;
198+
PG_RETURN_UINT32(h);
204199
}
205200

206-
207-
208201
/*
209202
* (Comment from the original db3 hashing code: )
210203
*
@@ -216,19 +209,17 @@ hashname(NameData *n)
216209
*
217210
* "OZ's original sdbm hash"
218211
*/
219-
uint32
220-
hashtext(structvarlena*key)
212+
Datum
213+
hashtext(PG_FUNCTION_ARGS)
221214
{
215+
text*key=PG_GETARG_TEXT_P(0);
222216
intkeylen;
223217
char*keydata;
224218
uint32n;
225219
intloop;
226220

227221
keydata=VARDATA(key);
228-
keylen=VARSIZE(key);
229-
230-
/* keylen includes the four bytes in which string keylength is stored */
231-
keylen-=sizeof(VARSIZE(key));
222+
keylen=VARSIZE(key)-VARHDRSZ;
232223

233224
#defineHASHCn = *keydata++ + 65599 * n
234225

@@ -260,5 +251,5 @@ hashtext(struct varlena * key)
260251
}while (--loop);
261252
}
262253
}
263-
returnn;
254+
PG_RETURN_UINT32(n);
264255
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp