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
2ee0d554
Commit
2ee0d554
authored
Jun 14, 2005
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add -L option to psql to log sessions.
Lorne Sunley
parent
e31cd673
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
89 additions
and
41 deletions
+89
-41
doc/src/sgml/ref/psql-ref.sgml
doc/src/sgml/ref/psql-ref.sgml
+12
-1
src/bin/psql/common.c
src/bin/psql/common.c
+20
-3
src/bin/psql/describe.c
src/bin/psql/describe.c
+17
-17
src/bin/psql/help.c
src/bin/psql/help.c
+3
-2
src/bin/psql/large_obj.c
src/bin/psql/large_obj.c
+2
-2
src/bin/psql/print.c
src/bin/psql/print.c
+7
-4
src/bin/psql/print.h
src/bin/psql/print.h
+4
-3
src/bin/psql/settings.h
src/bin/psql/settings.h
+2
-1
src/bin/psql/startup.c
src/bin/psql/startup.c
+18
-4
src/bin/scripts/createlang.c
src/bin/scripts/createlang.c
+2
-2
src/bin/scripts/droplang.c
src/bin/scripts/droplang.c
+2
-2
No files found.
doc/src/sgml/ref/psql-ref.sgml
View file @
2ee0d554
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.14
4 2005/06/13 06:36:22 neilc
Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.14
5 2005/06/14 02:57:38 momjian
Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -222,6 +222,17 @@ PostgreSQL documentation
...
@@ -222,6 +222,17 @@ PostgreSQL documentation
</listitem>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
<term><option>-L <replaceable class="parameter">filename</replaceable></></term>
<term><option>--log <replaceable class="parameter">filename</replaceable></></term>
<listitem>
<para>
Log all query output into file <replaceable
class="parameter">filename</replaceable> in addition to the regular output source.
</para>
</listitem>
</varlistentry>
<varlistentry>
<varlistentry>
<term><option>-o <replaceable class="parameter">filename</replaceable></></term>
<term><option>-o <replaceable class="parameter">filename</replaceable></></term>
<term><option>--output <replaceable class="parameter">filename</replaceable></></term>
<term><option>--output <replaceable class="parameter">filename</replaceable></></term>
...
...
src/bin/psql/common.c
View file @
2ee0d554
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.10
1 2005/06/13 06:36:22 neilc
Exp $
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.10
2 2005/06/14 02:57:41 momjian
Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "common.h"
#include "common.h"
...
@@ -723,6 +723,13 @@ PSQLexec(const char *query, bool start_xact)
...
@@ -723,6 +723,13 @@ PSQLexec(const char *query, bool start_xact)
"%s
\n
"
"%s
\n
"
"**************************
\n\n
"
,
query
);
"**************************
\n\n
"
,
query
);
fflush
(
stdout
);
fflush
(
stdout
);
if
(
pset
.
logfile
)
{
fprintf
(
pset
.
logfile
,
"********* QUERY **********
\n
"
"%s
\n
"
"**************************
\n\n
"
,
query
);
fflush
(
pset
.
logfile
);
}
if
(
echo_hidden
==
1
)
/* noexec? */
if
(
echo_hidden
==
1
)
/* noexec? */
return
NULL
;
return
NULL
;
...
@@ -803,7 +810,7 @@ PrintQueryTuples(const PGresult *results)
...
@@ -803,7 +810,7 @@ PrintQueryTuples(const PGresult *results)
return
false
;
return
false
;
}
}
printQuery
(
results
,
&
my_popt
,
pset
.
queryFout
);
printQuery
(
results
,
&
my_popt
,
pset
.
queryFout
,
pset
.
logfile
);
/* close file/pipe, restore old setting */
/* close file/pipe, restore old setting */
setQFout
(
NULL
);
setQFout
(
NULL
);
...
@@ -815,7 +822,7 @@ PrintQueryTuples(const PGresult *results)
...
@@ -815,7 +822,7 @@ PrintQueryTuples(const PGresult *results)
pset
.
gfname
=
NULL
;
pset
.
gfname
=
NULL
;
}
}
else
else
printQuery
(
results
,
&
my_popt
,
pset
.
queryFout
);
printQuery
(
results
,
&
my_popt
,
pset
.
queryFout
,
pset
.
logfile
);
return
true
;
return
true
;
}
}
...
@@ -905,6 +912,8 @@ PrintQueryResults(PGresult *results)
...
@@ -905,6 +912,8 @@ PrintQueryResults(PGresult *results)
else
else
fprintf
(
pset
.
queryFout
,
"%s
\n
"
,
PQcmdStatus
(
results
));
fprintf
(
pset
.
queryFout
,
"%s
\n
"
,
PQcmdStatus
(
results
));
}
}
if
(
pset
.
logfile
)
fprintf
(
pset
.
logfile
,
"%s
\n
"
,
PQcmdStatus
(
results
));
SetVariable
(
pset
.
vars
,
"LASTOID"
,
buf
);
SetVariable
(
pset
.
vars
,
"LASTOID"
,
buf
);
break
;
break
;
}
}
...
@@ -976,6 +985,14 @@ SendQuery(const char *query)
...
@@ -976,6 +985,14 @@ SendQuery(const char *query)
fflush
(
stdout
);
fflush
(
stdout
);
}
}
if
(
pset
.
logfile
)
{
fprintf
(
pset
.
logfile
,
"********* QUERY **********
\n
"
"%s
\n
"
"**************************
\n\n
"
,
query
);
fflush
(
pset
.
logfile
);
}
SetCancelConn
();
SetCancelConn
();
transaction_status
=
PQtransactionStatus
(
pset
.
db
);
transaction_status
=
PQtransactionStatus
(
pset
.
db
);
...
...
src/bin/psql/describe.c
View file @
2ee0d554
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.11
5 2005/04/06 05:23:32 neilc
Exp $
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.11
6 2005/06/14 02:57:41 momjian
Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "describe.h"
#include "describe.h"
...
@@ -94,7 +94,7 @@ describeAggregates(const char *pattern, bool verbose)
...
@@ -94,7 +94,7 @@ describeAggregates(const char *pattern, bool verbose)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of aggregate functions"
);
myopt
.
title
=
_
(
"List of aggregate functions"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
@@ -147,7 +147,7 @@ describeTablespaces(const char *pattern, bool verbose)
...
@@ -147,7 +147,7 @@ describeTablespaces(const char *pattern, bool verbose)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of tablespaces"
);
myopt
.
title
=
_
(
"List of tablespaces"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
@@ -219,7 +219,7 @@ describeFunctions(const char *pattern, bool verbose)
...
@@ -219,7 +219,7 @@ describeFunctions(const char *pattern, bool verbose)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of functions"
);
myopt
.
title
=
_
(
"List of functions"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
@@ -287,7 +287,7 @@ describeTypes(const char *pattern, bool verbose)
...
@@ -287,7 +287,7 @@ describeTypes(const char *pattern, bool verbose)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of data types"
);
myopt
.
title
=
_
(
"List of data types"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
@@ -334,7 +334,7 @@ describeOperators(const char *pattern)
...
@@ -334,7 +334,7 @@ describeOperators(const char *pattern)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of operators"
);
myopt
.
title
=
_
(
"List of operators"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
@@ -379,7 +379,7 @@ listAllDbs(bool verbose)
...
@@ -379,7 +379,7 @@ listAllDbs(bool verbose)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of databases"
);
myopt
.
title
=
_
(
"List of databases"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
@@ -436,7 +436,7 @@ permissionsList(const char *pattern)
...
@@ -436,7 +436,7 @@ permissionsList(const char *pattern)
printfPQExpBuffer
(
&
buf
,
_
(
"Access privileges for database
\"
%s
\"
"
),
PQdb
(
pset
.
db
));
printfPQExpBuffer
(
&
buf
,
_
(
"Access privileges for database
\"
%s
\"
"
),
PQdb
(
pset
.
db
));
myopt
.
title
=
buf
.
data
;
myopt
.
title
=
buf
.
data
;
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
termPQExpBuffer
(
&
buf
);
termPQExpBuffer
(
&
buf
);
PQclear
(
res
);
PQclear
(
res
);
...
@@ -592,7 +592,7 @@ objectDescription(const char *pattern)
...
@@ -592,7 +592,7 @@ objectDescription(const char *pattern)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"Object descriptions"
);
myopt
.
title
=
_
(
"Object descriptions"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
@@ -1279,7 +1279,7 @@ describeOneTableDetails(const char *schemaname,
...
@@ -1279,7 +1279,7 @@ describeOneTableDetails(const char *schemaname,
printTable
(
title
.
data
,
headers
,
printTable
(
title
.
data
,
headers
,
(
const
char
**
)
cells
,
(
const
char
**
)
footers
,
(
const
char
**
)
cells
,
(
const
char
**
)
footers
,
"llll"
,
&
myopt
,
pset
.
queryFout
);
"llll"
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
retval
=
true
;
retval
=
true
;
...
@@ -1391,7 +1391,7 @@ describeUsers(const char *pattern)
...
@@ -1391,7 +1391,7 @@ describeUsers(const char *pattern)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of users"
);
myopt
.
title
=
_
(
"List of users"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
@@ -1431,7 +1431,7 @@ describeGroups(const char *pattern)
...
@@ -1431,7 +1431,7 @@ describeGroups(const char *pattern)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of groups"
);
myopt
.
title
=
_
(
"List of groups"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
@@ -1549,7 +1549,7 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
...
@@ -1549,7 +1549,7 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of relations"
);
myopt
.
title
=
_
(
"List of relations"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
}
}
PQclear
(
res
);
PQclear
(
res
);
...
@@ -1605,7 +1605,7 @@ listDomains(const char *pattern)
...
@@ -1605,7 +1605,7 @@ listDomains(const char *pattern)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of domains"
);
myopt
.
title
=
_
(
"List of domains"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
@@ -1656,7 +1656,7 @@ listConversions(const char *pattern)
...
@@ -1656,7 +1656,7 @@ listConversions(const char *pattern)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of conversions"
);
myopt
.
title
=
_
(
"List of conversions"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
@@ -1706,7 +1706,7 @@ listCasts(const char *pattern)
...
@@ -1706,7 +1706,7 @@ listCasts(const char *pattern)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of casts"
);
myopt
.
title
=
_
(
"List of casts"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
@@ -1756,7 +1756,7 @@ listSchemas(const char *pattern, bool verbose)
...
@@ -1756,7 +1756,7 @@ listSchemas(const char *pattern, bool verbose)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of schemas"
);
myopt
.
title
=
_
(
"List of schemas"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
...
src/bin/psql/help.c
View file @
2ee0d554
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.10
1 2005/02/22 04:40:55
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.10
2 2005/06/14 02:57:41
momjian Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "common.h"
#include "common.h"
...
@@ -60,7 +60,7 @@ usage(void)
...
@@ -60,7 +60,7 @@ usage(void)
user
=
getenv
(
"PGUSER"
);
user
=
getenv
(
"PGUSER"
);
if
(
!
user
)
if
(
!
user
)
{
{
#if
ndef WIN32
#if
!defined(WIN32) && !defined(__OS2__)
pw
=
getpwuid
(
geteuid
());
pw
=
getpwuid
(
geteuid
());
if
(
pw
)
if
(
pw
)
user
=
pw
->
pw_name
;
user
=
pw
->
pw_name
;
...
@@ -107,6 +107,7 @@ usage(void)
...
@@ -107,6 +107,7 @@ usage(void)
puts
(
_
(
" -n disable enhanced command line editing (readline)"
));
puts
(
_
(
" -n disable enhanced command line editing (readline)"
));
puts
(
_
(
" -s single-step mode (confirm each query)"
));
puts
(
_
(
" -s single-step mode (confirm each query)"
));
puts
(
_
(
" -S single-line mode (end of line terminates SQL command)"
));
puts
(
_
(
" -S single-line mode (end of line terminates SQL command)"
));
puts
(
_
(
" -L FILENAME send session log to file"
));
puts
(
_
(
"
\n
Output format options:"
));
puts
(
_
(
"
\n
Output format options:"
));
puts
(
_
(
" -A unaligned table output mode (-P format=unaligned)"
));
puts
(
_
(
" -A unaligned table output mode (-P format=unaligned)"
));
...
...
src/bin/psql/large_obj.c
View file @
2ee0d554
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.3
6 2005/02/22 04:40:55
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.3
7 2005/06/14 02:57:41
momjian Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "large_obj.h"
#include "large_obj.h"
...
@@ -263,7 +263,7 @@ do_lo_list(void)
...
@@ -263,7 +263,7 @@ do_lo_list(void)
myopt
.
nullPrint
=
NULL
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"Large objects"
);
myopt
.
title
=
_
(
"Large objects"
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
);
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
PQclear
(
res
);
PQclear
(
res
);
return
true
;
return
true
;
...
...
src/bin/psql/print.c
View file @
2ee0d554
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.5
8 2005/06/13 06:36:22 neilc
Exp $
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.5
9 2005/06/14 02:57:41 momjian
Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "common.h"
#include "common.h"
...
@@ -1255,7 +1255,7 @@ printTable(const char *title,
...
@@ -1255,7 +1255,7 @@ printTable(const char *title,
const
char
*
const
*
cells
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
const
*
footers
,
const
char
*
align
,
const
char
*
align
,
const
printTableOpt
*
opt
,
FILE
*
fout
)
const
printTableOpt
*
opt
,
FILE
*
fout
,
FILE
*
flog
)
{
{
const
char
*
default_footer
[]
=
{
NULL
};
const
char
*
default_footer
[]
=
{
NULL
};
unsigned
short
int
border
=
opt
->
border
;
unsigned
short
int
border
=
opt
->
border
;
...
@@ -1312,6 +1312,9 @@ printTable(const char *title,
...
@@ -1312,6 +1312,9 @@ printTable(const char *title,
/* print the stuff */
/* print the stuff */
if
(
flog
)
print_aligned_text
(
title
,
headers
,
cells
,
footers
,
align
,
opt
->
tuples_only
,
border
,
opt
->
encoding
,
flog
);
switch
(
opt
->
format
)
switch
(
opt
->
format
)
{
{
case
PRINT_UNALIGNED
:
case
PRINT_UNALIGNED
:
...
@@ -1380,7 +1383,7 @@ printTable(const char *title,
...
@@ -1380,7 +1383,7 @@ printTable(const char *title,
void
void
printQuery
(
const
PGresult
*
result
,
const
printQueryOpt
*
opt
,
FILE
*
fout
)
printQuery
(
const
PGresult
*
result
,
const
printQueryOpt
*
opt
,
FILE
*
fout
,
FILE
*
flog
)
{
{
int
nfields
;
int
nfields
;
int
ncells
;
int
ncells
;
...
@@ -1476,7 +1479,7 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
...
@@ -1476,7 +1479,7 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
/* call table printer */
/* call table printer */
printTable
(
opt
->
title
,
headers
,
cells
,
printTable
(
opt
->
title
,
headers
,
cells
,
(
const
char
*
const
*
)
footers
,
(
const
char
*
const
*
)
footers
,
align
,
&
opt
->
topt
,
fout
);
align
,
&
opt
->
topt
,
fout
,
flog
);
free
(
headers
);
free
(
headers
);
free
(
cells
);
free
(
cells
);
...
...
src/bin/psql/print.h
View file @
2ee0d554
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.2
4 2005/06/13 06:36:22 neilc
Exp $
* $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.2
5 2005/06/14 02:57:41 momjian
Exp $
*/
*/
#ifndef PRINT_H
#ifndef PRINT_H
#define PRINT_H
#define PRINT_H
...
@@ -62,7 +62,7 @@ typedef struct _printTableOpt
...
@@ -62,7 +62,7 @@ typedef struct _printTableOpt
void
printTable
(
const
char
*
title
,
const
char
*
const
*
headers
,
void
printTable
(
const
char
*
title
,
const
char
*
const
*
headers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
align
,
const
char
*
align
,
const
printTableOpt
*
opt
,
FILE
*
fout
);
const
printTableOpt
*
opt
,
FILE
*
fout
,
FILE
*
flog
);
...
@@ -82,7 +82,8 @@ typedef struct _printQueryOpt
...
@@ -82,7 +82,8 @@ typedef struct _printQueryOpt
*
*
* It calls the printTable above with all the things set straight.
* It calls the printTable above with all the things set straight.
*/
*/
void
printQuery
(
const
PGresult
*
result
,
const
printQueryOpt
*
opt
,
FILE
*
fout
);
void
printQuery
(
const
PGresult
*
result
,
const
printQueryOpt
*
opt
,
FILE
*
fout
,
FILE
*
flog
);
#ifndef __CYGWIN__
#ifndef __CYGWIN__
#define DEFAULT_PAGER "more"
#define DEFAULT_PAGER "more"
...
...
src/bin/psql/settings.h
View file @
2ee0d554
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.2
4 2005/06/09 23:28:10
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.2
5 2005/06/14 02:57:41
momjian Exp $
*/
*/
#ifndef SETTINGS_H
#ifndef SETTINGS_H
#define SETTINGS_H
#define SETTINGS_H
...
@@ -56,6 +56,7 @@ typedef struct _psqlSettings
...
@@ -56,6 +56,7 @@ typedef struct _psqlSettings
bool
timing
;
/* enable timing of all queries */
bool
timing
;
/* enable timing of all queries */
PGVerbosity
verbosity
;
/* current error verbosity level */
PGVerbosity
verbosity
;
/* current error verbosity level */
FILE
*
logfile
;
/* session log file handle */
}
PsqlSettings
;
}
PsqlSettings
;
extern
PsqlSettings
pset
;
extern
PsqlSettings
pset
;
...
...
src/bin/psql/startup.c
View file @
2ee0d554
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.11
6 2005/06/13 06:36:22 neilc
Exp $
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.11
7 2005/06/14 02:57:41 momjian
Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
...
@@ -71,6 +71,7 @@ struct adhoc_opts
...
@@ -71,6 +71,7 @@ struct adhoc_opts
char
*
host
;
char
*
host
;
char
*
port
;
char
*
port
;
char
*
username
;
char
*
username
;
char
*
logfilename
;
enum
_actions
action
;
enum
_actions
action
;
char
*
action_string
;
char
*
action_string
;
bool
no_readline
;
bool
no_readline
;
...
@@ -109,8 +110,6 @@ main(int argc, char *argv[])
...
@@ -109,8 +110,6 @@ main(int argc, char *argv[])
set_pglocale_pgservice
(
argv
[
0
],
"psql"
);
set_pglocale_pgservice
(
argv
[
0
],
"psql"
);
pset
.
progname
=
get_progname
(
argv
[
0
]);
if
(
argc
>
1
)
if
(
argc
>
1
)
{
{
if
(
strcmp
(
argv
[
1
],
"--help"
)
==
0
||
strcmp
(
argv
[
1
],
"-?"
)
==
0
)
if
(
strcmp
(
argv
[
1
],
"--help"
)
==
0
||
strcmp
(
argv
[
1
],
"-?"
)
==
0
)
...
@@ -125,6 +124,8 @@ main(int argc, char *argv[])
...
@@ -125,6 +124,8 @@ main(int argc, char *argv[])
}
}
}
}
pset
.
progname
=
get_progname
(
argv
[
0
]);
#ifdef WIN32
#ifdef WIN32
setvbuf
(
stderr
,
NULL
,
_IONBF
,
0
);
setvbuf
(
stderr
,
NULL
,
_IONBF
,
0
);
setup_win32_locks
();
setup_win32_locks
();
...
@@ -234,6 +235,13 @@ main(int argc, char *argv[])
...
@@ -234,6 +235,13 @@ main(int argc, char *argv[])
exit
(
success
?
EXIT_SUCCESS
:
EXIT_FAILURE
);
exit
(
success
?
EXIT_SUCCESS
:
EXIT_FAILURE
);
}
}
if
(
options
.
logfilename
)
{
pset
.
logfile
=
fopen
(
options
.
logfilename
,
"a"
);
if
(
!
pset
.
logfile
)
fprintf
(
stderr
,
gettext
(
"logfile open failed for %s
\n\n
"
),
options
.
logfilename
);
}
/*
/*
* Now find something to do
* Now find something to do
*/
*/
...
@@ -316,6 +324,8 @@ main(int argc, char *argv[])
...
@@ -316,6 +324,8 @@ main(int argc, char *argv[])
}
}
/* clean up */
/* clean up */
if
(
pset
.
logfile
)
fclose
(
pset
.
logfile
);
PQfinish
(
pset
.
db
);
PQfinish
(
pset
.
db
);
setQFout
(
NULL
);
setQFout
(
NULL
);
...
@@ -344,6 +354,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
...
@@ -344,6 +354,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
{
"host"
,
required_argument
,
NULL
,
'h'
},
{
"host"
,
required_argument
,
NULL
,
'h'
},
{
"html"
,
no_argument
,
NULL
,
'H'
},
{
"html"
,
no_argument
,
NULL
,
'H'
},
{
"list"
,
no_argument
,
NULL
,
'l'
},
{
"list"
,
no_argument
,
NULL
,
'l'
},
{
"log"
,
required_argument
,
NULL
,
'L'
},
{
"no-readline"
,
no_argument
,
NULL
,
'n'
},
{
"no-readline"
,
no_argument
,
NULL
,
'n'
},
{
"output"
,
required_argument
,
NULL
,
'o'
},
{
"output"
,
required_argument
,
NULL
,
'o'
},
{
"port"
,
required_argument
,
NULL
,
'p'
},
{
"port"
,
required_argument
,
NULL
,
'p'
},
...
@@ -373,7 +384,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
...
@@ -373,7 +384,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
memset
(
options
,
0
,
sizeof
*
options
);
memset
(
options
,
0
,
sizeof
*
options
);
while
((
c
=
getopt_long
(
argc
,
argv
,
"aAc:d:eEf:F:h:Hlno:p:P:qR:sStT:uU:v:VWxX?"
,
while
((
c
=
getopt_long
(
argc
,
argv
,
"aAc:d:eEf:F:h:Hl
L:
no:p:P:qR:sStT:uU:v:VWxX?"
,
long_options
,
&
optindex
))
!=
-
1
)
long_options
,
&
optindex
))
!=
-
1
)
{
{
switch
(
c
)
switch
(
c
)
...
@@ -419,6 +430,9 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
...
@@ -419,6 +430,9 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
case
'l'
:
case
'l'
:
options
->
action
=
ACT_LIST_DB
;
options
->
action
=
ACT_LIST_DB
;
break
;
break
;
case
'L'
:
options
->
logfilename
=
optarg
;
break
;
case
'n'
:
case
'n'
:
options
->
no_readline
=
true
;
options
->
no_readline
=
true
;
break
;
break
;
...
...
src/bin/scripts/createlang.c
View file @
2ee0d554
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.1
5 2004/12/31 22:03:17 pgsql
Exp $
* $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.1
6 2005/06/14 02:57:45 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -148,7 +148,7 @@ main(int argc, char *argv[])
...
@@ -148,7 +148,7 @@ main(int argc, char *argv[])
popt
.
topt
.
border
=
1
;
popt
.
topt
.
border
=
1
;
popt
.
topt
.
encoding
=
PQclientEncoding
(
conn
);
popt
.
topt
.
encoding
=
PQclientEncoding
(
conn
);
popt
.
title
=
_
(
"Procedural Languages"
);
popt
.
title
=
_
(
"Procedural Languages"
);
printQuery
(
result
,
&
popt
,
stdout
);
printQuery
(
result
,
&
popt
,
stdout
,
NULL
);
PQfinish
(
conn
);
PQfinish
(
conn
);
exit
(
0
);
exit
(
0
);
...
...
src/bin/scripts/droplang.c
View file @
2ee0d554
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.1
4 2004/12/31 22:03:17 pgsql
Exp $
* $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.1
5 2005/06/14 02:57:45 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -145,7 +145,7 @@ main(int argc, char *argv[])
...
@@ -145,7 +145,7 @@ main(int argc, char *argv[])
popt
.
topt
.
border
=
1
;
popt
.
topt
.
border
=
1
;
popt
.
topt
.
encoding
=
PQclientEncoding
(
conn
);
popt
.
topt
.
encoding
=
PQclientEncoding
(
conn
);
popt
.
title
=
_
(
"Procedural Languages"
);
popt
.
title
=
_
(
"Procedural Languages"
);
printQuery
(
result
,
&
popt
,
stdout
);
printQuery
(
result
,
&
popt
,
stdout
,
NULL
);
PQfinish
(
conn
);
PQfinish
(
conn
);
exit
(
0
);
exit
(
0
);
...
...
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