Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
49448524
Commit
49448524
authored
Dec 31, 2007
by
Alvaro Herrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing return code checks in the uuid-ossp contrib module, per bug #3841.
parent
7284dfe4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
13 deletions
+53
-13
contrib/uuid-ossp/uuid-ossp.c
contrib/uuid-ossp/uuid-ossp.c
+53
-13
No files found.
contrib/uuid-ossp/uuid-ossp.c
View file @
49448524
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*
*
* Copyright (c) 2007 PostgreSQL Global Development Group
* Copyright (c) 2007 PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.c,v 1.
5 2007/11/15 22:25:14 momjian
Exp $
* $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.c,v 1.
6 2007/12/31 03:55:50 alvherre
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -64,6 +64,20 @@ PG_FUNCTION_INFO_V1(uuid_generate_v3);
...
@@ -64,6 +64,20 @@ PG_FUNCTION_INFO_V1(uuid_generate_v3);
PG_FUNCTION_INFO_V1
(
uuid_generate_v4
);
PG_FUNCTION_INFO_V1
(
uuid_generate_v4
);
PG_FUNCTION_INFO_V1
(
uuid_generate_v5
);
PG_FUNCTION_INFO_V1
(
uuid_generate_v5
);
static
void
pguuid_complain
(
uuid_rc_t
rc
)
{
char
*
err
=
uuid_error
(
rc
);
if
(
err
!=
NULL
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_EXTERNAL_ROUTINE_EXCEPTION
),
errmsg
(
"OSSP uuid library failure: %s"
,
err
)));
else
ereport
(
ERROR
,
(
errcode
(
ERRCODE_EXTERNAL_ROUTINE_EXCEPTION
),
errmsg
(
"OSSP uuid library failure: error code %d"
,
rc
)));
}
static
char
*
static
char
*
uuid_to_string
(
const
uuid_t
*
uuid
)
uuid_to_string
(
const
uuid_t
*
uuid
)
...
@@ -71,8 +85,11 @@ uuid_to_string(const uuid_t * uuid)
...
@@ -71,8 +85,11 @@ uuid_to_string(const uuid_t * uuid)
char
*
buf
=
palloc
(
UUID_LEN_STR
+
1
);
char
*
buf
=
palloc
(
UUID_LEN_STR
+
1
);
void
*
ptr
=
buf
;
void
*
ptr
=
buf
;
size_t
len
=
UUID_LEN_STR
+
1
;
size_t
len
=
UUID_LEN_STR
+
1
;
uuid_rc_t
rc
;
uuid_export
(
uuid
,
UUID_FMT_STR
,
&
ptr
,
&
len
);
rc
=
uuid_export
(
uuid
,
UUID_FMT_STR
,
&
ptr
,
&
len
);
if
(
rc
!=
UUID_RC_OK
)
pguuid_complain
(
rc
);
return
buf
;
return
buf
;
}
}
...
@@ -81,7 +98,11 @@ uuid_to_string(const uuid_t * uuid)
...
@@ -81,7 +98,11 @@ uuid_to_string(const uuid_t * uuid)
static
void
static
void
string_to_uuid
(
const
char
*
str
,
uuid_t
*
uuid
)
string_to_uuid
(
const
char
*
str
,
uuid_t
*
uuid
)
{
{
uuid_import
(
uuid
,
UUID_FMT_STR
,
str
,
UUID_LEN_STR
+
1
);
uuid_rc_t
rc
;
rc
=
uuid_import
(
uuid
,
UUID_FMT_STR
,
str
,
UUID_LEN_STR
+
1
);
if
(
rc
!=
UUID_RC_OK
)
pguuid_complain
(
rc
);
}
}
...
@@ -90,11 +111,18 @@ special_uuid_value(const char *name)
...
@@ -90,11 +111,18 @@ special_uuid_value(const char *name)
{
{
uuid_t
*
uuid
;
uuid_t
*
uuid
;
char
*
str
;
char
*
str
;
uuid_rc_t
rc
;
uuid_create
(
&
uuid
);
uuid_load
(
uuid
,
name
);
rc
=
uuid_create
(
&
uuid
);
if
(
rc
!=
UUID_RC_OK
)
pguuid_complain
(
rc
);
rc
=
uuid_load
(
uuid
,
name
);
if
(
rc
!=
UUID_RC_OK
)
pguuid_complain
(
rc
);
str
=
uuid_to_string
(
uuid
);
str
=
uuid_to_string
(
uuid
);
uuid_destroy
(
uuid
);
rc
=
uuid_destroy
(
uuid
);
if
(
rc
!=
UUID_RC_OK
)
pguuid_complain
(
rc
);
return
DirectFunctionCall1
(
uuid_in
,
CStringGetDatum
(
str
));
return
DirectFunctionCall1
(
uuid_in
,
CStringGetDatum
(
str
));
}
}
...
@@ -140,11 +168,18 @@ uuid_generate_internal(int mode, const uuid_t * ns, const char *name)
...
@@ -140,11 +168,18 @@ uuid_generate_internal(int mode, const uuid_t * ns, const char *name)
{
{
uuid_t
*
uuid
;
uuid_t
*
uuid
;
char
*
str
;
char
*
str
;
uuid_rc_t
rc
;
uuid_create
(
&
uuid
);
uuid_make
(
uuid
,
mode
,
ns
,
name
);
rc
=
uuid_create
(
&
uuid
);
if
(
rc
!=
UUID_RC_OK
)
pguuid_complain
(
rc
);
rc
=
uuid_make
(
uuid
,
mode
,
ns
,
name
);
if
(
rc
!=
UUID_RC_OK
)
pguuid_complain
(
rc
);
str
=
uuid_to_string
(
uuid
);
str
=
uuid_to_string
(
uuid
);
uuid_destroy
(
uuid
);
rc
=
uuid_destroy
(
uuid
);
if
(
rc
!=
UUID_RC_OK
)
pguuid_complain
(
rc
);
return
DirectFunctionCall1
(
uuid_in
,
CStringGetDatum
(
str
));
return
DirectFunctionCall1
(
uuid_in
,
CStringGetDatum
(
str
));
}
}
...
@@ -169,8 +204,11 @@ uuid_generate_v35_internal(int mode, pg_uuid_t *ns, text *name)
...
@@ -169,8 +204,11 @@ uuid_generate_v35_internal(int mode, pg_uuid_t *ns, text *name)
{
{
uuid_t
*
ns_uuid
;
uuid_t
*
ns_uuid
;
Datum
result
;
Datum
result
;
uuid_rc_t
rc
;
uuid_create
(
&
ns_uuid
);
rc
=
uuid_create
(
&
ns_uuid
);
if
(
rc
!=
UUID_RC_OK
)
pguuid_complain
(
rc
);
string_to_uuid
(
DatumGetCString
(
DirectFunctionCall1
(
uuid_out
,
UUIDPGetDatum
(
ns
))),
string_to_uuid
(
DatumGetCString
(
DirectFunctionCall1
(
uuid_out
,
UUIDPGetDatum
(
ns
))),
ns_uuid
);
ns_uuid
);
...
@@ -178,7 +216,9 @@ uuid_generate_v35_internal(int mode, pg_uuid_t *ns, text *name)
...
@@ -178,7 +216,9 @@ uuid_generate_v35_internal(int mode, pg_uuid_t *ns, text *name)
ns_uuid
,
ns_uuid
,
DatumGetCString
(
DirectFunctionCall1
(
textout
,
PointerGetDatum
(
name
))));
DatumGetCString
(
DirectFunctionCall1
(
textout
,
PointerGetDatum
(
name
))));
uuid_destroy
(
ns_uuid
);
rc
=
uuid_destroy
(
ns_uuid
);
if
(
rc
!=
UUID_RC_OK
)
pguuid_complain
(
rc
);
return
result
;
return
result
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment