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
3d726290
Commit
3d726290
authored
Apr 24, 2002
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove traces of NAMEDATALEN and INDEX_MAX_KEYS from psql. Build buffers
dynamically with PQExpBuffer.
parent
246f47fd
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
292 additions
and
293 deletions
+292
-293
src/bin/psql/command.c
src/bin/psql/command.c
+6
-4
src/bin/psql/copy.c
src/bin/psql/copy.c
+23
-27
src/bin/psql/describe.c
src/bin/psql/describe.c
+263
-262
No files found.
src/bin/psql/command.c
View file @
3d726290
...
...
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.7
1 2002/03/27 19:16:13
petere Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.7
2 2002/04/24 05:24:00
petere Exp $
*/
#include "postgres_fe.h"
#include "command.h"
...
...
@@ -1433,14 +1433,16 @@ bool
test_superuser
(
const
char
*
username
)
{
PGresult
*
res
;
char
buf
[
64
+
NAMEDATALEN
]
;
PQExpBufferData
buf
;
bool
answer
;
if
(
!
username
)
return
false
;
sprintf
(
buf
,
"SELECT usesuper FROM pg_user WHERE usename = '%.*s'"
,
NAMEDATALEN
,
username
);
res
=
PSQLexec
(
buf
);
initPQExpBuffer
(
&
buf
);
printfPQExpBuffer
(
&
buf
,
"SELECT usesuper FROM pg_user WHERE usename = '%s'"
,
username
);
res
=
PSQLexec
(
buf
.
data
);
termPQExpBuffer
(
&
buf
);
answer
=
(
PQntuples
(
res
)
>
0
&&
PQnfields
(
res
)
>
0
...
...
src/bin/psql/copy.c
View file @
3d726290
...
...
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.2
0 2002/02/23 21:46:03 momjian
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.2
1 2002/04/24 05:24:00 petere
Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
...
...
@@ -19,6 +19,7 @@
#endif
#include "libpq-fe.h"
#include "pqexpbuffer.h"
#include "pqsignal.h"
#include "settings.h"
...
...
@@ -229,12 +230,12 @@ parse_slash_copy(const char *args)
bool
do_copy
(
const
char
*
args
)
{
char
query
[
128
+
NAMEDATALEN
]
;
PQExpBufferData
query
;
FILE
*
copystream
;
struct
copy_options
*
options
;
PGresult
*
result
;
bool
success
;
struct
stat
st
;
struct
stat
st
;
/* parse options */
options
=
parse_slash_copy
(
args
);
...
...
@@ -242,35 +243,27 @@ do_copy(const char *args)
if
(
!
options
)
return
false
;
strcpy
(
query
,
"COPY "
);
initPQExpBuffer
(
&
query
);
printfPQExpBuffer
(
&
query
,
"COPY "
);
if
(
options
->
binary
)
strcat
(
query
,
"BINARY "
);
appendPQExpBuffer
(
&
query
,
"BINARY "
);
strcat
(
query
,
"
\"
"
);
strncat
(
query
,
options
->
table
,
NAMEDATALEN
);
strcat
(
query
,
"
\"
"
);
appendPQExpBuffer
(
&
query
,
"
\"
%s
\"
"
,
options
->
table
);
if
(
options
->
oids
)
strcat
(
query
,
"WITH OIDS "
);
appendPQExpBuffer
(
&
query
,
"WITH OIDS "
);
if
(
options
->
from
)
strcat
(
query
,
"FROM STDIN"
);
appendPQExpBuffer
(
&
query
,
"FROM STDIN"
);
else
strcat
(
query
,
"TO STDOUT"
);
appendPQExpBuffer
(
&
query
,
"TO STDOUT"
);
if
(
options
->
delim
)
{
strcat
(
query
,
" USING DELIMITERS '"
);
strcat
(
query
,
options
->
delim
);
strcat
(
query
,
"'"
);
}
appendPQExpBuffer
(
&
query
,
" USING DELIMITERS '%s'"
,
options
->
delim
);
if
(
options
->
null
)
{
strcat
(
query
,
" WITH NULL AS '"
);
strcat
(
query
,
options
->
null
);
strcat
(
query
,
"'"
);
}
appendPQExpBuffer
(
&
query
,
" WITH NULL AS '%s'"
,
options
->
null
);
if
(
options
->
from
)
{
...
...
@@ -294,17 +287,20 @@ do_copy(const char *args)
free_copy_options
(
options
);
return
false
;
}
/* make sure the specified file is not a directory */
fstat
(
fileno
(
copystream
),
&
st
);
if
(
S_ISDIR
(
st
.
st_mode
)
){
fclose
(
copystream
);
/* make sure the specified file is not a directory */
fstat
(
fileno
(
copystream
),
&
st
);
if
(
S_ISDIR
(
st
.
st_mode
)
)
{
fclose
(
copystream
);
psql_error
(
"%s: cannot COPY TO/FROM a directory
\n
"
,
options
->
file
);
free_copy_options
(
options
);
return
false
;
}
}
result
=
PSQLexec
(
query
);
result
=
PSQLexec
(
query
.
data
);
termPQExpBuffer
(
&
query
);
switch
(
PQresultStatus
(
result
))
{
...
...
src/bin/psql/describe.c
View file @
3d726290
This diff is collapsed.
Click to expand it.
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