~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

Viewing changes to src/interfaces/ecpg/test/expected/sql-dynalloc2.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Processed by ecpg (regression mode) */
 
2
/* These include files are added by the preprocessor */
 
3
#include <ecpglib.h>
 
4
#include <ecpgerrno.h>
 
5
#include <sqlca.h>
 
6
/* End of automatic include section */
 
7
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
 
8
 
 
9
#line 1 "dynalloc2.pgc"
 
10
#include <stdio.h>
 
11
 
 
12
#line 1 "sqlca.h"
 
13
#ifndef POSTGRES_SQLCA_H
 
14
#define POSTGRES_SQLCA_H
 
15
 
 
16
#ifndef PGDLLIMPORT
 
17
#if  defined(WIN32) || defined(__CYGWIN__)
 
18
#define PGDLLIMPORT __declspec (dllimport)
 
19
#else
 
20
#define PGDLLIMPORT
 
21
#endif   /* __CYGWIN__ */
 
22
#endif   /* PGDLLIMPORT */
 
23
 
 
24
#define SQLERRMC_LEN    150
 
25
 
 
26
#ifdef __cplusplus
 
27
extern          "C"
 
28
{
 
29
#endif
 
30
 
 
31
struct sqlca_t
 
32
{
 
33
        char            sqlcaid[8];
 
34
        long            sqlabc;
 
35
        long            sqlcode;
 
36
        struct
 
37
        {
 
38
                int                     sqlerrml;
 
39
                char            sqlerrmc[SQLERRMC_LEN];
 
40
        }                       sqlerrm;
 
41
        char            sqlerrp[8];
 
42
        long            sqlerrd[6];
 
43
        /* Element 0: empty                                             */
 
44
        /* 1: OID of processed tuple if applicable                      */
 
45
        /* 2: number of rows processed                          */
 
46
        /* after an INSERT, UPDATE or                           */
 
47
        /* DELETE statement                                     */
 
48
        /* 3: empty                                             */
 
49
        /* 4: empty                                             */
 
50
        /* 5: empty                                             */
 
51
        char            sqlwarn[8];
 
52
        /* Element 0: set to 'W' if at least one other is 'W'   */
 
53
        /* 1: if 'W' at least one character string              */
 
54
        /* value was truncated when it was                      */
 
55
        /* stored into a host variable.                         */
 
56
 
 
57
        /*
 
58
         * 2: if 'W' a (hopefully) non-fatal notice occurred
 
59
         */     /* 3: empty */
 
60
        /* 4: empty                                             */
 
61
        /* 5: empty                                             */
 
62
        /* 6: empty                                             */
 
63
        /* 7: empty                                             */
 
64
 
 
65
        char            sqlstate[5];
 
66
};
 
67
 
 
68
struct sqlca_t *ECPGget_sqlca(void);
 
69
 
 
70
#ifndef POSTGRES_ECPG_INTERNAL
 
71
#define sqlca (*ECPGget_sqlca())
 
72
#endif
 
73
 
 
74
#ifdef __cplusplus
 
75
}
 
76
#endif
 
77
 
 
78
#endif
 
79
 
 
80
#line 2 "dynalloc2.pgc"
 
81
 
 
82
#include <stdlib.h>
 
83
 
 
84
#line 1 "regression.h"
 
85
 
 
86
 
 
87
 
 
88
 
 
89
 
 
90
 
 
91
#line 4 "dynalloc2.pgc"
 
92
 
 
93
 
 
94
int main(void)
 
95
{
 
96
   /* exec sql begin declare section */
 
97
    
 
98
    
 
99
    
 
100
    
 
101
    
 
102
   
 
103
#line 9 "dynalloc2.pgc"
 
104
 int * ip1 = 0 ;
 
105
 
 
106
#line 10 "dynalloc2.pgc"
 
107
 char ** cp2 = 0 ;
 
108
 
 
109
#line 11 "dynalloc2.pgc"
 
110
 int * ipointer1 = 0 ;
 
111
 
 
112
#line 12 "dynalloc2.pgc"
 
113
 int * ipointer2 = 0 ;
 
114
 
 
115
#line 13 "dynalloc2.pgc"
 
116
 int colnum ;
 
117
/* exec sql end declare section */
 
118
#line 14 "dynalloc2.pgc"
 
119
 
 
120
   int i;
 
121
 
 
122
   ECPGdebug(1, stderr);
 
123
 
 
124
   /* exec sql whenever sqlerror  do sqlprint ( ) ; */
 
125
#line 19 "dynalloc2.pgc"
 
126
 
 
127
   { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
 
128
#line 20 "dynalloc2.pgc"
 
129
 
 
130
if (sqlca.sqlcode < 0) sqlprint ( );}
 
131
#line 20 "dynalloc2.pgc"
 
132
 
 
133
 
 
134
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to postgres", ECPGt_EOIT, ECPGt_EORT);
 
135
#line 22 "dynalloc2.pgc"
 
136
 
 
137
if (sqlca.sqlcode < 0) sqlprint ( );}
 
138
#line 22 "dynalloc2.pgc"
 
139
 
 
140
 
 
141
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( a int , b text )", ECPGt_EOIT, ECPGt_EORT);
 
142
#line 24 "dynalloc2.pgc"
 
143
 
 
144
if (sqlca.sqlcode < 0) sqlprint ( );}
 
145
#line 24 "dynalloc2.pgc"
 
