*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.358 2003/08/12 18:23:21 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.359 2003/08/12 18:52:38 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
GucSource gucsource;
char *tmp;
int firstchar;
- StringInfo input_message;
+ StringInfoData input_message;
volatile bool send_rfq = true;
/*
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.358 $ $Date: 2003/08/12 18:23:21 $\n");
+ puts("$Revision: 1.359 $ $Date: 2003/08/12 18:52:38 $\n");
}
/*
MemoryContextSwitchTo(MessageContext);
MemoryContextResetAndDeleteChildren(MessageContext);
- input_message = makeStringInfo();
+ initStringInfo(&input_message);
/*
- * (1) tell the frontend we're ready for a new query.
+ * (1) If we've reached idle state, tell the frontend we're ready
+ * for a new query.
*
* Note: this includes fflush()'ing the last of the prior output.
+ *
+ * This is also a good time to send collected statistics to the
+ * collector, and to update the PS stats display. We avoid doing
+ * those every time through the message loop because it'd slow down
+ * processing of batched messages.
*/
if (send_rfq)
{
- ReadyForQuery(whereToSendOutput);
- send_rfq = false;
- }
+ pgstat_report_tabstat();
- /* ----------
- * Tell the statistics collector what we've collected
- * so far.
- * ----------
- */
- pgstat_report_tabstat();
+ if (IsTransactionBlock())
+ {
+ set_ps_display("idle in transaction");
+ pgstat_report_activity("<IDLE> in transaction");
+ }
+ else
+ {
+ set_ps_display("idle");
+ pgstat_report_activity("<IDLE>");
+ }
- if (IsTransactionBlock())
- {
- set_ps_display("idle in transaction");
- pgstat_report_activity("<IDLE> in transaction");
- }
- else
- {
- set_ps_display("idle");
- pgstat_report_activity("<IDLE>");
+ ReadyForQuery(whereToSendOutput);
+ send_rfq = false;
}
/*
/*
* (3) read a command (loop blocks here)
*/
- firstchar = ReadCommand(input_message);
+ firstchar = ReadCommand(&input_message);
/*
* (4) disable async signal conditions again.
{
const char *query_string;
- query_string = pq_getmsgstring(input_message);
- pq_getmsgend(input_message);
+ query_string = pq_getmsgstring(&input_message);
+ pq_getmsgend(&input_message);
exec_simple_query(query_string);
int numParams;
Oid *paramTypes = NULL;
- stmt_name = pq_getmsgstring(input_message);
- query_string = pq_getmsgstring(input_message);
- numParams = pq_getmsgint(input_message, 2);
+ stmt_name = pq_getmsgstring(&input_message);
+ query_string = pq_getmsgstring(&input_message);
+ numParams = pq_getmsgint(&input_message, 2);
if (numParams > 0)
{
int i;
paramTypes = (Oid *) palloc(numParams * sizeof(Oid));
for (i = 0; i < numParams; i++)
- paramTypes[i] = pq_getmsgint(input_message, 4);
+ paramTypes[i] = pq_getmsgint(&input_message, 4);
}
- pq_getmsgend(input_message);
+ pq_getmsgend(&input_message);
exec_parse_message(query_string, stmt_name,
paramTypes, numParams);
* this message is complex enough that it seems best to
* put the field extraction out-of-line
*/
- exec_bind_message(input_message);
+ exec_bind_message(&input_message);
break;
case 'E': /* execute */
const char *portal_name;
int max_rows;
- portal_name = pq_getmsgstring(input_message);
- max_rows = pq_getmsgint(input_message, 4);
- pq_getmsgend(input_message);
+ portal_name = pq_getmsgstring(&input_message);
+ max_rows = pq_getmsgint(&input_message, 4);
+ pq_getmsgend(&input_message);
exec_execute_message(portal_name, max_rows);
}
/* switch back to message context */
MemoryContextSwitchTo(MessageContext);
- if (HandleFunctionRequest(input_message) == EOF)
+ if (HandleFunctionRequest(&input_message) == EOF)
{
/* lost frontend connection during F message input */
int close_type;
const char *close_target;
- close_type = pq_getmsgbyte(input_message);
- close_target = pq_getmsgstring(input_message);
- pq_getmsgend(input_message);
+ close_type = pq_getmsgbyte(&input_message);
+ close_target = pq_getmsgstring(&input_message);
+ pq_getmsgend(&input_message);
switch (close_type)
{
int describe_type;
const char *describe_target;
- describe_type = pq_getmsgbyte(input_message);
- describe_target = pq_getmsgstring(input_message);
- pq_getmsgend(input_message);
+ describe_type = pq_getmsgbyte(&input_message);
+ describe_target = pq_getmsgstring(&input_message);
+ pq_getmsgend(&input_message);
switch (describe_type)
{
break;
case 'H': /* flush */
- pq_getmsgend(input_message);
+ pq_getmsgend(&input_message);
if (whereToSendOutput == Remote)
pq_flush();
break;
case 'S': /* sync */
- pq_getmsgend(input_message);
+ pq_getmsgend(&input_message);
finish_xact_command();
send_rfq = true;
break;