Commit e2d6da07 authored by Michael Meskes's avatar Michael Meskes

Improved ECPG warning as suggested by Michael Paquier and removed test case

that triggers the warning during regression tests.
parent b88377ad
...@@ -595,7 +595,8 @@ check_declared_list(const char *name) ...@@ -595,7 +595,8 @@ check_declared_list(const char *name)
if (strcmp(name, ptr -> name) == 0) if (strcmp(name, ptr -> name) == 0)
{ {
if (connection) if (connection)
mmerror(PARSE_ERROR, ET_WARNING, "connection %s is overwritten to %s.", connection, ptr->connection); if (connection && strcmp(ptr->connection, connection) != 0)
mmerror(PARSE_ERROR, ET_WARNING, "connection %s is overwritten with %s by declare statement %s.", connection, ptr->connection, name);
connection = mm_strdup(ptr -> connection); connection = mm_strdup(ptr -> connection);
return true; return true;
} }
......
...@@ -366,74 +366,42 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -366,74 +366,42 @@ if (sqlca.sqlcode < 0) sqlprint();}
printResult("testcase2", 2); printResult("testcase2", 2);
/* /*
* testcase3. using DECLARE STATEMENT at con1, * testcase3. using DECLARE STATEMENT without using AT clause,
* using PREPARE and CURSOR statement at con2 * using PREPARE and EXECUTE statement without using AT clause
*/ */
reset(); reset();
/* declare \"stmt_3\" as an SQL identifier */ /* declare \"stmt_3\" as an SQL identifier */
#line 122 "declare.pgc" #line 122 "declare.pgc"
{ ECPGprepare(__LINE__, "con1", 0, "stmt_3", selectString); { ECPGprepare(__LINE__, NULL, 0, "stmt_3", selectString);
#line 123 "declare.pgc" #line 123 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 123 "declare.pgc" #line 123 "declare.pgc"
/* declare cur_3 cursor for $1 */ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt_3", ECPGt_EOIT,
#line 124 "declare.pgc" ECPGt_int,(f1),(long)1,(long)ARRAY_SIZE,sizeof(int),
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "declare cur_3 cursor for $1",
ECPGt_char_variable,(ECPGprepared_statement("con1", "stmt_3", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 125 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 125 "declare.pgc"
/* exec sql whenever not found break ; */
#line 127 "declare.pgc"
i = 0;
while (1)
{
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "fetch cur_3", ECPGt_EOIT,
ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), ECPGt_int,(f2),(long)1,(long)ARRAY_SIZE,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), ECPGt_char,(f3),(long)20,(long)ARRAY_SIZE,(20)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 131 "declare.pgc" #line 124 "declare.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
#line 131 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 131 "declare.pgc" #line 124 "declare.pgc"
i++;
}
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "close cur_3", ECPGt_EOIT, ECPGt_EORT);
#line 134 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 134 "declare.pgc"
{ ECPGdeallocate(__LINE__, 0, "con1", "stmt_3"); { ECPGdeallocate(__LINE__, 0, NULL, "stmt_3");
#line 135 "declare.pgc" #line 126 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 135 "declare.pgc" #line 126 "declare.pgc"
/* exec sql whenever not found continue ; */
#line 136 "declare.pgc"
printResult("testcase3", 2); printResult("testcase3", 2);
/* /*
* testcase4. using DECLARE STATEMENT without using AT clause, * testcase4. using DECLARE STATEMENT without using AT clause,
* using PREPARE and CURSOR statement at con2 * using PREPARE and CURSOR statement at con2
...@@ -441,28 +409,28 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -441,28 +409,28 @@ if (sqlca.sqlcode < 0) sqlprint();}
reset(); reset();
/* declare \"stmt_4\" as an SQL identifier */ /* declare \"stmt_4\" as an SQL identifier */
#line 147 "declare.pgc" #line 136 "declare.pgc"
{ ECPGprepare(__LINE__, "con2", 0, "stmt_4", selectString); { ECPGprepare(__LINE__, "con2", 0, "stmt_4", selectString);
#line 148 "declare.pgc" #line 137 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 148 "declare.pgc" #line 137 "declare.pgc"
/* declare cur_4 cursor for $1 */ /* declare cur_4 cursor for $1 */
#line 149 "declare.pgc" #line 138 "declare.pgc"
{ ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "declare cur_4 cursor for $1", { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "declare cur_4 cursor for $1",
ECPGt_char_variable,(ECPGprepared_statement("con2", "stmt_4", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_char_variable,(ECPGprepared_statement("con2", "stmt_4", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 150 "declare.pgc" #line 139 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 150 "declare.pgc" #line 139 "declare.pgc"
/* exec sql whenever not found break ; */ /* exec sql whenever not found break ; */
#line 152 "declare.pgc" #line 141 "declare.pgc"
i = 0; i = 0;
while (1) while (1)
...@@ -474,173 +442,136 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -474,173 +442,136 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 156 "declare.pgc" #line 145 "declare.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) break; if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
#line 156 "declare.pgc" #line 145 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 156 "declare.pgc" #line 145 "declare.pgc"
i++; i++;
} }
{ ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "close cur_4", ECPGt_EOIT, ECPGt_EORT); { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "close cur_4", ECPGt_EOIT, ECPGt_EORT);
#line 159 "declare.pgc" #line 148 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 159 "declare.pgc" #line 148 "declare.pgc"
{ ECPGdeallocate(__LINE__, 0, "con2", "stmt_4"); { ECPGdeallocate(__LINE__, 0, "con2", "stmt_4");
#line 160 "declare.pgc" #line 149 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 160 "declare.pgc" #line 149 "declare.pgc"
/* exec sql whenever not found continue ; */ /* exec sql whenever not found continue ; */
#line 161 "declare.pgc" #line 150 "declare.pgc"
printResult("testcase4", 2); printResult("testcase4", 2);
/*
* testcase5. using DECLARE STATEMENT without using AT clause,
* using PREPARE and EXECUTE statement without using AT clause
*/
reset();
/* declare \"stmt_5\" as an SQL identifier */
#line 171 "declare.pgc"
{ ECPGprepare(__LINE__, NULL, 0, "stmt_5", selectString);
#line 172 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 172 "declare.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt_5", ECPGt_EOIT,
ECPGt_int,(f1),(long)1,(long)ARRAY_SIZE,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_int,(f2),(long)1,(long)ARRAY_SIZE,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(f3),(long)20,(long)ARRAY_SIZE,(20)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 173 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 173 "declare.pgc"
{ ECPGdeallocate(__LINE__, 0, NULL, "stmt_5");
#line 175 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 175 "declare.pgc"
printResult("testcase5", 2);
/* /*
* DESCRIBE statement is also supported. * DESCRIBE statement is also supported.
*/ */
/* declare \"stmt_desc\" as an SQL identifier */ /* declare \"stmt_desc\" as an SQL identifier */
#line 182 "declare.pgc" #line 157 "declare.pgc"
{ ECPGprepare(__LINE__, "con1", 0, "stmt_desc", selectString); { ECPGprepare(__LINE__, "con1", 0, "stmt_desc", selectString);
#line 183 "declare.pgc" #line 158 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 183 "declare.pgc" #line 158 "declare.pgc"
/* declare cur_desc cursor for $1 */ /* declare cur_desc cursor for $1 */
#line 184 "declare.pgc" #line 159 "declare.pgc"
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "declare cur_desc cursor for $1", { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "declare cur_desc cursor for $1",
ECPGt_char_variable,(ECPGprepared_statement("con1", "stmt_desc", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_char_variable,(ECPGprepared_statement("con1", "stmt_desc", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 185 "declare.pgc" #line 160 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 185 "declare.pgc" #line 160 "declare.pgc"
/* descriptor can be used for describe statement */ /* descriptor can be used for describe statement */
ECPGallocate_desc(__LINE__, "desc_for_describe"); ECPGallocate_desc(__LINE__, "desc_for_describe");
#line 188 "declare.pgc" #line 163 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint(); if (sqlca.sqlcode < 0) sqlprint();
#line 188 "declare.pgc" #line 163 "declare.pgc"
{ ECPGdescribe(__LINE__, 0, 0, "con1", "stmt_desc", { ECPGdescribe(__LINE__, 0, 0, "con1", "stmt_desc",
ECPGt_descriptor, "desc_for_describe", 1L, 1L, 1L, ECPGt_descriptor, "desc_for_describe", 1L, 1L, 1L,
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 189 "declare.pgc" #line 164 "declare.pgc"
{ ECPGget_desc_header(__LINE__, "desc_for_describe", &(count)); { ECPGget_desc_header(__LINE__, "desc_for_describe", &(count));
#line 191 "declare.pgc" #line 166 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 191 "declare.pgc" #line 166 "declare.pgc"
{ ECPGget_desc(__LINE__, "desc_for_describe", 3,ECPGd_length, { ECPGget_desc(__LINE__, "desc_for_describe", 3,ECPGd_length,
ECPGt_int,&(length),(long)1,(long)1,sizeof(int), ECPGd_EODT); ECPGt_int,&(length),(long)1,(long)1,sizeof(int), ECPGd_EODT);
#line 192 "declare.pgc" #line 167 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 192 "declare.pgc" #line 167 "declare.pgc"
ECPGdeallocate_desc(__LINE__, "desc_for_describe"); ECPGdeallocate_desc(__LINE__, "desc_for_describe");
#line 194 "declare.pgc" #line 169 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint(); if (sqlca.sqlcode < 0) sqlprint();
#line 194 "declare.pgc" #line 169 "declare.pgc"
/* for fetch statement */ /* for fetch statement */
ECPGallocate_desc(__LINE__, "desc_for_fetch"); ECPGallocate_desc(__LINE__, "desc_for_fetch");
#line 197 "declare.pgc" #line 172 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint(); if (sqlca.sqlcode < 0) sqlprint();
#line 197 "declare.pgc" #line 172 "declare.pgc"
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "fetch cur_desc", ECPGt_EOIT, { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "fetch cur_desc", ECPGt_EOIT,
ECPGt_descriptor, "desc_for_fetch", 1L, 1L, 1L, ECPGt_descriptor, "desc_for_fetch", 1L, 1L, 1L,
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 198 "declare.pgc" #line 173 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 198 "declare.pgc" #line 173 "declare.pgc"
{ ECPGget_desc(__LINE__, "desc_for_fetch", 3,ECPGd_data, { ECPGget_desc(__LINE__, "desc_for_fetch", 3,ECPGd_data,
ECPGt_char,(f3[0]),(long)20,(long)1,(20)*sizeof(char), ECPGd_EODT); ECPGt_char,(f3[0]),(long)20,(long)1,(20)*sizeof(char), ECPGd_EODT);
#line 200 "declare.pgc" #line 175 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 200 "declare.pgc" #line 175 "declare.pgc"
ECPGdeallocate_desc(__LINE__, "desc_for_fetch"); ECPGdeallocate_desc(__LINE__, "desc_for_fetch");
#line 202 "declare.pgc" #line 177 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint(); if (sqlca.sqlcode < 0) sqlprint();
#line 202 "declare.pgc" #line 177 "declare.pgc"
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "close cur_desc", ECPGt_EOIT, ECPGt_EORT); { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "close cur_desc", ECPGt_EOIT, ECPGt_EORT);
#line 203 "declare.pgc" #line 178 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 203 "declare.pgc" #line 178 "declare.pgc"
{ ECPGdeallocate(__LINE__, 0, "con1", "stmt_desc"); { ECPGdeallocate(__LINE__, 0, "con1", "stmt_desc");
#line 204 "declare.pgc" #line 179 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 204 "declare.pgc" #line 179 "declare.pgc"
printf("****descriptor results****\n"); printf("****descriptor results****\n");
...@@ -650,16 +581,16 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -650,16 +581,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
void commitTable() void commitTable()
{ {
{ ECPGtrans(__LINE__, "con1", "commit"); { ECPGtrans(__LINE__, "con1", "commit");
#line 212 "declare.pgc" #line 187 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 212 "declare.pgc" #line 187 "declare.pgc"
{ ECPGtrans(__LINE__, "con2", "commit"); { ECPGtrans(__LINE__, "con2", "commit");
#line 213 "declare.pgc" #line 188 "declare.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 213 "declare.pgc" #line 188 "declare.pgc"
} }
......
...@@ -7,14 +7,10 @@ f1=1, f2=10, f3=db on con1 ...@@ -7,14 +7,10 @@ f1=1, f2=10, f3=db on con1
f1=2, f2=20, f3=db on con1 f1=2, f2=20, f3=db on con1
****testcase3 test results:**** ****testcase3 test results:****
f1=1, f2=10, f3=db on con1
f1=2, f2=20, f3=db on con1
****testcase4 test results:****
f1=1, f2=10, f3=db on con2 f1=1, f2=10, f3=db on con2
f1=2, f2=20, f3=db on con2 f1=2, f2=20, f3=db on con2
****testcase5 test results:**** ****testcase4 test results:****
f1=1, f2=10, f3=db on con2 f1=1, f2=10, f3=db on con2
f1=2, f2=20, f3=db on con2 f1=2, f2=20, f3=db on con2
......
...@@ -114,30 +114,19 @@ void execute_test(void) ...@@ -114,30 +114,19 @@ void execute_test(void)
printResult("testcase2", 2); printResult("testcase2", 2);
/* /*
* testcase3. using DECLARE STATEMENT at con1, * testcase3. using DECLARE STATEMENT without using AT clause,
* using PREPARE and CURSOR statement at con2 * using PREPARE and EXECUTE statement without using AT clause
*/ */
reset(); reset();
EXEC SQL AT con1 DECLARE stmt_3 STATEMENT; EXEC SQL DECLARE stmt_3 STATEMENT;
EXEC SQL AT con2 PREPARE stmt_3 FROM :selectString; EXEC SQL PREPARE stmt_3 FROM :selectString;
EXEC SQL AT con2 DECLARE cur_3 CURSOR FOR stmt_3; EXEC SQL EXECUTE stmt_3 INTO :f1, :f2, :f3;
EXEC SQL AT con2 OPEN cur_3;
EXEC SQL WHENEVER NOT FOUND DO BREAK; EXEC SQL DEALLOCATE PREPARE stmt_3;
i = 0;
while (1)
{
EXEC SQL AT con2 FETCH cur_3 INTO :f1[i], :f2[i], :f3[i];
i++;
}
EXEC SQL AT con2 CLOSE cur_3;
EXEC SQL AT con2 DEALLOCATE PREPARE stmt_3;
EXEC SQL WHENEVER NOT FOUND CONTINUE;
printResult("testcase3", 2); printResult("testcase3", 2);
/* /*
* testcase4. using DECLARE STATEMENT without using AT clause, * testcase4. using DECLARE STATEMENT without using AT clause,
* using PREPARE and CURSOR statement at con2 * using PREPARE and CURSOR statement at con2
...@@ -162,20 +151,6 @@ void execute_test(void) ...@@ -162,20 +151,6 @@ void execute_test(void)
printResult("testcase4", 2); printResult("testcase4", 2);
/*
* testcase5. using DECLARE STATEMENT without using AT clause,
* using PREPARE and EXECUTE statement without using AT clause
*/
reset();
EXEC SQL DECLARE stmt_5 STATEMENT;
EXEC SQL PREPARE stmt_5 FROM :selectString;
EXEC SQL EXECUTE stmt_5 INTO :f1, :f2, :f3;
EXEC SQL DEALLOCATE PREPARE stmt_5;
printResult("testcase5", 2);
/* /*
* DESCRIBE statement is also supported. * DESCRIBE statement is also supported.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment