Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
9b7fea9b
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,发现更多精彩内容 >>
提交
9b7fea9b
编写于
6月 20, 2016
作者:
G
Gang Xiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove dead code
上级
5d408fc1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
70 addition
and
104 deletion
+70
-104
src/backend/cdb/dispatcher/cdbconn.c
src/backend/cdb/dispatcher/cdbconn.c
+9
-8
src/backend/cdb/dispatcher/cdbdisp.c
src/backend/cdb/dispatcher/cdbdisp.c
+1
-1
src/backend/cdb/dispatcher/cdbdispatchresult.c
src/backend/cdb/dispatcher/cdbdispatchresult.c
+37
-71
src/backend/cdb/dispatcher/cdbgang.c
src/backend/cdb/dispatcher/cdbgang.c
+21
-20
src/include/cdb/cdbdispatchresult.h
src/include/cdb/cdbdispatchresult.h
+2
-4
未找到文件。
src/backend/cdb/dispatcher/cdbconn.c
浏览文件 @
9b7fea9b
...
...
@@ -514,29 +514,30 @@ void setQEIdentifier(SegmentDatabaseDescriptor *segdbDesc,
{
CdbComponentDatabaseInfo
*
cdbinfo
=
segdbDesc
->
segment_database_info
;
MemoryContext
oldContext
=
MemoryContextSwitchTo
(
mcxt
);
StringInfo
string
=
makeStringInfo
();
StringInfoData
string
;
initStringInfo
(
&
string
);
/* Format the identity of the segment db. */
if
(
segdbDesc
->
segindex
>=
0
)
{
appendStringInfo
(
string
,
"seg%d"
,
segdbDesc
->
segindex
);
appendStringInfo
(
&
string
,
"seg%d"
,
segdbDesc
->
segindex
);
/* Format the slice index. */
if
(
sliceIndex
>
0
)
appendStringInfo
(
string
,
" slice%d"
,
sliceIndex
);
appendStringInfo
(
&
string
,
" slice%d"
,
sliceIndex
);
}
else
appendStringInfo
(
string
,
SEGMENT_IS_ACTIVE_PRIMARY
(
cdbinfo
)
?
"entry db"
:
"mirror entry db"
);
appendStringInfo
(
&
string
,
SEGMENT_IS_ACTIVE_PRIMARY
(
cdbinfo
)
?
"entry db"
:
"mirror entry db"
);
/* Format the connection info. */
appendStringInfo
(
string
,
" %s:%d"
,
cdbinfo
->
hostip
,
cdbinfo
->
port
);
appendStringInfo
(
&
string
,
" %s:%d"
,
cdbinfo
->
hostip
,
cdbinfo
->
port
);
/* If connected, format the QE's process id. */
if
(
segdbDesc
->
backendPid
!=
0
)
appendStringInfo
(
string
,
" pid=%d"
,
segdbDesc
->
backendPid
);
appendStringInfo
(
&
string
,
" pid=%d"
,
segdbDesc
->
backendPid
);
segdbDesc
->
whoami
=
string
->
data
;
pfree
(
string
);
segdbDesc
->
whoami
=
string
.
data
;
MemoryContextSwitchTo
(
oldContext
);
}
src/backend/cdb/dispatcher/cdbdisp.c
浏览文件 @
9b7fea9b
...
...
@@ -202,7 +202,7 @@ cdbdisp_finishCommand(struct CdbDispatcherState *ds,
* Format error messages from the primary gang.
*/
initStringInfo
(
&
buf
);
cdbdisp_dumpDispatchResults
(
ds
->
primaryResults
,
&
buf
,
false
);
cdbdisp_dumpDispatchResults
(
ds
->
primaryResults
,
&
buf
);
cdbdisp_destroyDispatcherState
(
ds
);
...
...
src/backend/cdb/dispatcher/cdbdispatchresult.c
浏览文件 @
9b7fea9b
...
...
@@ -510,11 +510,11 @@ cdbdisp_debugDispatchResult(CdbDispatchResult * dispatchResult,
/*
* Format a CdbDispatchResult into a StringInfo buffer provided by caller.
* I
f verbose = true, reports all info; else
reports at most one error.
* I
t
reports at most one error.
*/
void
cdbdisp_dumpDispatchResult
(
CdbDispatchResult
*
dispatchResult
,
bool
verbose
,
struct
StringInfoData
*
buf
)
struct
StringInfoData
*
buf
)
{
int
ires
;
int
nres
;
...
...
@@ -540,59 +540,46 @@ cdbdisp_dumpDispatchResult(CdbDispatchResult *dispatchResult,
resultStatus
==
PGRES_COPY_IN
||
resultStatus
==
PGRES_COPY_OUT
||
resultStatus
==
PGRES_EMPTY_QUERY
)
{
if
(
verbose
)
{
char
*
cmdStatus
=
PQcmdStatus
(
pgresult
);
oneTrailingNewline
(
buf
);
appendStringInfo
(
buf
,
"ok: %s"
,
cmdStatus
?
cmdStatus
:
""
);
if
(
whoami
)
appendStringInfo
(
buf
,
" (%s)"
,
whoami
);
}
}
continue
;
/*
* QE error or libpq error
*/
char
*
pri
=
PQresultErrorField
(
pgresult
,
PG_DIAG_MESSAGE_PRIMARY
);
char
*
dtl
=
PQresultErrorField
(
pgresult
,
PG_DIAG_MESSAGE_DETAIL
);
char
*
ctx
=
PQresultErrorField
(
pgresult
,
PG_DIAG_CONTEXT
);
oneTrailingNewline
(
buf
);
if
(
pri
)
{
appendStringInfoString
(
buf
,
pri
);
}
else
{
char
*
pri
=
PQresultErrorField
(
pgresult
,
PG_DIAG_MESSAGE_PRIMARY
);
char
*
dtl
=
PQresultErrorField
(
pgresult
,
PG_DIAG_MESSAGE_DETAIL
);
char
*
ctx
=
PQresultErrorField
(
pgresult
,
PG_DIAG_CONTEXT
);
elog
(
LOG
,
"No primary message?"
);
appendStringInfoString
(
buf
,
PQresultErrorMessage
(
pgresult
));
}
if
(
whoami
)
{
noTrailingNewline
(
buf
);
appendStringInfo
(
buf
,
" (%s)"
,
whoami
);
}
if
(
dtl
)
{
oneTrailingNewline
(
buf
);
if
(
pri
)
{
appendStringInfoString
(
buf
,
pri
);
}
else
{
elog
(
LOG
,
"No primary message?"
);
appendStringInfoString
(
buf
,
PQresultErrorMessage
(
pgresult
));
}
if
(
whoami
)
{
noTrailingNewline
(
buf
);
appendStringInfo
(
buf
,
" (%s)"
,
whoami
);
}
if
(
dtl
)
{
oneTrailingNewline
(
buf
);
appendStringInfo
(
buf
,
"%s"
,
dtl
);
}
if
(
ctx
)
{
oneTrailingNewline
(
buf
);
appendStringInfo
(
buf
,
"%s"
,
ctx
);
}
if
(
!
verbose
)
goto
done
;
appendStringInfo
(
buf
,
"%s"
,
dtl
);
}
if
(
ctx
)
{
oneTrailingNewline
(
buf
);
appendStringInfo
(
buf
,
"%s"
,
ctx
);
}
noTrailingNewline
(
buf
);
return
;
}
/*
...
...
@@ -603,12 +590,8 @@ cdbdisp_dumpDispatchResult(CdbDispatchResult *dispatchResult,
{
oneTrailingNewline
(
buf
);
appendStringInfoString
(
buf
,
dispatchResult
->
error_message
->
data
);
if
(
!
verbose
)
goto
done
;
noTrailingNewline
(
buf
);
}
done:
noTrailingNewline
(
buf
);
}
/*
...
...
@@ -619,7 +602,7 @@ done:
*/
int
cdbdisp_dumpDispatchResults
(
struct
CdbDispatchResults
*
meleeResults
,
struct
StringInfoData
*
buffer
,
bool
verbose
)
struct
StringInfoData
*
buffer
)
{
CdbDispatchResult
*
dispatchResult
;
...
...
@@ -643,24 +626,7 @@ cdbdisp_dumpDispatchResults(struct CdbDispatchResults *meleeResults,
/*
* Format one QE's result.
*/
cdbdisp_dumpDispatchResult
(
dispatchResult
,
verbose
,
buffer
);
/*
* Optionally, format results from the rest of the QEs that got errors.
*/
if
(
verbose
)
{
int
i
;
for
(
i
=
0
;
i
<
meleeResults
->
resultCount
;
++
i
)
{
dispatchResult
=
&
meleeResults
->
resultArray
[
i
];
if
(
i
==
meleeResults
->
iFirstError
)
continue
;
if
(
dispatchResult
->
errcode
)
cdbdisp_dumpDispatchResult
(
dispatchResult
,
verbose
,
buffer
);
}
}
cdbdisp_dumpDispatchResult
(
dispatchResult
,
buffer
);
return
meleeResults
->
errcode
;
}
...
...
@@ -877,7 +843,7 @@ cdbdisp_returnResults(CdbDispatchResults * primaryResults,
/*
* Append error messages to caller's buffer.
*/
cdbdisp_dumpDispatchResult
(
dispatchResult
,
false
,
errmsgbuf
);
cdbdisp_dumpDispatchResult
(
dispatchResult
,
errmsgbuf
);
/*
* Take ownership of this QE's PGresult object(s).
...
...
src/backend/cdb/dispatcher/cdbgang.c
浏览文件 @
9b7fea9b
...
...
@@ -103,7 +103,7 @@ typedef struct DoConnectParms
int
gangId
;
/* connect options. GUC etc. */
StringInfo
connectOptions
;
char
*
connectOptions
;
/* The pthread_t thread handle. */
pthread_t
thread
;
...
...
@@ -125,7 +125,7 @@ static void disconnectAndDestroyGang(Gang *gp);
static
void
disconnectAndDestroyAllReaderGangs
(
bool
destroyAllocated
);
static
bool
isTargetPortal
(
const
char
*
p1
,
const
char
*
p2
);
static
void
addOptions
(
StringInfo
string
,
bool
iswriter
);
static
char
*
makeOptions
(
bool
iswriter
);
static
bool
cleanupGang
(
Gang
*
gp
);
static
void
resetSessionForPrimaryGangLoss
(
void
);
static
const
char
*
gangTypeToString
(
GangType
);
...
...
@@ -549,7 +549,7 @@ thread_DoConnect(void *arg)
pParms
->
gangId
);
/* check the result in createGang */
cdbconn_doConnect
(
segdbDesc
,
gpqeid
,
pParms
->
connectOptions
->
data
);
cdbconn_doConnect
(
segdbDesc
,
gpqeid
,
pParms
->
connectOptions
);
}
return
(
NULL
);
...
...
@@ -930,21 +930,25 @@ static void addOneOption(StringInfo string, struct config_generic * guc)
/*
* Add GUCs to option string.
*/
static
void
addOptions
(
StringInfo
string
,
bool
iswriter
)
static
char
*
makeOptions
(
bool
iswriter
)
{
struct
config_generic
**
gucs
=
get_guc_variables
();
int
ngucs
=
get_num_guc_variables
();
CdbComponentDatabaseInfo
*
qdinfo
=
NULL
;
StringInfoData
string
;
int
i
;
initStringInfo
(
&
string
);
Assert
(
Gp_role
==
GP_ROLE_DISPATCH
);
LOG_GANG_DEBUG
(
LOG
,
"
add
Options: iswriter %d"
,
iswriter
);
LOG_GANG_DEBUG
(
LOG
,
"
make
Options: iswriter %d"
,
iswriter
);
qdinfo
=
&
cdb_component_dbs
->
entry_db_info
[
0
];
appendStringInfo
(
string
,
" -c gp_qd_hostname=%s"
,
qdinfo
->
hostip
);
appendStringInfo
(
string
,
" -c gp_qd_port=%d"
,
qdinfo
->
port
);
appendStringInfo
(
&
string
,
" -c gp_qd_hostname=%s"
,
qdinfo
->
hostip
);
appendStringInfo
(
&
string
,
" -c gp_qd_port=%d"
,
qdinfo
->
port
);
appendStringInfo
(
string
,
" -c gp_qd_callback_info=port=%d"
,
PostPortNumber
);
appendStringInfo
(
&
string
,
" -c gp_qd_callback_info=port=%d"
,
PostPortNumber
);
/*
* Transactions are tricky.
...
...
@@ -961,13 +965,13 @@ static void addOptions(StringInfo string, bool iswriter)
if
(
DefaultXactIsoLevel
!=
XACT_READ_COMMITTED
)
{
if
(
DefaultXactIsoLevel
==
XACT_SERIALIZABLE
)
appendStringInfo
(
string
,
" -c default_transaction_isolation=serializable"
);
appendStringInfo
(
&
string
,
" -c default_transaction_isolation=serializable"
);
}
if
(
XactIsoLevel
!=
XACT_READ_COMMITTED
)
{
if
(
XactIsoLevel
==
XACT_SERIALIZABLE
)
appendStringInfo
(
string
,
" -c transaction_isolation=serializable"
);
appendStringInfo
(
&
string
,
" -c transaction_isolation=serializable"
);
}
for
(
i
=
0
;
i
<
ngucs
;
++
i
)
...
...
@@ -975,8 +979,10 @@ static void addOptions(StringInfo string, bool iswriter)
struct
config_generic
*
guc
=
gucs
[
i
];
if
((
guc
->
flags
&
GUC_GPDB_ADDOPT
)
&&
(
guc
->
context
==
PGC_USERSET
||
procRoleIsSuperuser
()))
addOneOption
(
string
,
guc
);
addOneOption
(
&
string
,
guc
);
}
return
string
.
data
;
}
/*
...
...
@@ -989,12 +995,9 @@ static DoConnectParms* makeConnectParms(int parmsCount, GangType type, int gangI
DoConnectParms
*
doConnectParmsAr
=
(
DoConnectParms
*
)
palloc0
(
parmsCount
*
sizeof
(
DoConnectParms
));
DoConnectParms
*
pParms
=
NULL
;
StringInfo
pOptions
=
makeStringInfo
();
int
segdbPerThread
=
gp_connections_per_thread
;
int
i
=
0
;
addOptions
(
pOptions
,
type
==
GANGTYPE_PRIMARY_WRITER
);
for
(
i
=
0
;
i
<
parmsCount
;
i
++
)
{
pParms
=
&
doConnectParmsAr
[
i
];
...
...
@@ -1003,7 +1006,7 @@ static DoConnectParms* makeConnectParms(int parmsCount, GangType type, int gangI
MemSet
(
&
pParms
->
thread
,
0
,
sizeof
(
pthread_t
));
pParms
->
db_count
=
0
;
pParms
->
type
=
type
;
pParms
->
connectOptions
=
pOptions
;
pParms
->
connectOptions
=
makeOptions
(
type
==
GANGTYPE_PRIMARY_WRITER
)
;
pParms
->
gangId
=
gangId
;
}
return
doConnectParmsAr
;
...
...
@@ -1020,13 +1023,11 @@ static void destroyConnectParms(DoConnectParms *doConnectParmsAr, int count)
for
(
i
=
0
;
i
<
count
;
i
++
)
{
DoConnectParms
*
pParms
=
&
doConnectParmsAr
[
i
];
StringInfo
pOptions
=
pParms
->
connectOptions
;
if
(
pOptions
->
data
!=
NULL
)
if
(
pParms
->
connectOptions
!=
NULL
)
{
pfree
(
p
Options
->
data
);
p
Options
->
data
=
NULL
;
pfree
(
p
Parms
->
connectOptions
);
p
Parms
->
connectOptions
=
NULL
;
}
pParms
->
connectOptions
=
NULL
;
pfree
(
pParms
->
segdbDescPtrArray
);
pParms
->
segdbDescPtrArray
=
NULL
;
...
...
src/include/cdb/cdbdispatchresult.h
浏览文件 @
9b7fea9b
...
...
@@ -244,11 +244,10 @@ cdbdisp_debugDispatchResult(CdbDispatchResult *dispatchResult,
/*
* Format a CdbDispatchResult into a StringInfo buffer provided by caller.
* I
f verbose = true, reports all results; else
reports at most one error.
* I
t
reports at most one error.
*/
void
cdbdisp_dumpDispatchResult
(
CdbDispatchResult
*
dispatchResult
,
bool
verbose
,
struct
StringInfoData
*
buf
);
/*
...
...
@@ -259,8 +258,7 @@ cdbdisp_dumpDispatchResult(CdbDispatchResult *dispatchResult,
*/
int
cdbdisp_dumpDispatchResults
(
struct
CdbDispatchResults
*
gangResults
,
struct
StringInfoData
*
buffer
,
bool
verbose
);
struct
StringInfoData
*
buffer
);
/*
* Return sum of the cmdTuples values from CdbDispatchResult
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录