[Bug Fix] ECPG: could not use set xxx to default statement - Mailing list pgsql-hackers

From Higuchi, Daisuke
Subject [Bug Fix] ECPG: could not use set xxx to default statement
Date
Msg-id 1803D792815FC24D871C00D17AE95905DB51CE@g01jpexmbkw24
Whole thread Raw
Responses Re: [Bug Fix] ECPG: could not use set xxx to default statement
List pgsql-hackers
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


Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Reaping Temp tables to avoid XID wraparound
Next
From: Alvaro Herrera
Date:
Subject: Re: Prepared transaction releasing locks before deregistering its GID