How to solve "ERROR: column p.adsrc does not exist" with PostgreSQL

Symptom

When you create a DataWindow or call function SyntaxFromSQL, the PostgreSQL server log shows the following error.

2022-07-03 19:00:30.324 PDT [7484] ERROR:  column p.adsrc does not exist at character 26

Environment

PowerBuilder 2017/2019/2021

Cause

Since PostgreSQL 12, column adsrc was removed.

Solution

You need to use function pg_get_expr to get the default value instead of using the adsrc column.

Please find the following line in pbodb.ini:

SelectDefault='SELECT a.attname as name,p.adsrc FROM pg_catalog.pg_class as c Left JOIN pg_catalog.pg_attrdef as p ON c.oid = p.adrelid LEFT JOIN pg_catalog.pg_attribute as a ON p.adnum = a.attnum INNER JOIN pg_catalog.pg_type ON pg_type.oid = a.atttypid WHERE c.relname = ''&TableName'' AND a.attrelid = c.oid AND a.attnum>0'

And modify it as follows:

SelectDefault='SELECT a.attname as name, pg_catalog.pg_get_expr(p.adbin, p.adrelid) as adsrc FROM pg_catalog.pg_class as c Left JOIN pg_catalog.pg_attrdef as p ON c.oid = p.adrelid LEFT JOIN pg_catalog.pg_attribute as a ON p.adnum = a.attnum INNER JOIN pg_catalog.pg_type ON pg_type.oid = a.atttypid WHERE c.relname = ''&TableName'' AND a.attrelid = c.oid AND a.attnum>0'