DASSL / ClassDB

An open-source system to let students experiment with relational data
https://dassl.github.io/ClassDB/
Other
7 stars 2 forks source link

Connection log import fails on Postgres 13 (W) #283

Open smurthys opened 3 years ago

smurthys commented 3 years ago

Running the function classdb.importConnectionLog on an instance of Postgres 13 fails to import any data. Here is an example of the result table the function returns when the function is run without any parameter:

logdate numconnections numdisconnections info
2021-02-26T00:00:00Z 0 0 extra data after last expected column

The failure to import is due to an exception, but the content of the column info in the result table does not include any hint there was an exception.

Looking into the code and Postgres docs, the failure to import is due to Postgres 13 adding a new column (named backend_type) to the server log. The solution is to conditionally include the new column in the temporary table ImportedLogData.

Further, it will help to to prefix the text in the info column with a string such as exception: instead of placing just the value of SQLERRM in that column when an exception occurs.

smurthys commented 3 years ago

I have confirmed again that the issue is indeed due to the missing column added in Postgres 13. I have also verified that the following code to conditionally add the missing column works if the server version is later than 12.x. I have tested this patch only on Postgres 13.1. It needs to be tested on 13.0 and any version earlier than 13.0. This code should added immediately after temp table ImportedLogData is created.

IF ClassDB.isServerVersionAfter('12', FALSE) THEN
   ALTER TABLE ImportedLogData ADD COLUMN backend_type TEXT;
END IF;
smurthys commented 3 years ago

I no longer feel that a prefix exception: should be included in the values of info column, because that column presently gets a value only when there is an exception. In all other cases, that column's value is NULL. I suggest revising this issue if the column is ever populated when there are no exceptions. Thus, I'm removing the "missing" characterization from the issue title.