DASSL / ClassDB

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

prepareClassDB: Latest version in comments-consistency-fixes-M1 results in errors when run (W) #54

Closed afig closed 7 years ago

afig commented 7 years ago

Attempting to run the prepareClassDB script results in the transaction being aborted due to a few syntax errors in the file, and an incompatibility with an older version. The specific problems are listed below:

afig commented 7 years ago

The last three points have been resolved in commits c1a4d7c13c24a60325edcead4c413cc8987ff403, 2c365c0db51315a1641981283b777465abe0ed13, and e448264cb1c567c2a6b358143f9f6be36dbf1212 .

The first point is being ignored for now. This is because any change in the name or type of a parameter would require using a similar facility. Thus, every function would likely be preceded by multiple DROP FUNCTION IF EXISTS statements, depending on how many revisions it has had. A better solution to this problem might be to have a cleanup script. For now, manually running a DROP FUNCTION statement should be sufficient. This situation should generally only occur during development.

smurthys commented 7 years ago

I am a bit concerned about the need to always quote role names and it is incompatible with the use of the name PUBLIC. It was an error on my part to use %I: I didn't intend to. :(. mea maxima culpa

DROP FUNCTION could be required when functions are patched, and patches should be expected (for example, on the DASSL VM). I would consider prefixing each CREATE FUNCTION with a DROP FUNCTION instead of using CREATE OR REPLACE FUNCTION. I also advise studying the behavior of DROP FUNCTION with and without parameter names included.

afig commented 7 years ago

Using %s instead of %I does not automatically double quote the role names when using the format function. It might be a better choice to use this in the pg_temp.createGroupRoles function in prepareClassServer. By using this, we will not have to quote role names, and we can use the capitalization we were using prior.

Improper formatting and SQL Injection should not be an issue as the function is created and dropped within the same script (and transaction).

afig commented 7 years ago

Fixed by d974bb7869e0dcb7bcbcbc5a0f381d0ad6ad1bb7, merged into master in 916e05feac2512acccf1395ff769455f4be62fe8