Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb6e5823

Browse files
committed
Marginal hacks to move some processing out of the per-client-message
processing loop; avoids extra overhead when using parse/bind/executemessages instead of single Query message.
1 parentfcb90fd commitb6e5823

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

‎src/backend/tcop/postgres.c

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* 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 $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -2023,7 +2023,7 @@ PostgresMain(int argc, char *argv[], const char *username)
20232023
GucSourcegucsource;
20242024
char*tmp;
20252025
intfirstchar;
2026-
StringInfoinput_message;
2026+
StringInfoDatainput_message;
20272027
volatileboolsend_rfq= true;
20282028

20292029
/*
@@ -2646,7 +2646,7 @@ PostgresMain(int argc, char *argv[], const char *username)
26462646
if (!IsUnderPostmaster)
26472647
{
26482648
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");
26502650
}
26512651

26522652
/*
@@ -2765,35 +2765,36 @@ PostgresMain(int argc, char *argv[], const char *username)
27652765
MemoryContextSwitchTo(MessageContext);
27662766
MemoryContextResetAndDeleteChildren(MessageContext);
27672767

2768-
input_message=makeStringInfo();
2768+
initStringInfo(&input_message);
27692769

27702770
/*
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.
27722773
*
27732774
* 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.
27742780
*/
27752781
if (send_rfq)
27762782
{
2777-
ReadyForQuery(whereToSendOutput);
2778-
send_rfq= false;
2779-
}
2783+
pgstat_report_tabstat();
27802784

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+
}
27872795

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;
27972798
}
27982799

27992800
/*
@@ -2815,7 +2816,7 @@ PostgresMain(int argc, char *argv[], const char *username)
28152816
/*
28162817
* (3) read a command (loop blocks here)
28172818
*/
2818-
firstchar=ReadCommand(input_message);
2819+
firstchar=ReadCommand(&input_message);
28192820

28202821
/*
28212822
* (4) disable async signal conditions again.
@@ -2848,8 +2849,8 @@ PostgresMain(int argc, char *argv[], const char *username)
28482849
{
28492850
constchar*query_string;
28502851

2851-
query_string=pq_getmsgstring(input_message);
2852-
pq_getmsgend(input_message);
2852+
query_string=pq_getmsgstring(&input_message);
2853+
pq_getmsgend(&input_message);
28532854

28542855
exec_simple_query(query_string);
28552856

@@ -2864,18 +2865,18 @@ PostgresMain(int argc, char *argv[], const char *username)
28642865
intnumParams;
28652866
Oid*paramTypes=NULL;
28662867

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);
28702871
if (numParams>0)
28712872
{
28722873
inti;
28732874

28742875
paramTypes= (Oid*)palloc(numParams*sizeof(Oid));
28752876
for (i=0;i<numParams;i++)
2876-
paramTypes[i]=pq_getmsgint(input_message,4);
2877+
paramTypes[i]=pq_getmsgint(&input_message,4);
28772878
}
2878-
pq_getmsgend(input_message);
2879+
pq_getmsgend(&input_message);
28792880

28802881
exec_parse_message(query_string,stmt_name,
28812882
paramTypes,numParams);
@@ -2888,17 +2889,17 @@ PostgresMain(int argc, char *argv[], const char *username)
28882889
* this message is complex enough that it seems best to
28892890
* put the field extraction out-of-line
28902891
*/
2891-
exec_bind_message(input_message);
2892+
exec_bind_message(&input_message);
28922893
break;
28932894

28942895
case'E':/* execute */
28952896
{
28962897
constchar*portal_name;
28972898
intmax_rows;
28982899

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);
29022903

29032904
exec_execute_message(portal_name,max_rows);
29042905
}
@@ -2914,7 +2915,7 @@ PostgresMain(int argc, char *argv[], const char *username)
29142915
/* switch back to message context */
29152916
MemoryContextSwitchTo(MessageContext);
29162917

2917-
if (HandleFunctionRequest(input_message)==EOF)
2918+
if (HandleFunctionRequest(&input_message)==EOF)
29182919
{
29192920
/* lost frontend connection during F message input */
29202921

@@ -2939,9 +2940,9 @@ PostgresMain(int argc, char *argv[], const char *username)
29392940
intclose_type;
29402941
constchar*close_target;
29412942

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);
29452946

29462947
switch (close_type)
29472948
{
@@ -2987,9 +2988,9 @@ PostgresMain(int argc, char *argv[], const char *username)
29872988
intdescribe_type;
29882989
constchar*describe_target;
29892990

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);
29932994

29942995
switch (describe_type)
29952996
{
@@ -3010,13 +3011,13 @@ PostgresMain(int argc, char *argv[], const char *username)
30103011
break;
30113012

30123013
case'H':/* flush */
3013-
pq_getmsgend(input_message);
3014+
pq_getmsgend(&input_message);
30143015
if (whereToSendOutput==Remote)
30153016
pq_flush();
30163017
break;
30173018

30183019
case'S':/* sync */
3019-
pq_getmsgend(input_message);
3020+
pq_getmsgend(&input_message);
30203021
finish_xact_command();
30213022
send_rfq= true;
30223023
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp