Skip to content

Commit 5b88b85

Browse files
author
Michael Meskes
committed
Applied Joachim's patch for a --regression option.
Made this option mark the .c files, so the environment variable is no longer needed. Created a special MinGW file with the special error message. Do not print port into log file when running regression tests.
1 parent c0c00ac commit 5b88b85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+249
-128
lines changed

src/interfaces/ecpg/ecpglib/connect.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.37 2006/11/08 10:46:47 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.38 2007/01/11 15:47:33 meskes Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -19,6 +19,7 @@ static pthread_once_t actual_connection_key_once = PTHREAD_ONCE_INIT;
1919
#endif
2020
static struct connection *actual_connection = NULL;
2121
static struct connection *all_connections = NULL;
22+
extern int ecpg_internal_regression_mode;
2223

2324
#ifdef ENABLE_THREAD_SAFETY
2425
static void
@@ -464,7 +465,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
464465
ECPGlog("ECPGconnect: opening database %s on %s port %s %s%s%s%s\n",
465466
realname ? realname : "<DEFAULT>",
466467
host ? host : "<DEFAULT>",
467-
port ? port : "<DEFAULT>",
468+
port ? (ecpg_internal_regression_mode ? "<REGRESSION_PORT>" : port) : "<DEFAULT>",
468469
options ? "with options " : "", options ? options : "",
469470
user ? "for user " : "", user ? user : "");
470471

@@ -478,7 +479,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
478479
ECPGlog("connect: could not open database %s on %s port %s %s%s%s%s in line %d\n\t%s\n",
479480
db,
480481
host ? host : "<DEFAULT>",
481-
port ? port : "<DEFAULT>",
482+
port ? (ecpg_internal_regression_mode ? "<REGRESSION_PORT>" : port) : "<DEFAULT>",
482483
options ? "with options " : "", options ? options : "",
483484
user ? "for user " : "", user ? user : "",
484485
lineno, errmsg);

src/interfaces/ecpg/ecpglib/data.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.35 2006/10/04 00:30:11 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.36 2007/01/11 15:47:33 meskes Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -16,10 +16,7 @@
1616
#include "pgtypes_timestamp.h"
1717
#include "pgtypes_interval.h"
1818

19-
static enum
20-
{
21-
NOT_CHECKED, REGRESS, NORMAL
22-
} ECPG_regression_mode = NOT_CHECKED;
19+
extern int ecpg_internal_regression_mode;
2320

2421
static bool
2522
garbage_left(enum ARRAY_TYPE isarray, char *scan_length, enum COMPAT_MODE compat)
@@ -56,24 +53,11 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
5653
int value_for_indicator = 0;
5754
long log_offset;
5855

59-
/*
60-
* use a global variable to see if the environment variable
61-
* ECPG_REGRESSION is set or not. Remember the state in order to avoid
62-
* subsequent calls to getenv() for this purpose.
63-
*/
64-
if (ECPG_regression_mode == NOT_CHECKED)
65-
{
66-
if (getenv("ECPG_REGRESSION"))
67-
ECPG_regression_mode = REGRESS;
68-
else
69-
ECPG_regression_mode = NORMAL;
70-
}
71-
7256
/*
7357
* If we are running in a regression test, do not log the offset variable,
7458
* it depends on the machine's alignment.
7559
*/
76-
if (ECPG_regression_mode == REGRESS)
60+
if (ecpg_internal_regression_mode)
7761
log_offset = -1;
7862
else
7963
log_offset = offset;

src/interfaces/ecpg/ecpglib/misc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.32 2006/10/04 00:30:11 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.33 2007/01/11 15:47:33 meskes Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -28,6 +28,8 @@
2828
#endif
2929
#endif
3030

31+
extern int ecpg_internal_regression_mode;
32+
3133
static struct sqlca_t sqlca_init =
3234
{
3335
{
@@ -262,7 +264,7 @@ ECPGlog(const char *format,...)
262264
* regression tests set this environment variable to get the same
263265
* output for every run.
264266
*/
265-
if (getenv("ECPG_REGRESSION"))
267+
if (ecpg_internal_regression_mode)
266268
snprintf(f, bufsize, "[NO_PID]: %s", format);
267269
else
268270
snprintf(f, bufsize, "[%d]: %s", (int) getpid(), format);
@@ -272,7 +274,7 @@ ECPGlog(const char *format,...)
272274
va_end(ap);
273275

274276
/* dump out internal sqlca variables */
275-
if (getenv("ECPG_REGRESSION"))
277+
if (ecpg_internal_regression_mode)
276278
fprintf(debugstream, "[NO_PID]: sqlca: code: %ld, state: %s\n",
277279
sqlca->sqlcode, sqlca->sqlstate);
278280

src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.94 2006/02/08 09:10:04 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.95 2007/01/11 15:47:33 meskes Exp $ */
22

33
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
44
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
@@ -8,12 +8,7 @@
88

99
#include <unistd.h>
1010
#include <string.h>
11-
#ifdef HAVE_GETOPT_H
12-
#include <getopt.h>
13-
#endif
14-
15-
extern int optind;
16-
extern char *optarg;
11+
#include "getopt_long.h"
1712

1813
#include "extern.h"
1914

@@ -22,7 +17,8 @@ int ret_value = 0,
2217
auto_create_c = false,
2318
system_includes = false,
2419
force_indicator = true,
25-
header_mode = false;
20+
header_mode = false,
21+
regression_mode = false;
2622

2723
enum COMPAT_MODE compat = ECPG_COMPAT_PGSQL;
2824

@@ -56,6 +52,7 @@ help(const char *progname)
5652
" OPTION may only be \"no_indicator\"\n");
5753
printf(" -t turn on autocommit of transactions\n");
5854
printf(" --help show this help, then exit\n");
55+
printf(" --regression run in regression testing mode\n");
5956
printf(" --version output version information, then exit\n");
6057
printf("\nIf no output file is specified, the name is formed by adding .c to the\n"
6158
"input file name, after stripping off .pgc if present.\n");
@@ -112,9 +109,19 @@ add_preprocessor_define(char *define)
112109
defines->next = pd;
113110
}
114111

