Hi,

On 2015-07-08 14:50:37 +0200, Pavel Stehule wrote:
> -                     static const char *const my_list[] =
> -                     {"DEFAULT", NULL};
> +                     /* fallback for GUC settings */
>  
> -                     COMPLETE_WITH_LIST(my_list);
> +                     char *vartype = get_vartype(prev2_wd);
> +
> +                     if (strcmp(vartype, "enum") == 0)
> +                     {
> +                             char querybuf[1024];
> +
> +                             snprintf(querybuf, 1024, Query_for_enum, 
> prev2_wd);
> +                             COMPLETE_WITH_QUERY(querybuf);
> +                     }

Won't that mean that enum variables don't complete to default anymore?

> +static char *
> +get_vartype(const char *varname)
> +{
> +     PQExpBufferData query_buffer;
> +     char    *e_varname;
> +     PGresult *result;
> +     int     string_length;
> +     static char resbuf[10];
> +
> +     initPQExpBuffer(&query_buffer);
> +
> +     string_length = strlen(varname);
> +     e_varname = pg_malloc(string_length * 2 + 1);
> +     PQescapeString(e_varname, varname, string_length);

Independent of this patch, we really shouldn't do this in several places
:(

> +     appendPQExpBuffer(&query_buffer,
> +             "SELECT vartype FROM pg_settings WHERE pg_catalog.lower(name) = 
> pg_catalog.lower('%s')",
> +                      e_varname);

Missing pg_catalog for pg_settings.

Greetings,

Andres Freund


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to