Index: src/backend/tcop/postgres.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/tcop/postgres.c,v retrieving revision 1.394 diff -c -r1.394 postgres.c *** src/backend/tcop/postgres.c 9 Mar 2004 04:43:07 -0000 1.394 --- src/backend/tcop/postgres.c 11 Mar 2004 16:31:10 -0000 *************** *** 118,123 **** --- 118,128 ---- static bool ignore_till_sync = false; /* + * place to save the input pointer in case of a parse error + */ + static char *parse_input_string = NULL; + + /* * If an unnamed prepared statement exists, it's stored here. * We keep it separate from the hashtable kept by commands/prepare.c * in order to reduce overhead for short-lived queries. *************** *** 462,476 **** { List *raw_parsetree_list; - if (log_statement) - ereport(LOG, - (errmsg("statement: %s", query_string))); - if (log_parser_stats) ResetUsage(); raw_parsetree_list = raw_parser(query_string); if (log_parser_stats) ShowUsage("PARSER STATISTICS"); --- 467,487 ---- { List *raw_parsetree_list; if (log_parser_stats) ResetUsage(); + parse_input_string = query_string; + raw_parsetree_list = raw_parser(query_string); + /* if we get here there was no parse error */ + + parse_input_string = NULL; + + if (log_statement) + ereport(LOG, + (errmsg("statement: %s", query_string))); + if (log_parser_stats) ShowUsage("PARSER STATISTICS"); *************** *** 2747,2752 **** --- 2758,2775 ---- send_rfq = true; /* initially, or after error */ /* + * if parse_input_string is not null, we must have got here through a + * parser error, in which case we log it if appropriate. + */ + + if (log_statement && parse_input_string != NULL) + ereport(LOG, + (errmsg("parse error in statement: %s", parse_input_string))); + + parse_input_string = NULL; + + + /* * Non-error queries loop here. */