Re: Problems with variable cursorname in ecpg
От | Boszormenyi Zoltan |
---|---|
Тема | Re: Problems with variable cursorname in ecpg |
Дата | |
Msg-id | 4BB3336E.50204@cybertec.at обсуждение исходный текст |
Ответ на | Re: Problems with variable cursorname in ecpg (Michael Meskes <meskes@postgresql.org>) |
Список | pgsql-hackers |
Michael Meskes írta: > On Wed, Mar 31, 2010 at 10:35:31AM +0200, Boszormenyi Zoltan wrote: > >>> I think we should make the error message/documentation a little bit clearer as >>> people have stumbled over it. >>> >> Yes, we need to document it. >> > > I changed the error message and documented a possible improvement in the TODO list. > > >> I think you forget that in this case, only global variables are >> usable in the DECLARE in this case, no local variables in >> functions preceding the DECLARE are visible to it. >> > > I thought about not allowing variables in declare statements that are outside a > function. Do you think it makes sense to allow those? Forbidding these right > now would give us more headroomfor future development. > I think forbidding global variables in DECLARE is not good. Consider this code (existing code using this practice is in use): /* globals for our cursor */ EXEC SQL BEGIN DECLARE SECTION; char *global_curname; EXEC SQL END DECLARE SECTION; void open_cursor(char *curname) { global_curname = curname; EXEC SQL DECLARE :global_curname CURSOR FOR ...; EXEC SQL OPEN :global_curname; } ... and similar codes for FETCH (into SQLDA) and CLOSE. It works nicely for single-threaded code. The dump_variables() code cannot distinguish between the dynamic cursorname variable (used for $0) and the other input variables. Considering the usefulness of the current state, we shouldn't disallow global variables for DECLARE. Best regards, Zoltán Böszörményi -- Bible has answers for everything. Proof: "But let your communication be, Yea, yea; Nay, nay: for whatsoever is more than these cometh of evil." (Matthew 5:37) - basics of digital technology. "May your kingdom come" - superficial description of plate tectonics ---------------------------------- Zoltán Böszörményi Cybertec Schönig & Schönig GmbH http://www.postgresql.at/
В списке pgsql-hackers по дате отправления: