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

Commit74a1a2b

Browse files
author
Neil Conway
committed
Rename the uuid_t type to pg_uuid_t, to avoid a conflict with any
definitions of uuid_t that may be provided by the system headers. Thisshould hopefully fix the Win32 build problems reported by Magnus.
1 parentcd47d0f commit74a1a2b

File tree

2 files changed

+49
-47
lines changed

2 files changed

+49
-47
lines changed

‎src/backend/utils/adt/uuid.c

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2007, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/utils/adt/uuid.c,v 1.1 2007/01/2816:16:52 neilc Exp $
9+
* $PostgreSQL: pgsql/src/backend/utils/adt/uuid.c,v 1.2 2007/01/2820:25:38 neilc Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -35,50 +35,49 @@
3535
/* uuid size in bytes */
3636
#defineUUID_LEN 16
3737

38-
/*The uuid_t typeis declaredasstructuuid_t in uuid.h */
39-
structuuid_t
38+
/*pg_uuid_tis declaredto bestructpg_uuid_t in uuid.h */
39+
structpg_uuid_t
4040
{
4141
chardata[UUID_LEN];
4242
};
4343

44-
staticvoiduuid_data_from_string(constchar*source,unsignedchar*data);
45-
staticvoidstring_from_uuid_data(constchar*fmt,constchar*data,char*uuid_str);
44+
staticvoidstring_to_uuid(constchar*source,pg_uuid_t*uuid);
45+
staticvoiduuid_to_string(constchar*fmt,constpg_uuid_t*uuid,
46+
char*uuid_str);
4647
staticboolparse_uuid_string(constchar*fmt,constchar*chk_fmt,
47-
constchar*source,unsignedchar*data);
48+
constchar*source,char*data);
4849
staticboolis_valid_format(constchar*source,constchar*fmt);
49-
staticint32uuid_internal_cmp(uuid_t*arg1,uuid_t*arg2);
50+
staticintuuid_internal_cmp(constpg_uuid_t*arg1,constpg_uuid_t*arg2);
5051

5152
Datum
5253
uuid_in(PG_FUNCTION_ARGS)
5354
{
5455
char*uuid_str=PG_GETARG_CSTRING(0);
55-
uuid_t*uuid;
56-
uint8data[UUID_LEN];
56+
pg_uuid_t*uuid;
5757

58-
uuid_data_from_string(uuid_str,data);
59-
uuid= (uuid_t*)palloc(sizeof(uuid_t));
60-
memcpy(uuid->data,data,UUID_LEN);
58+
uuid= (pg_uuid_t*)palloc(sizeof(*uuid));
59+
string_to_uuid(uuid_str,uuid);
6160
PG_RETURN_UUID_P(uuid);
6261
}
6362

6463
Datum
6564
uuid_out(PG_FUNCTION_ARGS)
6665
{
67-
uuid_t*uuid=(uuid_t*)PG_GETARG_POINTER(0);
66+
pg_uuid_t*uuid=PG_GETARG_UUID_P(0);
6867
char*uuid_str;
6968

7069
uuid_str= (char*)palloc(PRINT_SIZE);
71-
string_from_uuid_data(UUID_FMT1,uuid->data,uuid_str);
70+
uuid_to_string(UUID_FMT1,uuid,uuid_str);
7271
PG_RETURN_CSTRING(uuid_str);
7372
}
7473

