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
0dd73814
Commit
0dd73814
authored
Oct 30, 1997
by
Thomas G. Lockhart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support SQL92 delimited identifiers by checking some attribute names
for mixed-case and surrounding with double quotes.
parent
cc1b420c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
29 deletions
+59
-29
src/bin/pg_dump/common.c
src/bin/pg_dump/common.c
+28
-1
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+27
-27
src/bin/pg_dump/pg_dump.h
src/bin/pg_dump/pg_dump.h
+4
-1
No files found.
src/bin/pg_dump/common.c
View file @
0dd73814
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.1
7 1997/10/02 13:57:03 vadim
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.1
8 1997/10/30 16:47:57 thomas
Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
...
...
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/param.h>
/* for MAXHOSTNAMELEN on most */
#ifdef sparc_solaris
#include <netdb.h>
/* for MAXHOSTNAMELEN on some */
...
...
@@ -478,3 +479,29 @@ isArchiveName(const char *relname)
{
return
(
strlen
(
relname
)
>
1
&&
relname
[
1
]
==
','
);
}
/*
* fmtId
*
* checks input string for non-lowercase characters
* returns pointer to input string or string surrounded by double quotes
*/
const
char
*
fmtId
(
const
char
*
rawid
)
{
const
char
*
cp
;
static
char
id
[
MAXQUERYLEN
];
for
(
cp
=
rawid
;
*
cp
!=
'\0'
;
cp
++
)
if
(
!
(
islower
(
*
cp
)
||
isdigit
(
*
cp
)
||
(
*
cp
==
'_'
)))
break
;
if
(
*
cp
!=
'\0'
)
{
strcpy
(
id
,
"
\"
"
);
strcat
(
id
,
rawid
);
strcat
(
id
,
"
\"
"
);
cp
=
id
;
}
else
{
cp
=
rawid
;
}
return
(
cp
);
}
/* fmtId() */
src/bin/pg_dump/pg_dump.c
View file @
0dd73814
...
...
@@ -21,7 +21,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.5
1 1997/10/30 03:59:46 momjian
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.5
2 1997/10/30 16:47:59 thomas
Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
...
...
@@ -205,14 +205,14 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids)
if
(
oids
)
{
fprintf
(
fout
,
"COPY %s WITH OIDS FROM stdin;
\n
"
,
classname
);
fmtId
(
classname
)
);
sprintf
(
query
,
"COPY %s WITH OIDS TO stdout;
\n
"
,
classname
);
fmtId
(
classname
)
);
}
else
{
fprintf
(
fout
,
"COPY %s FROM stdin;
\n
"
,
classname
);
sprintf
(
query
,
"COPY %s TO stdout;
\n
"
,
classname
);
fprintf
(
fout
,
"COPY %s FROM stdin;
\n
"
,
fmtId
(
classname
)
);
sprintf
(
query
,
"COPY %s TO stdout;
\n
"
,
fmtId
(
classname
)
);
}
res
=
PQexec
(
g_conn
,
query
);
if
(
!
res
)
...
...
@@ -309,7 +309,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname,
tuple
=
0
;
while
(
tuple
<
PQntuples
(
res
))
{
fprintf
(
fout
,
"insert into %s "
,
classname
);
fprintf
(
fout
,
"insert into %s "
,
fmtId
(
classname
)
);
if
(
attrNames
)
{
int
j
;
...
...
@@ -323,7 +323,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname,
sprintf
(
q
,
"%s%s%s"
,
q
,
(
actual_atts
>
0
)
?
","
:
""
,
tblinfo
.
attnames
[
j
]
);
fmtId
(
tblinfo
.
attnames
[
j
])
);
actual_atts
++
;
}
}
...
...
@@ -1944,12 +1944,12 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
sprintf
(
q
,
"%s%s%s"
,
q
,
(
j
>
0
)
?
","
:
""
,
typname
);
fmtId
(
typname
)
);
}
sprintf
(
q
,
"%s ) RETURNS %s%s AS '%s' LANGUAGE '%s';
\n
"
,
q
,
(
finfo
[
i
].
retset
)
?
" SETOF "
:
""
,
f
indTypeByOid
(
tinfo
,
numTypes
,
finfo
[
i
].
prorettype
),
f
mtId
(
findTypeByOid
(
tinfo
,
numTypes
,
finfo
[
i
].
prorettype
)
),
(
finfo
[
i
].
lang
==
INTERNALlanguageId
)
?
finfo
[
i
].
prosrc
:
(
finfo
[
i
].
lang
==
ClanguageId
)
?
finfo
[
i
].
probin
:
(
finfo
[
i
].
lang
==
SQLlanguageId
)
?
finfo
[
i
].
prosrc
:
"unknown"
,
...
...
@@ -2005,13 +2005,13 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators,
strcmp
(
oprinfo
[
i
].
oprkind
,
"b"
)
==
0
)
{
sprintf
(
leftarg
,
", LEFTARG = %s "
,
f
indTypeByOid
(
tinfo
,
numTypes
,
oprinfo
[
i
].
oprleft
));
f
mtId
(
findTypeByOid
(
tinfo
,
numTypes
,
oprinfo
[
i
].
oprleft
)
));
}
if
(
strcmp
(
oprinfo
[
i
].
oprkind
,
"l"
)
==
0
||
strcmp
(
oprinfo
[
i
].
oprkind
,
"b"
)
==
0
)
{
sprintf
(
rightarg
,
", RIGHTARG = %s "
,
f
indTypeByOid
(
tinfo
,
numTypes
,
oprinfo
[
i
].
oprright
));
f
mtId
(
findTypeByOid
(
tinfo
,
numTypes
,
oprinfo
[
i
].
oprright
)
));
}
if
(
strcmp
(
oprinfo
[
i
].
oprcom
,
"0"
)
==
0
)
commutator
[
0
]
=
'\0'
;
...
...
@@ -2094,7 +2094,7 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs,
sprintf
(
basetype
,
"BASETYPE = %s, "
,
f
indTypeByOid
(
tinfo
,
numTypes
,
agginfo
[
i
].
aggbasetype
));
f
mtId
(
findTypeByOid
(
tinfo
,
numTypes
,
agginfo
[
i
].
aggbasetype
)
));
if
(
strcmp
(
agginfo
[
i
].
aggtransfn1
,
"-"
)
==
0
)
sfunc1
[
0
]
=
'\0'
;
...
...
@@ -2103,7 +2103,7 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs,
sprintf
(
sfunc1
,
"SFUNC1 = %s, STYPE1 = %s"
,
agginfo
[
i
].
aggtransfn1
,
f
indTypeByOid
(
tinfo
,
numTypes
,
agginfo
[
i
].
aggtranstype1
));
f
mtId
(
findTypeByOid
(
tinfo
,
numTypes
,
agginfo
[
i
].
aggtranstype1
)
));
if
(
agginfo
[
i
].
agginitval1
)
sprintf
(
sfunc1
,
"%s, INITCOND1 = '%s'"
,
sfunc1
,
agginfo
[
i
].
agginitval1
);
...
...
@@ -2117,7 +2117,7 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs,
sprintf
(
sfunc2
,
"SFUNC2 = %s, STYPE2 = %s"
,
agginfo
[
i
].
aggtransfn2
,
f
indTypeByOid
(
tinfo
,
numTypes
,
agginfo
[
i
].
aggtranstype2
));
f
mtId
(
findTypeByOid
(
tinfo
,
numTypes
,
agginfo
[
i
].
aggtranstype2
)
));
if
(
agginfo
[
i
].
agginitval2
)
sprintf
(
sfunc2
,
"%s, INITCOND2 = '%s'"
,
sfunc2
,
agginfo
[
i
].
agginitval2
);
...
...
@@ -2213,7 +2213,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
fprintf
(
fout
,
"
\\
connect - %s
\n
"
,
tblinfo
[
i
].
usename
);
sprintf
(
q
,
"CREATE TABLE %s ("
,
tblinfo
[
i
].
relname
);
sprintf
(
q
,
"CREATE TABLE %s ("
,
fmtId
(
tblinfo
[
i
].
relname
)
);
actual_atts
=
0
;
for
(
j
=
0
;
j
<
tblinfo
[
i
].
numatts
;
j
++
)
{
...
...
@@ -2226,7 +2226,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
sprintf
(
q
,
"%s%s%s char"
,
q
,
(
actual_atts
>
0
)
?
", "
:
""
,
tblinfo
[
i
].
attnames
[
j
]
);
fmtId
(
tblinfo
[
i
].
attnames
[
j
])
);
/* stored length can be -1 (variable) */
if
(
tblinfo
[
i
].
attlen
[
j
]
>
0
)
...
...
@@ -2240,7 +2240,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
sprintf
(
q
,
"%s%s%s %s"
,
q
,
(
actual_atts
>
0
)
?
", "
:
""
,
tblinfo
[
i
].
attnames
[
j
]
,
fmtId
(
tblinfo
[
i
].
attnames
[
j
])
,
tblinfo
[
i
].
typnames
[
j
]);
/* stored length can be -1 (variable) */
...
...
@@ -2255,8 +2255,8 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
sprintf
(
q
,
"%s%s%s %s"
,
q
,
(
actual_atts
>
0
)
?
", "
:
""
,
tblinfo
[
i
].
attnames
[
j
]
,
tblinfo
[
i
].
typnames
[
j
]
);
fmtId
(
tblinfo
[
i
].
attnames
[
j
])
,
fmtId
(
tblinfo
[
i
].
typnames
[
j
])
);
actual_atts
++
;
}
if
(
tblinfo
[
i
].
adef_expr
[
j
]
!=
NULL
)
...
...
@@ -2347,7 +2347,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
for
(
i
=
0
;
i
<
numIndices
;
i
++
)
{
tableInd
=
findTableByName
(
tblinfo
,
numTables
,
indinfo
[
i
].
indrelname
);
fmtId
(
indinfo
[
i
].
indrelname
)
);
if
(
strcmp
(
indinfo
[
i
].
indproc
,
"0"
)
==
0
)
{
...
...
@@ -2420,7 +2420,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
attname
=
tblinfo
[
tableInd
].
attnames
[
indkey
];
if
(
funcname
)
sprintf
(
attlist
+
strlen
(
attlist
),
"%s%s"
,
(
k
==
0
)
?
""
:
", "
,
attname
);
(
k
==
0
)
?
""
:
", "
,
fmtId
(
attname
)
);
else
{
if
(
k
>=
nclass
)
...
...
@@ -2431,7 +2431,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
exit_nicely
(
g_conn
);
}
sprintf
(
attlist
+
strlen
(
attlist
),
"%s%s %s"
,
(
k
==
0
)
?
""
:
", "
,
attname
,
classname
[
k
]
);
(
k
==
0
)
?
""
:
", "
,
fmtId
(
attname
),
fmtId
(
classname
[
k
])
);
free
(
classname
[
k
]);
}
}
...
...
@@ -2441,13 +2441,13 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
sprintf
(
q
,
"CREATE %s INDEX %s on %s using %s ("
,
(
strcmp
(
indinfo
[
i
].
indisunique
,
"t"
)
==
0
)
?
"UNIQUE"
:
""
,
indinfo
[
i
].
indexrelname
,
indinfo
[
i
].
indrelname
,
fmtId
(
indinfo
[
i
].
indexrelname
)
,
fmtId
(
indinfo
[
i
].
indrelname
)
,
indinfo
[
i
].
indamname
);
if
(
funcname
)
{
sprintf
(
q
,
"%s %s (%s) %s );
\n
"
,
q
,
funcname
,
attlist
,
classname
[
0
]
);
q
,
funcname
,
attlist
,
fmtId
(
classname
[
0
])
);
free
(
funcname
);
free
(
classname
[
0
]);
}
...
...
@@ -2666,7 +2666,7 @@ dumpSequence(FILE *fout, TableInfo tbinfo)
sprintf
(
query
,
"SELECT sequence_name, last_value, increment_by, max_value, "
"min_value, cache_value, is_cycled, is_called from %s"
,
tbinfo
.
relname
);
fmtId
(
tbinfo
.
relname
)
);
res
=
PQexec
(
g_conn
,
query
);
if
(
!
res
||
PQresultStatus
(
res
)
!=
PGRES_TUPLES_OK
)
...
...
@@ -2706,7 +2706,7 @@ dumpSequence(FILE *fout, TableInfo tbinfo)
sprintf
(
query
,
"CREATE SEQUENCE %s start %d increment %d maxvalue %d "
"minvalue %d cache %d %s;
\n
"
,
tbinfo
.
relname
,
last
,
incby
,
maxv
,
minv
,
cache
,
fmtId
(
tbinfo
.
relname
)
,
last
,
incby
,
maxv
,
minv
,
cache
,
(
cycled
==
't'
)
?
"cycle"
:
""
);
fputs
(
query
,
fout
);
...
...
src/bin/pg_dump/pg_dump.h
View file @
0dd73814
...
...
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_dump.h,v 1.2
5 1997/10/02 13:57:07 vadim
Exp $
* $Id: pg_dump.h,v 1.2
6 1997/10/30 16:48:03 thomas
Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
...
...
@@ -233,5 +233,8 @@ extern void
dumpIndices
(
FILE
*
fout
,
IndInfo
*
indinfo
,
int
numIndices
,
TableInfo
*
tbinfo
,
int
numTables
,
const
char
*
tablename
);
extern
const
char
*
fmtId
(
const
char
*
identifier
);
/* largest query string size */
#define MAXQUERYLEN 5000
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