Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5b88b85

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 parentc0c00ac commit5b88b85

File tree

50 files changed

+249
-128
lines changed

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
#definePOSTGRES_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
staticstructconnection*actual_connection=NULL;
2121
staticstructconnection*all_connections=NULL;
22+
externintecpg_internal_regression_mode;
2223

2324
#ifdefENABLE_THREAD_SAFETY
2425
staticvoid
@@ -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
#definePOSTGRES_ECPG_INTERNAL
44
#include"postgres_fe.h"
@@ -16,10 +16,7 @@
1616
#include"pgtypes_timestamp.h"
1717
#include"pgtypes_interval.h"
1818

19-
staticenum
20-
{
21-
NOT_CHECKED,REGRESS,NORMAL
22-
}ECPG_regression_mode=NOT_CHECKED;
19+
externintecpg_internal_regression_mode;
2320

2421
staticbool
2522
garbage_left(enumARRAY_TYPEisarray,char*scan_length,enumCOMPAT_MODEcompat)
@@ -56,24 +53,11 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
5653
intvalue_for_indicator=0;
5754
longlog_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
#definePOSTGRES_ECPG_INTERNAL
44
#include"postgres_fe.h"
@@ -28,6 +28,8 @@
2828
#endif
2929
#endif
3030

31+
externintecpg_internal_regression_mode;
32+
3133
staticstructsqlca_tsqlca_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-
#ifdefHAVE_GETOPT_H
12-
#include<getopt.h>
13-
#endif
14-
15-
externintoptind;
16-
externchar*optarg;
11+
#include"getopt_long.h"
1712

1813
#include"extern.h"
1914

@@ -22,7 +17,8 @@ intret_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
enumCOMPAT_MODEcompat=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+
#defineECPG_GETOPT_LONG_HELP1
113+
#defineECPG_GETOPT_LONG_VERSION2
114+
#defineECPG_GETOPT_LONG_REGRESSION3
115115
int
116116
main(intargc,char*constargv[])
117117
{
118+
staticstructoptionecpg_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
intfnr,
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-
elseif (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+
caseECPG_GETOPT_LONG_VERSION:
143+
printf("ecpg (PostgreSQL %s) %d.%d.%d\n",PG_VERSION,
144+
MAJOR_VERSION,MINOR_VERSION,PATCHLEVEL);
145+
exit(0);
146+
caseECPG_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+
caseECPG_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/1104:38:40 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/extern.h,v 1.64 2007/01/1115:47:33 meskes Exp $ */
22

33
#ifndef_ECPG_PREPROC_EXTERN_H
44
#define_ECPG_PREPROC_EXTERN_H
@@ -21,7 +21,8 @@ extern intbraces_open,
2121
force_indicator,
2222
ret_value,
2323
struct_level,
24-
ecpg_informix_var;
24+
ecpg_informix_var,
25+
regression_mode;
2526
externchar*descriptor_index;
2627
externchar*descriptor_name;
2728
externchar*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+
intecpg_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+
intecpg_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+
intecpg_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+
intecpg_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-rnull.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+
intecpg_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-test_informix.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+
intecpg_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-test_informix2.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+
intecpg_internal_regression_mode=1;
23
/* These include files are added by the preprocessor */
34
#include<ecpgtype.h>
45
#include<ecpglib.h>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
2+
THE PORT NUMBER MIGHT HAVE BEEN CHANGED BY THE REGRESSION SCRIPT
3+
4+
[NO_PID]: ECPGdebug: set to 1
5+
[NO_PID]: sqlca: code: 0, state: 00000
6+
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT>
7+
[NO_PID]: sqlca: code: 0, state: 00000
8+
[NO_PID]: ECPGexecute line 23: QUERY: alter user connectuser encrypted password 'connectpw' on connection main
9+
[NO_PID]: sqlca: code: 0, state: 00000
10+
[NO_PID]: ECPGexecute line 23 Ok: ALTER ROLE
11+
[NO_PID]: sqlca: code: 0, state: 00000
12+
[NO_PID]: ecpg_finish: Connection main closed.
13+
[NO_PID]: sqlca: code: 0, state: 00000
14+
[NO_PID]: ECPGconnect: opening database connectdb on localhost port <DEFAULT>
15+
[NO_PID]: sqlca: code: 0, state: 00000
16+
[NO_PID]: ecpg_finish: Connection main closed.
17+
[NO_PID]: sqlca: code: 0, state: 00000
18+
[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT> for user connectdb
19+
[NO_PID]: sqlca: code: 0, state: 00000
20+
[NO_PID]: ecpg_finish: Connection main closed.
21+
[NO_PID]: sqlca: code: 0, state: 00000
22+
[NO_PID]: ECPGconnect: opening database connectdb on localhost port 55432
23+
[NO_PID]: sqlca: code: 0, state: 00000
24+
[NO_PID]: ecpg_finish: Connection main closed.
25+
[NO_PID]: sqlca: code: 0, state: 00000
26+
[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port 55432 for user connectdb
27+
[NO_PID]: sqlca: code: 0, state: 00000
28+
[NO_PID]: ecpg_finish: Connection main closed.
29+
[NO_PID]: sqlca: code: 0, state: 00000
30+
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port 55432
31+
[NO_PID]: sqlca: code: 0, state: 00000
32+
[NO_PID]: ecpg_finish: Connection main closed.
33+
[NO_PID]: sqlca: code: 0, state: 00000
34+
[NO_PID]: ECPGconnect: opening database <DEFAULT> on <DEFAULT> port 55432 for user connectdb
35+
[NO_PID]: sqlca: code: 0, state: 00000
36+
[NO_PID]: ecpg_finish: Connection main closed.
37+
[NO_PID]: sqlca: code: 0, state: 00000
38+
[NO_PID]: ECPGconnect: opening database connectdb on localhost port 55432 for user connectuser
39+
[NO_PID]: sqlca: code: 0, state: 00000
40+
[NO_PID]: ecpg_finish: Connection connectdb closed.
41+
[NO_PID]: sqlca: code: 0, state: 00000
42+
[NO_PID]: ECPGconnect: opening database on localhost port 55432 for user connectdb
43+
[NO_PID]: sqlca: code: 0, state: 00000
44+
[NO_PID]: ecpg_finish: Connection closed.
45+
[NO_PID]: sqlca: code: 0, state: 00000
46+
[NO_PID]: ECPGconnect: opening database connectdb on localhost port 55432 for user connectuser
47+
[NO_PID]: sqlca: code: 0, state: 00000
48+
[NO_PID]: ecpg_finish: Connection connectdb closed.
49+
[NO_PID]: sqlca: code: 0, state: 00000
50+
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port 55432 for user connectuser
51+
[NO_PID]: sqlca: code: 0, state: 00000
52+
[NO_PID]: ecpg_finish: Connection connectdb closed.
53+
[NO_PID]: sqlca: code: 0, state: 00000
54+
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port 55432 for user connectuser
55+
[NO_PID]: sqlca: code: 0, state: 00000
56+
[NO_PID]: ecpg_finish: Connection connectdb closed.
57+
[NO_PID]: sqlca: code: 0, state: 00000
58+
[NO_PID]: ECPGconnect: opening database nonexistant on localhost port 55432 for user connectuser
59+
[NO_PID]: sqlca: code: 0, state: 00000
60+
[NO_PID]: connect: could not open database nonexistant on localhost port 55432 for user connectuser in line 62
61+
FATAL: database "nonexistant" does not exist
62+
63+
[NO_PID]: sqlca: code: 0, state: 00000
64+
[NO_PID]: ecpg_finish: Connection nonexistant closed.
65+
[NO_PID]: sqlca: code: 0, state: 00000
66+
[NO_PID]: raising sqlcode -402 in line 62, 'Could not connect to database nonexistant in line 62.'.
67+
[NO_PID]: sqlca: code: -402, state: 08001
68+
[NO_PID]: raising sqlcode -220 in line 63, 'No such connection CURRENT in line 63.'.
69+
[NO_PID]: sqlca: code: -220, state: 08003
70+
[NO_PID]: ECPGconnect: opening database connectdb on localhost port 20 for user connectuser
71+
[NO_PID]: sqlca: code: 0, state: 00000
72+
[NO_PID]: connect: could not open database connectdb on localhost port 20 for user connectuser in line 66
73+
could not connect to server: Connection refused (0x0000274D/10061)
74+
Is the server running on host "localhost" and accepting
75+
TCP/IP connections on port 20?
76+
77+
[NO_PID]: sqlca: code: 0, state: 00000
78+
[NO_PID]: ecpg_finish: Connection connectdb closed.
79+
[NO_PID]: sqlca: code: 0, state: 00000
80+
[NO_PID]: raising sqlcode -402 in line 66, 'Could not connect to database connectdb in line 66.'.
81+
[NO_PID]: sqlca: code: -402, state: 08001
82+
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port 55432 for user connectuser
83+
[NO_PID]: sqlca: code: 0, state: 00000

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp