@@ -288,48 +288,52 @@ ECPGis_type_an_array(int type,const struct statement * stmt,const struct variabl
288
288
289
289
if ((stmt -> connection -> cache_head )== NULL )
290
290
{
291
+ /* Text like types are not an array for ecpg, but postgres counts them as
292
+ an array. This define reminds you to not 'correct' these values. */
293
+ #define not_an_array_in_ecpg false
294
+
291
295
/* populate cache with well known types to speed things up */
292
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), BOOLOID , false, stmt -> lineno );
293
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), BYTEAOID , true , stmt -> lineno );
294
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), CHAROID , false, stmt -> lineno );
295
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), NAMEOID , true , stmt -> lineno );
296
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), INT8OID , false, stmt -> lineno );
297
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), INT2OID , false, stmt -> lineno );
298
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), INT2VECTOROID , true, stmt -> lineno );
299
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), INT4OID , false, stmt -> lineno );
300
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), REGPROCOID , false, stmt -> lineno );
301
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), TEXTOID , true , stmt -> lineno );
302
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), OIDOID , false, stmt -> lineno );
303
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), TIDOID , false, stmt -> lineno );
304
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), XIDOID , false, stmt -> lineno );
305
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), CIDOID , false, stmt -> lineno );
306
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), OIDVECTOROID , true, stmt -> lineno );
307
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), POINTOID , true, stmt -> lineno );
308
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), LSEGOID , true, stmt -> lineno );
309
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), PATHOID , true , stmt -> lineno );
310
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), BOXOID , true, stmt -> lineno );
311
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), POLYGONOID , false, stmt -> lineno );
312
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), LINEOID , true, stmt -> lineno );
313
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), FLOAT4OID , false, stmt -> lineno );
314
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), FLOAT8OID , false, stmt -> lineno );
315
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), ABSTIMEOID , false, stmt -> lineno );
316
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), RELTIMEOID , false, stmt -> lineno );
317
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), TINTERVALOID , false, stmt -> lineno );
318
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), UNKNOWNOID , true , stmt -> lineno );
319
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), CIRCLEOID , false, stmt -> lineno );
320
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), CASHOID , false, stmt -> lineno );
321
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), INETOID , false, stmt -> lineno );
322
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), CIDROID , false, stmt -> lineno );
323
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), BPCHAROID , false, stmt -> lineno );
324
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), VARCHAROID , false, stmt -> lineno );
325
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), DATEOID , false, stmt -> lineno );
326
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), TIMEOID , false, stmt -> lineno );
327
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), TIMESTAMPOID , false, stmt -> lineno );
328
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), INTERVALOID , false, stmt -> lineno );
329
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), TIMETZOID , false, stmt -> lineno );
330
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), ZPBITOID , false, stmt -> lineno );
331
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), VARBITOID , false, stmt -> lineno );
332
- ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), NUMERICOID , false, stmt -> lineno );
296
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), BOOLOID , false, stmt -> lineno );
297
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), BYTEAOID , not_an_array_in_ecpg , stmt -> lineno );
298
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), CHAROID , false, stmt -> lineno );
299
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), NAMEOID , not_an_array_in_ecpg , stmt -> lineno );
300
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), INT8OID , false, stmt -> lineno );
301
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), INT2OID , false, stmt -> lineno );
302
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), INT2VECTOROID , true, stmt -> lineno );
303
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), INT4OID , false, stmt -> lineno );
304
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), REGPROCOID , false, stmt -> lineno );
305
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), TEXTOID , not_an_array_in_ecpg , stmt -> lineno );
306
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), OIDOID , false, stmt -> lineno );
307
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), TIDOID , false, stmt -> lineno );
308
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), XIDOID , false, stmt -> lineno );
309
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), CIDOID , false, stmt -> lineno );
310
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), OIDVECTOROID , true, stmt -> lineno );
311
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), POINTOID , true, stmt -> lineno );
312
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), LSEGOID , true, stmt -> lineno );
313
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), PATHOID , not_an_array_in_ecpg , stmt -> lineno );
314
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), BOXOID , true, stmt -> lineno );
315
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), POLYGONOID , false, stmt -> lineno );
316
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), LINEOID , true, stmt -> lineno );
317
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), FLOAT4OID , false, stmt -> lineno );
318
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), FLOAT8OID , false, stmt -> lineno );
319
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), ABSTIMEOID , false, stmt -> lineno );
320
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), RELTIMEOID , false, stmt -> lineno );
321
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), TINTERVALOID , false, stmt -> lineno );
322
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), UNKNOWNOID , not_an_array_in_ecpg , stmt -> lineno );
323
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), CIRCLEOID , false, stmt -> lineno );
324
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), CASHOID , false, stmt -> lineno );
325
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), INETOID , false, stmt -> lineno );
326
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), CIDROID , false, stmt -> lineno );
327
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), BPCHAROID , false, stmt -> lineno );
328
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), VARCHAROID , false, stmt -> lineno );
329
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), DATEOID , false, stmt -> lineno );
330
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), TIMEOID , false, stmt -> lineno );
331
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), TIMESTAMPOID , false, stmt -> lineno );
332
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), INTERVALOID , false, stmt -> lineno );
333
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), TIMETZOID , false, stmt -> lineno );
334
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), ZPBITOID , false, stmt -> lineno );
335
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), VARBITOID , false, stmt -> lineno );
336
+ ECPGtypeinfocache_push (& (stmt -> connection -> cache_head ), NUMERICOID , false, stmt -> lineno );
333
337
}
334
338
335
339
for (cache_entry = (stmt -> connection -> cache_head );cache_entry != NULL ;cache_entry = cache_entry -> next )
@@ -630,13 +634,27 @@ ECPGexecute(struct statement * stmt)
630
634
{
631
635
strncpy (mallocedval , "'{" , sizeof ("'{" ));
632
636
633
- for (element = 0 ; element < var -> arrsize ; element ++ )
634
- sprintf (mallocedval + strlen (mallocedval ), "%c," , (((char * ) var -> value )[element ]) ? 't' : 'f' );
637
+ if (var -> offset == sizeof (char ))
638
+ for (element = 0 ; element < var -> arrsize ; element ++ )
639
+ sprintf (mallocedval + strlen (mallocedval ), "%c," , (((char * ) var -> value )[element ]) ? 't' : 'f' );
640
+ // this is necessary since sizeof(C++'s bool)==sizeof(int)
641
+ else if (var -> offset == sizeof (int ))
642
+ for (element = 0 ; element < var -> arrsize ; element ++ )
643
+ sprintf (mallocedval + strlen (mallocedval ), "%c," , (((int * ) var -> value )[element ]) ? 't' : 'f' );
644
+ else
645
+ ECPGraise (stmt -> lineno , ECPG_CONVERT_BOOL , "different size" );
635
646
636
647
strncpy (mallocedval + strlen (mallocedval ) - 1 , "}'" , sizeof ("}'" ));
637
648
}
638
649
else
639
- sprintf (mallocedval , "'%c'" , (* ((char * ) var -> value )) ? 't' : 'f' );
650
+ {
651
+ if (var -> offset == sizeof (char ))
652
+ sprintf (mallocedval , "'%c'" , (* ((char * ) var -> value )) ? 't' : 'f' );
653
+ else if (var -> offset == sizeof (int ))
654
+ sprintf (mallocedval , "'%c'" , (* ((int * ) var -> value )) ? 't' : 'f' );
655
+ else
656
+ ECPGraise (stmt -> lineno , ECPG_CONVERT_BOOL , "different size" );
657
+ }
640
658
641
659
tobeinserted = mallocedval ;
642
660
break ;
@@ -1006,7 +1024,7 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
1006
1024
*
1007
1025
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
1008
1026
*
1009
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.16 2001/01/02 22:03:02 momjian Exp $
1027
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.17 2001/01/31 16:12:34 meskes Exp $
1010
1028
*/
1011
1029
1012
1030
PGconn * ECPG_internal_get_connection (char * name );
0 commit comments