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
d65bea26
Commit
d65bea26
authored
Mar 24, 2016
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move psql's print.c and mbprint.c into src/fe_utils.
Just turning the crank ...
parent
a376960c
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
108 additions
and
76 deletions
+108
-76
src/bin/psql/Makefile
src/bin/psql/Makefile
+2
-2
src/bin/psql/command.c
src/bin/psql/command.c
+1
-1
src/bin/psql/command.h
src/bin/psql/command.h
+1
-1
src/bin/psql/common.c
src/bin/psql/common.c
+1
-1
src/bin/psql/common.h
src/bin/psql/common.h
+1
-5
src/bin/psql/describe.c
src/bin/psql/describe.c
+2
-2
src/bin/psql/nls.mk
src/bin/psql/nls.mk
+2
-1
src/bin/psql/settings.h
src/bin/psql/settings.h
+1
-1
src/bin/psql/startup.c
src/bin/psql/startup.c
+1
-1
src/bin/scripts/.gitignore
src/bin/scripts/.gitignore
+0
-3
src/bin/scripts/Makefile
src/bin/scripts/Makefile
+4
-8
src/bin/scripts/createlang.c
src/bin/scripts/createlang.c
+1
-1
src/bin/scripts/droplang.c
src/bin/scripts/droplang.c
+1
-1
src/bin/scripts/nls.mk
src/bin/scripts/nls.mk
+1
-0
src/fe_utils/Makefile
src/fe_utils/Makefile
+1
-1
src/fe_utils/mbprint.c
src/fe_utils/mbprint.c
+19
-12
src/fe_utils/print.c
src/fe_utils/print.c
+20
-18
src/include/fe_utils/mbprint.h
src/include/fe_utils/mbprint.h
+29
-0
src/include/fe_utils/print.h
src/include/fe_utils/print.h
+18
-10
src/tools/msvc/Mkvcbuild.pm
src/tools/msvc/Mkvcbuild.pm
+2
-7
No files found.
src/bin/psql/Makefile
View file @
d65bea26
...
...
@@ -22,8 +22,8 @@ override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
LDFLAGS
+=
-L
$(top_builddir)
/src/fe_utils
-lpgfeutils
OBJS
=
command.o common.o help.o input.o stringutils.o mainloop.o copy.o
\
startup.o prompt.o variables.o large_obj.o
print.o
describe.o
\
tab-complete.o
mbprint.o
\
startup.o prompt.o variables.o large_obj.o describe.o
\
tab-complete.o
\
sql_help.o psqlscan.o psqlscanslash.o
\
$(WIN32RES)
...
...
src/bin/psql/command.c
View file @
d65bea26
...
...
@@ -44,7 +44,7 @@
#include "input.h"
#include "large_obj.h"
#include "mainloop.h"
#include "print.h"
#include "
fe_utils/
print.h"
#include "psqlscanslash.h"
#include "settings.h"
#include "variables.h"
...
...
src/bin/psql/command.h
View file @
d65bea26
...
...
@@ -8,7 +8,7 @@
#ifndef COMMAND_H
#define COMMAND_H
#include "print.h"
#include "
fe_utils/
print.h"
#include "psqlscan.h"
...
...
src/bin/psql/common.c
View file @
d65bea26
...
...
@@ -23,7 +23,7 @@
#include "settings.h"
#include "command.h"
#include "copy.h"
#include "mbprint.h"
#include "
fe_utils/
mbprint.h"
static
bool
ExecQueryUsingCursor
(
const
char
*
query
,
double
*
elapsed_msec
);
...
...
src/bin/psql/common.h
View file @
d65bea26
...
...
@@ -11,7 +11,7 @@
#include <setjmp.h>
#include "libpq-fe.h"
#include "print.h"
#include "
fe_utils/
print.h"
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
...
...
@@ -28,10 +28,6 @@ extern volatile bool sigint_interrupt_enabled;
extern
sigjmp_buf
sigint_interrupt_jmp
;
extern
volatile
bool
cancel_pressed
;
/* Note: cancel_pressed is defined in print.c, see that file for reasons */
extern
void
setup_cancel_handler
(
void
);
extern
void
SetCancelConn
(
void
);
...
...
src/bin/psql/describe.c
View file @
d65bea26
...
...
@@ -19,8 +19,8 @@
#include "common.h"
#include "describe.h"
#include "mbprint.h"
#include "print.h"
#include "
fe_utils/
mbprint.h"
#include "
fe_utils/
print.h"
#include "settings.h"
#include "variables.h"
...
...
src/bin/psql/nls.mk
View file @
d65bea26
...
...
@@ -2,9 +2,10 @@
CATALOG_NAME
=
psql
AVAIL_LANGUAGES
=
cs de es fr it ja pl pt_BR ru zh_CN zh_TW
GETTEXT_FILES
=
command.c common.c copy.c help.c input.c large_obj.c
\
mainloop.c p
rint.c p
sqlscan.c psqlscanslash.c startup.c
\
mainloop.c psqlscan.c psqlscanslash.c startup.c
\
describe.c sql_help.h sql_help.c
\
tab-complete.c variables.c
\
../../fe_utils/print.c
\
../../common/exec.c ../../common/fe_memutils.c ../../common/username.c
\
../../common/wait_error.c
GETTEXT_TRIGGERS
=
N_ psql_error simple_prompt
...
...
src/bin/psql/settings.h
View file @
d65bea26
...
...
@@ -10,7 +10,7 @@
#include "variables.h"
#include "print.h"
#include "
fe_utils/
print.h"
#define DEFAULT_FIELD_SEP "|"
#define DEFAULT_RECORD_SEP "\n"
...
...
src/bin/psql/startup.c
View file @
d65bea26
...
...
@@ -26,7 +26,7 @@
#include "help.h"
#include "input.h"
#include "mainloop.h"
#include "print.h"
#include "
fe_utils/
print.h"
#include "settings.h"
...
...
src/bin/scripts/.gitignore
View file @
d65bea26
...
...
@@ -9,7 +9,4 @@
/vacuumdb
/pg_isready
/mbprint.c
/print.c
/tmp_check/
src/bin/scripts/Makefile
View file @
d65bea26
...
...
@@ -18,7 +18,7 @@ include $(top_builddir)/src/Makefile.global
PROGRAMS
=
createdb createlang createuser dropdb droplang dropuser clusterdb vacuumdb reindexdb pg_isready
override CPPFLAGS
:
= -I$(
top_srcdir)/src/bin/psql -I$(
libpq_srcdir) $(CPPFLAGS)
override CPPFLAGS
:
= -I$(libpq_srcdir) $(CPPFLAGS)
LDFLAGS
+=
-L
$(top_builddir)
/src/fe_utils
-lpgfeutils
all
:
$(PROGRAMS)
...
...
@@ -27,19 +27,16 @@ all: $(PROGRAMS)
$(CC)
$(CFLAGS)
$^
$(libpq_pgport)
$(LDFLAGS)
$(LDFLAGS_EX)
$(LIBS)
-o
$@$(X)
createdb
:
createdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
createlang
:
createlang.o common.o
print.o mbprint.o | submake-libpq submake-libpgport
createlang
:
createlang.o common.o
| submake-libpq submake-libpgport submake-libpgfeutils
createuser
:
createuser.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
dropdb
:
dropdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
droplang
:
droplang.o common.o
print.o mbprint.o | submake-libpq submake-libpgport
droplang
:
droplang.o common.o
| submake-libpq submake-libpgport submake-libpgfeutils
dropuser
:
dropuser.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
clusterdb
:
clusterdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
vacuumdb
:
vacuumdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
reindexdb
:
reindexdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
pg_isready
:
pg_isready.o common.o | submake-libpq submake-libpgport
print.c mbprint.c
:
% : $(top_srcdir)/src/bin/psql/%
rm
-f
$@
&&
$(LN_S)
$<
.
install
:
all installdirs
$(INSTALL_PROGRAM)
createdb
$(X)
'
$(DESTDIR)$(bindir)
'
/createdb
$(X)
$(INSTALL_PROGRAM)
dropdb
$(X)
'
$(DESTDIR)$(bindir)
'
/dropdb
$(X)
...
...
@@ -60,8 +57,7 @@ uninstall:
clean distclean maintainer-clean
:
rm
-f
$(
addsuffix
$(X)
,
$(PROGRAMS)
)
$(
addsuffix
.o,
$(PROGRAMS)
)
rm
-f
common.o print.o mbprint.o
$(WIN32RES)
rm
-f
print.c mbprint.c
rm
-f
common.o
$(WIN32RES)
rm
-rf
tmp_check
check
:
...
...
src/bin/scripts/createlang.c
View file @
d65bea26
...
...
@@ -12,7 +12,7 @@
#include "postgres_fe.h"
#include "common.h"
#include "print.h"
#include "
fe_utils/
print.h"
static
void
help
(
const
char
*
progname
);
...
...
src/bin/scripts/droplang.c
View file @
d65bea26
...
...
@@ -12,7 +12,7 @@
#include "postgres_fe.h"
#include "common.h"
#include "print.h"
#include "
fe_utils/
print.h"
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
...
...
src/bin/scripts/nls.mk
View file @
d65bea26
...
...
@@ -6,5 +6,6 @@ GETTEXT_FILES = createdb.c createlang.c createuser.c \
clusterdb.c vacuumdb.c reindexdb.c
\
pg_isready.c
\
common.c
\
../../fe_utils/print.c
\
../../common/fe_memutils.c ../../common/username.c
GETTEXT_TRIGGERS
=
simple_prompt yesno_prompt
src/fe_utils/Makefile
View file @
d65bea26
...
...
@@ -17,7 +17,7 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS
:
= -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS)
OBJS
=
simple_list.o string_utils.o
OBJS
=
mbprint.o print.o
simple_list.o string_utils.o
all
:
libpgfeutils.a
...
...
src/
bin/psql
/mbprint.c
→
src/
fe_utils
/mbprint.c
View file @
d65bea26
/*
* psql - the PostgreSQL interactive terminal
/*-------------------------------------------------------------------------
*
* Multibyte character printing support for frontend code
*
*
* Copyright (c) 2000-2016, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/
bin/psql
/mbprint.c
* src/
fe_utils
/mbprint.c
*
* XXX this file does not really belong in psql/. Perhaps move to libpq?
* It also seems that the mbvalidate function is redundant with existing
* functionality.
*-------------------------------------------------------------------------
*/
#include "postgres_fe.h"
#include "mbprint.h"
#ifndef PGSCRIPTS
#include "settings.h"
#endif
#include "fe_utils/mbprint.h"
#include "libpq-fe.h"
/*
* To avoid version-skew problems, this file must not use declarations
...
...
@@ -381,6 +382,12 @@ pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding,
(
lines
+
1
)
->
ptr
=
NULL
;
/* terminate line array */
}
/*
* Encoding validation: delete any unvalidatable characters from the string
*
* This seems redundant with existing functionality elsewhere?
*/
unsigned
char
*
mbvalidate
(
unsigned
char
*
pwcs
,
int
encoding
)
{
...
...
src/
bin/psql
/print.c
→
src/
fe_utils
/print.c
View file @
d65bea26
/*
* psql - the PostgreSQL interactive terminal
/*-------------------------------------------------------------------------
*
* Query-result printing support for frontend code
*
* This file used to be part of psql, but now it's separated out to allow
* other frontend programs to use it. Because the printing code needs
* access to the cancel_pressed flag as well as SIGPIPE trapping and
* pager open/close functions, all that stuff came with it.
*
*
* Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
Copyright (c) 2000-2016, PostgreSQL Global Development Group
*
src/fe_utils/print.c
*
*
src/bin/psql/print.c
*
-------------------------------------------------------------------------
*/
#include "postgres_fe.h"
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <signal.h>
#include <unistd.h>
...
...
@@ -20,32 +31,23 @@
#include <termios.h>
#endif
#include
<locale.h>
#include
"fe_utils/print.h"
#include "catalog/pg_type.h"
#include "fe_utils/mbprint.h"
#include "common.h"
#include "mbprint.h"
#include "print.h"
/*
* We define the cancel_pressed flag in this file, rather than common.c where
* it naturally belongs, because this file is also used by non-psql programs
* (see the bin/scripts/ directory). In those programs cancel_pressed will
* never become set and will have no effect.
* If the calling program doesn't have any mechanism for setting
* cancel_pressed, it will have no effect.
*
* Note: print.c's general strategy for when to check cancel_pressed is to do
* so at completion of each row of output.
*/
volatile
bool
cancel_pressed
=
false
;
/*
* Likewise, the sigpipe_trap and pager open/close functions are here rather
* than in common.c so that this file can be used by non-psql programs.
*/
static
bool
always_ignore_sigpipe
=
false
;
/* info for locale-aware numeric formatting; set up by setDecimalLocale() */
static
char
*
decimal_point
;
static
int
groupdigits
;
...
...
@@ -139,7 +141,7 @@ typedef struct unicodeStyleFormat
bool
wrap_right_border
;
}
unicodeStyleFormat
;
const
unicodeStyleFormat
unicode_style
=
{
static
const
unicodeStyleFormat
unicode_style
=
{
{
{
/* ─ */
...
...
src/
bin/psql
/mbprint.h
→
src/
include/fe_utils
/mbprint.h
View file @
d65bea26
/* src/bin/psql/mbprint.h */
/*-------------------------------------------------------------------------
*
* Multibyte character printing support for frontend code
*
*
* Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/fe_utils/mbprint.h
*
*-------------------------------------------------------------------------
*/
#ifndef MBPRINT_H
#define MBPRINT_H
struct
lineptr
{
unsigned
char
*
ptr
;
...
...
@@ -11,7 +21,8 @@ struct lineptr
extern
unsigned
char
*
mbvalidate
(
unsigned
char
*
pwcs
,
int
encoding
);
extern
int
pg_wcswidth
(
const
char
*
pwcs
,
size_t
len
,
int
encoding
);
extern
void
pg_wcsformat
(
const
unsigned
char
*
pwcs
,
size_t
len
,
int
encoding
,
struct
lineptr
*
lines
,
int
count
);
extern
void
pg_wcsformat
(
const
unsigned
char
*
pwcs
,
size_t
len
,
int
encoding
,
struct
lineptr
*
lines
,
int
count
);
extern
void
pg_wcssize
(
const
unsigned
char
*
pwcs
,
size_t
len
,
int
encoding
,
int
*
width
,
int
*
height
,
int
*
format_size
);
...
...
src/
bin/psql
/print.h
→
src/
include/fe_utils
/print.h
View file @
d65bea26
/*
* psql - the PostgreSQL interactive terminal
/*-------------------------------------------------------------------------
*
* Query-result printing support for frontend code
*
*
* Copyright (c) 2000-2016, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/bin/psql/print.h
* src/include/fe_utils/print.h
*
*-------------------------------------------------------------------------
*/
#ifndef PRINT_H
#define PRINT_H
...
...
@@ -11,6 +16,13 @@
#include "libpq-fe.h"
/* This is not a particularly great place for this ... */
#ifndef __CYGWIN__
#define DEFAULT_PAGER "more"
#else
#define DEFAULT_PAGER "less"
#endif
enum
printFormat
{
PRINT_NOTHING
=
0
,
/* to make sure someone initializes this */
...
...
@@ -161,6 +173,8 @@ typedef struct printQueryOpt
}
printQueryOpt
;
extern
volatile
bool
cancel_pressed
;
extern
const
printTextFormat
pg_asciiformat
;
extern
const
printTextFormat
pg_asciiformat_old
;
extern
printTextFormat
pg_utf8format
;
/* ideally would be const, but... */
...
...
@@ -196,10 +210,4 @@ extern void setDecimalLocale(void);
extern
const
printTextFormat
*
get_line_style
(
const
printTableOpt
*
opt
);
extern
void
refresh_utf8format
(
const
printTableOpt
*
opt
);
#ifndef __CYGWIN__
#define DEFAULT_PAGER "more"
#else
#define DEFAULT_PAGER "less"
#endif
#endif
/* PRINT_H */
src/tools/msvc/Mkvcbuild.pm
View file @
d65bea26
...
...
@@ -120,7 +120,7 @@ sub mkvcbuild
our
@pgcommonbkndfiles
=
@pgcommonallfiles
;
our
@pgfeutilsfiles
=
qw(
simple_list.c string_utils.c)
;
mbprint.c print.c
simple_list.c string_utils.c)
;
$libpgport
=
$solution
->
AddProject
('
libpgport
',
'
lib
',
'
misc
');
$libpgport
->
AddDefine
('
FRONTEND
');
...
...
@@ -622,17 +622,12 @@ sub mkvcbuild
foreach
my
$f
(
@files
)
{
$f
=~
s/\.o$/\.c/
;
if
(
$f
=~
/print\.c$/
)
{
# Also catches mbprint.c
$proj
->
AddFile
('
src/bin/psql/
'
.
$f
);
}
elsif
(
$f
=~
/\.c$/
)
if
(
$f
=~
/\.c$/
)
{
$proj
->
AddFile
('
src/bin/scripts/
'
.
$f
);
}
}
$proj
->
AddIncludeDir
('
src/interfaces/libpq
');
$proj
->
AddIncludeDir
('
src/bin/psql
');
$proj
->
AddReference
(
$libpq
,
$libpgfeutils
,
$libpgcommon
,
$libpgport
);
$proj
->
AddDirResourceFile
('
src/bin/scripts
');
...
...
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