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
e10bb051
Commit
e10bb051
authored
Jan 25, 2004
by
Neil Conway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More fallout from the recent psql patch: rename xmalloc and friends to
pg_malloc, to avoid linker failures on same platforms.
parent
afe7b7b6
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
108 additions
and
120 deletions
+108
-120
src/bin/psql/command.c
src/bin/psql/command.c
+17
-17
src/bin/psql/common.c
src/bin/psql/common.c
+7
-8
src/bin/psql/common.h
src/bin/psql/common.h
+5
-5
src/bin/psql/copy.c
src/bin/psql/copy.c
+10
-10
src/bin/psql/describe.c
src/bin/psql/describe.c
+24
-35
src/bin/psql/input.c
src/bin/psql/input.c
+6
-6
src/bin/psql/mainloop.c
src/bin/psql/mainloop.c
+3
-3
src/bin/psql/prompt.c
src/bin/psql/prompt.c
+3
-3
src/bin/psql/startup.c
src/bin/psql/startup.c
+11
-11
src/bin/psql/stringutils.c
src/bin/psql/stringutils.c
+2
-2
src/bin/psql/tab-complete.c
src/bin/psql/tab-complete.c
+12
-12
src/bin/psql/variables.c
src/bin/psql/variables.c
+8
-8
No files found.
src/bin/psql/command.c
View file @
e10bb051
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.11
0 2004/01/24 19:38:49
neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.11
1 2004/01/25 03:07:22
neilc Exp $
*/
#include "postgres_fe.h"
#include "command.h"
...
...
@@ -97,7 +97,7 @@ HandleSlashCmds(const char *line,
* backslash command ended */
psql_assert
(
line
);
my_line
=
x
strdup
(
line
);
my_line
=
pg_
strdup
(
line
);
/*
* Find the first whitespace. line[blank_loc] will now be the
...
...
@@ -199,7 +199,7 @@ exec_command(const char *cmd,
* end.
*/
if
(
options_string
)
string
=
string_cpy
=
x
strdup
(
options_string
);
string
=
string_cpy
=
pg_
strdup
(
options_string
);
else
string
=
string_cpy
=
NULL
;
...
...
@@ -497,7 +497,7 @@ exec_command(const char *cmd,
else
{
expand_tilde
(
&
fname
);
pset
.
gfname
=
x
strdup
(
fname
);
pset
.
gfname
=
pg_
strdup
(
fname
);
}
free
(
fname
);
status
=
CMD_SEND
;
...
...
@@ -693,7 +693,7 @@ exec_command(const char *cmd,
char
*
opt
;
opt
=
scan_option
(
&
string
,
OT_NORMAL
,
NULL
,
false
);
newval
=
x
strdup
(
opt
?
opt
:
""
);
newval
=
pg_
strdup
(
opt
?
opt
:
""
);
free
(
opt
);
while
((
opt
=
scan_option
(
&
string
,
OT_NORMAL
,
NULL
,
false
)))
...
...
@@ -1057,7 +1057,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
}
else
{
return_val
=
x
strdup
(
""
);
return_val
=
pg_
strdup
(
""
);
termPQExpBuffer
(
&
output
);
}
...
...
@@ -1081,7 +1081,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
save_char
=
options_string
[
pos
+
token_end
+
1
];
options_string
[
pos
+
token_end
+
1
]
=
'\0'
;
value
=
GetVariable
(
pset
.
vars
,
options_string
+
pos
+
1
);
return_val
=
x
strdup
(
value
?
value
:
""
);
return_val
=
pg_
strdup
(
value
?
value
:
""
);
options_string
[
pos
+
token_end
+
1
]
=
save_char
;
*
string
=
&
options_string
[
pos
+
token_end
+
1
];
/* XXX should we set *quote to ':' here? */
...
...
@@ -1096,7 +1096,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
if
(
type
==
OT_FILEPIPE
)
{
*
string
+=
strlen
(
*
string
);
return
x
strdup
(
options_string
+
pos
);
return
pg_
strdup
(
options_string
+
pos
);
}
/* fallthrough for other option types */
...
...
@@ -1156,7 +1156,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
/* Copy the option */
token_len
=
cp
-
&
options_string
[
pos
];
return_val
=
x
malloc
(
token_len
+
1
);
return_val
=
pg_
malloc
(
token_len
+
1
);
memcpy
(
return_val
,
&
options_string
[
pos
],
token_len
);
return_val
[
token_len
]
=
'\0'
;
...
...
@@ -1245,7 +1245,7 @@ unescape(const unsigned char *source, size_t len)
length
=
Min
(
len
,
strlen
(
source
))
+
1
;
tmp
=
destination
=
x
malloc
(
length
);
tmp
=
destination
=
pg_
malloc
(
length
);
for
(
p
=
source
;
p
-
source
<
(
int
)
len
&&
*
p
;
p
+=
PQmblen
(
p
,
pset
.
encoding
))
{
...
...
@@ -1526,7 +1526,7 @@ editFile(const char *fname)
if
(
!
editorName
)
editorName
=
DEFAULT_EDITOR
;
sys
=
x
malloc
(
strlen
(
editorName
)
+
strlen
(
fname
)
+
10
+
1
);
sys
=
pg_
malloc
(
strlen
(
editorName
)
+
strlen
(
fname
)
+
10
+
1
);
sprintf
(
sys
,
#ifndef WIN32
"exec "
...
...
@@ -1802,7 +1802,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if
(
value
)
{
free
(
popt
->
nullPrint
);
popt
->
nullPrint
=
x
strdup
(
value
);
popt
->
nullPrint
=
pg_
strdup
(
value
);
}
if
(
!
quiet
)
printf
(
gettext
(
"Null display is
\"
%s
\"
.
\n
"
),
popt
->
nullPrint
?
popt
->
nullPrint
:
""
);
...
...
@@ -1814,7 +1814,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if
(
value
)
{
free
(
popt
->
topt
.
fieldSep
);
popt
->
topt
.
fieldSep
=
x
strdup
(
value
);
popt
->
topt
.
fieldSep
=
pg_
strdup
(
value
);
}
if
(
!
quiet
)
printf
(
gettext
(
"Field separator is
\"
%s
\"
.
\n
"
),
popt
->
topt
.
fieldSep
);
...
...
@@ -1826,7 +1826,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if
(
value
)
{
free
(
popt
->
topt
.
recordSep
);
popt
->
topt
.
recordSep
=
x
strdup
(
value
);
popt
->
topt
.
recordSep
=
pg_
strdup
(
value
);
}
if
(
!
quiet
)
{
...
...
@@ -1857,7 +1857,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if
(
!
value
)
popt
->
title
=
NULL
;
else
popt
->
title
=
x
strdup
(
value
);
popt
->
title
=
pg_
strdup
(
value
);
if
(
!
quiet
)
{
...
...
@@ -1875,7 +1875,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if
(
!
value
)
popt
->
topt
.
tableAttr
=
NULL
;
else
popt
->
topt
.
tableAttr
=
x
strdup
(
value
);
popt
->
topt
.
tableAttr
=
pg_
strdup
(
value
);
if
(
!
quiet
)
{
...
...
@@ -1946,7 +1946,7 @@ do_shell(const char *command)
if
(
shellName
==
NULL
)
shellName
=
DEFAULT_SHELL
;
sys
=
x
malloc
(
strlen
(
shellName
)
+
16
);
sys
=
pg_
malloc
(
strlen
(
shellName
)
+
16
);
sprintf
(
sys
,
#ifndef WIN32
"exec "
...
...
src/bin/psql/common.c
View file @
e10bb051
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.8
1 2004/01/24 19:38:49
neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.8
2 2004/01/25 03:07:22
neilc Exp $
*/
#include "postgres_fe.h"
#include "common.h"
...
...
@@ -70,7 +70,7 @@ static bool is_transact_command(const char *query);
* "Safe" wrapper around strdup()
*/
char
*
x
strdup
(
const
char
*
string
)
pg_
strdup
(
const
char
*
string
)
{
char
*
tmp
;
...
...
@@ -90,7 +90,7 @@ xstrdup(const char *string)
}
void
*
x
malloc
(
size_t
size
)
pg_
malloc
(
size_t
size
)
{
void
*
tmp
;
...
...
@@ -104,17 +104,17 @@ xmalloc(size_t size)
}
void
*
x
malloc_zero
(
size_t
size
)
pg_
malloc_zero
(
size_t
size
)
{
void
*
tmp
;
tmp
=
x
malloc
(
size
);
tmp
=
pg_
malloc
(
size
);
memset
(
tmp
,
0
,
size
);
return
tmp
;
}
void
*
x
calloc
(
size_t
nmemb
,
size_t
size
)
pg_
calloc
(
size_t
nmemb
,
size_t
size
)
{
void
*
tmp
;
...
...
@@ -127,7 +127,6 @@ xcalloc(size_t nmemb, size_t size)
return
tmp
;
}
/*
* setQFout
* -- handler for -o command line option and \o command
...
...
@@ -891,7 +890,7 @@ expand_tilde(char **filename)
{
char
*
newfn
;
newfn
=
x
malloc
(
strlen
(
home
)
+
strlen
(
p
)
+
1
);
newfn
=
pg_
malloc
(
strlen
(
home
)
+
strlen
(
p
)
+
1
);
strcpy
(
newfn
,
home
);
strcat
(
newfn
,
p
);
...
...
src/bin/psql/common.h
View file @
e10bb051
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.3
3 2004/01/24 19:38:49
neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.3
4 2004/01/25 03:07:22
neilc Exp $
*/
#ifndef COMMON_H
#define COMMON_H
...
...
@@ -25,10 +25,10 @@
* out-of-memory condition occurs, these functions will bail out
* safely; therefore, their return value is guaranteed to be non-NULL.
*/
extern
char
*
x
strdup
(
const
char
*
string
);
extern
void
*
x
malloc
(
size_t
size
);
extern
void
*
x
malloc_zero
(
size_t
size
);
extern
void
*
x
calloc
(
size_t
nmemb
,
size_t
size
);
extern
char
*
pg_
strdup
(
const
char
*
string
);
extern
void
*
pg_
malloc
(
size_t
size
);
extern
void
*
pg_
malloc_zero
(
size_t
size
);
extern
void
*
pg_
calloc
(
size_t
nmemb
,
size_t
size
);
extern
bool
setQFout
(
const
char
*
fname
);
...
...
src/bin/psql/copy.c
View file @
e10bb051
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.3
8 2004/01/24 19:38:49
neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.3
9 2004/01/25 03:07:22
neilc Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
...
...
@@ -83,7 +83,7 @@ xstrcat(char **var, const char *more)
{
char
*
newvar
;
newvar
=
x
malloc
(
strlen
(
*
var
)
+
strlen
(
more
)
+
1
);
newvar
=
pg_
malloc
(
strlen
(
*
var
)
+
strlen
(
more
)
+
1
);
strcpy
(
newvar
,
*
var
);
strcat
(
newvar
,
more
);
free
(
*
var
);
...
...
@@ -100,14 +100,14 @@ parse_slash_copy(const char *args)
const
char
*
whitespace
=
"
\t\n\r
"
;
if
(
args
)
line
=
x
strdup
(
args
);
line
=
pg_
strdup
(
args
);
else
{
psql_error
(
"
\\
copy: arguments required
\n
"
);
return
NULL
;
}
result
=
x
calloc
(
1
,
sizeof
(
struct
copy_options
));
result
=
pg_
calloc
(
1
,
sizeof
(
struct
copy_options
));
token
=
strtokx
(
line
,
whitespace
,
".,()"
,
"
\"
"
,
0
,
false
,
pset
.
encoding
);
...
...
@@ -126,7 +126,7 @@ parse_slash_copy(const char *args)
}
#endif
result
->
table
=
x
strdup
(
token
);
result
->
table
=
pg_
strdup
(
token
);
token
=
strtokx
(
NULL
,
whitespace
,
".,()"
,
"
\"
"
,
0
,
false
,
pset
.
encoding
);
...
...
@@ -156,7 +156,7 @@ parse_slash_copy(const char *args)
if
(
token
[
0
]
==
'('
)
{
/* handle parenthesized column list */
result
->
column_list
=
x
strdup
(
token
);
result
->
column_list
=
pg_
strdup
(
token
);
for
(;;)
{
token
=
strtokx
(
NULL
,
whitespace
,
".,()"
,
"
\"
"
,
...
...
@@ -227,7 +227,7 @@ parse_slash_copy(const char *args)
else
{
result
->
in_dash
=
false
;
result
->
file
=
x
strdup
(
token
);
result
->
file
=
pg_
strdup
(
token
);
expand_tilde
(
&
result
->
file
);
}
...
...
@@ -247,7 +247,7 @@ parse_slash_copy(const char *args)
'\\'
,
false
,
pset
.
encoding
);
if
(
!
token
)
goto
error
;
result
->
delim
=
x
strdup
(
token
);
result
->
delim
=
pg_
strdup
(
token
);
token
=
strtokx
(
NULL
,
whitespace
,
NULL
,
NULL
,
0
,
false
,
pset
.
encoding
);
}
...
...
@@ -267,7 +267,7 @@ parse_slash_copy(const char *args)
token
=
strtokx
(
NULL
,
whitespace
,
NULL
,
"'"
,
'\\'
,
false
,
pset
.
encoding
);
if
(
token
)
result
->
delim
=
x
strdup
(
token
);
result
->
delim
=
pg_
strdup
(
token
);
else
goto
error
;
}
...
...
@@ -279,7 +279,7 @@ parse_slash_copy(const char *args)
token
=
strtokx
(
NULL
,
whitespace
,
NULL
,
"'"
,
'\\'
,
false
,
pset
.
encoding
);
if
(
token
)
result
->
null
=
x
strdup
(
token
);
result
->
null
=
pg_
strdup
(
token
);
else
goto
error
;
}
...
...
src/bin/psql/describe.c
View file @
e10bb051
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.9
3 2004/01/24 19:38:49
neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.9
4 2004/01/25 03:07:22
neilc Exp $
*/
#include "postgres_fe.h"
#include "describe.h"
...
...
@@ -39,17 +39,6 @@ static void processNamePattern(PQExpBuffer buf, const char *pattern,
const
char
*
schemavar
,
const
char
*
namevar
,
const
char
*
altnamevar
,
const
char
*
visibilityrule
);
static
void
*
xmalloczero
(
size_t
size
)
{
void
*
tmp
;
tmp
=
xmalloc
(
size
);
memset
(
tmp
,
0
,
size
);
return
tmp
;
}
/*----------------
* Handlers for various slash commands displaying some sort of list
* of things in the database.
...
...
@@ -737,14 +726,14 @@ describeOneTableDetails(const char *schemaname,
goto
error_return
;
if
(
PQntuples
(
result
)
>
0
)
view_def
=
x
strdup
(
PQgetvalue
(
result
,
0
,
0
));
view_def
=
pg_
strdup
(
PQgetvalue
(
result
,
0
,
0
));
PQclear
(
result
);
}
/* Generate table cells to be printed */
/* note: initialize all cells[] to NULL in case of error exit */
cells
=
xmalloc
zero
((
numrows
*
cols
+
1
)
*
sizeof
(
*
cells
));
cells
=
pg_malloc_
zero
((
numrows
*
cols
+
1
)
*
sizeof
(
*
cells
));
for
(
i
=
0
;
i
<
numrows
;
i
++
)
{
...
...
@@ -782,9 +771,9 @@ describeOneTableDetails(const char *schemaname,
}
#ifdef WIN32
cells
[
i
*
cols
+
2
]
=
x
strdup
(
mbvalidate
(
tmpbuf
.
data
,
myopt
.
encoding
));
cells
[
i
*
cols
+
2
]
=
pg_
strdup
(
mbvalidate
(
tmpbuf
.
data
,
myopt
.
encoding
));
#else
cells
[
i
*
cols
+
2
]
=
x
strdup
(
tmpbuf
.
data
);
cells
[
i
*
cols
+
2
]
=
pg_
strdup
(
tmpbuf
.
data
);
#endif
}
...
...
@@ -879,8 +868,8 @@ describeOneTableDetails(const char *schemaname,
if
(
strlen
(
indpred
))
appendPQExpBuffer
(
&
tmpbuf
,
_
(
", predicate (%s)"
),
indpred
);
footers
=
xmalloc
zero
(
2
*
sizeof
(
*
footers
));
footers
[
0
]
=
x
strdup
(
tmpbuf
.
data
);
footers
=
pg_malloc_
zero
(
2
*
sizeof
(
*
footers
));
footers
[
0
]
=
pg_
strdup
(
tmpbuf
.
data
);
footers
[
1
]
=
NULL
;
}
...
...
@@ -908,8 +897,8 @@ describeOneTableDetails(const char *schemaname,
}
/* Footer information about a view */
footers
=
xmalloc
zero
((
rule_count
+
3
)
*
sizeof
(
*
footers
));
footers
[
count_footers
]
=
x
malloc
(
64
+
strlen
(
view_def
));
footers
=
pg_malloc_
zero
((
rule_count
+
3
)
*
sizeof
(
*
footers
));
footers
[
count_footers
]
=
pg_
malloc
(
64
+
strlen
(
view_def
));
snprintf
(
footers
[
count_footers
],
64
+
strlen
(
view_def
),
_
(
"View definition:
\n
%s"
),
view_def
);
count_footers
++
;
...
...
@@ -918,7 +907,7 @@ describeOneTableDetails(const char *schemaname,
if
(
rule_count
>
0
)
{
printfPQExpBuffer
(
&
buf
,
_
(
"Rules:"
));
footers
[
count_footers
++
]
=
x
strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_
strdup
(
buf
.
data
);
for
(
i
=
0
;
i
<
rule_count
;
i
++
)
{
const
char
*
ruledef
;
...
...
@@ -929,7 +918,7 @@ describeOneTableDetails(const char *schemaname,
printfPQExpBuffer
(
&
buf
,
" %s"
,
ruledef
);
footers
[
count_footers
++
]
=
x
strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_
strdup
(
buf
.
data
);
}
PQclear
(
result
);
}
...
...
@@ -1066,14 +1055,14 @@ describeOneTableDetails(const char *schemaname,
else
inherits_count
=
PQntuples
(
result6
);
footers
=
xmalloc
zero
((
index_count
+
check_count
+
rule_count
+
trigger_count
+
foreignkey_count
+
inherits_count
+
6
)
*
sizeof
(
*
footers
));
footers
=
pg_malloc_
zero
((
index_count
+
check_count
+
rule_count
+
trigger_count
+
foreignkey_count
+
inherits_count
+
6
)
*
sizeof
(
*
footers
));
/* print indexes */
if
(
index_count
>
0
)
{
printfPQExpBuffer
(
&
buf
,
_
(
"Indexes:"
));
footers
[
count_footers
++
]
=
x
strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_
strdup
(
buf
.
data
);
for
(
i
=
0
;
i
<
index_count
;
i
++
)
{
const
char
*
indexdef
;
...
...
@@ -1099,7 +1088,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBuffer
(
&
buf
,
" %s"
,
indexdef
);
footers
[
count_footers
++
]
=
x
strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_
strdup
(
buf
.
data
);
}
}
...
...
@@ -1107,14 +1096,14 @@ describeOneTableDetails(const char *schemaname,
if
(
check_count
>
0
)
{
printfPQExpBuffer
(
&
buf
,
_
(
"Check constraints:"
));
footers
[
count_footers
++
]
=
x
strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_
strdup
(
buf
.
data
);
for
(
i
=
0
;
i
<
check_count
;
i
++
)
{
printfPQExpBuffer
(
&
buf
,
_
(
"
\"
%s
\"
%s"
),
PQgetvalue
(
result2
,
i
,
1
),
PQgetvalue
(
result2
,
i
,
0
));
footers
[
count_footers
++
]
=
x
strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_
strdup
(
buf
.
data
);
}
}
...
...
@@ -1122,14 +1111,14 @@ describeOneTableDetails(const char *schemaname,
if
(
foreignkey_count
>
0
)
{
printfPQExpBuffer
(
&
buf
,
_
(
"Foreign-key constraints:"
));
footers
[
count_footers
++
]
=
x
strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_
strdup
(
buf
.
data
);
for
(
i
=
0
;
i
<
foreignkey_count
;
i
++
)
{
printfPQExpBuffer
(
&
buf
,
_
(
"
\"
%s
\"
%s"
),
PQgetvalue
(
result5
,
i
,
0
),
PQgetvalue
(
result5
,
i
,
1
));
footers
[
count_footers
++
]
=
x
strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_
strdup
(
buf
.
data
);
}
}
...
...
@@ -1137,7 +1126,7 @@ describeOneTableDetails(const char *schemaname,
if
(
rule_count
>
0
)
{
printfPQExpBuffer
(
&
buf
,
_
(
"Rules:"
));
footers
[
count_footers
++
]
=
x
strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_
strdup
(
buf
.
data
);
for
(
i
=
0
;
i
<
rule_count
;
i
++
)
{
const
char
*
ruledef
;
...
...
@@ -1148,7 +1137,7 @@ describeOneTableDetails(const char *schemaname,
printfPQExpBuffer
(
&
buf
,
" %s"
,
ruledef
);
footers
[
count_footers
++
]
=
x
strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_
strdup
(
buf
.
data
);
}
}
...
...
@@ -1156,7 +1145,7 @@ describeOneTableDetails(const char *schemaname,
if
(
trigger_count
>
0
)
{
printfPQExpBuffer
(
&
buf
,
_
(
"Triggers:"
));
footers
[
count_footers
++
]
=
x
strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_
strdup
(
buf
.
data
);
for
(
i
=
0
;
i
<
trigger_count
;
i
++
)
{
const
char
*
tgdef
;
...
...
@@ -1170,7 +1159,7 @@ describeOneTableDetails(const char *schemaname,
printfPQExpBuffer
(
&
buf
,
" %s"
,
tgdef
);
footers
[
count_footers
++
]
=
x
strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_
strdup
(
buf
.
data
);
}
}
...
...
@@ -1186,7 +1175,7 @@ describeOneTableDetails(const char *schemaname,
if
(
i
<
inherits_count
-
1
)
appendPQExpBuffer
(
&
buf
,
","
);
footers
[
count_footers
++
]
=
x
strdup
(
buf
.
data
);
footers
[
count_footers
++
]
=
pg_
strdup
(
buf
.
data
);
}
/* end of list marker */
...
...
src/bin/psql/input.c
View file @
e10bb051
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.3
3 2004/01/24 19:38:49
neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.3
4 2004/01/25 03:07:22
neilc Exp $
*/
#include "postgres_fe.h"
#include "input.h"
...
...
@@ -113,7 +113,7 @@ gets_interactive(const char *prompt)
else
{
free
(
prev_hist
);
prev_hist
=
x
strdup
(
s
);
prev_hist
=
pg_
strdup
(
s
);
add_history
(
s
);
}
}
...
...
@@ -185,8 +185,8 @@ initializeInput(int flags)
{
char
*
psql_history
;
psql_history
=
x
malloc
(
strlen
(
home
)
+
1
+
strlen
(
PSQLHISTORY
)
+
1
);
psql_history
=
pg_
malloc
(
strlen
(
home
)
+
1
+
strlen
(
PSQLHISTORY
)
+
1
);
sprintf
(
psql_history
,
"%s/%s"
,
home
,
PSQLHISTORY
);
read_history
(
psql_history
);
free
(
psql_history
);
...
...
@@ -239,8 +239,8 @@ finishInput(int exitstatus, void *arg)
char
*
psql_history
;
int
hist_size
;
psql_history
=
x
malloc
(
strlen
(
home
)
+
1
+
strlen
(
PSQLHISTORY
)
+
1
);
psql_history
=
pg_
malloc
(
strlen
(
home
)
+
1
+
strlen
(
PSQLHISTORY
)
+
1
);
hist_size
=
GetVariableNum
(
pset
.
vars
,
"HISTSIZE"
,
-
1
,
-
1
,
true
);
...
...
src/bin/psql/mainloop.c
View file @
e10bb051
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.6
0 2004/01/24 19:38:49
neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.6
1 2004/01/25 03:07:22
neilc Exp $
*/
#include "postgres_fe.h"
#include "mainloop.h"
...
...
@@ -144,7 +144,7 @@ MainLoop(FILE *source)
* just returned from editing the line? then just copy to the
* input buffer
*/
line
=
x
strdup
(
query_buf
->
data
);
line
=
pg_
strdup
(
query_buf
->
data
);
resetPQExpBuffer
(
query_buf
);
/* reset parsing state since we are rescanning whole line */
in_xcomment
=
0
;
...
...
@@ -332,7 +332,7 @@ MainLoop(FILE *source)
/* It is a variable, perform substitution */
out_length
=
strlen
(
value
);
new
=
x
malloc
(
len
+
out_length
-
in_length
+
1
);
new
=
pg_
malloc
(
len
+
out_length
-
in_length
+
1
);
sprintf
(
new
,
"%.*s%s%s"
,
i
,
line
,
value
,
&
line
[
i
+
thislen
+
in_length
]);
...
...
src/bin/psql/prompt.c
View file @
e10bb051
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.3
3 2004/01/24 19:38:49
neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.3
4 2004/01/25 03:07:22
neilc Exp $
*/
#include "postgres_fe.h"
#include "prompt.h"
...
...
@@ -248,7 +248,7 @@ get_prompt(promptStatus_t status)
case
'`'
:
{
FILE
*
fd
=
NULL
;
char
*
file
=
x
strdup
(
p
+
1
);
char
*
file
=
pg_
strdup
(
p
+
1
);
int
cmdend
;
cmdend
=
strcspn
(
file
,
"`"
);
...
...
@@ -274,7 +274,7 @@ get_prompt(promptStatus_t status)
const
char
*
val
;
int
nameend
;
name
=
x
strdup
(
p
+
1
);
name
=
pg_
strdup
(
p
+
1
);
nameend
=
strcspn
(
name
,
":"
);
name
[
nameend
]
=
'\0'
;
val
=
GetVariable
(
pset
.
vars
,
name
);
...
...
src/bin/psql/startup.c
View file @
e10bb051
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.8
2 2004/01/24 19:38:49
neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.8
3 2004/01/25 03:07:22
neilc Exp $
*/
#include "postgres_fe.h"
...
...
@@ -156,9 +156,9 @@ main(int argc, char *argv[])
parse_psql_options
(
argc
,
argv
,
&
options
);
if
(
!
pset
.
popt
.
topt
.
fieldSep
)
pset
.
popt
.
topt
.
fieldSep
=
x
strdup
(
DEFAULT_FIELD_SEP
);
pset
.
popt
.
topt
.
fieldSep
=
pg_
strdup
(
DEFAULT_FIELD_SEP
);
if
(
!
pset
.
popt
.
topt
.
recordSep
)
pset
.
popt
.
topt
.
recordSep
=
x
strdup
(
DEFAULT_RECORD_SEP
);
pset
.
popt
.
topt
.
recordSep
=
pg_
strdup
(
DEFAULT_RECORD_SEP
);
if
(
options
.
username
)
{
...
...
@@ -170,7 +170,7 @@ main(int argc, char *argv[])
if
(
strcmp
(
options
.
username
,
"
\001
"
)
==
0
)
username
=
simple_prompt
(
"User name: "
,
100
,
true
);
else
username
=
x
strdup
(
options
.
username
);
username
=
pg_
strdup
(
options
.
username
);
}
if
(
pset
.
getPassword
)
...
...
@@ -387,7 +387,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
options
->
action_string
=
optarg
;
break
;
case
'F'
:
pset
.
popt
.
topt
.
fieldSep
=
x
strdup
(
optarg
);
pset
.
popt
.
topt
.
fieldSep
=
pg_
strdup
(
optarg
);
break
;
case
'h'
:
options
->
host
=
optarg
;
...
...
@@ -413,7 +413,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
char
*
equal_loc
;
bool
result
;
value
=
x
strdup
(
optarg
);
value
=
pg_
strdup
(
optarg
);
equal_loc
=
strchr
(
value
,
'='
);
if
(
!
equal_loc
)
result
=
do_pset
(
value
,
NULL
,
&
pset
.
popt
,
true
);
...
...
@@ -436,7 +436,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
SetVariableBool
(
pset
.
vars
,
"QUIET"
);
break
;
case
'R'
:
pset
.
popt
.
topt
.
recordSep
=
x
strdup
(
optarg
);
pset
.
popt
.
topt
.
recordSep
=
pg_
strdup
(
optarg
);
break
;
case
's'
:
SetVariableBool
(
pset
.
vars
,
"SINGLESTEP"
);
...
...
@@ -448,7 +448,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
pset
.
popt
.
topt
.
tuples_only
=
true
;
break
;
case
'T'
:
pset
.
popt
.
topt
.
tableAttr
=
x
strdup
(
optarg
);
pset
.
popt
.
topt
.
tableAttr
=
pg_
strdup
(
optarg
);
break
;
case
'u'
:
pset
.
getPassword
=
true
;
...
...
@@ -465,7 +465,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
char
*
value
;
char
*
equal_loc
;
value
=
x
strdup
(
optarg
);
value
=
pg_
strdup
(
optarg
);
equal_loc
=
strchr
(
value
,
'='
);
if
(
!
equal_loc
)
{
...
...
@@ -567,8 +567,8 @@ process_psqlrc(void)
if
(
home
)
{
psqlrc
=
x
malloc
(
strlen
(
home
)
+
1
+
strlen
(
PSQLRC
)
+
1
+
strlen
(
PG_VERSION
)
+
1
);
psqlrc
=
pg_
malloc
(
strlen
(
home
)
+
1
+
strlen
(
PSQLRC
)
+
1
+
strlen
(
PG_VERSION
)
+
1
);
sprintf
(
psqlrc
,
"%s/%s-%s"
,
home
,
PSQLRC
,
PG_VERSION
);
if
(
access
(
psqlrc
,
R_OK
)
==
0
)
...
...
src/bin/psql/stringutils.c
View file @
e10bb051
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.3
7 2004/01/24 19:38:49
neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.3
8 2004/01/25 03:07:22
neilc Exp $
*/
#include "postgres_fe.h"
...
...
@@ -77,7 +77,7 @@ strtokx(const char *s,
* tokens. 2X the space is a gross overestimate, but it's
* unlikely that this code will be used on huge strings anyway.
*/
storage
=
x
malloc
(
2
*
strlen
(
s
)
+
1
);
storage
=
pg_
malloc
(
2
*
strlen
(
s
)
+
1
);
strcpy
(
storage
,
s
);
string
=
storage
;
}
...
...
src/bin/psql/tab-complete.c
View file @
e10bb051
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.
99 2004/01/24 19:38:49
neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.
100 2004/01/25 03:07:22
neilc Exp $
*/
/*----------------------------------------------------------------------
...
...
@@ -1417,7 +1417,7 @@ create_command_generator(const char *text, int state)
/* find something that matches */
while
((
name
=
words_after_create
[
list_index
++
].
name
))
if
(
strncasecmp
(
name
,
text
,
string_length
)
==
0
)
return
x
strdup
(
name
);
return
pg_
strdup
(
name
);
/* if nothing matches, return NULL */
return
NULL
;
...
...
@@ -1485,7 +1485,7 @@ _complete_from_query(int is_schema_query, const char *text, int state)
/* Set up suitably-escaped copies of textual inputs */
if
(
text
)
{
e_text
=
x
malloc
(
strlen
(
text
)
*
2
+
1
);
e_text
=
pg_
malloc
(
strlen
(
text
)
*
2
+
1
);
PQescapeString
(
e_text
,
text
,
strlen
(
text
));
}
else
...
...
@@ -1496,7 +1496,7 @@ _complete_from_query(int is_schema_query, const char *text, int state)
size_t
charp_len
;
charp_len
=
strlen
(
completion_info_charp
);
e_info_charp
=
x
malloc
(
charp_len
*
2
+
1
);
e_info_charp
=
pg_
malloc
(
charp_len
*
2
+
1
);
PQescapeString
(
e_info_charp
,
completion_info_charp
,
charp_len
);
}
...
...
@@ -1618,7 +1618,7 @@ _complete_from_query(int is_schema_query, const char *text, int state)
while
(
list_index
<
PQntuples
(
result
)
&&
(
item
=
PQgetvalue
(
result
,
list_index
++
,
0
)))
if
(
strncasecmp
(
text
,
item
,
string_length
)
==
0
)
return
x
strdup
(
item
);
return
pg_
strdup
(
item
);
}
/* If nothing matches, free the db structure and return null */
...
...
@@ -1659,12 +1659,12 @@ complete_from_list(const char *text, int state)
if
(
casesensitive
&&
strncmp
(
text
,
item
,
string_length
)
==
0
)
{
matches
++
;
return
x
strdup
(
item
);
return
pg_
strdup
(
item
);
}
/* Second pass is case insensitive, don't bother counting matches */
if
(
!
casesensitive
&&
strncasecmp
(
text
,
item
,
string_length
)
==
0
)
return
x
strdup
(
item
);
return
pg_
strdup
(
item
);
}
/*
...
...
@@ -1698,7 +1698,7 @@ complete_from_const(const char *text, int state)
psql_assert
(
completion_charp
);
if
(
state
==
0
)
return
x
strdup
(
completion_charp
);
return
pg_
strdup
(
completion_charp
);
else
return
NULL
;
}
...
...
@@ -1788,7 +1788,7 @@ previous_word(int point, int skip)
}
/* make a copy */
s
=
x
malloc
(
end
-
start
+
2
);
s
=
pg_
malloc
(
end
-
start
+
2
);
strncpy
(
s
,
&
rl_line_buffer
[
start
],
end
-
start
+
1
);
s
[
end
-
start
+
1
]
=
'\0'
;
...
...
@@ -1814,7 +1814,7 @@ quote_file_name(char *text, int match_type, char *quote_pointer)
(void) quote_pointer; /* not used */
length = strlen(text) +(match_type == SINGLE_MATCH ? 3 : 2);
s =
x
malloc(length);
s =
pg_
malloc(length);
s[0] = '\'';
strcpy(s + 1, text);
if (match_type == SINGLE_MATCH)
...
...
@@ -1832,10 +1832,10 @@ dequote_file_name(char *text, char quote_char)
size_t length;
if (!quote_char)
return
x
strdup(text);
return
pg_
strdup(text);
length = strlen(text);
s =
x
malloc(length - 2 + 1);
s =
pg_
malloc(length - 2 + 1);
strncpy(s, text +1, length - 2);
s[length] = '\0';
...
...
src/bin/psql/variables.c
View file @
e10bb051
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.1
6 2004/01/24 19:38:49
neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.1
7 2004/01/25 03:07:22
neilc Exp $
*/
#include "postgres_fe.h"
#include "common.h"
...
...
@@ -14,9 +14,9 @@ CreateVariableSpace(void)
{
struct
_variable
*
ptr
;
ptr
=
x
calloc
(
1
,
sizeof
*
ptr
);
ptr
->
name
=
x
strdup
(
"@"
);
ptr
->
value
=
x
strdup
(
""
);
ptr
=
pg_
calloc
(
1
,
sizeof
*
ptr
);
ptr
->
name
=
pg_
strdup
(
"@"
);
ptr
->
value
=
pg_
strdup
(
""
);
return
ptr
;
}
...
...
@@ -152,14 +152,14 @@ SetVariable(VariableSpace space, const char *name, const char *value)
if
(
strcmp
(
current
->
name
,
name
)
==
0
)
{
free
(
current
->
value
);
current
->
value
=
x
strdup
(
value
);
current
->
value
=
pg_
strdup
(
value
);
return
true
;
}
}
previous
->
next
=
x
calloc
(
1
,
sizeof
*
(
previous
->
next
));
previous
->
next
->
name
=
x
strdup
(
name
);
previous
->
next
->
value
=
x
strdup
(
value
);
previous
->
next
=
pg_
calloc
(
1
,
sizeof
*
(
previous
->
next
));
previous
->
next
->
name
=
pg_
strdup
(
name
);
previous
->
next
->
value
=
pg_
strdup
(
value
);
return
true
;
}
...
...
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