On 01/30/2013 11:03 AM, Tom Lane wrote:
Andrew Dunstan <and...@dunslane.net> writes:
On 01/30/2013 09:58 AM, Tom Lane wrote:
Marko Tiikkaja <pgm...@joh.to> writes:
On 1/30/13 7:52 AM, Jeevan Chalke wrote:
However, I am not sure about putting "WRAP_COLUMN_DEFAULT" by default. In
my opinion we should put that by default but other people may object so I
will keep that in code committors plate.
FWIW, I'd vote for not enabling that by default --- it's basically an
unwarranted assumption about how wide people's terminal windows are.
I'm not exactly sure what you're arguing for.
Maybe I'm confused - I thought the alternative Jeevan was talking about
was that we enable PRETTY_INDENT processing by default, but not
wrapColumn processing.

                        


Well, we could actually set the wrap value to 0, which would mean always wrap. That wouldn't be making any assumption about the user's terminal window size ;-)

Here are two examples, one of which is with exactly Marko's patch which doesn't change the wrap value (i.e. leaves it at -1, meaning no wrap) , the other sets it at 0. The example is a view that is the same as information_schema.columns.

Personally I find the wrapped case MUCH more readable. I guess anything is an advance, but turning on PRETTY_INDENT without turning on some level of target wrapping seems like a half-done job.

cheers

andrew
--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;

--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: 
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';


SET search_path = public, pg_catalog;

--
-- Name: mycols; Type: VIEW; Schema: public; Owner: andrew
--

CREATE VIEW mycols AS
     SELECT (current_database())::information_schema.sql_identifier AS table_catalog, (nc.nspname)::information_schema.sql_identifier AS table_schema, (c.relname)::information_schema.sql_identifier AS table_name, (a.attname)::information_schema.sql_identifier AS column_name, (a.attnum)::information_schema.cardinal_number AS ordinal_position, (pg_get_expr(ad.adbin, ad.adrelid))::information_schema.character_data AS column_default, (
        CASE
            WHEN (a.attnotnull OR ((t.typtype = 'd'::"char") AND t.typnotnull)) THEN 'NO'::text
            ELSE 'YES'::text
        END)::information_schema.yes_or_no AS is_nullable, (
        CASE
            WHEN (t.typtype = 'd'::"char") THEN 
            CASE
                WHEN ((bt.typelem <> (0)::oid) AND (bt.typlen = (-1))) THEN 'ARRAY'::text
                WHEN (nbt.nspname = 'pg_catalog'::name) THEN format_type(t.typbasetype, NULL::integer)
                ELSE 'USER-DEFINED'::text
            END
            ELSE 
            CASE
                WHEN ((t.typelem <> (0)::oid) AND (t.typlen = (-1))) THEN 'ARRAY'::text
                WHEN (nt.nspname = 'pg_catalog'::name) THEN format_type(a.atttypid, NULL::integer)
                ELSE 'USER-DEFINED'::text
            END
        END)::information_schema.character_data AS data_type, (information_schema._pg_char_max_length(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number AS character_maximum_length, (information_schema._pg_char_octet_length(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number AS character_octet_length, (information_schema._pg_numeric_precision(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number AS numeric_precision, (information_schema._pg_numeric_precision_radix(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number AS numeric_precision_radix, (information_schema._pg_numeric_scale(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number AS numeric_scale, (information_schema._pg_datetime_precision(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number AS datetime_precision, (information_schema._pg_interval_type(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.character_data AS interval_type, (NULL::integer)::information_schema.cardinal_number AS interval_precision, (NULL::character varying)::information_schema.sql_identifier AS character_set_catalog, (NULL::character varying)::information_schema.sql_identifier AS character_set_schema, (NULL::character varying)::information_schema.sql_identifier AS character_set_name, (
        CASE
            WHEN (nco.nspname IS NOT NULL) THEN current_database()
            ELSE NULL::name
        END)::information_schema.sql_identifier AS collation_catalog, (nco.nspname)::information_schema.sql_identifier AS collation_schema, (co.collname)::information_schema.sql_identifier AS collation_name, (
        CASE
            WHEN (t.typtype = 'd'::"char") THEN current_database()
            ELSE NULL::name
        END)::information_schema.sql_identifier AS domain_catalog, (
        CASE
            WHEN (t.typtype = 'd'::"char") THEN nt.nspname
            ELSE NULL::name
        END)::information_schema.sql_identifier AS domain_schema, (
        CASE
            WHEN (t.typtype = 'd'::"char") THEN t.typname
            ELSE NULL::name
        END)::information_schema.sql_identifier AS domain_name, (current_database())::information_schema.sql_identifier AS udt_catalog, (COALESCE(nbt.nspname, nt.nspname))::information_schema.sql_identifier AS udt_schema, (COALESCE(bt.typname, t.typname))::information_schema.sql_identifier AS udt_name, (NULL::character varying)::information_schema.sql_identifier AS scope_catalog, (NULL::character varying)::information_schema.sql_identifier AS scope_schema, (NULL::character varying)::information_schema.sql_identifier AS scope_name, (NULL::integer)::information_schema.cardinal_number AS maximum_cardinality, (a.attnum)::information_schema.sql_identifier AS dtd_identifier, ('NO'::character varying)::information_schema.yes_or_no AS is_self_referencing, ('NO'::character varying)::information_schema.yes_or_no AS is_identity, (NULL::character varying)::information_schema.character_data AS identity_generation, (NULL::character varying)::information_schema.character_data AS identity_start, (NULL::character varying)::information_schema.character_data AS identity_increment, (NULL::character varying)::information_schema.character_data AS identity_maximum, (NULL::character varying)::information_schema.character_data AS identity_minimum, (NULL::character varying)::information_schema.yes_or_no AS identity_cycle, ('NEVER'::character varying)::information_schema.character_data AS is_generated, (NULL::character varying)::information_schema.character_data AS generation_expression, (
        CASE
            WHEN ((c.relkind = 'r'::"char") OR ((c.relkind = 'v'::"char") AND pg_view_is_updatable(c.oid))) THEN 'YES'::text
            ELSE 'NO'::text
        END)::information_schema.yes_or_no AS is_updatable
   FROM (((((pg_attribute a
   LEFT JOIN pg_attrdef ad ON (((a.attrelid = ad.adrelid) AND (a.attnum = ad.adnum))))
   JOIN (pg_class c
   JOIN pg_namespace nc ON ((c.relnamespace = nc.oid))) ON ((a.attrelid = c.oid)))
   JOIN (pg_type t
   JOIN pg_namespace nt ON ((t.typnamespace = nt.oid))) ON ((a.atttypid = t.oid)))
   LEFT JOIN (pg_type bt
   JOIN pg_namespace nbt ON ((bt.typnamespace = nbt.oid))) ON (((t.typtype = 'd'::"char") AND (t.typbasetype = bt.oid))))
   LEFT JOIN (pg_collation co
   JOIN pg_namespace nco ON ((co.collnamespace = nco.oid))) ON (((a.attcollation = co.oid) AND ((nco.nspname <> 'pg_catalog'::name) OR (co.collname <> 'default'::name)))))
  WHERE (((((NOT pg_is_other_temp_schema(nc.oid)) AND (a.attnum > 0)) AND (NOT a.attisdropped)) AND (c.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'f'::"char"]))) AND (pg_has_role(c.relowner, 'USAGE'::text) OR has_column_privilege(c.oid, a.attnum, 'SELECT, INSERT, UPDATE, REFERENCES'::text)));


ALTER TABLE public.mycols OWNER TO andrew;

--
-- Name: public; Type: ACL; Schema: -; Owner: andrew
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM andrew;
GRANT ALL ON SCHEMA public TO andrew;
GRANT ALL ON SCHEMA public TO PUBLIC;


--
-- PostgreSQL database dump complete
--

--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;

--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: 
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';


SET search_path = public, pg_catalog;

--
-- Name: mycols; Type: VIEW; Schema: public; Owner: andrew
--

CREATE VIEW mycols AS
     SELECT (current_database())::information_schema.sql_identifier AS table_catalog, 
    (nc.nspname)::information_schema.sql_identifier AS table_schema, 
    (c.relname)::information_schema.sql_identifier AS table_name, 
    (a.attname)::information_schema.sql_identifier AS column_name, 
    (a.attnum)::information_schema.cardinal_number AS ordinal_position, 
    (pg_get_expr(ad.adbin, ad.adrelid))::information_schema.character_data AS column_default, 
    (
        CASE
            WHEN (a.attnotnull OR ((t.typtype = 'd'::"char") AND t.typnotnull)) THEN 'NO'::text
            ELSE 'YES'::text
        END)::information_schema.yes_or_no AS is_nullable, 
    (
        CASE
            WHEN (t.typtype = 'd'::"char") THEN 
            CASE
                WHEN ((bt.typelem <> (0)::oid) AND (bt.typlen = (-1))) THEN 'ARRAY'::text
                WHEN (nbt.nspname = 'pg_catalog'::name) THEN format_type(t.typbasetype, NULL::integer)
                ELSE 'USER-DEFINED'::text
            END
            ELSE 
            CASE
                WHEN ((t.typelem <> (0)::oid) AND (t.typlen = (-1))) THEN 'ARRAY'::text
                WHEN (nt.nspname = 'pg_catalog'::name) THEN format_type(a.atttypid, NULL::integer)
                ELSE 'USER-DEFINED'::text
            END
        END)::information_schema.character_data AS data_type, 
    (information_schema._pg_char_max_length(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number AS character_maximum_length, 
    (information_schema._pg_char_octet_length(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number AS character_octet_length, 
    (information_schema._pg_numeric_precision(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number AS numeric_precision, 
    (information_schema._pg_numeric_precision_radix(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number AS numeric_precision_radix, 
    (information_schema._pg_numeric_scale(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number AS numeric_scale, 
    (information_schema._pg_datetime_precision(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number AS datetime_precision, 
    (information_schema._pg_interval_type(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.character_data AS interval_type, 
    (NULL::integer)::information_schema.cardinal_number AS interval_precision, 
    (NULL::character varying)::information_schema.sql_identifier AS character_set_catalog, 
    (NULL::character varying)::information_schema.sql_identifier AS character_set_schema, 
    (NULL::character varying)::information_schema.sql_identifier AS character_set_name, 
    (
        CASE
            WHEN (nco.nspname IS NOT NULL) THEN current_database()
            ELSE NULL::name
        END)::information_schema.sql_identifier AS collation_catalog, 
    (nco.nspname)::information_schema.sql_identifier AS collation_schema, 
    (co.collname)::information_schema.sql_identifier AS collation_name, 
    (
        CASE
            WHEN (t.typtype = 'd'::"char") THEN current_database()
            ELSE NULL::name
        END)::information_schema.sql_identifier AS domain_catalog, 
    (
        CASE
            WHEN (t.typtype = 'd'::"char") THEN nt.nspname
            ELSE NULL::name
        END)::information_schema.sql_identifier AS domain_schema, 
    (
        CASE
            WHEN (t.typtype = 'd'::"char") THEN t.typname
            ELSE NULL::name
        END)::information_schema.sql_identifier AS domain_name, 
    (current_database())::information_schema.sql_identifier AS udt_catalog, 
    (COALESCE(nbt.nspname, nt.nspname))::information_schema.sql_identifier AS udt_schema, 
    (COALESCE(bt.typname, t.typname))::information_schema.sql_identifier AS udt_name, 
    (NULL::character varying)::information_schema.sql_identifier AS scope_catalog, 
    (NULL::character varying)::information_schema.sql_identifier AS scope_schema, 
    (NULL::character varying)::information_schema.sql_identifier AS scope_name, 
    (NULL::integer)::information_schema.cardinal_number AS maximum_cardinality, 
    (a.attnum)::information_schema.sql_identifier AS dtd_identifier, 
    ('NO'::character varying)::information_schema.yes_or_no AS is_self_referencing, 
    ('NO'::character varying)::information_schema.yes_or_no AS is_identity, 
    (NULL::character varying)::information_schema.character_data AS identity_generation, 
    (NULL::character varying)::information_schema.character_data AS identity_start, 
    (NULL::character varying)::information_schema.character_data AS identity_increment, 
    (NULL::character varying)::information_schema.character_data AS identity_maximum, 
    (NULL::character varying)::information_schema.character_data AS identity_minimum, 
    (NULL::character varying)::information_schema.yes_or_no AS identity_cycle, 
    ('NEVER'::character varying)::information_schema.character_data AS is_generated, 
    (NULL::character varying)::information_schema.character_data AS generation_expression, 
    (
        CASE
            WHEN ((c.relkind = 'r'::"char") OR ((c.relkind = 'v'::"char") AND pg_view_is_updatable(c.oid))) THEN 'YES'::text
            ELSE 'NO'::text
        END)::information_schema.yes_or_no AS is_updatable
   FROM (((((pg_attribute a
   LEFT JOIN pg_attrdef ad ON (((a.attrelid = ad.adrelid) AND (a.attnum = ad.adnum))))
   JOIN (pg_class c
   JOIN pg_namespace nc ON ((c.relnamespace = nc.oid))) ON ((a.attrelid = c.oid)))
   JOIN (pg_type t
   JOIN pg_namespace nt ON ((t.typnamespace = nt.oid))) ON ((a.atttypid = t.oid)))
   LEFT JOIN (pg_type bt
   JOIN pg_namespace nbt ON ((bt.typnamespace = nbt.oid))) ON (((t.typtype = 'd'::"char") AND (t.typbasetype = bt.oid))))
   LEFT JOIN (pg_collation co
   JOIN pg_namespace nco ON ((co.collnamespace = nco.oid))) ON (((a.attcollation = co.oid) AND ((nco.nspname <> 'pg_catalog'::name) OR (co.collname <> 'default'::name)))))
  WHERE (((((NOT pg_is_other_temp_schema(nc.oid)) AND (a.attnum > 0)) AND (NOT a.attisdropped)) AND (c.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'f'::"char"]))) AND (pg_has_role(c.relowner, 'USAGE'::text) OR has_column_privilege(c.oid, a.attnum, 'SELECT, INSERT, UPDATE, REFERENCES'::text)));


ALTER TABLE public.mycols OWNER TO andrew;

--
-- Name: public; Type: ACL; Schema: -; Owner: andrew
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM andrew;
GRANT ALL ON SCHEMA public TO andrew;
GRANT ALL ON SCHEMA public TO PUBLIC;


--
-- PostgreSQL database dump complete
--

-- 
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