@@ -109,7 +109,7 @@ register_error(long code, char *fmt,...)
109
109
110
110
sqlca .sqlcode = code ;
111
111
va_start (args , fmt );
112
- vsprintf (sqlca .sqlerrm .sqlerrmc , fmt , args );
112
+ vsnprintf (sqlca .sqlerrm .sqlerrmc , SQLERRMC_LEN , fmt , args );
113
113
va_end (args );
114
114
sqlca .sqlerrm .sqlerrml = strlen (sqlca .sqlerrm .sqlerrmc );
115
115
@@ -649,7 +649,8 @@ ECPGexecute(struct statement * stmt)
649
649
int nfields ,
650
650
ntuples ,
651
651
act_tuple ,
652
- act_field ;
652
+ act_field ,
653
+ isarray ;
653
654
654
655
case PGRES_TUPLES_OK :
655
656
nfields = PQnfields (results );
@@ -678,6 +679,16 @@ ECPGexecute(struct statement * stmt)
678
679
return (false);
679
680
}
680
681
682
+ array_query = (char * )ecpg_alloc (strlen ("select typelem from pg_type where oid=" ) + 11 , stmt -> lineno );
683
+ sprintf (array_query , "select typelem from pg_type where oid=%d" , PQftype (results , act_field ));
684
+ query = PQexec (stmt -> connection -> connection , array_query );
685
+ isarray = 0 ;
686
+ if (PQresultStatus (query ) == PGRES_TUPLES_OK ) {
687
+ isarray = atol ((char * )PQgetvalue (query , 0 , 0 ));
688
+ ECPGlog ("ECPGexecute line %d: TYPE database: %d C: %d array: %s\n" , stmt -> lineno , PQftype (results , act_field ), var -> type , isarray ? "yes" : "no" );
689
+ }
690
+ PQclear (query );
691
+
681
692
/*
682
693
* if we don't have enough space, we cannot read all
683
694
* tuples
@@ -726,14 +737,6 @@ ECPGexecute(struct statement * stmt)
726
737
add_mem (var -> value , stmt -> lineno );
727
738
}
728
739
729
- #if 0
730
- array_query = (char * )ecpg_alloc (strlen ("select typelem from pg_type where oid=" ) + 11 , stmt -> lineno );
731
- sprintf (array_query , "select typelem from pg_type where oid=%d" , PQftype (results , act_field ));
732
- query = PQexec (stmt -> connection -> connection , array_query );
733
- if (PQresultStatus (query ) == PGRES_TUPLES_OK )
734
- ECPGlog ("ECPGexecute line %d: TYPE database: %d C: %d array OID: %s\n" , stmt -> lineno , PQftype (results , act_field ), var -> type , (char * )PQgetvalue (query , 0 , 0 ));
735
- PQclear (query );
736
- #endif
737
740
for (act_tuple = 0 ; act_tuple < ntuples && status ; act_tuple ++ )
738
741
{
739
742
pval = (char * )PQgetvalue (results , act_tuple , act_field );
0 commit comments