postgresql14报错
Uncaught think\db\exception\PDOException: SQLSTATE[42703]: Undefined column: 7 ERROR: column pg_attrdef.adsrc does not exist LINE 10: pg_attrdef.adsrc AS fields_default, ^ QUERY: SELECT pg_attribute.attname AS fields_name, pg_attribute.attnum AS fields_index, pgsql_type(pg_type.typname::varchar) AS fields_type, pg_attribute.atttypmod-4 as fields_length, CASE WHEN pg_attribute.attnotnull THEN 'not null' ELSE '' END AS fields_not_null, pg_attrdef.adsrc AS fields_default, pg_description.description AS fields_comment FROM pg_attribute INNER JOIN pg_class ON pg_attribute.attrelid = pg_class.oid INNER JOIN pg_type ON pg_attribute.atttypid = pg_type.oid LEFT OUTER JOIN pg_attrdef ON pg_attrdef.adrelid = pg_class.oid AND pg_attrdef.adnum = pg_attribute.attnum LEFT OUTER JOIN pg_description ON pg_description.objoid = pg_class.oid AND pg_description.objsubid = pg_attribute.attnum WHERE pg_attribute.attnum > 0 AND attisdropped <> 't' AND pg_class.oid = 16431 ORDER BY pg_attribute.attnum CONTEXT: PL/pgSQL function table_msg(character varying,character varying) line 43 at FOR over EXECUTE statement PL/pgSQL function table_msg(character varying) line 5 at FOR over SELECT rows
pgsql 11 后的版本已经取消了 pg_attrdef.adsrc ,要使用 解析 pg_attrdef.adbin 获取 默认值。
把SQL语句中的 pg_attrdef.adsrc 改成 pg_get_expr(pg_attrdef.adbin, pg_attrdef.adrelid)