PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
sqlda.c
Go to the documentation of this file.
1 /*
2  * SQLDA support routines
3  *
4  * The allocated memory area pointed by an sqlda pointer
5  * contains both the metadata and the data, so freeing up
6  * is a simple free(sqlda) as expected by the ESQL/C examples.
7  */
8 
9 #define POSTGRES_ECPG_INTERNAL
10 #include "postgres_fe.h"
11 #include "pg_type.h"
12 
13 #include "ecpg-pthread-win32.h"
14 #include "decimal.h"
15 #include "ecpgtype.h"
16 #include "ecpglib.h"
17 #include "ecpgerrno.h"
18 #include "extern.h"
19 #include "sqlca.h"
20 #include "sqlda-native.h"
21 #include "sqlda-compat.h"
22 
23 /*
24  * Compute the next variable's offset with
25  * the current variable's size and alignment.
26  *
27  *
28  * Returns:
29  * - the current variable's offset in *current
30  * - the next variable's offset in *next
31  */
32 static void
33 ecpg_sqlda_align_add_size(long offset, int alignment, int size, long *current, long *next)
34 {
35  if (offset % alignment)
36  offset += alignment - (offset % alignment);
37  if (current)
38  *current = offset;
39  offset += size;
40  if (next)
41  *next = offset;
42 }
43 
44 static long
46 {
47  long offset;
48  int i;
49  int sqld = PQnfields(res);
50 
51  /* Initial size to store main structure and field structures */
52  offset = sizeof(struct sqlda_compat) + sqld * sizeof(struct sqlvar_compat);
53 
54  /* Add space for field names */
55  for (i = 0; i < sqld; i++)
56  offset += strlen(PQfname(res, i)) + 1;
57 
58  /* Add padding to the first field value */
59  ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
60 
61  return offset;
62 }
63 
64 static long
65 sqlda_common_total_size(const PGresult *res, int row, enum COMPAT_MODE compat, long offset)
66 {
67  int sqld = PQnfields(res);
68  int i;
69  long next_offset;
70 
71  /* Add space for the field values */
72  for (i = 0; i < sqld; i++)
73  {
74  enum ECPGttype type = sqlda_dynamic_type(PQftype(res, i), compat);
75 
76  switch (type)
77  {
78  case ECPGt_short:
80  ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
81  break;
82  case ECPGt_int:
83  case ECPGt_unsigned_int:
84  ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
85  break;
86  case ECPGt_long:
88  ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
89  break;
90  case ECPGt_long_long:
92  ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
93  break;
94  case ECPGt_bool:
95  ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
96  break;
97  case ECPGt_float:
98  ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
99  break;
100  case ECPGt_double:
101  ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
102  break;
103  case ECPGt_decimal:
104  ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
105  break;
106  case ECPGt_numeric:
107 
108  /*
109  * Let's align both the numeric struct and the digits array to
110  * int Unfortunately we need to do double work here to compute
111  * the size of the space needed for the numeric structure.
112  */
113  ecpg_sqlda_align_add_size(offset, sizeof(NumericDigit *), sizeof(numeric), &offset, &next_offset);
114  if (!PQgetisnull(res, row, i))
115  {
116  char *val = PQgetvalue(res, row, i);
117  numeric *num;
118 
119  num = PGTYPESnumeric_from_asc(val, NULL);
120  if (!num)
121  break;
122  if (num->ndigits)
123  ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
124  PGTYPESnumeric_free(num);
125  }
126  break;
127  case ECPGt_date:
128  ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
129  break;
130  case ECPGt_timestamp:
131  ecpg_sqlda_align_add_size(offset, sizeof(int64), sizeof(timestamp), &offset, &next_offset);
132  break;
133  case ECPGt_interval:
134  ecpg_sqlda_align_add_size(offset, sizeof(int64), sizeof(interval), &offset, &next_offset);
135  break;
136  case ECPGt_char:
137  case ECPGt_unsigned_char:
138  case ECPGt_string:
139  default:
140  {
141  long datalen = strlen(PQgetvalue(res, row, i)) + 1;
142 
143  ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
144  break;
145  }
146  }
147  offset = next_offset;
148  }
149  return offset;
150 }
151 
152 
153 static long
155 {
156  long offset;
157 
158  offset = sqlda_compat_empty_size(res);
159 
160  if (row < 0)
161  return offset;
162 
163  offset = sqlda_common_total_size(res, row, compat, offset);
164  return offset;
165 }
166 
167 static long
169 {
170  long offset;
171  int sqld = PQnfields(res);
172 
173  /* Initial size to store main structure and field structures */
174  offset = sizeof(struct sqlda_struct) + (sqld - 1) * sizeof(struct sqlvar_struct);
175 
176  /* Add padding to the first field value */
177  ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
178 
179  return offset;
180 }
181 
182 static long
184 {
185  long offset;
186 
187  offset = sqlda_native_empty_size(res);
188 
189  if (row < 0)
190  return offset;
191 
192  offset = sqlda_common_total_size(res, row, compat, offset);
193  return offset;
194 }
195 
196 /*
197  * Build "struct sqlda_compat" (metadata only) from PGresult
198  * leaving enough space for the field values in
199  * the given row number
200  */
201 struct sqlda_compat *
202 ecpg_build_compat_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
203 {
204  struct sqlda_compat *sqlda;
205  struct sqlvar_compat *sqlvar;
206  char *fname;
207  long size;
208  int sqld;
209  int i;
210 
211  size = sqlda_compat_total_size(res, row, compat);
212  sqlda = (struct sqlda_compat *) ecpg_alloc(size, line);
213  if (!sqlda)
214  return NULL;
215 
216  memset(sqlda, 0, size);
217  sqlvar = (struct sqlvar_compat *) (sqlda + 1);
218  sqld = PQnfields(res);
219  fname = (char *) (sqlvar + sqld);
220 
221  sqlda->sqld = sqld;
222  ecpg_log("ecpg_build_compat_sqlda on line %d sqld = %d\n", line, sqld);
223  sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
224  sqlda->sqlvar = sqlvar;
225 
226  for (i = 0; i < sqlda->sqld; i++)
227  {
228  sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
229  strcpy(fname, PQfname(res, i));
230  sqlda->sqlvar[i].sqlname = fname;
231  fname += strlen(sqlda->sqlvar[i].sqlname) + 1;
232 
233  /*
234  * this is reserved for future use, so we leave it empty for the time
235  * being
236  */
237  /* sqlda->sqlvar[i].sqlformat = (char *) (long) PQfformat(res, i); */
238  sqlda->sqlvar[i].sqlxid = PQftype(res, i);
239  sqlda->sqlvar[i].sqltypelen = PQfsize(res, i);
240  }
241 
242  return sqlda;
243 }
244 
245 /*
246  * Sets values from PGresult.
247  */
248 static int16 value_is_null = -1;
250 
251 void
252 ecpg_set_compat_sqlda(int lineno, struct sqlda_compat ** _sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
253 {
254  struct sqlda_compat *sqlda = (*_sqlda);
255  int i;
256  long offset,
257  next_offset;
258 
259  if (row < 0)
260  return;
261 
262  /* Offset for the first field value */
263  offset = sqlda_compat_empty_size(res);
264 
265  /*
266  * Set sqlvar[i]->sqldata pointers and convert values to correct format
267  */
268  for (i = 0; i < sqlda->sqld; i++)
269  {
270  int isnull;
271  int datalen;
272  bool set_data = true;
273 
274  switch (sqlda->sqlvar[i].sqltype)
275  {
276  case ECPGt_short:
278  ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
279  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
280  sqlda->sqlvar[i].sqllen = sizeof(short);
281  break;
282  case ECPGt_int:
283  case ECPGt_unsigned_int:
284  ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
285  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
286  sqlda->sqlvar[i].sqllen = sizeof(int);
287  break;
288  case ECPGt_long:
289  case ECPGt_unsigned_long:
290  ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
291  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
292  sqlda->sqlvar[i].sqllen = sizeof(long);
293  break;
294  case ECPGt_long_long:
296  ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
297  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
298  sqlda->sqlvar[i].sqllen = sizeof(long long);
299  break;
300  case ECPGt_bool:
301  ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
302  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
303  sqlda->sqlvar[i].sqllen = sizeof(bool);
304  break;
305  case ECPGt_float:
306  ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
307  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
308  sqlda->sqlvar[i].sqllen = sizeof(float);
309  break;
310  case ECPGt_double:
311  ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
312  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
313  sqlda->sqlvar[i].sqllen = sizeof(double);
314  break;
315  case ECPGt_decimal:
316  ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
317  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
318  sqlda->sqlvar[i].sqllen = sizeof(decimal);
319  break;
320  case ECPGt_numeric:
321  {
322  numeric *num;
323  char *val;
324 
325  set_data = false;
326 
327  ecpg_sqlda_align_add_size(offset, sizeof(NumericDigit *), sizeof(numeric), &offset, &next_offset);
328  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
329  sqlda->sqlvar[i].sqllen = sizeof(numeric);
330 
331  if (PQgetisnull(res, row, i))
332  {
334  break;
335  }
336 
337  val = PQgetvalue(res, row, i);
338  num = PGTYPESnumeric_from_asc(val, NULL);
339  if (!num)
340  {
342  break;
343  }
344 
345  memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
346 
347  if (num->ndigits)
348  {
349  ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
350  memcpy((char *) sqlda + offset, num->buf, num->ndigits + 1);
351 
352  ((numeric *) sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *) sqlda + offset;
353  ((numeric *) sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *) sqlda + offset + (num->digits - num->buf);
354  }
355 
356  PGTYPESnumeric_free(num);
357 
358  break;
359  }
360  case ECPGt_date:
361  ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
362  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
363  sqlda->sqlvar[i].sqllen = sizeof(date);
364  break;
365  case ECPGt_timestamp:
366  ecpg_sqlda_align_add_size(offset, sizeof(int64), sizeof(timestamp), &offset, &next_offset);
367  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
368  sqlda->sqlvar[i].sqllen = sizeof(timestamp);
369  break;
370  case ECPGt_interval:
371  ecpg_sqlda_align_add_size(offset, sizeof(int64), sizeof(interval), &offset, &next_offset);
372  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
373  sqlda->sqlvar[i].sqllen = sizeof(interval);
374  break;
375  case ECPGt_char:
376  case ECPGt_unsigned_char:
377  case ECPGt_string:
378  default:
379  datalen = strlen(PQgetvalue(res, row, i)) + 1;
380  ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
381  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
382  sqlda->sqlvar[i].sqllen = datalen;
383  if (datalen > 32768)
384  sqlda->sqlvar[i].sqlilongdata = sqlda->sqlvar[i].sqldata;
385  break;
386  }
387 
388  isnull = PQgetisnull(res, row, i);
389  ecpg_log("ecpg_set_compat_sqlda on line %d row %d col %d %s\n", lineno, row, i, isnull ? "IS NULL" : "IS NOT NULL");
390  sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
391  sqlda->sqlvar[i].sqlitype = ECPGt_short;
392  sqlda->sqlvar[i].sqlilen = sizeof(short);
393  if (!isnull)
394  {
395  if (set_data)
396  ecpg_get_data(res, row, i, lineno,
397  sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
398  sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
399  ECPG_ARRAY_NONE, compat, false);
400  }
401  else
402  ECPGset_noind_null(sqlda->sqlvar[i].sqltype, sqlda->sqlvar[i].sqldata);
403 
404  offset = next_offset;
405  }
406 }
407 
408 struct sqlda_struct *
409 ecpg_build_native_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
410 {
411  struct sqlda_struct *sqlda;
412  long size;
413  int i;
414 
415  size = sqlda_native_total_size(res, row, compat);
416  sqlda = (struct sqlda_struct *) ecpg_alloc(size, line);
417  if (!sqlda)
418  return NULL;
419 
420  memset(sqlda, 0, size);
421 
422  sprintf(sqlda->sqldaid, "SQLDA ");
423  sqlda->sqld = sqlda->sqln = PQnfields(res);
424  ecpg_log("ecpg_build_native_sqlda on line %d sqld = %d\n", line, sqlda->sqld);
425  sqlda->sqldabc = sizeof(struct sqlda_struct) + (sqlda->sqld - 1) * sizeof(struct sqlvar_struct);
426 
427  for (i = 0; i < sqlda->sqld; i++)
428  {
429  char *fname;
430 
431  sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
432  fname = PQfname(res, i);
433  sqlda->sqlvar[i].sqlname.length = strlen(fname);
434  strcpy(sqlda->sqlvar[i].sqlname.data, fname);
435  }
436 
437  return sqlda;
438 }
439 
440 void
441 ecpg_set_native_sqlda(int lineno, struct sqlda_struct ** _sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
442 {
443  struct sqlda_struct *sqlda = (*_sqlda);
444  int i;
445  long offset,
446  next_offset;
447 
448  if (row < 0)
449  return;
450 
451  /* Offset for the first field value */
452  offset = sqlda_native_empty_size(res);
453 
454  /*
455  * Set sqlvar[i]->sqldata pointers and convert values to correct format
456  */
457  for (i = 0; i < sqlda->sqld; i++)
458  {
459  int isnull;
460  int datalen;
461  bool set_data = true;
462 
463  switch (sqlda->sqlvar[i].sqltype)
464  {
465  case ECPGt_short:
467  ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
468  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
469  sqlda->sqlvar[i].sqllen = sizeof(short);
470  break;
471  case ECPGt_int:
472  case ECPGt_unsigned_int:
473  ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
474  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
475  sqlda->sqlvar[i].sqllen = sizeof(int);
476  break;
477  case ECPGt_long:
478  case ECPGt_unsigned_long:
479  ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
480  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
481  sqlda->sqlvar[i].sqllen = sizeof(long);
482  break;
483  case ECPGt_long_long:
485  ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
486  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
487  sqlda->sqlvar[i].sqllen = sizeof(long long);
488  break;
489  case ECPGt_bool:
490  ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
491  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
492  sqlda->sqlvar[i].sqllen = sizeof(bool);
493  break;
494  case ECPGt_float:
495  ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
496  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
497  sqlda->sqlvar[i].sqllen = sizeof(float);
498  break;
499  case ECPGt_double:
500  ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
501  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
502  sqlda->sqlvar[i].sqllen = sizeof(double);
503  break;
504  case ECPGt_decimal:
505  ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
506  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
507  sqlda->sqlvar[i].sqllen = sizeof(decimal);
508  break;
509  case ECPGt_numeric:
510  {
511  numeric *num;
512  char *val;
513 
514  set_data = false;
515 
516  ecpg_sqlda_align_add_size(offset, sizeof(NumericDigit *), sizeof(numeric), &offset, &next_offset);
517  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
518  sqlda->sqlvar[i].sqllen = sizeof(numeric);
519 
520  if (PQgetisnull(res, row, i))
521  {
523  break;
524  }
525 
526  val = PQgetvalue(res, row, i);
527  num = PGTYPESnumeric_from_asc(val, NULL);
528  if (!num)
529  {
531  break;
532  }
533 
534  memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
535 
536  if (num->ndigits)
537  {
538  ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
539  memcpy((char *) sqlda + offset, num->buf, num->ndigits + 1);
540 
541  ((numeric *) sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *) sqlda + offset;
542  ((numeric *) sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *) sqlda + offset + (num->digits - num->buf);
543  }
544 
545  PGTYPESnumeric_free(num);
546 
547  break;
548  }
549  case ECPGt_date:
550  ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
551  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
552  sqlda->sqlvar[i].sqllen = sizeof(date);
553  break;
554  case ECPGt_timestamp:
555  ecpg_sqlda_align_add_size(offset, sizeof(int64), sizeof(timestamp), &offset, &next_offset);
556  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
557  sqlda->sqlvar[i].sqllen = sizeof(timestamp);
558  break;
559  case ECPGt_interval:
560  ecpg_sqlda_align_add_size(offset, sizeof(int64), sizeof(interval), &offset, &next_offset);
561  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
562  sqlda->sqlvar[i].sqllen = sizeof(interval);
563  break;
564  case ECPGt_char:
565  case ECPGt_unsigned_char:
566  case ECPGt_string:
567  default:
568  datalen = strlen(PQgetvalue(res, row, i)) + 1;
569  ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
570  sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
571  sqlda->sqlvar[i].sqllen = datalen;
572  break;
573  }
574 
575  isnull = PQgetisnull(res, row, i);
576  ecpg_log("ecpg_set_native_sqlda on line %d row %d col %d %s\n", lineno, row, i, isnull ? "IS NULL" : "IS NOT NULL");
577  sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
578  if (!isnull)
579  {
580  if (set_data)
581  ecpg_get_data(res, row, i, lineno,
582  sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
583  sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
584  ECPG_ARRAY_NONE, compat, false);
585  }
586 
587  offset = next_offset;
588  }
589 }
signed short int16
Definition: c.h:252
static long sqlda_common_total_size(const PGresult *res, int row, enum COMPAT_MODE compat, long offset)
Definition: sqlda.c:65
int PQnfields(const PGresult *res)
Definition: fe-exec.c:2681
static int32 next
Definition: blutils.c:210
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3067
static long sqlda_native_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
Definition: sqlda.c:183
int PQfsize(const PGresult *res, int field_num)
Definition: fe-exec.c:2922
char * PQfname(const PGresult *res, int field_num)
Definition: fe-exec.c:2759
short sqltypelen
Definition: sqlda-compat.h:21
int64 timestamp
short length
Definition: sqlda-native.h:20
struct sqlda_struct * ecpg_build_native_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
Definition: sqlda.c:409
struct sqlvar_struct sqlvar[1]
Definition: sqlda-native.h:40
NumericDigit * buf
void ecpg_set_native_sqlda(int lineno, struct sqlda_struct **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
Definition: sqlda.c:441
static int16 value_is_not_null
Definition: sqlda.c:249
long date
Definition: pgtypes_date.h:8
char * sqldata
Definition: sqlda-native.h:28
char bool
Definition: c.h:199
char * sqlname
Definition: sqlda-compat.h:14
void PGTYPESnumeric_free(numeric *)
Definition: numeric.c:470
short desc_occ
Definition: sqlda-compat.h:42
void ecpg_log(const char *format,...) pg_attribute_printf(1
char * sqldata
Definition: sqlda-compat.h:12
static void ecpg_sqlda_align_add_size(long offset, int alignment, int size, long *current, long *next)
Definition: sqlda.c:33
NumericDigit * digits
Oid PQftype(const PGresult *res, int field_num)
Definition: fe-exec.c:2911
char sqldaid[8]
Definition: sqlda-native.h:35
Datum numeric(PG_FUNCTION_ARGS)
Definition: numeric.c:933
int16 NumericDigit
Definition: numeric.c:99
char * ecpg_alloc(long, int)
Definition: memory.c:19
static int16 value_is_null
Definition: sqlda.c:248
enum COMPAT_MODE compat
Definition: ecpg.c:25
void ecpg_set_compat_sqlda(int lineno, struct sqlda_compat **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
Definition: sqlda.c:252
bool ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, enum ECPGttype type, enum ECPGttype ind_type, char *var, char *ind, long varcharsize, long offset, long ind_offset, enum ARRAY_TYPE isarray, enum COMPAT_MODE compat, bool force_indicator)
Definition: data.c:123
numeric * PGTYPESnumeric_from_asc(char *, char **)
Definition: numeric.c:406
#define NULL
Definition: c.h:226
struct sqlda_compat * ecpg_build_compat_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
Definition: sqlda.c:202
void ECPGset_noind_null(enum ECPGttype type, void *ptr)
Definition: misc.c:314
char data[NAMEDATALEN]
Definition: sqlda-native.h:21
short * sqlind
Definition: sqlda-native.h:29
int i
static long sqlda_compat_empty_size(const PGresult *res)
Definition: sqlda.c:45
short * sqlind
Definition: sqlda-compat.h:13
COMPAT_MODE
Definition: extern.h:16
char * sqlilongdata
Definition: sqlda-compat.h:32
static long sqlda_compat_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
Definition: sqlda.c:154
static long sqlda_native_empty_size(const PGresult *res)
Definition: sqlda.c:168
int sqlda_dynamic_type(Oid, enum COMPAT_MODE)
Definition: typename.c:106
int PQgetisnull(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3092
struct sqlname sqlname
Definition: sqlda-native.h:30
long val
Definition: informix.c:689
struct sqlvar_compat * sqlvar
Definition: sqlda-compat.h:40
ECPGttype
Definition: ecpgtype.h:41