Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
69f909ba
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,发现更多精彩内容 >>
提交
69f909ba
编写于
1月 18, 2002
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
You might want to run pg_indent on pg_backup_db.c however ...
tom lane
上级
83b5ae65
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
69 addition
and
65 deletion
+69
-65
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_archiver.c
+7
-7
src/bin/pg_dump/pg_backup_db.c
src/bin/pg_dump/pg_backup_db.c
+40
-38
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+18
-16
src/bin/pg_dump/pg_restore.c
src/bin/pg_dump/pg_restore.c
+4
-4
未找到文件。
src/bin/pg_dump/pg_backup_archiver.c
浏览文件 @
69f909ba
...
...
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.
39 2002/01/18 17:13:50 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.
40 2002/01/18 19:17:04 momjian
Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
...
...
@@ -64,7 +64,7 @@
*
* Modifications - 18-Jan-2002 - pjw@rhyme.com.au
* - Modified _tocEntryRequired to handle '<Init>/Max OID' as a special
*
case (ie. as a DATA item) as per bugs reported by Bruce Momjian
* case (ie. as a DATA item) as per bugs reported by Bruce Momjian
* around 17-Jan-2002.
*
*-------------------------------------------------------------------------
...
...
@@ -1922,12 +1922,12 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt)
res
=
res
&
~
REQ_DATA
;
}
/* Special case: <Init> type with <Max OID> name; this is part of
* a DATA restore even though it has SQL.
*/
if
(
(
strcmp
(
te
->
desc
,
"<Init>"
)
==
0
)
&&
(
strcmp
(
te
->
name
,
"Max OID"
)
==
0
)
)
{
/*
* Special case: <Init> type with <Max OID> name; this is part of a
* DATA restore even though it has SQL.
*/
if
((
strcmp
(
te
->
desc
,
"<Init>"
)
==
0
)
&&
(
strcmp
(
te
->
name
,
"Max OID"
)
==
0
))
res
=
REQ_DATA
;
}
/* Mask it if we only want schema */
if
(
ropt
->
schemaOnly
)
...
...
src/bin/pg_dump/pg_backup_db.c
浏览文件 @
69f909ba
...
...
@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.3
0 2002/01/18 17:13:51 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.3
1 2002/01/18 19:17:05 momjian
Exp $
*
* NOTES
*
...
...
@@ -20,7 +20,7 @@
*
* Modifications - 18-Jan-2002 - pjw@rhyme.com.au
*
*
- Split ExecuteSqlCommandBuf into 3 routines for (slightly) improved
*
- Split ExecuteSqlCommandBuf into 3 routines for (slightly) improved
* clarity. Modify loop to cater for COPY commands buried in the SQL
* command buffer (prev version assumed COPY command was executed
* in prior call). This was to fix the buf in the 'set max oid' code.
...
...
@@ -51,8 +51,8 @@ static void _check_database_version(ArchiveHandle *AH, bool ignoreVersion);
static
PGconn
*
_connectDB
(
ArchiveHandle
*
AH
,
const
char
*
newdbname
,
const
char
*
newUser
);
static
int
_executeSqlCommand
(
ArchiveHandle
*
AH
,
PGconn
*
conn
,
PQExpBuffer
qry
,
char
*
desc
);
static
void
notice_processor
(
void
*
arg
,
const
char
*
message
);
static
char
*
_sendSQLLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
);
static
char
*
_sendCopyLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
);
static
char
*
_sendSQLLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
);
static
char
*
_sendCopyLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
);
/*
...
...
@@ -544,23 +544,24 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
return
strlen
(
qry
->
data
);
}
/*
/*
* Used by ExecuteSqlCommandBuf to send one buffered line when running a COPY command.
*/
static
char
*
_sendCopyLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
)
static
char
*
_sendCopyLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
)
{
int
loc
;
/* Location of next newline */
int
pos
=
0
;
/* Current position */
int
sPos
=
0
;
/* Last pos of a slash char */
int
isEnd
=
0
;
int
loc
;
/* Location of next newline */
int
pos
=
0
;
/* Current position */
int
sPos
=
0
;
/* Last pos of a slash char */
int
isEnd
=
0
;
/* loop to find unquoted newline ending the line of COPY data */
for
(;;)
{
for
(;;)
{
loc
=
strcspn
(
&
qry
[
pos
],
"
\n
"
)
+
pos
;
/* If no match, then wait */
if
(
loc
>=
(
eos
-
qry
))
/* None found */
if
(
loc
>=
(
eos
-
qry
))
/* None found */
{
appendBinaryPQExpBuffer
(
AH
->
pgCopyBuf
,
qry
,
(
eos
-
qry
));
return
eos
;
...
...
@@ -579,8 +580,8 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
sPos
=
loc
-
sPos
;
/*
* If an odd number of preceding slashes, then \n was escaped
* s
o s
et the next search pos, and loop (if any left).
* If an odd number of preceding slashes, then \n was escaped
so
* set the next search pos, and loop (if any left).
*/
if
((
sPos
&
1
)
==
1
)
{
...
...
@@ -591,9 +592,9 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
appendBinaryPQExpBuffer
(
AH
->
pgCopyBuf
,
qry
,
(
eos
-
qry
));
return
eos
;
}
}
else
{
break
;
}
else
break
;
}
/* We found an unquoted newline */
...
...
@@ -613,8 +614,7 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
resetPQExpBuffer
(
AH
->
pgCopyBuf
);
/*
* fprintf(stderr, "Buffer is '%s'\n",
* AH->pgCopyBuf->data);
* fprintf(stderr, "Buffer is '%s'\n", AH->pgCopyBuf->data);
*/
if
(
isEnd
)
...
...
@@ -628,24 +628,23 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
return
qry
+
loc
+
1
;
}
/*
/*
* Used by ExecuteSqlCommandBuf to send one buffered line of SQL (not data for the copy command).
*/
static
char
*
_sendSQLLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
)
static
char
*
_sendSQLLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
)
{
int
pos
=
0
;
/* Current position */
int
pos
=
0
;
/* Current position */
/*
* The following is a mini state machine to assess the end of an
*
SQL statement. It really only needs to parse good SQL, or a
t
*
least that's the theory... End-of-statement is assumed to be an
* un
quoted, un
commented semi-colon.
* The following is a mini state machine to assess the end of an
SQL
*
statement. It really only needs to parse good SQL, or at leas
t
*
that's the theory... End-of-statement is assumed to be an unquoted,
* un commented semi-colon.
*/
/*
* fprintf(stderr, "Buffer at start is: '%s'\n\n",
* AH->sqlBuf->data);
* fprintf(stderr, "Buffer at start is: '%s'\n\n", AH->sqlBuf->data);
*/
for
(
pos
=
0
;
pos
<
(
eos
-
qry
);
pos
++
)
...
...
@@ -656,7 +655,7 @@ _sendSQLLine( ArchiveHandle *AH, char *qry, char *eos)
switch
(
AH
->
sqlparse
.
state
)
{
case
SQL_SCAN
:
/* Default state == 0, set in _allocAH */
case
SQL_SCAN
:
/* Default state == 0, set in _allocAH */
if
(
qry
[
pos
]
==
';'
&&
AH
->
sqlparse
.
braceDepth
==
0
)
{
...
...
@@ -670,11 +669,12 @@ _sendSQLLine( ArchiveHandle *AH, char *qry, char *eos)
resetPQExpBuffer
(
AH
->
sqlBuf
);
AH
->
sqlparse
.
lastChar
=
'\0'
;
/* Remove any following newlines - so that embedded COPY commands don't get a
* starting newline.
/*
* Remove any following newlines - so that embedded
* COPY commands don't get a starting newline.
*/
pos
++
;
for
(
;
pos
<
(
eos
-
qry
)
&&
qry
[
pos
]
==
'\n'
;
pos
++
)
;
for
(
;
pos
<
(
eos
-
qry
)
&&
qry
[
pos
]
==
'\n'
;
pos
++
)
;
/* We've got our line, so exit */
return
qry
+
pos
;
...
...
@@ -741,8 +741,11 @@ _sendSQLLine( ArchiveHandle *AH, char *qry, char *eos)
/* fprintf(stderr, "\n"); */
}
/* If we get here, we've processed entire string with no complete SQL stmt */
return
eos
;
/*
* If we get here, we've processed entire string with no complete SQL
* stmt
*/
return
eos
;
}
...
...
@@ -762,11 +765,10 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen)
/* Could switch between command and COPY IN mode at each line */
while
(
qry
<
eos
)
{
if
(
AH
->
pgCopyIn
)
{
if
(
AH
->
pgCopyIn
)
qry
=
_sendCopyLine
(
AH
,
qry
,
eos
);
}
else
{
else
qry
=
_sendSQLLine
(
AH
,
qry
,
eos
);
}
}
return
1
;
...
...
src/bin/pg_dump/pg_dump.c
浏览文件 @
69f909ba
...
...
@@ -22,7 +22,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.23
7 2002/01/11 23:21:55 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.23
8 2002/01/18 19:17:05 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -2035,7 +2035,7 @@ getFuncs(int *numFuncs)
* numTables is set to the number of tables read in
*/
TableInfo
*
getTables
(
int
*
numTables
,
FuncInfo
*
finfo
,
int
numFuncs
,
const
char
*
tablename
)
getTables
(
int
*
numTables
,
FuncInfo
*
finfo
,
int
numFuncs
,
const
char
*
tablename
)
{
PGresult
*
res
;
int
ntups
;
...
...
@@ -2127,14 +2127,15 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
/*
* First pass: extract data from result and lock tables. We do the
* locking before anything else, to minimize the window wherein a
table
* could disappear under us.
* locking before anything else, to minimize the window wherein a
*
table
could disappear under us.
*
* Note that we have to collect info about all tables here, even when
* dumping only one, because we don't know which tables might be
* inheritance ancestors of the target table. Possible future
* improvement: suppress later collection of schema info about tables
* that are determined not to be either targets or ancestors of targets.
* that are determined not to be either targets or ancestors of
* targets.
*/
tblinfo
=
(
TableInfo
*
)
malloc
(
ntups
*
sizeof
(
TableInfo
));
...
...
@@ -2167,26 +2168,27 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
*
* If no target tablename was specified, lock all tables we see,
* otherwise lock only the specified table. (This is incomplete
* because we'll still try to collect schema info about all tables,
* and could possibly lose during that phase. But for the typical
* use where we're dumping all tables anyway, it matters not.)
* because we'll still try to collect schema info about all
* tables, and could possibly lose during that phase. But for the
* typical use where we're dumping all tables anyway, it matters
* not.)
*
* NOTE: it'd be kinda nice to lock views and sequences too, not
*
only
plain tables, but the backend doesn't presently allow that.
* NOTE: it'd be kinda nice to lock views and sequences too, not
only
* plain tables, but the backend doesn't presently allow that.
*/
if
((
tblinfo
[
i
].
relkind
==
RELKIND_RELATION
)
&&
(
tablename
==
NULL
||
strcmp
(
tblinfo
[
i
].
relname
,
tablename
)
==
0
))
(
tablename
==
NULL
||
strcmp
(
tblinfo
[
i
].
relname
,
tablename
)
==
0
))
{
PGresult
*
lres
;
PGresult
*
lres
;
resetPQExpBuffer
(
lockquery
);
appendPQExpBuffer
(
lockquery
,
"LOCK TABLE %s IN ACCESS SHARE MODE"
,
fmtId
(
tblinfo
[
i
].
relname
,
force_quotes
));
lres
=
PQexec
(
g_conn
,
lockquery
->
data
);
lres
=
PQexec
(
g_conn
,
lockquery
->
data
);
if
(
!
lres
||
PQresultStatus
(
lres
)
!=
PGRES_COMMAND_OK
)
{
write_msg
(
NULL
,
"Attempt to lock table
\"
%s
\"
failed. %s"
,
write_msg
(
NULL
,
"Attempt to lock table
\"
%s
\"
failed. %s"
,
tblinfo
[
i
].
relname
,
PQerrorMessage
(
g_conn
));
exit_nicely
();
}
...
...
@@ -2198,8 +2200,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
res
=
NULL
;
/*
* Second pass: pick up additional information about each table,
*
as
required.
* Second pass: pick up additional information about each table,
as
* required.
*/
for
(
i
=
0
;
i
<
*
numTables
;
i
++
)
{
...
...
src/bin/pg_dump/pg_restore.c
浏览文件 @
69f909ba
...
...
@@ -34,7 +34,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.3
2 2002/01/10 01:11:45 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.3
3 2002/01/18 19:17:05 momjian
Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
...
...
@@ -393,7 +393,7 @@ usage(const char *progname)
" -F, --format={c|t} specify backup file format
\n
"
" -h, --host=HOSTNAME server host name
\n
"
" -i, --index=NAME restore named index
\n
"
" -l, --list print summarized TOC of the archive
\n
"
" -l, --list print summarized TOC of the archive
\n
"
" -L, --use-list=FILENAME use specified table of contents for ordering
\n
"
" output from this file
\n
"
" -N, --orig-order restore in original dump order
\n
"
...
...
@@ -429,12 +429,12 @@ usage(const char *progname)
" -F {c|t} specify backup file format
\n
"
" -h HOSTNAME server host name
\n
"
" -i NAME restore named index
\n
"
" -l print summarized TOC of the archive
\n
"
" -l print summarized TOC of the archive
\n
"
" -L FILENAME use specified table of contents for ordering
\n
"
" output from this file
\n
"
" -N restore in original dump order
\n
"
" -o restore in OID order
\n
"
" -O do not reconnect to database to match
\n
"
" -O do not reconnect to database to match
\n
"
" object owner
\n
"
" -p PORT server port number
\n
"
" -P NAME restore named function
\n
"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录