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
4cd086ce
Commit
4cd086ce
authored
Jan 18, 2000
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix quoting bugs and incorrect trigger argument printout.
parent
e1cce4d5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
62 deletions
+77
-62
src/bin/pg_dump/common.c
src/bin/pg_dump/common.c
+29
-18
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+48
-44
No files found.
src/bin/pg_dump/common.c
View file @
4cd086ce
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.3
7 2000/01/16 03:54
:58 tgl Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.3
8 2000/01/18 07:29
:58 tgl Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
...
...
@@ -39,8 +39,6 @@ static void flagInhAttrs(TableInfo *tbinfo, int numTables,
InhInfo
*
inhinfo
,
int
numInherits
);
static
int
strInArray
(
const
char
*
pattern
,
char
**
arr
,
int
arr_size
);
PQExpBuffer
id_return
;
/*
* findTypeByOid
* given an oid of a type, return its typename
...
...
@@ -505,27 +503,40 @@ findFuncByName(FuncInfo *finfo, int numFuncs, const char *name)
const
char
*
fmtId
(
const
char
*
rawid
,
bool
force_quotes
)
{
static
PQExpBuffer
id_return
=
NULL
;
const
char
*
cp
;
if
(
!
force_quotes
)
{
if
(
!
islower
(
*
rawid
))
force_quotes
=
true
;
else
for
(
cp
=
rawid
;
*
cp
;
cp
++
)
{
if
(
!
(
islower
(
*
cp
)
||
isdigit
(
*
cp
)
||
(
*
cp
==
'_'
)))
{
force_quotes
=
true
;
break
;
}
}
}
if
(
!
force_quotes
)
return
rawid
;
/* no quoting needed */
if
(
id_return
)
resetPQExpBuffer
(
id_return
);
else
id_return
=
createPQExpBuffer
();
if
(
!
force_quotes
)
for
(
cp
=
rawid
;
*
cp
!=
'\0'
;
cp
++
)
if
(
!
(
islower
(
*
cp
)
||
isdigit
(
*
cp
)
||
(
*
cp
==
'_'
)))
break
;
if
(
force_quotes
||
(
*
cp
!=
'\0'
))
appendPQExpBufferChar
(
id_return
,
'\"'
);
for
(
cp
=
rawid
;
*
cp
;
cp
++
)
{
appendPQExpBuffer
(
id_return
,
"
\"
"
);
appendPQExpBuffer
(
id_return
,
rawid
);
appendPQExpBuffer
(
id_return
,
"
\"
"
);
if
(
*
cp
==
'\"'
)
appendPQExpBufferChar
(
id_return
,
'\\'
);
appendPQExpBuffer
Char
(
id_return
,
*
cp
);
}
else
appendPQExpBuffer
(
id_return
,
rawid
);
appendPQExpBufferChar
(
id_return
,
'\"'
);
cp
=
id_return
->
data
;
return
cp
;
return
id_return
->
data
;
}
/* fmtId() */
src/bin/pg_dump/pg_dump.c
View file @
4cd086ce
...
...
@@ -21,7 +21,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.13
3 2000/01/18 00:03:37 petere
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.13
4 2000/01/18 07:29:58 tgl
Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
...
...
@@ -643,7 +643,8 @@ main(int argc, char **argv)
force_quotes
=
true
;
break
;
case
'o'
:
fprintf
(
stderr
,
"%s: The -o option for dumping oids is deprecated. Please use -O."
);
fprintf
(
stderr
,
"%s: The -o option for dumping oids is deprecated. Please use -O.
\n
"
,
progname
);
/* FALLTHRU */
case
'O'
:
/* Dump oids */
oids
=
true
;
break
;
...
...
@@ -1632,13 +1633,10 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
resetPQExpBuffer
(
query
);
if
(
name
[
0
]
!=
'$'
)
{
appendPQExpBuffer
(
query
,
"CONSTRAINT "
);
appendPQExpBuffer
(
query
,
fmtId
(
name
,
force_quotes
));
appendPQExpBufferChar
(
query
,
' '
);
appendPQExpBuffer
(
query
,
"CONSTRAINT %s "
,
fmtId
(
name
,
force_quotes
));
}
appendPQExpBuffer
(
query
,
"CHECK ("
);
appendPQExpBuffer
(
query
,
expr
);
appendPQExpBuffer
(
query
,
")"
);
appendPQExpBuffer
(
query
,
"CHECK (%s)"
,
expr
);
tblinfo
[
i
].
check_expr
[
i2
]
=
strdup
(
query
->
data
);
}
PQclear
(
res2
);
...
...
@@ -1650,7 +1648,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
if
(
strcmp
(
PQgetvalue
(
res
,
i
,
i_relhasindex
),
"t"
)
==
0
)
{
PGresult
*
res2
;
char
str
[
INDEX_MAX_KEYS
*
NAMEDATALEN
+
3
]
=
""
;
char
str
[
INDEX_MAX_KEYS
*
(
NAMEDATALEN
*
2
+
4
)
+
1
]
;
int
j
;
resetPQExpBuffer
(
query
);
...
...
@@ -1669,6 +1667,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
exit_nicely
(
g_conn
);
}
str
[
0
]
=
'\0'
;
for
(
j
=
0
;
j
<
PQntuples
(
res2
);
j
++
)
{
if
(
strlen
(
str
)
>
0
)
...
...
@@ -1740,7 +1739,6 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
int
tgnargs
=
atoi
(
PQgetvalue
(
res2
,
i2
,
i_tgnargs
));
const
char
*
tgargs
=
PQgetvalue
(
res2
,
i2
,
i_tgargs
);
const
char
*
p
;
PQExpBuffer
farg
=
createPQExpBuffer
();
int
findx
;
for
(
findx
=
0
;
findx
<
numFuncs
;
findx
++
)
...
...
@@ -1763,8 +1761,10 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
if (dropSchema)
{
resetPQExpBuffer(query);
appendPQExpBuffer(query, "DROP TRIGGER %s ON %s;\n",
fmtId(PQgetvalue(res2, i2, i_tgname), force_quotes),
appendPQExpBuffer(query, "DROP TRIGGER %s ",
fmtId(PQgetvalue(res2, i2, i_tgname),
force_quotes));
appendPQExpBuffer(query, "ON %s;\n",
fmtId(tblinfo[i].relname, force_quotes));
fputs(query->data, fout);
}
...
...
@@ -1800,8 +1800,10 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
else
appendPQExpBuffer
(
query
,
" UPDATE"
);
}
appendPQExpBuffer
(
query
,
" ON %s FOR EACH ROW EXECUTE PROCEDURE %s ("
,
fmtId
(
tblinfo
[
i
].
relname
,
force_quotes
),
tgfunc
);
appendPQExpBuffer
(
query
,
" ON %s FOR EACH ROW"
,
fmtId
(
tblinfo
[
i
].
relname
,
force_quotes
));
appendPQExpBuffer
(
query
,
" EXECUTE PROCEDURE %s ("
,
fmtId
(
tgfunc
,
force_quotes
));
for
(
findx
=
0
;
findx
<
tgnargs
;
findx
++
)
{
const
char
*
s
;
...
...
@@ -1827,15 +1829,14 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
break
;
}
p
--
;
appendPQExpBufferChar
(
query
,
'\''
);
for
(
s
=
tgargs
;
s
<
p
;)
{
if
(
*
s
==
'\''
)
appendPQExpBufferChar
(
farg
,
'\\'
);
appendPQExpBufferChar
(
farg
,
*
s
++
);
appendPQExpBufferChar
(
query
,
'\\'
);
appendPQExpBufferChar
(
query
,
*
s
++
);
}
appendPQExpBufferChar
(
query
,
'\''
);
appendPQExpBuffer
(
query
,
farg
->
data
);
appendPQExpBufferChar
(
query
,
'\''
);
appendPQExpBuffer
(
query
,
(
findx
<
tgnargs
-
1
)
?
", "
:
""
);
tgargs
=
p
+
4
;
}
...
...
@@ -2476,9 +2477,12 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators,
if
(
dropSchema
)
{
resetPQExpBuffer
(
q
);
appendPQExpBuffer
(
q
,
"DROP OPERATOR %s (%s, %s);
\n
"
,
oprinfo
[
i
].
oprname
,
fmtId
(
findTypeByOid
(
tinfo
,
numTypes
,
oprinfo
[
i
].
oprleft
),
false
),
fmtId
(
findTypeByOid
(
tinfo
,
numTypes
,
oprinfo
[
i
].
oprright
),
false
));
appendPQExpBuffer
(
q
,
"DROP OPERATOR %s (%s"
,
oprinfo
[
i
].
oprname
,
fmtId
(
findTypeByOid
(
tinfo
,
numTypes
,
oprinfo
[
i
].
oprleft
),
false
));
appendPQExpBuffer
(
q
,
", %s);
\n
"
,
fmtId
(
findTypeByOid
(
tinfo
,
numTypes
,
oprinfo
[
i
].
oprright
),
false
));
fputs
(
q
->
data
,
fout
);
}
...
...
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