Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change syntax for Oracle multi-row insert SQL statement #5837

Merged
merged 6 commits into from
Feb 19, 2020

Conversation

abepolk
Copy link
Contributor

@abepolk abepolk commented Jan 17, 2020

A fix for a bug involving SQL inserts in Oracle. This is not final yet.
See #5812 (comment)

@abepolk
Copy link
Contributor Author

abepolk commented Jan 17, 2020

Is it possible to run the Oracle tests on GitHub? The fix ended up being really simple and it probably only needs to be tested once or twice. This might be easier than installing Docker.

@tobiasdiez
Copy link
Member

They oracle tests are now invoked correctly.

@abepolk
Copy link
Contributor Author

abepolk commented Jan 17, 2020

Thanks! Is it normal for ccrypt to throw an error here in the Oracle tests?

@tobiasdiez
Copy link
Member

I don't think so.

@koppor ?

@koppor
Copy link
Member

koppor commented Jan 17, 2020

  • the docker container needs the Oracle RPM

  • Oracles requires agreement to the terms of use (not using it for terr.r, e.g.)

  • I wanted to enable the tests on our CI solution

  • Therefore, I stored the RPM encrypted

  • Without a secret, a decryption error is thrown.

    ccrypt: files/oracle-database-xe-18c-1.0-1.x86_64.rpm.cpt: key does not match -- unchanged
    
  • The secret to the encryption is stored in our GitHub secrets

  • GitHub secrets are not shared to external pull requests:

    With the exception of GITHUB_TOKEN, secrets are not passed to the runner when a workflow is triggered from a forked repository.

Therefore, @NorwayMaple gets the error and me not.

Solution: Someone of the core developers has to fetch the branch and push it into our main repo. Then wait for the check and then delete the branch again (to avoid confusion; especially because of a missing pull request (to THAT branch!) and the possible outdated branch)

I did it for https://github.com/JabRef/jabref/commit/f98c9b604f2cfa77376369770346e5e8814b2464/checks?check_suite_id=407206367 (needed to patch our oracle workflow -> ec618d7)

@koppor
Copy link
Member

koppor commented Jan 17, 2020

Did not succeed. E.g.,

  Test testGetSharedIDVersionMapping() FAILED

  org.opentest4j.AssertionFailedError: expected: <{1=1, 2=2}> but was: <{1=1, 2=1}>
      at org.jabref.logic.shared.DBMSProcessorTest.testGetSharedIDVersionMapping(DBMSProcessorTest.java:312)

@abepolk
Copy link
Contributor Author

abepolk commented Jan 17, 2020

Okay. I could still look into using Docker to work with Oracle locally - Docker is a useful skill in the job market anyway. I was just seeing if this might work as a quick fix.

@abepolk
Copy link
Contributor Author

abepolk commented Jan 24, 2020

I got Oracle to work in a docker container. To return to the JDBC, I am reading on Stack Overflow that it is actually better use the "batch" functionality of PreparedStatement rather than make very long single SQL queries. See, for example: https://stackoverflow.com/questions/4901997/oracle-and-jdbc-performance-insert-all-vs-preparedstatement-addbatch/4909200

Does that sound right? Should I switch to PreparedStatement batches?

@abepolk
Copy link
Contributor Author

abepolk commented Jan 24, 2020

I am currently getting an error when I run databaseTest with the Oracle DB container running saying the following:

  java.sql.SQLSyntaxErrorException: ORA-00955: name is already used by an existing object
      at org.jabref.logic.shared.DBMSProcessorTest.setup(DBMSProcessorTest.java:48)
  Caused by: Error : 955, Position : 13, Sql = CREATE TABLE "ENTRY" ("SHARED_ID" NUMBER NOT NULL, "TYPE" VARCHAR2(255) NULL, "VERSION" NUMBER DEFAULT 1, CONSTRAINT "ENTRY_PK" PRIMARY KEY ("SHARED_ID")), OriginalSql = CREATE TABLE "ENTRY" ("SHARED_ID" NUMBER NOT NULL, "TYPE" VARCHAR2(255) NULL, "VERSION" NUMBER DEFAULT 1, CONSTRAINT "ENTRY_PK" PRIMARY KEY ("SHARED_ID")), Error Msg = ORA-00955: name is already used by an existing object
      at org.jabref.logic.shared.DBMSProcessorTest.setup(DBMSProcessorTest.java:48)

It seems that the tables already exist at the beginning of each test. At least in DBMSProcessorTest, they shouldn't because of TestManager.clearTables(this.dbmsConnection);
Any ideas what is going on? The settings are basically the same as those on the GitHub test, except that I removed .setPort(32188) in TestConnector in order to get it to connect to my container properly.

@abepolk
Copy link
Contributor Author

abepolk commented Jan 26, 2020

I've been working on the issue with dropping tables, and it looks like the PL/SQL statement in TestManager is acting up locally, but not on GitHub CI:

BEGIN
EXECUTE IMMEDIATE 'DROP TABLE "FIELD"';
EXECUTE IMMEDIATE 'DROP TABLE "ENTRY"';
EXECUTE IMMEDIATE 'DROP TABLE "METADATA"';
EXECUTE IMMEDIATE 'DROP SEQUENCE "ENTRY_SEQ"';
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -942 THEN
RAISE;
END IF;
END;

I looked at the Oracle SQL docs, and it looks like this is a statement that drops the three tables if they exist, and if not (SQLCODE is 942) then it ignores the exception. It raises all other exceptions. When I run this block through JabRef and the JDBC it uses, nothing happens, and I get an error later in the tests when it tries to create the "ENTRY" table saying it already exists. Perhaps a 942 exception in dropping "FIELD" is short-circuiting the other table drops? But that still doesn't explain why it works on the GitHub CI.

@tobiasdiez
Copy link
Member

@koppor ideas?

@abepolk
Copy link
Contributor Author

abepolk commented Jan 27, 2020

I figured it out. It works out that because the table drops were all in the same PL/SQL block, when one threw an exception, the other table drops were ignored. I solved this by putting each drop in a separate PL/SQL block so that each one is dropped if it exists, even if previous one threw an exception for not existing. See commit bbc81ab. I also fixed SQL typos in OracleProcessor. The tests now pass on the Oracle DB in my local container. @koppor Can you push this to master and see if the Oracle tests pass now?

@koppor
Copy link
Member

koppor commented Jan 30, 2020

I enabled running the Oracle tests always and pushed to fix_fields_sql in our repo. See https://github.com/JabRef/jabref/actions/runs/33163398 for the tests.

In case there are updates, we can merge your updates to fix_fields_sql in this repository.

As soon as your PR is merged into master, we will delete fix_fields_sql in our repo (as everything is in master)

@koppor
Copy link
Member

koppor commented Feb 19, 2020

Since this touches Oracle only, I'll go ahead for a merge - to keep things going.

@koppor koppor changed the title [WIP] Change syntax for Oracle multi-row insert SQL statement Change syntax for Oracle multi-row insert SQL statement Feb 19, 2020
@koppor koppor merged commit 31a6279 into JabRef:master Feb 19, 2020
Siedlerchr added a commit that referenced this pull request Feb 19, 2020
* upstream/master:
  followup fix
  Fixfetcher (#5948)
  Bump byte-buddy-parent from 1.10.7 to 1.10.8 (#5952)
  Added MenuButtons to IntegrityCheckDialog (#5955)
  Reimplement custom entry types dialog (#5799)
  Bump unirest-java from 3.4.03 to 3.5.00 (#5953)
  MySQL: Allow public key retrieval (#5909)
  Restructure and improve docs for setting up IntelliJ (#5960)
  Change syntax for Oracle multi-row insert SQL statement (#5837)
  Bump classgraph from 4.8.62 to 4.8.64 (#5954)
  Squashed 'src/main/resources/csl-styles/' changes from c531528..9e81857
  Fix not escaping special characters in search pattern (#5938)
Siedlerchr added a commit that referenced this pull request Mar 6, 2020
* upstream/master:
  Try to fix linux pdf opening again (#5945)
  [WIP] Initial work on DBMSProcessor batch entry insertion into ENTRY table (#5814)
  followup fix
  Fixfetcher (#5948)
  Bump byte-buddy-parent from 1.10.7 to 1.10.8 (#5952)
  Added MenuButtons to IntegrityCheckDialog (#5955)
  Reimplement custom entry types dialog (#5799)
  Bump unirest-java from 3.4.03 to 3.5.00 (#5953)
  MySQL: Allow public key retrieval (#5909)
  Restructure and improve docs for setting up IntelliJ (#5960)
  Change syntax for Oracle multi-row insert SQL statement (#5837)
koppor pushed a commit that referenced this pull request Jan 15, 2022
5563ccc Update american-society-for-microbiology.csl (#5842)
19ab80f Merge pull request #5843 from POBrien333/patch-1002
d4a6c6d double trouble
424f7fe in-text >> superscript for T&F ACS style
605253c Merge pull request #5837 from POBrien333/patch-998
eb5417d Merge pull request #5838 from alessandro-gentilini/patch-1
7d2d3f5 Fix typo
9f557b5 Re-indent CSL styles
f587e60 polyglot style
3a3fe2c Create journal-fur-kulturpflanzen-journal-of-cultivated-plants.csl
cb24633 Merge pull request #5826 from dstark/patch-7
2590a6c Merge pull request #5833 from POBrien333/patch-997
5b2481e Create nist-techpubs-jres.csl (#5756)
d2a1a49 Re-indent CSL styles
42c51d1 Update tyndale-bulletin.csl
8dae693 rework style
070586b Localize IEEE dates (#5835)
588fbfe Hopefully fix sorting in CSE author-date (#5834)
1291d72 Update physiotherapy-theory-and-practice.csl
1a64076 New Style for "Neue Kriminalpolitik (Deutsch)" (#5586)
eac93a0 Create physiotherapy-theory-and-practice.csl
2e7a9f6 Merge pull request #5832 from POBrien333/patch-996
4dfad5f Update administrative-science-quarterly.csl
f56db0f Merge pull request #5829 from benthamite/patch-1
526b0b3 Update effective-altruism-wiki.csl
e5b11eb Update effective-altruism-wiki.csl
f2a7301 Update effective-altruism-wiki.csl
5b166c2 Update university-of-roehampton-harvard.csl (#5831)
b231514 Update european-society-of-cardiology.csl (#5519)
dbd902c Re-indent CSL styles
fe8892b Update effective-altruism-wiki.csl
734fa7d Update effective-altruism-wiki.csl
2430a32 Create effective-altruism-wiki.csl
a5101b6 update modern-pathology.csl (#5828)
16f77c8 Update tyndale-bulletin.csl
ea8804e Create the-korean-journal-of-mycology.csl (#5822)
22d8be0 Patch 3 (#5825)
0220ba2 Create jcom.csl (#5819)
cd7b72b Create taylor-and-francis-council-of-science-editors-numeric.csl (#5824)
0033383 Create gomis-senegalese-medicine-thesis.csl (#5774)
b221bcc Create mycobiology.csl (#5821)
d7056f9 Re-indent CSL styles
04ae08b Update tyndale-bulletin.csl
24bd577 Re-indent CSL styles
e08d431 clean up logging
f6ac2a6 Update tyndale-bulletin.csl
e4c07f8 this should be the PR repo name
7f9936c fetch pull request from originating repo
f232f51 Update tyndale-bulletin.csl
e2ae4fc Update tyndale-bulletin.csl
f09f8db Update Sheldon to csl-styles 2.0
a4d7dec re-indent style
a903664 sheldon
7db75fc sheldon
f08dc96 sheldon
35b8bfa sheldon
04e28ca pull req checkout
9c9d061 pull req checkout
9249490 sheldon reindent
9792be6 sheldon reindent
3bced06 reindent & commit
7cc9735 Update styles README and GitHub Actions with 1.0.2 information (#5803)
205c4ea remaining dependents
9458056 fix broken styles
07ba7af fix dependents
e2e7842 Fix term hacks for transition to CSL 1.0.2 (#5801)
5c8c5e9 Replace "sub verbo" with "sub-verbo" (#5799)
7ec637c Fix CSL styles
bcd3054 update to csl/citeproc-ruby 2.0
ec13830 bundle update

git-subtree-dir: buildres/csl/csl-styles
git-subtree-split: 5563ccc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants