Skip to content

Commit eb606d7

Browse files
author
Commitfest Bot
committed
[CF 5543] v6 - Add regression tests of ecpg command notice (error / warning)
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5543 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/[email protected] Author(s): Ryo Kanbayashi
2 parents 3f1db99 + 632e7c8 commit eb606d7

File tree

6 files changed

+138
-0
lines changed

6 files changed

+138
-0
lines changed

src/interfaces/ecpg/preproc/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ ecpg_keywords.o: ecpg_kwlist_d.h
8181
c_keywords.o: c_kwlist_d.h
8282
keywords.o: $(top_srcdir)/src/include/parser/kwlist.h
8383

84+
check:
85+
$(prove_check)
86+
8487
install: all installdirs
8588
$(INSTALL_PROGRAM) ecpg$(X) '$(DESTDIR)$(bindir)'
8689

src/interfaces/ecpg/preproc/meson.build

+13
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,16 @@ ecpg_exe = executable('ecpg',
8686
ecpg_targets += ecpg_exe
8787

8888
subdir('po', if_found: libintl)
89+
90+
tests += {
91+
'name': 'ecpg',
92+
'sd': meson.current_source_dir(),
93+
'bd': meson.current_build_dir(),
94+
'tap': {
95+
'tests': [
96+
't/001_ecpg_err_warn_msg.pl',
97+
't/002_ecpg_err_warn_msg_informix.pl',
98+
],
99+
'deps': ecpg_exe,
100+
},
101+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
# Copyright (c) 2021-2025, PostgreSQL Global Development Group
3+
4+
use strict;
5+
use warnings FATAL => 'all';
6+
use PostgreSQL::Test::Utils;
7+
use Test::More;
8+
9+
program_help_ok('ecpg');
10+
program_version_ok('ecpg');
11+
program_options_handling_ok('ecpg');
12+
command_fails(['ecpg'], 'ecpg without arguments fails');
13+
14+
# Test that the ecpg command correctly detects unsupported or disallowed
15+
# statements in the input file and reports the appropriate error or
16+
# warning messages.
17+
command_checks_all(
18+
[ 'ecpg', 't/err_warn_msg.pgc' ],
19+
3,
20+
[qr//],
21+
[
22+
qr/ERROR: AT option not allowed in CONNECT statement/,
23+
qr/ERROR: AT option not allowed in DISCONNECT statement/,
24+
qr/ERROR: AT option not allowed in SET CONNECTION statement/,
25+
qr/ERROR: AT option not allowed in TYPE statement/,
26+
qr/ERROR: AT option not allowed in WHENEVER statement/,
27+
qr/ERROR: AT option not allowed in VAR statement/,
28+
qr/WARNING: COPY FROM STDIN is not implemented/,
29+
qr/ERROR: using variable "cursor_var" in different declare statements is not supported/,
30+
qr/ERROR: cursor "duplicate_cursor" is already defined/,
31+
qr/ERROR: SHOW ALL is not implemented/,
32+
qr/WARNING: no longer supported LIMIT/,
33+
qr/WARNING: cursor "duplicate_cursor" has been declared but not opened/,
34+
qr/WARNING: cursor "duplicate_cursor" has been declared but not opened/,
35+
qr/WARNING: cursor ":cursor_var" has been declared but not opened/,
36+
qr/WARNING: cursor ":cursor_var" has been declared but not opened/
37+
],
38+
'ecpg with errors and warnings');
39+
40+
done_testing();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
# Copyright (c) 2021-2025, PostgreSQL Global Development Group
3+
4+
use strict;
5+
use warnings FATAL => 'all';
6+
use PostgreSQL::Test::Utils;
7+
use Test::More;
8+
9+
# Test that the ecpg command in INFORMIX mode correctly detects
10+
# unsupported or disallowed statements in the input file and reports
11+
# the appropriate error or warning messages.
12+
command_checks_all(
13+
[ 'ecpg', '-C', 'INFORMIX', 't/err_warn_msg_informix.pgc' ],
14+
3,
15+
[qr//],
16+
[
17+
qr/ERROR: AT option not allowed in CLOSE DATABASE statement/,
18+
qr/ERROR: "database" cannot be used as cursor name in INFORMIX mode/
19+
],
20+
'ecpg in INFORMIX mode with errors and warnings');
21+
22+
done_testing();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* Test ECPG warning/error messages */
2+
3+
#include <stdlib.h>
4+
5+
int
6+
main(void)
7+
{
8+
EXEC SQL BEGIN DECLARE SECTION;
9+
char *cursor_var = "mycursor";
10+
short a;
11+
EXEC SQL END DECLARE SECTION;
12+
13+
/* For consistency with other tests */
14+
EXEC SQL CONNECT TO testdb AS con1;
15+
16+
/* Test AT option errors */
17+
EXEC SQL AT con1 CONNECT TO testdb2;
18+
EXEC SQL AT con1 DISCONNECT;
19+
EXEC SQL AT con1 SET CONNECTION TO testdb2;
20+
EXEC SQL AT con1 TYPE string IS char[11];
21+
EXEC SQL AT con1 WHENEVER NOT FOUND CONTINUE;
22+
EXEC SQL AT con1 VAR a IS int;
23+
24+
/* Test COPY FROM STDIN warning */
25+
EXEC SQL COPY test FROM stdin;
26+
27+
/* Test same variable in multi declare statement */
28+
EXEC SQL DECLARE :cursor_var CURSOR FOR SELECT * FROM test;
29+
EXEC SQL DECLARE :cursor_var CURSOR FOR SELECT * FROM test;
30+
31+
/* Test duplicate cursor declarations */
32+
EXEC SQL DECLARE duplicate_cursor CURSOR FOR SELECT * FROM test;
33+
EXEC SQL DECLARE duplicate_cursor CURSOR FOR SELECT * FROM test;
34+
35+
/* Test SHOW ALL error */
36+
EXEC SQL SHOW ALL;
37+
38+
/* Test deprecated LIMIT syntax warning */
39+
EXEC SQL SELECT * FROM test LIMIT 10, 5;
40+
41+
return 0;
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Test ECPG warning/error messages in INFORMIX mode */
2+
3+
#include <stdlib.h>
4+
5+
int
6+
main(void)
7+
{
8+
/* For consistency with other tests */
9+
$CONNECT TO testdb AS con1;
10+
11+
/* Test AT option usage at CLOSE DATABASE statement in INFORMIX mode */
12+
$AT con1 CLOSE DATABASE;
13+
14+
/* Test cursor name errors in INFORMIX mode */
15+
$DECLARE database CURSOR FOR SELECT * FROM test;
16+
17+
return 0;
18+
}

0 commit comments

Comments
 (0)