Skip to content

Commit caad817

Browse files
committed
Add fprintf() custom version to libpgport.
Document use of macros for pg_printf functions. Bump major versions of all interfaces to handle movement of get_progname from libpq to libpgport in 8.0, and probably other libpgport changes in 8.1.
1 parent 3bc6bdf commit caad817

File tree

12 files changed

+64
-26
lines changed

12 files changed

+64
-26
lines changed

src/backend/bootstrap/bootscanner.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.38 2004/12/31 21:59:34 pgsql Exp $
12+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.39 2005/03/11 19:13:42 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -42,6 +42,7 @@
4242

4343

4444
/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
45+
#undef fprintf
4546
#define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg)))
4647

4748

src/backend/parser/scan.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.120 2005/02/22 04:36:22 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.121 2005/03/11 19:13:42 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -28,6 +28,7 @@
2828

2929

3030
/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
31+
#undef fprintf
3132
#define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg)))
3233

3334
extern YYSTYPE yylval;

src/backend/utils/misc/guc-file.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.29 2005/01/01 05:43:08 momjian Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.30 2005/03/11 19:13:42 momjian Exp $
88
*/
99

1010
%{
@@ -19,6 +19,7 @@
1919
#include "utils/guc.h"
2020

2121
/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
22+
#undef fprintf
2223
#define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg)))
2324

2425
static unsigned ConfigFileLineno;

src/include/port.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.71 2005/03/11 17:20:34 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.72 2005/03/11 19:13:42 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -112,17 +112,27 @@ extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
112112
extern int pg_snprintf(char *str, size_t count, const char *fmt,...)
113113
/* This extension allows gcc to check the format string */
114114
__attribute__((format(printf, 3, 4)));
115+
extern int pg_fprintf(FILE *stream, const char *fmt,...)
116+
/* This extension allows gcc to check the format string */
117+
__attribute__((format(printf, 2, 3)));
115118
extern int pg_printf(const char *fmt,...)
116119
/* This extension allows gcc to check the format string */
117120
__attribute__((format(printf, 1, 2)));
118121

122+
/*
123+
* The GCC-specific code below prevents the __attribute__(... 'printf')
124+
* above from being replaced, and this is required because gcc doesn't
125+
* know anything about pg_printf.
126+
*/
119127
#ifdef __GNUC__
120-
#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__)
128+
#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__)
121129
#define snprintf(...) pg_snprintf(__VA_ARGS__)
130+
#define fprintf(...) pg_fprintf(__VA_ARGS__)
122131
#define printf(...) pg_printf(__VA_ARGS__)
123132
#else
124133
#define vsnprintf pg_vsnprintf
125134
#define snprintf pg_snprintf
135+
#define fprintf pg_fprintf
126136
#define printf pg_printf
127137
#endif
128138
#endif

src/interfaces/ecpg/compatlib/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.19 2005/01/18 05:00:15 momjian Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.20 2005/03/11 19:13:42 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -13,8 +13,8 @@ top_builddir = ../../../..
1313
include $(top_builddir)/src/Makefile.global
1414

1515
NAME= ecpg_compat
16-
SO_MAJOR_VERSION= 1
17-
SO_MINOR_VERSION= 2
16+
SO_MAJOR_VERSION= 2
17+
SO_MINOR_VERSION= 0
1818
DLTYPE= library
1919

2020
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) \

src/interfaces/ecpg/ecpglib/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.31 2005/01/26 19:24:01 tgl Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.32 2005/03/11 19:13:42 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -13,8 +13,8 @@ top_builddir = ../../../..
1313
include $(top_builddir)/src/Makefile.global
1414

1515
NAME= ecpg
16-
SO_MAJOR_VERSION= 4
17-
SO_MINOR_VERSION= 3
16+
SO_MAJOR_VERSION= 5
17+
SO_MINOR_VERSION= 0
1818
DLTYPE= library
1919

2020
override CPPFLAGS := -DFRONTEND -I$(top_srcdir)/src/interfaces/ecpg/include \

src/interfaces/ecpg/pgtypeslib/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.24 2005/01/18 05:00:23 momjian Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.25 2005/03/11 19:13:43 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -13,8 +13,8 @@ top_builddir = ../../../..
1313
include $(top_builddir)/src/Makefile.global
1414

1515
NAME= pgtypes
16-
SO_MAJOR_VERSION= 1
17-
SO_MINOR_VERSION= 3
16+
SO_MAJOR_VERSION= 2
17+
SO_MINOR_VERSION= 0
1818
DLTYPE= library
1919

2020
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include \

src/interfaces/ecpg/preproc/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1998-2005, PostgreSQL Global Development Group
66
#
7-
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.112 2005/01/25 12:51:31 meskes Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.113 2005/03/11 19:13:43 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -13,8 +13,8 @@ subdir = src/interfaces/ecpg/preproc
1313
top_builddir = ../../../..
1414
include $(top_builddir)/src/Makefile.global
1515

16-
MAJOR_VERSION=3
17-
MINOR_VERSION=2
16+
MAJOR_VERSION= 4
17+
MINOR_VERSION= 0
1818
PATCHLEVEL=1
1919

2020
override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) \

src/interfaces/libpq/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.128 2005/01/26 19:24:02 tgl Exp $
8+
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.129 2005/03/11 19:13:43 momjian Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -16,8 +16,8 @@ include $(top_builddir)/src/Makefile.global
1616

1717
# shared library parameters
1818
NAME= pq
19-
SO_MAJOR_VERSION= 3
20-
SO_MINOR_VERSION= 3
19+
SO_MAJOR_VERSION= 4
20+
SO_MINOR_VERSION= 0
2121
DLTYPE= library
2222

2323
override CPPFLAGS := -DFRONTEND -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port

src/pl/plpgsql/src/scan.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* procedural language
55
*
66
* IDENTIFICATION
7-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.39 2005/02/22 07:18:24 neilc Exp $
7+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.40 2005/03/11 19:13:43 momjian Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -45,6 +45,7 @@
4545
#define YY_READ_BUF_SIZE 16777216
4646

4747
/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
48+
#undef fprintf
4849
#define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg)))
4950

5051
/* Handles to the buffer that the lexer uses internally */

src/port/snprintf.c

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,19 @@
6565
* causing nasty effects.
6666
**************************************************************/
6767

68-
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.17 2005/03/11 17:20:35 momjian Exp $";*/
68+
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.18 2005/03/11 19:13:43 momjian Exp $";*/
6969

7070
int pg_snprintf(char *str, size_t count, const char *fmt,...);
7171
int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
7272
int pg_printf(const char *format, ...);
7373
static void dopr(char *buffer, const char *format, va_list args, char *end);
7474

75+
/* Prevent recursion */
76+
#undef vsnprintf
77+
#undef snprintf
78+
#undef fprintf
79+
#undef printf
80+
7581
int
7682
pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
7783
{
@@ -96,19 +102,36 @@ pg_snprintf(char *str, size_t count, const char *fmt,...)
96102
return len;
97103
}
98104

105+
int
106+
pg_fprintf(FILE *stream, const char *fmt,...)
107+
{
108+
int len;
109+
va_list args;
110+
char* buffer[4096];
111+
char* p;
112+
113+
va_start(args, fmt);
114+
len = pg_vsnprintf((char*)buffer, (size_t)4096, fmt, args);
115+
va_end(args);
116+
p = (char*)buffer;
117+
for( ;*p; p++)
118+
putc(*p, stream);
119+
return len;
120+
}
121+
99122
int
100123
pg_printf(const char *fmt,...)
101124
{
102125
int len;
103-
va_list args;
126+
va_list args;
104127
char* buffer[4096];
105-
char* p;
128+
char* p;
106129

107130
va_start(args, fmt);
108131
len = pg_vsnprintf((char*)buffer, (size_t)4096, fmt, args);
109132
va_end(args);
110133
p = (char*)buffer;
111-
for(;*p;p++)
134+
for( ;*p; p++)
112135
putchar(*p);
113136
return len;
114137
}

src/tools/RELEASE_CHANGES

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
* Version numbers
77
o configure.in, and run autoconf or update configure
88
o doc/bug.template
9-
o bump interface version numbers
9+
o bump library versions
1010
- src/interfaces/*/Makefile (major releases only)
1111
- src/interfaces/*/*/Makefile (major releases only)
12+
o bump interface version numbers
1213
- src/interfaces/libpq/libpq.rc.in (major and minor releases)
1314
- src/include/pg_config.h.win32 (major and minor releases)
1415
- src/port/win32ver.rc (major and minor releases)

0 commit comments

Comments
 (0)