[pgpool-hackers: 4291] Re: minimal parser and multi-statement query

Tatsuo Ishii ishii at sraoss.co.jp
Thu Feb 23 19:47:13 JST 2023


> Hi Usama,
> 
> While taking care of this:
> https://www.pgpool.net/mantisbt/view.php?id=780
> 
> I realized that pgpool fails to judge whether a query is
> multi-statement or not, if clustering mode is streaming/logical
> replication and the multi-statement query includes INSERT or UPDATE
> statements. This is because our minimal-parser returns single parse
> tree for multi-statement queries including INSERT/UPDATE statements.
> 
> gram_minimal.y:
> 
> InsertStmtShort:
> 			opt_with_clause INSERT INTO insert_target
> 			{
> 				InsertStmt *insert = makeNode(InsertStmt);
> 				insert->relation = $4;
> 				$$ = (Node *) insert;
> 				/*
> 				 * Assign the node directly to the parsetree and exit the scanner
> 				 * we don't want to keep parsing for information we don't need
> 				 */
> 				pg_yyget_extra(yyscanner)->parsetree = list_make1(makeRawStmt($$, 0));
> 				YYACCEPT;
> 			}
> 		;
> 
> As a result, the test below in SimpleQuery() fails to set
> is_multi_statement to true even if the query is a multi-statement
> query.
> 
> 		if (parse_tree_list && list_length(parse_tree_list) > 1)
> 		{
> 			query_context->is_multi_statement = true;
> 		}
> 		else
> 		{
> 			query_context->is_multi_statement = false;
> 		}
> 
> We could avoid this without using the minimal parser but it will take
> more time to parse lengthy INSERT/UPDATE queries.
> 
> Is there any workaround for this?

I temporarily turns off the optimization and adds regression test for
that in master branch.
    
Hopefully before releasing 4.5 we find a way to determine whether the
query is a multi-statement query or not in less expensive way. And if
it is not a multi-statement query, we can turn on the optimization.

Best reagards,
--
Tatsuo Ishii
SRA OSS LLC
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp


More information about the pgpool-hackers mailing list