146
 
 
147
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 1 , 'one' )", ECPGt_EOIT, ECPGt_EORT);
 
148
#line 25 "dynalloc2.pgc"
 
149
 
 
150
if (sqlca.sqlcode < 0) sqlprint ( );}
 
151
#line 25 "dynalloc2.pgc"
 
152
 
 
153
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 2 , 'two' )", ECPGt_EOIT, ECPGt_EORT);
 
154
#line 26 "dynalloc2.pgc"
 
155
 
 
156
if (sqlca.sqlcode < 0) sqlprint ( );}
 
157
#line 26 "dynalloc2.pgc"
 
158
 
 
159
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( null , 'three' )", ECPGt_EOIT, ECPGt_EORT);
 
160
#line 27 "dynalloc2.pgc"
 
161
 
 
162
if (sqlca.sqlcode < 0) sqlprint ( );}
 
163
#line 27 "dynalloc2.pgc"
 
164
 
 
165
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 4 , 'four' )", ECPGt_EOIT, ECPGt_EORT);
 
166
#line 28 "dynalloc2.pgc"
 
167
 
 
168
if (sqlca.sqlcode < 0) sqlprint ( );}
 
169
#line 28 "dynalloc2.pgc"
 
170
 
 
171
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 5 , null )", ECPGt_EOIT, ECPGt_EORT);
 
172
#line 29 "dynalloc2.pgc"
 
173
 
 
174
if (sqlca.sqlcode < 0) sqlprint ( );}
 
175
#line 29 "dynalloc2.pgc"
 
176
 
 
177
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( null , null )", ECPGt_EOIT, ECPGt_EORT);
 
178
#line 30 "dynalloc2.pgc"
 
179
 
 
180
if (sqlca.sqlcode < 0) sqlprint ( );}
 
181
#line 30 "dynalloc2.pgc"
 
182
 
 
183
 
 
184
   ECPGallocate_desc(__LINE__, "mydesc");
 
185
#line 32 "dynalloc2.pgc"
 
186
 
 
187
if (sqlca.sqlcode < 0) sqlprint ( );
 
188
#line 32 "dynalloc2.pgc"
 
189
 
 
190
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from test", ECPGt_EOIT, 
 
191
        ECPGt_descriptor, "mydesc", 0L, 0L, 0L, 
 
192
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 
193
#line 33 "dynalloc2.pgc"
 
194
 
 
195
if (sqlca.sqlcode < 0) sqlprint ( );}
 
196
#line 33 "dynalloc2.pgc"
 
197
 
 
198
   { ECPGget_desc_header(__LINE__, "mydesc", &(colnum));
 
199
 
 
200
#line 34 "dynalloc2.pgc"
 
201
 
 
202
if (sqlca.sqlcode < 0) sqlprint ( );}
 
203
#line 34 "dynalloc2.pgc"
 
204
 
 
205
   { ECPGget_desc(__LINE__, "mydesc", 1,ECPGd_indicator,
 
206
        ECPGt_int,&(ipointer1),(long)1,(long)0,sizeof(int), ECPGd_data,
 
207
        ECPGt_int,&(ip1),(long)1,(long)0,sizeof(int), ECPGd_EODT);
 
208
 
 
209
#line 35 "dynalloc2.pgc"
 
210
 
 
211
if (sqlca.sqlcode < 0) sqlprint ( );}
 
212
#line 35 "dynalloc2.pgc"
 
213
 
 
214
   { ECPGget_desc(__LINE__, "mydesc", 2,ECPGd_indicator,
 
215
        ECPGt_int,&(ipointer2),(long)1,(long)0,sizeof(int), ECPGd_data,
 
216
        ECPGt_char,&(cp2),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
 
217
 
 
218
#line 36 "dynalloc2.pgc"
 
219
 
 
220
if (sqlca.sqlcode < 0) sqlprint ( );}
 
221
#line 36 "dynalloc2.pgc"
 
222
 
 
223
 
 
224
   printf("Result (%d columns):\n", colnum);
 
225
   for (i=0;i < sqlca.sqlerrd[2];++i)
 
226
   {
 
227
      if (ipointer1[i]) printf("NULL, ");
 
228
      else printf("%d, ",ip1[i]); 
 
229
 
 
230
      if (ipointer2[i]) printf("NULL, ");
 
231
      else printf("'%s', ",cp2[i]); 
 
232
      printf("\n");
 
233
   }
 
234
   ECPGfree_auto_mem();
 
235
   printf("\n");
 
236
 
 
237
   ECPGdeallocate_desc(__LINE__, "mydesc");
 
238
#line 51 "dynalloc2.pgc"
 
239
 
 
240
if (sqlca.sqlcode < 0) sqlprint ( );
 
241
#line 51 "dynalloc2.pgc"
 
242
 
 
243
   { ECPGtrans(__LINE__, NULL, "rollback");
 
244
#line 52 "dynalloc2.pgc"
 
245
 
 
246
if (sqlca.sqlcode < 0) sqlprint ( );}
 
247
#line 52 "dynalloc2.pgc"
 
248
 
 
249
   { ECPGdisconnect(__LINE__, "CURRENT");
 
250
#line 53 "dynalloc2.pgc"
 
251
 
 
252
if (sqlca.sqlcode < 0) sqlprint ( );}
 
253
#line 53 "dynalloc2.pgc"
 
254
 
 
255
   return 0;
 
256
}