Re: psql tab completion bug and possible fix - Mailing list pgsql-patches

From Ian Barwick
Subject Re: psql tab completion bug and possible fix
Date
Msg-id 200310152226.38481.barwick@gmx.net
Whole thread Raw
In response to Re: psql tab completion bug and possible fix  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: psql tab completion bug and possible fix
List pgsql-patches
On Tuesday 14 October 2003 23:38, Tom Lane wrote:
> Ian Barwick <barwick@gmx.net> writes:
> > A patch for this using PQescapeString (is there another preferred
> > method?) is attached as a possible solution.
>
> Surely all those replacements of \\ with \\\\ are wrong.

The slash in the slash command gets escaped too...:

#include <stdio.h>
#include "libpq-fe.h"

main() {
  char *s, *r;

  s = "\\d";

  printf("%s\n", s);

  r = (char *) malloc(strlen(s) * 2);
  PQescapeString(r, s, strlen(s));

  printf("%s\n", r);

  if(strcmp(r, "\\\\d") == 0) {
    printf("match\n");
  }

  free(s);
  free(r);
}

Without \\\\ tab expansion for slash commands doesn't work.

There may of course be better ways of solving this problem.


Ian Barwick
barwick@gmx.net

pgsql-patches by date:

Previous
From: Fabrizio Mazzoni
Date:
Subject: psql-it corrected
Next
From: Tom Lane
Date:
Subject: Re: psql tab completion bug and possible fix