diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c index 997046b38b7..909ba700920 100644 --- a/src/interfaces/ecpg/ecpglib/connect.c +++ b/src/interfaces/ecpg/ecpglib/connect.c @@ -149,6 +149,13 @@ ecpg_finish(struct connection * act) for (cache = act->cache_head; cache; ptr = cache, cache = cache->next, ecpg_free(ptr)); ecpg_free(act->name); ecpg_free(act); + /* delete cursor variables when last connection gets closed */ + if (all_connections == NULL) + { + struct var_list *iv_ptr; + + for (; ivlist; iv_ptr = ivlist, ivlist = ivlist->next, ecpg_free(iv_ptr)); + } } else ecpg_log("ecpg_finish: called an extra time\n"); diff --git a/src/interfaces/ecpg/ecpglib/extern.h b/src/interfaces/ecpg/ecpglib/extern.h index 96d49a4a6b7..bd1ffb096c0 100644 --- a/src/interfaces/ecpg/ecpglib/extern.h +++ b/src/interfaces/ecpg/ecpglib/extern.h @@ -121,6 +121,15 @@ struct variable struct variable *next; }; +struct var_list +{ + int number; + void *pointer; + struct var_list *next; +}; + +extern struct var_list *ivlist; + /* Here are some methods used by the lib. */ /* Returns a pointer to a string containing a simple type name. */ diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c index 98e0597b03c..f24478271cd 100644 --- a/src/interfaces/ecpg/ecpglib/misc.c +++ b/src/interfaces/ecpg/ecpglib/misc.c @@ -501,12 +501,7 @@ ecpg_gettext(const char *msgid) } #endif /* ENABLE_NLS */ -static struct var_list -{ - int number; - void *pointer; - struct var_list *next; -} *ivlist = NULL; +struct var_list *ivlist = NULL; void ECPGset_var(int number, void *pointer, int lineno)