@ -694,7 +694,8 @@ ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es,
/*
/*
* This set returning function reads all the prepared statements and
* This set returning function reads all the prepared statements and
* returns a set of ( name , statement , prepare_time , param_types , from_sql ) .
* returns a set of ( name , statement , prepare_time , param_types , from_sql ,
* generic_plans , custom_plans ) .
*/
*/
Datum
Datum
pg_prepared_statement ( PG_FUNCTION_ARGS )
pg_prepared_statement ( PG_FUNCTION_ARGS )
@ -723,7 +724,7 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
* build tupdesc for result tuples . This must match the definition of the
* build tupdesc for result tuples . This must match the definition of the
* pg_prepared_statements view in system_views . sql
* pg_prepared_statements view in system_views . sql
*/
*/
tupdesc = CreateTemplateTupleDesc ( 5 ) ;
tupdesc = CreateTemplateTupleDesc ( 7 ) ;
TupleDescInitEntry ( tupdesc , ( AttrNumber ) 1 , " name " ,
TupleDescInitEntry ( tupdesc , ( AttrNumber ) 1 , " name " ,
TEXTOID , - 1 , 0 ) ;
TEXTOID , - 1 , 0 ) ;
TupleDescInitEntry ( tupdesc , ( AttrNumber ) 2 , " statement " ,
TupleDescInitEntry ( tupdesc , ( AttrNumber ) 2 , " statement " ,
@ -734,6 +735,10 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
REGTYPEARRAYOID , - 1 , 0 ) ;
REGTYPEARRAYOID , - 1 , 0 ) ;
TupleDescInitEntry ( tupdesc , ( AttrNumber ) 5 , " from_sql " ,
TupleDescInitEntry ( tupdesc , ( AttrNumber ) 5 , " from_sql " ,
BOOLOID , - 1 , 0 ) ;
BOOLOID , - 1 , 0 ) ;
TupleDescInitEntry ( tupdesc , ( AttrNumber ) 6 , " generic_plans " ,
INT8OID , - 1 , 0 ) ;
TupleDescInitEntry ( tupdesc , ( AttrNumber ) 7 , " custom_plans " ,
INT8OID , - 1 , 0 ) ;
/*
/*
* We put all the tuples into a tuplestore in one scan of the hashtable .
* We put all the tuples into a tuplestore in one scan of the hashtable .
@ -755,8 +760,8 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
hash_seq_init ( & hash_seq , prepared_queries ) ;
hash_seq_init ( & hash_seq , prepared_queries ) ;
while ( ( prep_stmt = hash_seq_search ( & hash_seq ) ) ! = NULL )
while ( ( prep_stmt = hash_seq_search ( & hash_seq ) ) ! = NULL )
{
{
Datum values [ 5 ] ;
Datum values [ 7 ] ;
bool nulls [ 5 ] ;
bool nulls [ 7 ] ;
MemSet ( nulls , 0 , sizeof ( nulls ) ) ;
MemSet ( nulls , 0 , sizeof ( nulls ) ) ;
@ -766,6 +771,8 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
values [ 3 ] = build_regtype_array ( prep_stmt - > plansource - > param_types ,
values [ 3 ] = build_regtype_array ( prep_stmt - > plansource - > param_types ,
prep_stmt - > plansource - > num_params ) ;
prep_stmt - > plansource - > num_params ) ;
values [ 4 ] = BoolGetDatum ( prep_stmt - > from_sql ) ;
values [ 4 ] = BoolGetDatum ( prep_stmt - > from_sql ) ;
values [ 5 ] = Int64GetDatumFast ( prep_stmt - > plansource - > num_generic_plans ) ;
values [ 6 ] = Int64GetDatumFast ( prep_stmt - > plansource - > num_custom_plans ) ;
tuplestore_putvalues ( tupstore , tupdesc , values , nulls ) ;
tuplestore_putvalues ( tupstore , tupdesc , values , nulls ) ;
}
}