Header And Logo

PostgreSQL
| The world's most advanced open source database.

preproc-whenever.c

Go to the documentation of this file.
00001 /* Processed by ecpg (regression mode) */
00002 /* These include files are added by the preprocessor */
00003 #include <ecpglib.h>
00004 #include <ecpgerrno.h>
00005 #include <sqlca.h>
00006 /* End of automatic include section */
00007 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
00008 
00009 #line 1 "whenever.pgc"
00010 #include <stdlib.h>
00011 
00012 
00013 #line 1 "regression.h"
00014 
00015 
00016 
00017 
00018 
00019 
00020 #line 3 "whenever.pgc"
00021 
00022 
00023 /* exec sql whenever sqlerror  sqlprint ; */
00024 #line 5 "whenever.pgc"
00025 
00026 
00027 static void print(char *msg)
00028 {
00029         fprintf(stderr, "Error in statement '%s':\n", msg);
00030         sqlprint();
00031 }
00032 
00033 static void print2(void)
00034 {
00035         fprintf(stderr, "Found another error\n");
00036         sqlprint();
00037 }
00038 
00039 static void warn(void)
00040 {
00041         fprintf(stderr, "Warning: At least one column was truncated\n");
00042 }
00043 
00044 int main(void)
00045 {
00046     
00047 #line 26 "whenever.pgc"
00048  int i ;
00049 
00050 #line 26 "whenever.pgc"
00051 
00052     
00053 #line 27 "whenever.pgc"
00054  char c [ 6 ] ;
00055 
00056 #line 27 "whenever.pgc"
00057 
00058 
00059     ECPGdebug(1, stderr);
00060 
00061     { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
00062 #line 31 "whenever.pgc"
00063 
00064 if (sqlca.sqlcode < 0) sqlprint();}
00065 #line 31 "whenever.pgc"
00066 
00067     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( i int , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
00068 #line 32 "whenever.pgc"
00069 
00070 if (sqlca.sqlcode < 0) sqlprint();}
00071 #line 32 "whenever.pgc"
00072 
00073     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 1 , 'abcdefghij' )", ECPGt_EOIT, ECPGt_EORT);
00074 #line 33 "whenever.pgc"
00075 
00076 if (sqlca.sqlcode < 0) sqlprint();}
00077 #line 33 "whenever.pgc"
00078 
00079 
00080     /* exec sql whenever sql_warning  do warn ( ) ; */
00081 #line 35 "whenever.pgc"
00082 
00083     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from test", ECPGt_EOIT, 
00084     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00085     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00086     ECPGt_char,(c),(long)6,(long)1,(6)*sizeof(char), 
00087     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00088 #line 36 "whenever.pgc"
00089 
00090 if (sqlca.sqlwarn[0] == 'W') warn ( );
00091 #line 36 "whenever.pgc"
00092 
00093 if (sqlca.sqlcode < 0) sqlprint();}
00094 #line 36 "whenever.pgc"
00095 
00096     { ECPGtrans(__LINE__, NULL, "rollback");
00097 #line 37 "whenever.pgc"
00098 
00099 if (sqlca.sqlwarn[0] == 'W') warn ( );
00100 #line 37 "whenever.pgc"
00101 
00102 if (sqlca.sqlcode < 0) sqlprint();}
00103 #line 37 "whenever.pgc"
00104 
00105 
00106     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistant", ECPGt_EOIT, 
00107     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00108     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00109 #line 39 "whenever.pgc"
00110 
00111 if (sqlca.sqlwarn[0] == 'W') warn ( );
00112 #line 39 "whenever.pgc"
00113 
00114 if (sqlca.sqlcode < 0) sqlprint();}
00115 #line 39 "whenever.pgc"
00116 
00117     { ECPGtrans(__LINE__, NULL, "rollback");
00118 #line 40 "whenever.pgc"
00119 
00120 if (sqlca.sqlwarn[0] == 'W') warn ( );
00121 #line 40 "whenever.pgc"
00122 
00123 if (sqlca.sqlcode < 0) sqlprint();}
00124 #line 40 "whenever.pgc"
00125 
00126 
00127     /* exec sql whenever sqlerror  do print ( \"select\" ) ; */
00128 #line 42 "whenever.pgc"
00129 
00130     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistant", ECPGt_EOIT, 
00131     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00132     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00133 #line 43 "whenever.pgc"
00134 
00135 if (sqlca.sqlwarn[0] == 'W') warn ( );
00136 #line 43 "whenever.pgc"
00137 
00138 if (sqlca.sqlcode < 0) print ( "select" );}
00139 #line 43 "whenever.pgc"
00140 
00141     { ECPGtrans(__LINE__, NULL, "rollback");
00142 #line 44 "whenever.pgc"
00143 
00144 if (sqlca.sqlwarn[0] == 'W') warn ( );
00145 #line 44 "whenever.pgc"
00146 
00147 if (sqlca.sqlcode < 0) print ( "select" );}
00148 #line 44 "whenever.pgc"
00149 
00150 
00151     /* exec sql whenever sqlerror  call print2 ( ) ; */
00152 #line 46 "whenever.pgc"
00153 
00154     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistant", ECPGt_EOIT, 
00155     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00156     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00157 #line 47 "whenever.pgc"
00158 
00159 if (sqlca.sqlwarn[0] == 'W') warn ( );
00160 #line 47 "whenever.pgc"
00161 
00162 if (sqlca.sqlcode < 0) print2 ( );}
00163 #line 47 "whenever.pgc"
00164 
00165     { ECPGtrans(__LINE__, NULL, "rollback");
00166 #line 48 "whenever.pgc"
00167 
00168 if (sqlca.sqlwarn[0] == 'W') warn ( );
00169 #line 48 "whenever.pgc"
00170 
00171 if (sqlca.sqlcode < 0) print2 ( );}
00172 #line 48 "whenever.pgc"
00173 
00174 
00175     /* exec sql whenever sqlerror  continue ; */
00176 #line 50 "whenever.pgc"
00177 
00178     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistant", ECPGt_EOIT, 
00179     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00180     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00181 #line 51 "whenever.pgc"
00182 
00183 if (sqlca.sqlwarn[0] == 'W') warn ( );}
00184 #line 51 "whenever.pgc"
00185 
00186     { ECPGtrans(__LINE__, NULL, "rollback");
00187 #line 52 "whenever.pgc"
00188 
00189 if (sqlca.sqlwarn[0] == 'W') warn ( );}
00190 #line 52 "whenever.pgc"
00191 
00192 
00193     /* exec sql whenever sqlerror  goto  error ; */
00194 #line 54 "whenever.pgc"
00195 
00196     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistant", ECPGt_EOIT, 
00197     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00198     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00199 #line 55 "whenever.pgc"
00200 
00201 if (sqlca.sqlwarn[0] == 'W') warn ( );
00202 #line 55 "whenever.pgc"
00203 
00204 if (sqlca.sqlcode < 0) goto error;}
00205 #line 55 "whenever.pgc"
00206 
00207     printf("Should not be reachable\n");
00208 
00209     error:
00210     { ECPGtrans(__LINE__, NULL, "rollback");
00211 #line 59 "whenever.pgc"
00212 
00213 if (sqlca.sqlwarn[0] == 'W') warn ( );
00214 #line 59 "whenever.pgc"
00215 
00216 if (sqlca.sqlcode < 0) goto error;}
00217 #line 59 "whenever.pgc"
00218 
00219 
00220     /* exec sql whenever sqlerror  stop ; */
00221 #line 61 "whenever.pgc"
00222 
00223     /* This cannot fail, thus we don't get an exit value not equal 0. */
00224     /* However, it still test the precompiler output. */
00225     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 1", ECPGt_EOIT, 
00226     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00227     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00228 #line 64 "whenever.pgc"
00229 
00230 if (sqlca.sqlwarn[0] == 'W') warn ( );
00231 #line 64 "whenever.pgc"
00232 
00233 if (sqlca.sqlcode < 0) exit (1);}
00234 #line 64 "whenever.pgc"
00235 
00236     { ECPGtrans(__LINE__, NULL, "rollback");
00237 #line 65 "whenever.pgc"
00238 
00239 if (sqlca.sqlwarn[0] == 'W') warn ( );
00240 #line 65 "whenever.pgc"
00241 
00242 if (sqlca.sqlcode < 0) exit (1);}
00243 #line 65 "whenever.pgc"
00244 
00245     exit (0);
00246 }