8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.358 2003/08/12 18:23:21 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.359 2003/08/12 18:52:38 tgl Exp $
12
12
*
13
13
* NOTES
14
14
* this is the "main" module of the postgres backend and
@@ -2023,7 +2023,7 @@ PostgresMain(int argc, char *argv[], const char *username)
2023
2023
GucSource gucsource ;
2024
2024
char * tmp ;
2025
2025
int firstchar ;
2026
- StringInfo input_message ;
2026
+ StringInfoData input_message ;
2027
2027
volatile bool send_rfq = true;
2028
2028
2029
2029
/*
@@ -2646,7 +2646,7 @@ PostgresMain(int argc, char *argv[], const char *username)
2646
2646
if (!IsUnderPostmaster )
2647
2647
{
2648
2648
puts ("\nPOSTGRES backend interactive interface " );
2649
- puts ("$Revision: 1.358 $ $Date: 2003/08/12 18:23:21 $\n" );
2649
+ puts ("$Revision: 1.359 $ $Date: 2003/08/12 18:52:38 $\n" );
2650
2650
}
2651
2651
2652
2652
/*
@@ -2765,35 +2765,36 @@ PostgresMain(int argc, char *argv[], const char *username)
2765
2765
MemoryContextSwitchTo (MessageContext );
2766
2766
MemoryContextResetAndDeleteChildren (MessageContext );
2767
2767
2768
- input_message = makeStringInfo ( );
2768
+ initStringInfo ( & input_message );
2769
2769
2770
2770
/*
2771
- * (1) tell the frontend we're ready for a new query.
2771
+ * (1) If we've reached idle state, tell the frontend we're ready
2772
+ * for a new query.
2772
2773
*
2773
2774
* Note: this includes fflush()'ing the last of the prior output.
2775
+ *
2776
+ * This is also a good time to send collected statistics to the
2777
+ * collector, and to update the PS stats display. We avoid doing
2778
+ * those every time through the message loop because it'd slow down
2779
+ * processing of batched messages.
2774
2780
*/
2775
2781
if (send_rfq )
2776
2782
{
2777
- ReadyForQuery (whereToSendOutput );
2778
- send_rfq = false;
2779
- }
2783
+ pgstat_report_tabstat ();
2780
2784
2781
- /* ----------
2782
- * Tell the statistics collector what we've collected
2783
- * so far.
2784
- * ----------
2785
- */
2786
- pgstat_report_tabstat ();
2785
+ if (IsTransactionBlock ())
2786
+ {
2787
+ set_ps_display ("idle in transaction" );
2788
+ pgstat_report_activity ("<IDLE> in transaction" );
2789
+ }
2790
+ else
2791
+ {
2792
+ set_ps_display ("idle" );
2793
+ pgstat_report_activity ("<IDLE>" );
2794
+ }
2787
2795
2788
- if (IsTransactionBlock ())
2789
- {
2790
- set_ps_display ("idle in transaction" );
2791
- pgstat_report_activity ("<IDLE> in transaction" );
2792
- }
2793
- else
2794
- {
2795
- set_ps_display ("idle" );
2796
- pgstat_report_activity ("<IDLE>" );
2796
+ ReadyForQuery (whereToSendOutput );
2797
+ send_rfq = false;
2797
2798
}
2798
2799
2799
2800
/*
@@ -2815,7 +2816,7 @@ PostgresMain(int argc, char *argv[], const char *username)
2815
2816
/*
2816
2817
* (3) read a command (loop blocks here)
2817
2818
*/
2818
- firstchar = ReadCommand (input_message );
2819
+ firstchar = ReadCommand (& input_message );
2819
2820
2820
2821
/*
2821
2822
* (4) disable async signal conditions again.
@@ -2848,8 +2849,8 @@ PostgresMain(int argc, char *argv[], const char *username)
2848
2849
{
2849
2850
const char * query_string ;
2850
2851
2851
- query_string = pq_getmsgstring (input_message );
2852
- pq_getmsgend (input_message );
2852
+ query_string = pq_getmsgstring (& input_message );
2853
+ pq_getmsgend (& input_message );
2853
2854
2854
2855
exec_simple_query (query_string );
2855
2856
@@ -2864,18 +2865,18 @@ PostgresMain(int argc, char *argv[], const char *username)
2864
2865
int numParams ;
2865
2866
Oid * paramTypes = NULL ;
2866
2867
2867
- stmt_name = pq_getmsgstring (input_message );
2868
- query_string = pq_getmsgstring (input_message );
2869
- numParams = pq_getmsgint (input_message , 2 );
2868
+ stmt_name = pq_getmsgstring (& input_message );
2869
+ query_string = pq_getmsgstring (& input_message );
2870
+ numParams = pq_getmsgint (& input_message , 2 );
2870
2871
if (numParams > 0 )
2871
2872
{
2872
2873
int i ;
2873
2874
2874
2875
paramTypes = (Oid * ) palloc (numParams * sizeof (Oid ));
2875
2876
for (i = 0 ; i < numParams ; i ++ )
2876
- paramTypes [i ] = pq_getmsgint (input_message , 4 );
2877
+ paramTypes [i ] = pq_getmsgint (& input_message , 4 );
2877
2878
}
2878
- pq_getmsgend (input_message );
2879
+ pq_getmsgend (& input_message );
2879
2880
2880
2881
exec_parse_message (query_string , stmt_name ,
2881
2882
paramTypes , numParams );
@@ -2888,17 +2889,17 @@ PostgresMain(int argc, char *argv[], const char *username)
2888
2889
* this message is complex enough that it seems best to
2889
2890
* put the field extraction out-of-line
2890
2891
*/
2891
- exec_bind_message (input_message );
2892
+ exec_bind_message (& input_message );
2892
2893
break ;
2893
2894
2894
2895
case 'E' : /* execute */
2895
2896
{
2896
2897
const char * portal_name ;
2897
2898
int max_rows ;
2898
2899
2899
- portal_name = pq_getmsgstring (input_message );
2900
- max_rows = pq_getmsgint (input_message , 4 );
2901
- pq_getmsgend (input_message );
2900
+ portal_name = pq_getmsgstring (& input_message );
2901
+ max_rows = pq_getmsgint (& input_message , 4 );
2902
+ pq_getmsgend (& input_message );
2902
2903
2903
2904
exec_execute_message (portal_name , max_rows );
2904
2905
}
@@ -2914,7 +2915,7 @@ PostgresMain(int argc, char *argv[], const char *username)
2914
2915
/* switch back to message context */
2915
2916
MemoryContextSwitchTo (MessageContext );
2916
2917
2917
- if (HandleFunctionRequest (input_message ) == EOF )
2918
+ if (HandleFunctionRequest (& input_message ) == EOF )
2918
2919
{
2919
2920
/* lost frontend connection during F message input */
2920
2921
@@ -2939,9 +2940,9 @@ PostgresMain(int argc, char *argv[], const char *username)
2939
2940
int close_type ;
2940
2941
const char * close_target ;
2941
2942
2942
- close_type = pq_getmsgbyte (input_message );
2943
- close_target = pq_getmsgstring (input_message );
2944
- pq_getmsgend (input_message );
2943
+ close_type = pq_getmsgbyte (& input_message );
2944
+ close_target = pq_getmsgstring (& input_message );
2945
+ pq_getmsgend (& input_message );
2945
2946
2946
2947
switch (close_type )
2947
2948
{
@@ -2987,9 +2988,9 @@ PostgresMain(int argc, char *argv[], const char *username)
2987
2988
int describe_type ;
2988
2989
const char * describe_target ;
2989
2990
2990
- describe_type = pq_getmsgbyte (input_message );
2991
- describe_target = pq_getmsgstring (input_message );
2992
- pq_getmsgend (input_message );
2991
+ describe_type = pq_getmsgbyte (& input_message );
2992
+ describe_target = pq_getmsgstring (& input_message );
2993
+ pq_getmsgend (& input_message );
2993
2994
2994
2995
switch (describe_type )
2995
2996
{
@@ -3010,13 +3011,13 @@ PostgresMain(int argc, char *argv[], const char *username)
3010
3011
break ;
3011
3012
3012
3013
case 'H' : /* flush */
3013
- pq_getmsgend (input_message );
3014
+ pq_getmsgend (& input_message );
3014
3015
if (whereToSendOutput == Remote )
3015
3016
pq_flush ();
3016
3017
break ;
3017
3018
3018
3019
case 'S' : /* sync */
3019
- pq_getmsgend (input_message );
3020
+ pq_getmsgend (& input_message );
3020
3021
finish_xact_command ();
3021
3022
send_rfq = true;
3022
3023
break ;
0 commit comments