7574
/* string to uuid convertor by various format types */
7675
staticvoid
77-
uuid_data_from_string(constchar*source,unsignedchar*data)
76+
string_to_uuid(constchar*source,pg_uuid_t*uuid)
7877
{
79-
if (!parse_uuid_string(UUID_FMT1,UUID_CHK_FMT1,source,data)&&
80-
!parse_uuid_string(UUID_FMT2,UUID_CHK_FMT2,source,data)&&
81-
!parse_uuid_string(UUID_FMT3,UUID_CHK_FMT3,source,data))
78+
if (!parse_uuid_string(UUID_FMT1,UUID_CHK_FMT1,source,uuid->data)&&
79+
!parse_uuid_string(UUID_FMT2,UUID_CHK_FMT2,source,uuid->data)&&
80+
!parse_uuid_string(UUID_FMT3,UUID_CHK_FMT3,source,uuid->data))
8281
{
8382
ereport(ERROR,
8483
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
@@ -126,7 +125,7 @@ is_valid_format(const char *source, const char *fmt)
126125
/* parse the uuid string to a format and return true if okay */
127126
staticbool
128127
parse_uuid_string(constchar*fmt,constchar*chk_fmt,
129-
constchar*source,unsignedchar*data)
128+
constchar*source,char*data)
130129
{
131130
intresult=sscanf(source,fmt,
132131
&data[0],&data[1],&data[2],&data[3],&data[4],
@@ -139,8 +138,9 @@ parse_uuid_string(const char *fmt, const char *chk_fmt,
139138

140139
/* create a string representation of the uuid */
141140
staticvoid
142-
string_from_uuid_data(constchar*fmt,constchar*data,char*uuid_str)
141+
uuid_to_string(constchar*fmt,constpg_uuid_t*uuid,char*uuid_str)
143142
{
143+
constchar*data=uuid->data;
144144
snprintf(uuid_str,PRINT_SIZE,fmt,
145145
data[0],data[1],data[2],data[3],data[4],
146146
data[5],data[6],data[7],data[8],data[9],
@@ -152,17 +152,17 @@ Datum
152152
uuid_recv(PG_FUNCTION_ARGS)
153153
{
154154
StringInfobuffer= (StringInfo)PG_GETARG_POINTER(0);
155-
uuid_t*uuid;
155+
pg_uuid_t*uuid;
156156

157-
uuid= (uuid_t*)palloc(UUID_LEN);
157+
uuid= (pg_uuid_t*)palloc(UUID_LEN);
158158
memcpy(uuid->data,pq_getmsgbytes(buffer,UUID_LEN),UUID_LEN);
159159
PG_RETURN_POINTER(uuid);
160160
}
161161

162162
Datum
163163
uuid_send(PG_FUNCTION_ARGS)
164164
{
165-
uuid_t*uuid=PG_GETARG_UUID_P(0);
165+
pg_uuid_t*uuid=PG_GETARG_UUID_P(0);
166166
StringInfoDatabuffer;
167167

168168
pq_begintypsend(&buffer);
@@ -171,62 +171,62 @@ uuid_send(PG_FUNCTION_ARGS)
171171
}
172172

173173
/* internal uuid compare function */
174-
staticint32
175-
uuid_internal_cmp(uuid_t*arg1,uuid_t*arg2)
174+
staticint
175+
uuid_internal_cmp(constpg_uuid_t*arg1,constpg_uuid_t*arg2)
176176
{
177177
returnmemcmp(arg1->data,arg2->data,UUID_LEN);
178178
}
179179

180180
Datum
181181
uuid_lt(PG_FUNCTION_ARGS)
182182
{
183-
uuid_t*arg1=PG_GETARG_UUID_P(0);
184-
uuid_t*arg2=PG_GETARG_UUID_P(1);
183+
pg_uuid_t*arg1=PG_GETARG_UUID_P(0);
184+
pg_uuid_t*arg2=PG_GETARG_UUID_P(1);
185185

186186
PG_RETURN_BOOL(uuid_internal_cmp(arg1,arg2)<0);
187187
}
188188

189189
Datum
190190
uuid_le(PG_FUNCTION_ARGS)
191191
{
192-
uuid_t*arg1=PG_GETARG_UUID_P(0);
193-
uuid_t*arg2=PG_GETARG_UUID_P(1);
192+
pg_uuid_t*arg1=PG_GETARG_UUID_P(0);
193+
pg_uuid_t*arg2=PG_GETARG_UUID_P(1);
194194

195195
PG_RETURN_BOOL(uuid_internal_cmp(arg1,arg2) <=0);
196196
}
197197

198198
Datum
199199
uuid_eq(PG_FUNCTION_ARGS)
200200
{
201-
uuid_t*arg1=PG_GETARG_UUID_P(0);
202-
uuid_t*arg2=PG_GETARG_UUID_P(1);
201+
pg_uuid_t*arg1=PG_GETARG_UUID_P(0);
202+
pg_uuid_t*arg2=PG_GETARG_UUID_P(1);
203203

204204
PG_RETURN_BOOL(uuid_internal_cmp(arg1,arg2)==0);
205205
}
206206

207207
Datum
208208
uuid_ge(PG_FUNCTION_ARGS)
209209
{
210-
uuid_t*arg1=PG_GETARG_UUID_P(0);
211-
uuid_t*arg2=PG_GETARG_UUID_P(1);
210+
pg_uuid_t*arg1=PG_GETARG_UUID_P(0);
211+
pg_uuid_t*arg2=PG_GETARG_UUID_P(1);
212212

213213
PG_RETURN_BOOL(uuid_internal_cmp(arg1,arg2) >=0);
214214
}
215215

216216
Datum
217217
uuid_gt(PG_FUNCTION_ARGS)
218218
{
219-
uuid_t*arg1=PG_GETARG_UUID_P(0);
220-
uuid_t*arg2=PG_GETARG_UUID_P(1);
219+
pg_uuid_t*arg1=PG_GETARG_UUID_P(0);
220+
pg_uuid_t*arg2=PG_GETARG_UUID_P(1);
221221

222222
PG_RETURN_BOOL(uuid_internal_cmp(arg1,arg2)>0);
223223
}
224224

225225
Datum
226226
uuid_ne(PG_FUNCTION_ARGS)
227227
{
228-
uuid_t*arg1=PG_GETARG_UUID_P(0);
229-
uuid_t*arg2=PG_GETARG_UUID_P(1);
228+
pg_uuid_t*arg1=PG_GETARG_UUID_P(0);
229+
pg_uuid_t*arg2=PG_GETARG_UUID_P(1);
230230

231231
PG_RETURN_BOOL(uuid_internal_cmp(arg1,arg2)!=0);
232232
}
@@ -235,8 +235,8 @@ uuid_ne(PG_FUNCTION_ARGS)
235235
Datum
236236
uuid_cmp(PG_FUNCTION_ARGS)
237237
{
238-
uuid_t*arg1=PG_GETARG_UUID_P(0);
239-
uuid_t*arg2=PG_GETARG_UUID_P(1);
238+
pg_uuid_t*arg1=PG_GETARG_UUID_P(0);
239+
pg_uuid_t*arg2=PG_GETARG_UUID_P(1);
240240

241241
PG_RETURN_INT32(uuid_internal_cmp(arg1,arg2));
242242
}
@@ -245,8 +245,8 @@ uuid_cmp(PG_FUNCTION_ARGS)
245245
Datum
246246
uuid_hash(PG_FUNCTION_ARGS)
247247
{
248-
uuid_t*key=PG_GETARG_UUID_P(0);
249-
returnhash_any((unsignedchar*)key,sizeof(uuid_t));
248+
pg_uuid_t*key=PG_GETARG_UUID_P(0);
249+
returnhash_any((unsignedchar*)key,sizeof(pg_uuid_t));
250250
}
251251

252252
/* cast text to uuid */
@@ -272,8 +272,8 @@ text_uuid(PG_FUNCTION_ARGS)
272272
Datum
273273
uuid_text(PG_FUNCTION_ARGS)
274274
{
275-
uuid_t*uuid=PG_GETARG_UUID_P(0);
276-
Datumuuid_str=DirectFunctionCall1(uuid_out,UUIDPGetDatum(uuid));
275+
pg_uuid_t*uuid=PG_GETARG_UUID_P(0);
276+
Datumuuid_str=DirectFunctionCall1(uuid_out,UUIDPGetDatum(uuid));
277277

278278
PG_RETURN_DATUM(DirectFunctionCall1(textin,uuid_str));
279279
}

‎src/include/utils/uuid.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/*-------------------------------------------------------------------------
22
*
33
* uuid.h
4-
* Header file for the "uuid" data type.
4+
* Header file for the "uuid" ADT. In C, we use the name pg_uuid_t,
5+
* to avoid conflicts with any uuid_t type that might be defined by
6+
* the system headers.
57
*
68
* Copyright (c) 2007, PostgreSQL Global Development Group
79
*
8-
* $PostgreSQL: pgsql/src/include/utils/uuid.h,v 1.1 2007/01/2816:16:54 neilc Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/uuid.h,v 1.2 2007/01/2820:25:38 neilc Exp $
911
*
1012
*-------------------------------------------------------------------------
1113
*/
@@ -16,12 +18,12 @@
1618
#defineUUID_LEN 16
1719

1820
/* opaque struct; defined in uuid.c */
19-
typedefstructuuid_tuuid_t;
21+
typedefstructpg_uuid_tpg_uuid_t;
2022

2123
/* fmgr interface macros */
2224
#defineUUIDPGetDatum(X)PointerGetDatum(X)
2325
#definePG_RETURN_UUID_P(X)return UUIDPGetDatum(X)
24-
#defineDatumGetUUIDP(X)((uuid_t *) DatumGetPointer(X))
26+
#defineDatumGetUUIDP(X)((pg_uuid_t *) DatumGetPointer(X))
2527
#definePG_GETARG_UUID_P(X)DatumGetUUIDP(PG_GETARG_DATUM(X))
2628

2729
#endif/* UUID_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp