[Pgpool-general] Howto analyse sql statement.

Tatsuo Ishii ishii at sraoss.co.jp
Tue Feb 16 01:19:31 UTC 2010


Cced: to pgpool-general:

> Dear Tatsuo.
> 
> how to analyse sql statement like this
> 
> BEGIN ;
> DELETE FROM "test" ;
> DELETE FROM "log" ;
> COMMIT ;
> 
> I just need that last commmand is "COMMIT ;" , there is separator ";" at the end command.
> also there is BEGIN ;
> 
> using "node" ?.
> Would you like give me clue where I start reading code ?.

Please take a look at is_commit_query().

	stmt = (TransactionStmt *)node;

where stmt is one of:

typedef enum TransactionStmtKind
{
	TRANS_STMT_BEGIN,
	TRANS_STMT_START,			/* semantically identical to BEGIN */
	TRANS_STMT_COMMIT,
	TRANS_STMT_ROLLBACK,
	TRANS_STMT_SAVEPOINT,
	TRANS_STMT_RELEASE,
	TRANS_STMT_ROLLBACK_TO,
	TRANS_STMT_PREPARE,
	TRANS_STMT_COMMIT_PREPARED,
	TRANS_STMT_ROLLBACK_PREPARED
} TransactionStmtKind;

So for example you need to know the query is "BEGIN", you can check if
it is either TRANS_STMT_BEGIN or TRANS_STMT_START.
Hope this helps,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp


More information about the Pgpool-general mailing list