Related TODO paragraph: «Prevent PQfnumber() from lowercasing unquoted the column name. PQfnumber() should never have been doing lowercasing, but historically it has so we need a way to prevent it.»
PQfnumber() Fix Proposal ------------------------ In the current version of PQfnumber(), if user doesn't put quotes around requested column name, libpq tries to lowercase both requested column name and actual column names, then compares each of them one by one. Here's the deal: [1] If user put quotes around requested column name, no lowercasing will be made in the libpq while comparing column names. (Current behaviour for quoted column names.) [2] If user doesn't use any quotes, API will assume the requested column name is lowercased. After that, it will compare the given input with the "lowercased column names"(*). (*) How can we transmit column names lowercased in the server side without causing any compatibility problems? When we look at the fe-protocol3.c, getRowDescriptions() splits data (conn->workBuffer) in this way: Offset: 0 4 6 10 12 16 18 +----+--+----+--+----+--+--------------+ | | | | | | | | +----+--+----+--+----+--+--------------+ [ 0: 3] tableid [ 4: 5] columnid [ 6: 9] typid [10:11] typlen [12:15] atttypmod [16:17] format [18: ] name Here's my proposal without breaking the current implementation: [18: ] name + '\0' + lowercased_name ("'\0' + lowercased_name" part will be added in the server side while building column descriptions.) Current functions in libpq, compares given column names using strcmp(attDescs[i].name, input) call. So new implementation won't casue any compatibility issues. But new getRowDescriptions() function will be aware of the hidden "lowercased column name" in the retrieved column description data and escape it to another variable in attDescs as (for instance) lowername. Therefore, PQfnumber() can use attDescs[i].lowername while making case insensitive compare. Waiting for your comments. Regards. ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings