Hello,
Sorry for not quick problem fixing, I was quite busy last time...
I submit the new version of my patch (against the CVS tip), correcting the
problem with \edit (pointed by Andreas). So now everything works fine.
With Best Regards,
Sergey
On Thu, 1 Dec 2005, Bruce Momjian wrote:
>
> Where are we on this patch? Was it submitted? Applied? Just an idea?
>
> ---------------------------------------------------------------------------
>
> Andreas Seltenreich wrote:
> > Sergey E. Koposov writes:
> >
> > > I'm proposing the small patch for the TODO item -- Improve psql's
> > > handling
> > > of multi-line queries. With this patch the multi-line queries are saved
> > > by readline as whole and not line by line.
> >
> > I like it already!
> >
> > > This is my first patch for Postgres but it seems to work and to not break
> > > anything.
> > >
> > > I'm waiting for review, comments, objections, etc...
> >
> > Did you consider its interaction with \e? Editing the query_buffer
> > with \e will leave that query prefixed with \e in the history. That
> > wasn't the case before your patch.
> >
> > Also, using \e several times on a query without sending it (i.e.
> > without a semicolon) will yield a history entry of a concatenation of
> > old query buffers.
> >
> > Thanks,
> > Andreas
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 4: Have you searched our list archives?
> >
> > http://archives.postgresql.org
> >
>
>
*****************************************************
Sergey E. Koposov
Max-Planck Institut for Astronomy
Web: http://lnfm1.sai.msu.ru/~math
E-mail: [EMAIL PROTECTED]
Index: input.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/psql/input.c,v
retrieving revision 1.46
diff -r1.46 input.c
93,94d92
< static char *prev_hist = NULL;
<
101c99,112
< if (useHistory && s && s[0])
---
> return s;
> #else
> return gets_basic(prompt);
> #endif
> }
>
> /* Put the line in the history buffer and also add the trailing \n */
> char *pgadd_history(char *s, char *history_buf, int *cur_len)
> {
> #ifdef USE_READLINE
>
> int slen;
> char *history_buf1 = 0;
> if (useReadline && useHistory && s && s[0])
102a114,146
> slen = strlen(s);
> history_buf1 = history_buf;
> history_buf1 = realloc(history_buf1, (*cur_len + slen + 2) *
> sizeof(char));
> strcpy(history_buf1 + *cur_len, s);
> if (s[slen-1]!='\n')
> {
> *cur_len += (slen + 1);
> history_buf1[*cur_len - 1] = '\n';
> history_buf1[*cur_len] = 0;
> }
> else
> {
> *cur_len += (slen);
> history_buf1[*cur_len] = 0;
> }
>
> }
> return history_buf1;
> #endif
> }
>
> /* Feed the contents of the history buffer to readline */
> void pgflush_history(char **history_buf, int *cur_len)
> {
>
> #ifdef USE_READLINE
>
> char *s;
> static char *prev_hist;
>
> if (useReadline && useHistory && ((*cur_len) > 0))
> {
>
103a148,152
>
> s = *history_buf;
> prev_hist = NULL;
>
> s[(*cur_len) - 1] = 0;
117a167,170
>
> free(s);
> *history_buf = 0;
> *cur_len = 0;
119,122d171
<
< return s;
< #else
< return gets_basic(prompt);
124d172
< }
125a174
> }
Index: input.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/psql/input.h,v
retrieving revision 1.23
diff -r1.23 input.h
41a42,44
> char *pgadd_history(char *s, char *history_buf, int *cur_len);
> void pgflush_history(char **history_buf, int *cur_len);
>
Index: mainloop.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/psql/mainloop.c,v
retrieving revision 1.68
diff -r1.68 mainloop.c
40a41,42
> char *history_buf = 0;
> int history_buf_len = 0;
140a143,151
>
> if ( pset.cur_cmd_interactive )
> {
> /* Pass all the contents of history_buf to
> readline
> * and free the history buffer.
>
> */
> pgflush_history(&history_buf,
> &history_buf_len);
> }
>
215c226,232
<
---
>
> if (pset.cur_cmd_interactive)
> {
> /* Put current line in the history buffer */
> history_buf = pgadd_history(line, history_buf,
> &history_buf_len);
> }
>
231a249
>
251a270,271
>
>
255a276
>
268a290
>
289a312,319
>
> if (pset.cur_cmd_interactive && (prompt_status !=
> PROMPT_CONTINUE))
> {
> /* Pass all the contents of history_buf to readline
> and free the history buffer.
> */
> pgflush_history(&history_buf, &history_buf_len);
> }
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq