Hi,
I found ECPG's bug which SET xxx = DEFAULT statement could not be used.
[PROBLEM]
When the source code (*.pgc) has "EXEC SQL set xxx = default;", created c program by ECPG has no " = default".
For example, "EXEC SQL set search_path = default;" in *.pgc will be converted to "{ ECPGdo(__LINE__, 0, 1, NULL, 0,
ECPGst_normal,"set search_path", ECPGt_EOIT, ECPGt_EORT);}" in c program.
[Investigation]
gram.y lacks ";" in the end of section "generic_set", so preproc.y's syntax is broken.
src/backend/parser/gram.y
-------------------------------------------
generic_set:
| var_name '=' DEFAULT
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->kind = VAR_SET_DEFAULT;
n->name = $1;
$$ = n;
}
set_rest_more: /* Generic SET syntaxes: */
-------------------------------------------
src/interfaces/ecpg/preproc/preproc.y
-------------------------------------------
generic_set:
| var_name TO DEFAULT
{
$$ = cat_str(2,$1,mm_strdup("to default"));
}
| var_name '=' DEFAULT set_rest_more:
generic_set
{
$$ = $1;
}
-------------------------------------------
I attached the patch which has ";" in the end of section "generic_set" and regression.
Regards,
Daisuke, Higuchi