Hi, Recently, I am reading the postgres codes, and I have a question about the deparsing some expressions which is contains Const node. The following SQL will retrieve the definition stored by postgres database for table "t":
CREATE TABLE "t" (c1 CHAR(5) DEFAULT 'abc', c2 CHAR(5) DEFAULT 'abc'::CHAR(5)); SELECT pg_get_expr(adbin, adrelid) FROM pg_attrdef WHERE adrelid = (SELECT oid FROM pg_class WHERE relname = 't'); pg_get_expr --------------------- 'abc'::bpchar 'abc'::character(5) (2 rows) Postgres will emit a implicit coercion for the default value of c1 column before the definition node can be stored in system catalog pg_attrdef. To retrieve a human-readable definition for the default value, pg_get_expr() will call get_func_expr() to display the default value. get_func_expr() will omit the implicit function and return the first argument barely. The default value for column c2 is pretty than the default value for column c1, so I am courious about is there any possibility to make the default value for c1 look like the default value for c2. If we do not concern the compatible with old system, is it possible to modify the function transformExpr() or something else to archieve the the 'pretty'(may be not pretty at all for someone) format? It seems assign the correct typmod to Const node during transform phase is possible, but most of time it is meaningless. typmod plays an important role during the process of coercion decision, it seems the coercion will absence iff the type and typmod is same. Thanks in advance, Tao Ma -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers