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