PostgreSQL Source Code: src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c Source File (original) (raw)

1

2

6

7#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))

8

9#line 1 "pointer_to_struct.pgc"

10#include <stdio.h>

11#include <stdlib.h>

12

13

14#line 1 "regression.h"

15

16

17

18

19

20

21#line 4 "pointer_to_struct.pgc"

22

23

24

25#line 6 "pointer_to_struct.pgc"

26

27

28#line 7 "pointer_to_struct.pgc"

29

30

31#line 8 "pointer_to_struct.pgc"

32

33

34typedef struct {

35#line 13 "pointer_to_struct.pgc"

36 struct varchar_1 { int len; char arr[ 50 ]; } name ;

37

38#line 14 "pointer_to_struct.pgc"

39 int phone ;

41#line 15 "pointer_to_struct.pgc"

42

43

44typedef struct ind {

45#line 20 "pointer_to_struct.pgc"

47

48#line 21 "pointer_to_struct.pgc"

51#line 22 "pointer_to_struct.pgc"

52

53

54typedef struct {

55#line 27 "pointer_to_struct.pgc"

58#line 28 "pointer_to_struct.pgc"

59

60

62{

63

64

65

66

67

68

69

70 typedef struct {

71#line 37 "pointer_to_struct.pgc"

72 struct varchar_2 { int len; char arr[ 50 ]; } name ;

73

74#line 38 "pointer_to_struct.pgc"

75 int phone ;

76 } customer2 ;

77

78#line 39 "pointer_to_struct.pgc"

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99#line 33 "pointer_to_struct.pgc"

101

102#line 34 "pointer_to_struct.pgc"

104

105#line 40 "pointer_to_struct.pgc"

106 customer2 * custs2 = ( customer2 * ) malloc ( sizeof ( customer2 ) * 10 ) ;

107

108#line 46 "pointer_to_struct.pgc"

109 struct customer3 {

110#line 44 "pointer_to_struct.pgc"

111 char name [ 50 ] ;

112

113#line 45 "pointer_to_struct.pgc"

114 int phone ;

115 } * custs3 = ( struct customer3 * ) malloc ( sizeof ( struct customer3 ) * 10 ) ;

116

117#line 52 "pointer_to_struct.pgc"

118 struct customer4 {

119#line 50 "pointer_to_struct.pgc"

120 struct varchar_3 { int len; char arr[ 50 ]; } name ;

121

122#line 51 "pointer_to_struct.pgc"

123 int phone ;

124 } * custs4 = ( struct customer4 * ) malloc ( sizeof ( struct customer4 ) ) ;

125

126#line 54 "pointer_to_struct.pgc"

128

129#line 56 "pointer_to_struct.pgc"

130 int r ;

131

132#line 57 "pointer_to_struct.pgc"

133 struct varchar_4 { int len; char arr[ 50 ]; } onlyname [ 2 ] ;

134

135#line 58 "pointer_to_struct.pgc"

136

137

139

141

142 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);

143#line 64 "pointer_to_struct.pgc"

144

146#line 64 "pointer_to_struct.pgc"

147

149#line 64 "pointer_to_struct.pgc"

150

151

153#line 66 "pointer_to_struct.pgc"

154

156#line 66 "pointer_to_struct.pgc"

157

159#line 66 "pointer_to_struct.pgc"

160

161

162

163 strcpy(custs1[0].name.arr, "John Doe");

164 custs1[0].name.len = strlen(custs1[0].name.arr);

165 custs1[0].phone = 12345;

166

170

171 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 1,1 , 1,2 )",

172 ECPGt_varchar,&(custs1->name),(long)50,(long)1,sizeof(struct varchar_1),

174 ECPGt_int,&(custs1[0].phone),(long)1,(long)1,sizeof(int),

176#line 78 "pointer_to_struct.pgc"

177

179#line 78 "pointer_to_struct.pgc"

180

182#line 78 "pointer_to_struct.pgc"

183

185#line 78 "pointer_to_struct.pgc"

186

187 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 1,1 , 1,2 )",

192#line 80 "pointer_to_struct.pgc"

193

195#line 80 "pointer_to_struct.pgc"

196

198#line 80 "pointer_to_struct.pgc"

199

201#line 80 "pointer_to_struct.pgc"

202

203

204

205 memset(custs1, 0, sizeof(customer) * 10);

206

207

213#line 86 "pointer_to_struct.pgc"

214

216#line 86 "pointer_to_struct.pgc"

217

219#line 86 "pointer_to_struct.pgc"

220

222#line 86 "pointer_to_struct.pgc"

223

225 for (r = 0; r < 2; r++)

226 {

227 printf( "name - %s\n", custs1[r].name.arr );

228 printf( "phone - %d\n", custs1[r].phone );

229 }

230

232 ECPGt_varchar,&(custs2->name),(long)50,(long)-1,sizeof( customer2 ),

234 ECPGt_int,&(custs2->phone),(long)1,(long)-1,sizeof( customer2 ),

236#line 94 "pointer_to_struct.pgc"

237

239#line 94 "pointer_to_struct.pgc"

240

242#line 94 "pointer_to_struct.pgc"

243

245#line 94 "pointer_to_struct.pgc"

246

247 printf("\ncusts2:\n");

248 for (r = 0; r < 2; r++)

249 {

250 printf( "name - %s\n", custs2[r].name.arr );

251 printf( "phone - %d\n", custs2[r].phone );

252 }

253

255 ECPGt_char,&(custs3->name),(long)50,(long)-1,sizeof( struct customer3 ),

257 ECPGt_int,&(custs3->phone),(long)1,(long)-1,sizeof( struct customer3 ),

259#line 102 "pointer_to_struct.pgc"

260

262#line 102 "pointer_to_struct.pgc"

263

265#line 102 "pointer_to_struct.pgc"

266

268#line 102 "pointer_to_struct.pgc"

269

270 printf("\ncusts3:\n");

271 for (r = 0; r < 2; r++)

272 {

273 printf( "name - %s\n", custs3[r].name );

274 printf( "phone - %d\n", custs3[r].phone );

275 }

276

278 ECPGt_varchar,&(custs4->name),(long)50,(long)-1,sizeof( struct customer4 ),

280 ECPGt_int,&(custs4->phone),(long)1,(long)-1,sizeof( struct customer4 ),

282#line 110 "pointer_to_struct.pgc"

283

285#line 110 "pointer_to_struct.pgc"

286

288#line 110 "pointer_to_struct.pgc"

289

291#line 110 "pointer_to_struct.pgc"

292

293 printf("\ncusts4:\n");

294 printf( "name - %s\n", custs4->name.arr );

295 printf( "phone - %d\n", custs4->phone );

296

298 ECPGt_varchar,(onlyname),(long)50,(long)2,sizeof(struct varchar_4),

300#line 115 "pointer_to_struct.pgc"

301

303#line 115 "pointer_to_struct.pgc"

304

306#line 115 "pointer_to_struct.pgc"

307

309#line 115 "pointer_to_struct.pgc"

310

312 for (r = 0; r < 2; r++)

313 {

314 printf( "name - %s\n", onlyname[r].arr );

315 }

316

318#line 122 "pointer_to_struct.pgc"

319

321#line 122 "pointer_to_struct.pgc"

322

324#line 122 "pointer_to_struct.pgc"

325

326

327

328 return 0;

329}

bool ECPGdisconnect(int lineno, const char *connection_name)

bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)

bool ECPGdo(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)

struct customer::varchar_1 name