112+
#define ECPG_GETOPT_LONG_HELP 1
113+
#define ECPG_GETOPT_LONG_VERSION 2
114+
#define ECPG_GETOPT_LONG_REGRESSION 3
115115
int
116116
main(int argc, char *const argv[])
117117
{
118+
static struct option ecpg_options[] = {
119+
{"help", no_argument, NULL, ECPG_GETOPT_LONG_HELP},
120+
{"version", no_argument, NULL, ECPG_GETOPT_LONG_VERSION},
121+
{"regression", no_argument, NULL, ECPG_GETOPT_LONG_REGRESSION},
122+
{ NULL, 0, NULL, 0}
123+
};
124+
118125
int fnr,
119126
c,
120127
verbose = false,
@@ -126,27 +133,35 @@ main(int argc, char *const argv[])
126133

127134
progname = get_progname(argv[0]);
128135

129-
if (argc > 1)
130-
{
131-
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
132-
{
133-
help(progname);
134-
exit(0);
135-
}
136-
else if (strcmp(argv[1], "--version") == 0)
137-
{
138-
printf("ecpg (PostgreSQL %s) %d.%d.%d\n", PG_VERSION,
139-
MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
140-
exit(0);
141-
}
142-
}
143-
144136
find_my_exec(argv[0], my_exec_path);
145137

146-
while ((c = getopt(argc, argv, "vcio:I:tD:dC:r:h")) != -1)
138+
while ((c = getopt_long(argc, argv, "vcio:I:tD:dC:r:h?", ecpg_options, NULL)) != -1)
147139
{
148140
switch (c)
149141
{
142+
case ECPG_GETOPT_LONG_VERSION:
143+
printf("ecpg (PostgreSQL %s) %d.%d.%d\n", PG_VERSION,
144+
MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
145+
exit(0);
146+
case ECPG_GETOPT_LONG_HELP:
147+
help(progname);
148+
exit(0);
149+
/*
150+
* -? is an alternative spelling of --help. However it is also
151+
* returned by getopt_long for unknown options. We can distinguish
152+
* both cases by means of the optopt variable which is set to 0 if
153+
* it was really -? and not an unknown option character.
154+
*/
155+
case '?':
156+
if (optopt == 0)
157+
{
158+
help(progname);
159+
exit(0);
160+
}
161+
break;
162+
case ECPG_GETOPT_LONG_REGRESSION:
163+
regression_mode = true;
164+
break;
150165
case 'o':
151166
if (strcmp(optarg, "-") == 0)
152167
yyout = stdout;
@@ -405,8 +420,12 @@ main(int argc, char *const argv[])
405420

406421
/* we need several includes */
407422
/* but not if we are in header mode */
408-
fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
423+
if (regression_mode)
424+
fprintf(yyout, "/* Processed by ecpg (regression mode) */\n");
425+
else
426+
fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
409427

428+
fprintf(yyout, "int ecpg_internal_regression_mode = %d;\n", regression_mode);
410429
if (header_mode == false)
411430
{
412431
fprintf(yyout, "/* These include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n");

src/interfaces/ecpg/preproc/extern.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/extern.h,v 1.63 2006/03/11 04:38:40 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/extern.h,v 1.64 2007/01/11 15:47:33 meskes Exp $ */
22

33
#ifndef _ECPG_PREPROC_EXTERN_H
44
#define _ECPG_PREPROC_EXTERN_H
@@ -21,7 +21,8 @@ extern int braces_open,
2121
force_indicator,
2222
ret_value,
2323
struct_level,
24-
ecpg_informix_var;
24+
ecpg_informix_var,
25+
regression_mode;
2526
extern char *descriptor_index;
2627
extern char *descriptor_name;
2728
extern char *connection;

src/interfaces/ecpg/test/Makefile.regress

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ override CFLAGS += $(PTHREAD_CFLAGS)
55
override LDFLAGS := -L../../ecpglib -L../../pgtypeslib $(LDFLAGS)
66
override LIBS := -lecpg -lpgtypes $(libpq) $(LIBS) $(PTHREAD_LIBS)
77

8-
ECPG = ../../preproc/ecpg -I$(srcdir)/../../include
8+
ECPG = ../../preproc/ecpg --regression -I$(srcdir)/../../include
99

1010
%: %.c
1111
$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) $(LIBS) -o $@

src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* Processed by ecpg (4.3.1) */
1+
/* Processed by ecpg (regression mode) */
2+
int ecpg_internal_regression_mode = 1;
23
/* These include files are added by the preprocessor */
34
#include <ecpgtype.h>
45
#include <ecpglib.h>

src/interfaces/ecpg/test/expected/compat_informix-dec_test.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* Processed by ecpg (4.3.1) */
1+
/* Processed by ecpg (regression mode) */
2+
int ecpg_internal_regression_mode = 1;
23
/* These include files are added by the preprocessor */
34
#include <ecpgtype.h>
45
#include <ecpglib.h>

src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* Processed by ecpg (4.3.1) */
1+
/* Processed by ecpg (regression mode) */
2+
int ecpg_internal_regression_mode = 1;
23
/* These include files are added by the preprocessor */
34
#include <ecpgtype.h>
45
#include <ecpglib.h>

src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* Processed by ecpg (4.3.1) */
1+
/* Processed by ecpg (regression mode) */
2+
int ecpg_internal_regression_mode = 1;
23
/* These include files are added by the preprocessor */
34
#include <ecpgtype.h>
45
#include <ecpglib.h>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy