From: Shigeru Hanada Date: Wed, 15 Jun 2011 03:02:20 +0000 (+0900) Subject: Fix psql to avoid variable width query with using NULL as placeholder. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=d1f80e72590551e9cba7e5ccfb70c91a771994ea;p=users%2Fhanada%2Fpostgres.git Fix psql to avoid variable width query with using NULL as placeholder. --- diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index b2c54b5f92..7f9e1fe844 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -1281,7 +1281,12 @@ describeOneTableDetails(const char *schemaname, res = NULL; } - /* Get column info */ + /* + * Get column info + * + * You need to modify value of "firstvcol" which willbe defined below if + * you are adding column(s) preceding to verbose-only columns. + */ printfPQExpBuffer(&buf, "SELECT a.attname,"); appendPQExpBuffer(&buf, "\n pg_catalog.format_type(a.atttypid, a.atttypmod)," "\n (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid) for 128)" @@ -1295,6 +1300,8 @@ describeOneTableDetails(const char *schemaname, appendPQExpBuffer(&buf, "\n NULL AS attcollation"); if (tableinfo.relkind == 'i') appendPQExpBuffer(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); + else + appendPQExpBuffer(&buf, ",\n NULL AS indexdef"); if (verbose) appendPQExpBuffer(&buf, ",\n a.attstorage, pg_catalog.col_description(a.attrelid, a.attnum)"); appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_attribute a"); @@ -1461,7 +1468,7 @@ describeOneTableDetails(const char *schemaname, /* Storage and Description */ if (verbose) { - int firstvcol = (tableinfo.relkind == 'i' ? 7 : 6); + int firstvcol = 7; char *storage = PQgetvalue(res, i, firstvcol); /* these strings are literal in our syntax, so not translated. */