folio-org / mod-reporting

Interface to Metadb/LDP reporting databases (plug-compatible reimplementation of mod-ldp)
Apache License 2.0
0 stars 1 forks source link

Running a report twice does not work correctly #55

Closed MikeTaylor closed 9 months ago

MikeTaylor commented 9 months ago

You can run an LDP Classic report using

curl 'http://localhost:12369/ldp/db/reports' --compressed -X POST -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/119.0' -H 'Accept: */*' -H 'Accept-Language: en-GB,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'xx-okapi-tenant: diku' -H 'content-type: application/json' -H 'x-okapi-token: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJkaWt1X2FkbWluIiwidHlwZSI6ImxlZ2FjeS1hY2Nlc3MiLCJ1c2VyX2lkIjoiOTdiYWUzYzctYzEwMi01NWRkLWI4ZWItMzY3NDg3MGI1NTQzIiwiaWF0IjoxNzAxMzM0ODE0LCJ0ZW5hbnQiOiJkaWt1In0.qgFsGPzd5wk-Iqaq5fijBgyyuVCjBMAWF7sq7GI9N8w' -H 'Origin: https://folio-snapshot.dev.folio.org' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Referer: https://folio-snapshot.dev.folio.org/' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-site' -H 'Sec-GPC: 1' --data-raw '{"url":"https://raw.githubusercontent.com/MikeTaylor/dummy-ldp-queries/main/queries/courses.sql","params":{"minimum_number_of_students":"5"},"limit":1000}'

(or my local run-ldp-report.sh script).

This will work correctly the first time (assuming that the running mod-reporting is targeted to an LDP Classic report); but it fails the second time you run it, saying:

function "get_courses" already exists with same argument types (SQLSTATE 42723)

This is presumably a leftover from the previous run of the report, but that's not supposed to happen as everything is wrapped in rolled-back transaction.

(I don't yet know whether the same problem occurs when running against MetaDB, but I would guess it probably does.)

MikeTaylor commented 9 months ago

When using a MetaDB reporting database, there is no difficulty in running the same report multiple times. So this seems to be a problem specifically to do with LDP Classic.

MikeTaylor commented 9 months ago

I now find that running the report in question fails the first time I attempt it, so it seems that something has permanently changed in the state of the LDP Classic database that I'm using: a permanent get_courses function has been created. I assume I did this the first time I successfully ran the report.