Handling optional columns in SELECT for PostgreSQL
During the discussions about #2886 (closed) it was apparent that we need to design a way of making SELECT queries in PostgreSQL with excluding some columns. It is particularly important for the lease6
table queries where we recently started adding new columns (related to BLQ) that are excluded in some (many?) cases. The PgSqlLease6Exchange
contains the list of constants designating the indexes of the columns in the SELECT statements. A temporary solution was to assign the highest indexes for optional columns (put them at the end), but it may be good for a single optional column. If you have two optional columns this solution has serious limitations. For example, to query the last optional column you need to query all preceding optional columns, even if they are not needed in the particular case.
The following thread in #2886 (closed) is relevant: !2016 (comment 377155)
It includes some ideas how to address this problem.