Hi Matsumura-san, > I must use a midrule action like the following that works as > expected. > I wonder how to write the replacement to ecpg.addons. > I think it's impossible, right? Please give me some advice.
You are right, for this change you have to replace the whole rule. This cannot be done with an addon. Please see the attached for a way to do this, untested though. Michael -- Michael Meskes Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) Meskes at (Debian|Postgresql) dot Org Jabber: michael at xmpp dot meskes dot org VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL
diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer index 1d58c778d9..be6c9d0ae9 100644 --- a/src/interfaces/ecpg/preproc/ecpg.trailer +++ b/src/interfaces/ecpg/preproc/ecpg.trailer @@ -1,5 +1,26 @@ /* src/interfaces/ecpg/preproc/ecpg.trailer */ +PrepareStmt: PREPARE prepared_name prep_type_clause AS + { + prepared_name = $2; + prepare_type_clause = $3; + is_in_preparable_stmt = true; + } + PreparableStmt + { + $$.name = prepared_name; + $$.type = prepare_type_clause; + $$.stmt = $6; + is_in_preparable_stmt = false; + } + | PREPARE prepared_name FROM execstring + { + $$.name = $2; + $$.type = NULL; + $$.stmt = $4; + } + ; + statements: /*EMPTY*/ | statements statement ; diff --git a/src/interfaces/ecpg/preproc/ecpg.type b/src/interfaces/ecpg/preproc/ecpg.type index 519b737dde..1c68095274 100644 --- a/src/interfaces/ecpg/preproc/ecpg.type +++ b/src/interfaces/ecpg/preproc/ecpg.type @@ -145,3 +145,5 @@ %type <type> var_type %type <action> action + +%type <prep> PrepareStmt diff --git a/src/interfaces/ecpg/preproc/parse.pl b/src/interfaces/ecpg/preproc/parse.pl index 6f67a5e942..cafca22f7a 100644 --- a/src/interfaces/ecpg/preproc/parse.pl +++ b/src/interfaces/ecpg/preproc/parse.pl @@ -64,6 +64,7 @@ my %replace_types = ( 'stmtblock' => 'ignore', 'stmtmulti' => 'ignore', 'CreateAsStmt' => 'ignore', + 'PrepareStmt' => 'ignore', 'DeallocateStmt' => 'ignore', 'ColId' => 'ignore', 'type_function_name' => 'ignore',