Header And Logo

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

compat_informix-rnull.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 /* Needed for informix compatibility */
00007 #include <ecpg_informix.h>
00008 /* End of automatic include section */
00009 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
00010 
00011 #line 1 "rnull.pgc"
00012 #include "sqltypes.h"
00013 #include <stdlib.h>
00014 
00015 
00016 #line 1 "regression.h"
00017 
00018 
00019 
00020 
00021 
00022 
00023 #line 4 "rnull.pgc"
00024 
00025 
00026 
00027 static void
00028 test_null(int type, char *ptr)
00029 {
00030     printf("null: %d\n", risnull(type, ptr));
00031 }
00032 
00033 int main(void)
00034 {
00035     
00036 #line 15 "rnull.pgc"
00037  char c [] = "abc" ;
00038 
00039 #line 15 "rnull.pgc"
00040 
00041     
00042 #line 16 "rnull.pgc"
00043  short s = 17 ;
00044 
00045 #line 16 "rnull.pgc"
00046 
00047     
00048 #line 17 "rnull.pgc"
00049  int i = - 74874 ;
00050 
00051 #line 17 "rnull.pgc"
00052 
00053     
00054 #line 18 "rnull.pgc"
00055  bool b = 1 ;
00056 
00057 #line 18 "rnull.pgc"
00058 
00059     
00060 #line 19 "rnull.pgc"
00061  float f = 3.71 ;
00062 
00063 #line 19 "rnull.pgc"
00064 
00065     
00066 #line 20 "rnull.pgc"
00067  long l = 487444 ;
00068 
00069 #line 20 "rnull.pgc"
00070 
00071     
00072 #line 21 "rnull.pgc"
00073  double dbl = 404.404 ;
00074 
00075 #line 21 "rnull.pgc"
00076 
00077     
00078 #line 22 "rnull.pgc"
00079  decimal dec ;
00080 
00081 #line 22 "rnull.pgc"
00082 
00083     
00084 #line 23 "rnull.pgc"
00085  date dat ;
00086 
00087 #line 23 "rnull.pgc"
00088 
00089     
00090 #line 24 "rnull.pgc"
00091  timestamp tmp ;
00092 
00093 #line 24 "rnull.pgc"
00094 
00095 
00096     ECPGdebug(1, stderr);
00097     /* exec sql whenever sqlerror  do sqlprint ( ) ; */
00098 #line 27 "rnull.pgc"
00099 
00100 
00101     { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0); 
00102 #line 29 "rnull.pgc"
00103 
00104 if (sqlca.sqlcode < 0) sqlprint ( );}
00105 #line 29 "rnull.pgc"
00106 
00107 
00108     { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "create table test ( id int , c char ( 10 ) , s smallint , i int , b bool , f float , l bigint , dbl double precision , dec decimal , dat date , tmp timestamptz )", ECPGt_EOIT, ECPGt_EORT);
00109 #line 33 "rnull.pgc"
00110 
00111 if (sqlca.sqlcode < 0) sqlprint ( );}
00112 #line 33 "rnull.pgc"
00113 
00114     { ECPGtrans(__LINE__, NULL, "commit");
00115 #line 34 "rnull.pgc"
00116 
00117 if (sqlca.sqlcode < 0) sqlprint ( );}
00118 #line 34 "rnull.pgc"
00119 
00120 
00121     { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "insert into test ( id , c , s , i , b , f , l , dbl ) values ( 1 , $1  , $2  , $3  , $4  , $5  , $6  , $7  )", 
00122     ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char), 
00123     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00124     ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
00125     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00126     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00127     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00128     ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
00129     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00130     ECPGt_float,&(f),(long)1,(long)1,sizeof(float), 
00131     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00132     ECPGt_long,&(l),(long)1,(long)1,sizeof(long), 
00133     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00134     ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), 
00135     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
00136 #line 38 "rnull.pgc"
00137 
00138 if (sqlca.sqlcode < 0) sqlprint ( );}
00139 #line 38 "rnull.pgc"
00140 
00141     { ECPGtrans(__LINE__, NULL, "commit");
00142 #line 39 "rnull.pgc"
00143 
00144 if (sqlca.sqlcode < 0) sqlprint ( );}
00145 #line 39 "rnull.pgc"
00146 
00147 
00148     rsetnull(CCHARTYPE, (char *) c);
00149     rsetnull(CSHORTTYPE, (char *) &s);
00150     rsetnull(CINTTYPE, (char *) &i);
00151     rsetnull(CBOOLTYPE, (char *) &b);
00152     rsetnull(CFLOATTYPE, (char *) &f);
00153     rsetnull(CLONGTYPE, (char *) &l);
00154     rsetnull(CDOUBLETYPE, (char *) &dbl);
00155     rsetnull(CDECIMALTYPE, (char *) &dec);
00156     rsetnull(CDATETYPE, (char *) &dat);
00157     rsetnull(CDTIMETYPE, (char *) &tmp);
00158 
00159     { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "insert into test ( id , c , s , i , b , f , l , dbl , dec , dat , tmp ) values ( 2 , $1  , $2  , $3  , $4  , $5  , $6  , $7  , $8  , $9  , $10  )", 
00160     ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char), 
00161     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00162     ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
00163     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00164     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00165     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00166     ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
00167     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00168     ECPGt_float,&(f),(long)1,(long)1,sizeof(float), 
00169     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00170     ECPGt_long,&(l),(long)1,(long)1,sizeof(long), 
00171     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00172     ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), 
00173     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00174     ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), 
00175     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00176     ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), 
00177     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00178     ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), 
00179     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
00180 #line 54 "rnull.pgc"
00181 
00182 if (sqlca.sqlcode < 0) sqlprint ( );}
00183 #line 54 "rnull.pgc"
00184 
00185     { ECPGtrans(__LINE__, NULL, "commit");
00186 #line 55 "rnull.pgc"
00187 
00188 if (sqlca.sqlcode < 0) sqlprint ( );}
00189 #line 55 "rnull.pgc"
00190 
00191 
00192     printf("first select\n");
00193 
00194     { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 1", ECPGt_EOIT, 
00195     ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char), 
00196     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00197     ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
00198     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00199     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00200     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00201     ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
00202     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00203     ECPGt_float,&(f),(long)1,(long)1,sizeof(float), 
00204     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00205     ECPGt_long,&(l),(long)1,(long)1,sizeof(long), 
00206     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00207     ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), 
00208     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00209     ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), 
00210     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00211     ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), 
00212     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00213     ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), 
00214     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00215 #line 61 "rnull.pgc"
00216 
00217 if (sqlca.sqlcode < 0) sqlprint ( );}
00218 #line 61 "rnull.pgc"
00219 
00220 
00221     test_null(CCHARTYPE, (char *) c);
00222     test_null(CSHORTTYPE, (char *) &s);
00223     test_null(CINTTYPE, (char *) &i);
00224     test_null(CBOOLTYPE, (char *) &b);
00225     test_null(CFLOATTYPE, (char *) &f);
00226     test_null(CLONGTYPE, (char *) &l);
00227     test_null(CDOUBLETYPE, (char *) &dbl);
00228     test_null(CDECIMALTYPE, (char *) &dec);
00229     test_null(CDATETYPE, (char *) &dat);
00230     test_null(CDTIMETYPE, (char *) &tmp);
00231 
00232     printf("second select\n");
00233 
00234     { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 2", ECPGt_EOIT, 
00235     ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char), 
00236     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00237     ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
00238     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00239     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00240     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00241     ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
00242     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00243     ECPGt_float,&(f),(long)1,(long)1,sizeof(float), 
00244     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00245     ECPGt_long,&(l),(long)1,(long)1,sizeof(long), 
00246     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00247     ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), 
00248     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00249     ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), 
00250     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00251     ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), 
00252     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00253     ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), 
00254     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00255 #line 78 "rnull.pgc"
00256 
00257 if (sqlca.sqlcode < 0) sqlprint ( );}
00258 #line 78 "rnull.pgc"
00259 
00260 
00261     test_null(CCHARTYPE, (char *) c);
00262     test_null(CSHORTTYPE, (char *) &s);
00263     test_null(CINTTYPE, (char *) &i);
00264     test_null(CBOOLTYPE, (char *) &b);
00265     test_null(CFLOATTYPE, (char *) &f);
00266     test_null(CLONGTYPE, (char *) &l);
00267     test_null(CDOUBLETYPE, (char *) &dbl);
00268     test_null(CDECIMALTYPE, (char *) &dec);
00269     test_null(CDATETYPE, (char *) &dat);
00270     test_null(CDTIMETYPE, (char *) &tmp);
00271 
00272     { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);
00273 #line 91 "rnull.pgc"
00274 
00275 if (sqlca.sqlcode < 0) sqlprint ( );}
00276 #line 91 "rnull.pgc"
00277 
00278     { ECPGtrans(__LINE__, NULL, "commit");
00279 #line 92 "rnull.pgc"
00280 
00281 if (sqlca.sqlcode < 0) sqlprint ( );}
00282 #line 92 "rnull.pgc"
00283 
00284 
00285     { ECPGdisconnect(__LINE__, "CURRENT");
00286 #line 94 "rnull.pgc"
00287 
00288 if (sqlca.sqlcode < 0) sqlprint ( );}
00289 #line 94 "rnull.pgc"
00290 
00291 
00292     return 0;
00293 }