Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
0db1a951
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0db1a951
编写于
12月 22, 2000
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Repair not-too-well-thought-out code to do rangechecking of OIDs on
64-bit machines. Also, make oidvectorin use the same code as oidin.
上级
369aace5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
98 addition
and
54 deletion
+98
-54
src/backend/utils/adt/oid.c
src/backend/utils/adt/oid.c
+88
-52
src/include/postgres_ext.h
src/include/postgres_ext.h
+10
-2
未找到文件。
src/backend/utils/adt/oid.c
浏览文件 @
0db1a951
/*-------------------------------------------------------------------------
*
* oid.c
* Functions for the built-in type Oid.
* Functions for the built-in type Oid
... also oidvector
.
*
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.4
1 2000/12/03 20:45:36
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.4
2 2000/12/22 21:36:09
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -16,6 +16,7 @@
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include "utils/builtins.h"
...
...
@@ -23,6 +24,85 @@
* USER I/O ROUTINES *
*****************************************************************************/
static
Oid
oidin_subr
(
const
char
*
funcname
,
const
char
*
s
,
char
**
endloc
)
{
unsigned
long
cvt
;
char
*
endptr
;
Oid
result
;
errno
=
0
;
cvt
=
strtoul
(
s
,
&
endptr
,
10
);
/*
* strtoul() normally only sets ERANGE. On some systems it also
* may set EINVAL, which simply means it couldn't parse the
* input string. This is handled by the second "if" consistent
* across platforms. Note that for historical reasons we accept
* an empty string as meaning 0.
*/
if
(
errno
&&
errno
!=
EINVAL
)
elog
(
ERROR
,
"%s: error reading
\"
%s
\"
: %m"
,
funcname
,
s
);
if
(
endptr
==
s
&&
*
endptr
)
elog
(
ERROR
,
"%s: error in
\"
%s
\"
: can't parse
\"
%s
\"
"
,
funcname
,
s
,
endptr
);
if
(
endloc
)
{
/* caller wants to deal with rest of string */
*
endloc
=
endptr
;
}
else
{
/* allow only whitespace after number */
while
(
*
endptr
&&
isspace
((
unsigned
char
)
*
endptr
))
endptr
++
;
if
(
*
endptr
)
elog
(
ERROR
,
"%s: error in
\"
%s
\"
: can't parse
\"
%s
\"
"
,
funcname
,
s
,
endptr
);
}
result
=
(
Oid
)
cvt
;
/*
* Cope with possibility that unsigned long is wider than Oid.
*
* To ensure consistent results on 32-bit and 64-bit platforms,
* make sure the error message is the same as if strtoul() had
* returned ERANGE.
*/
#if OID_MAX < ULONG_MAX
if
(
cvt
>
(
unsigned
long
)
OID_MAX
)
elog
(
ERROR
,
"%s: error reading
\"
%s
\"
: %s"
,
funcname
,
s
,
strerror
(
ERANGE
));
#endif
return
result
;
}
Datum
oidin
(
PG_FUNCTION_ARGS
)
{
char
*
s
=
PG_GETARG_CSTRING
(
0
);
Oid
result
;
result
=
oidin_subr
(
"oidin"
,
s
,
NULL
);
PG_RETURN_OID
(
result
);
}
Datum
oidout
(
PG_FUNCTION_ARGS
)
{
Oid
o
=
PG_GETARG_OID
(
0
);
char
*
result
=
(
char
*
)
palloc
(
12
);
snprintf
(
result
,
12
,
"%u"
,
o
);
PG_RETURN_CSTRING
(
result
);
}
/*
* oidvectorin - converts "num num ..." to internal form
*
...
...
@@ -38,14 +118,13 @@ oidvectorin(PG_FUNCTION_ARGS)
result
=
(
Oid
*
)
palloc
(
sizeof
(
Oid
[
INDEX_MAX_KEYS
]));
for
(
slot
=
0
;
*
oidString
&&
slot
<
INDEX_MAX_KEYS
;
slot
++
)
for
(
slot
=
0
;
slot
<
INDEX_MAX_KEYS
;
slot
++
)
{
if
(
sscanf
(
oidString
,
"%u"
,
&
result
[
slot
])
!=
1
)
break
;
while
(
*
oidString
&&
isspace
((
unsigned
char
)
*
oidString
))
oidString
++
;
while
(
*
oidString
&&
isdigit
((
unsigned
char
)
*
oidString
))
oidString
++
;
if
(
*
oidString
==
'\0'
)
break
;
result
[
slot
]
=
oidin_subr
(
"oidvectorin"
,
oidString
,
&
oidString
);
}
while
(
*
oidString
&&
isspace
((
unsigned
char
)
*
oidString
))
oidString
++
;
...
...
@@ -88,49 +167,6 @@ oidvectorout(PG_FUNCTION_ARGS)
PG_RETURN_CSTRING
(
result
);
}
Datum
oidin
(
PG_FUNCTION_ARGS
)
{
char
*
s
=
PG_GETARG_CSTRING
(
0
);
unsigned
long
cvt
;
char
*
endptr
;
Oid
result
;
errno
=
0
;
cvt
=
strtoul
(
s
,
&
endptr
,
10
);
/*
* strtoul() normally only sets ERANGE. On some systems it also
* may set EINVAL, which simply means it couldn't parse the
* input string. This is handled by the second "if" consistent
* across platforms.
*/
if
(
errno
&&
errno
!=
EINVAL
)
elog
(
ERROR
,
"oidin: error reading
\"
%s
\"
: %m"
,
s
);
if
(
endptr
&&
*
endptr
)
elog
(
ERROR
,
"oidin: error in
\"
%s
\"
: can't parse
\"
%s
\"
"
,
s
,
endptr
);
/*
* Cope with possibility that unsigned long is wider than Oid.
*/
result
=
(
Oid
)
cvt
;
if
((
unsigned
long
)
result
!=
cvt
)
elog
(
ERROR
,
"oidin: error reading
\"
%s
\"
: value too large"
,
s
);
return
ObjectIdGetDatum
(
result
);
}
Datum
oidout
(
PG_FUNCTION_ARGS
)
{
Oid
o
=
PG_GETARG_OID
(
0
);
char
*
result
=
(
char
*
)
palloc
(
12
);
snprintf
(
result
,
12
,
"%u"
,
o
);
PG_RETURN_CSTRING
(
result
);
}
/*****************************************************************************
* PUBLIC ROUTINES *
*****************************************************************************/
...
...
@@ -294,8 +330,8 @@ text_oid(PG_FUNCTION_ARGS)
memcpy
(
str
,
VARDATA
(
string
),
len
);
*
(
str
+
len
)
=
'\0'
;
result
=
DatumGetObjectId
(
DirectFunctionCall1
(
oidin
,
CStringGetDatum
(
str
)));
result
=
oidin_subr
(
"text_oid"
,
str
,
NULL
);
pfree
(
str
);
PG_RETURN_OID
(
result
);
...
...
src/include/postgres_ext.h
浏览文件 @
0db1a951
...
...
@@ -16,7 +16,7 @@
* use header files that are otherwise internal to Postgres to interface
* with the backend.
*
* $Id: postgres_ext.h,v 1.
4 1999/06/04 21:12:07
tgl Exp $
* $Id: postgres_ext.h,v 1.
5 2000/12/22 21:36:09
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -24,9 +24,17 @@
#ifndef POSTGRES_EXT_H
#define POSTGRES_EXT_H
/*
* Object ID is a fundamental type in Postgres.
*/
typedef
unsigned
int
Oid
;
/* NAMEDATALEN is the max length for system identifiers (e.g. table names,
#define OID_MAX UINT_MAX
/* you will need to include <limits.h> to use the above #define */
/*
* NAMEDATALEN is the max length for system identifiers (e.g. table names,
* attribute names, function names, etc.)
*
* NOTE that databases with different NAMEDATALEN's cannot interoperate!
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录