[Pgpool-general] Howto analyse sql statement.

Tatsuo Ishii ishii at sraoss.co.jp
Wed Feb 17 00:20:44 UTC 2010


If you just need to parse multi statement SQL, it is already
possible. For example, see around line 197 of pool_proto_modules.c:

	parse_tree_list = raw_parser(string);

Here parse_tree_list is a list of statements. If string is a multi
statement SQL, parse_tree_list will be consisted of two or more nodes.

However rest of codes does not support multi statment SQL. So there's
a long way before we supoort it. I would like to make some progress
this year.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp

> On this case , I get only "BEGIN" statement. I can't get "COMMIT".
> Something what I need is first node "BEGIN", second node "DELETE FROM test". . . . and last node is "COMMIT".
> 
> Do you have plan to analyse multi statement ?.
> Any suggestion ?.
> 
> > > 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