@@ -109,7 +109,7 @@ register_error(long code, char *fmt,...)
109109
110110sqlca .sqlcode = code ;
111111va_start (args ,fmt );
112- vsprintf (sqlca .sqlerrm .sqlerrmc ,fmt ,args );
112+ vsnprintf (sqlca .sqlerrm .sqlerrmc , SQLERRMC_LEN ,fmt ,args );
113113va_end (args );
114114sqlca .sqlerrm .sqlerrml = strlen (sqlca .sqlerrm .sqlerrmc );
115115
@@ -649,7 +649,8 @@ ECPGexecute(struct statement * stmt)
649649int nfields ,
650650ntuples ,
651651act_tuple ,
652- act_field ;
652+ act_field ,
653+ isarray ;
653654
654655case PGRES_TUPLES_OK :
655656nfields = PQnfields (results );
@@ -678,6 +679,16 @@ ECPGexecute(struct statement * stmt)
678679return (false);
679680}
680681
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+
681692/*
682693 * if we don't have enough space, we cannot read all
683694 * tuples
@@ -726,14 +737,6 @@ ECPGexecute(struct statement * stmt)
726737add_mem (var -> value ,stmt -> lineno );
727738}
728739
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
737740for (act_tuple = 0 ;act_tuple < ntuples && status ;act_tuple ++ )
738741{
739742pval = (char * )PQgetvalue (results ,act_tuple ,act_field );