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

Add Oracle backend support #45

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

stevefan1999-personal
Copy link

Well, let's hope that the "generic" interface is really generic enough for Oracle, one of the most egregious database system to date.

I've created this PR for...well you know Oracle offered free autonomous database and I don't want to miss a single opportunity to suck off those bastards. This also means this patch is potentially only for 19c and upwards.

But TBH I think using an ORM is a much better choice if you really want to generalize these cliche database difference. I suggest using GORM, and this could be another PR if I would like to work out the internal structure of this project.

Oh, If this gets patched I will keep on adding it to k3s too. That's actually my ultimate goal.

@stevefan1999-personal
Copy link
Author

I knew I had it coming. The nightmares of dealing with PL/SQL back in the days...are coming back to haunt me here.

On a bright side this thing is kind of working. I was able to get a connection to the autonomous database, but just as I said I ran into SQL issues.

One of the most significant thing here is that you need to replace LIMIT %d to FETCH FIRST %d ROWS ONLY, so I will make it a limit(count int) suffix format function.

And another one is that Oracle Database...doesn't really have a built-in boolean types. While the statement did found out the token "true" to be a BOOLEAN, it was expecting a NUMBER instead, so it is not coerced by default LUL.

I also want to mention that kv.deleted = (0 OR ?) doesn't work in PL/SQL too, but it can be replaced as WHERE kv.deleted = 0 OR kv.deleted = TO_NUMBER(?), well probably due to distributive law. The latter is more closer to ANSI SQL so can we use that instead?

Otherwise I think this is pretty okay.

func setup(db *sql.DB) error {
var str strings.Builder

for _, cmd := range procedureTemplate {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am only lightly versed in oracle's SQL dialect, but why is it necessary to wrap all the queries in a templated procedure wrapper? Is that the only way to keep errors from messing up the connection state or something?

@stevefan1999-personal
Copy link
Author

stevefan1999-personal commented Jul 13, 2020

This could be good. Sadly we don't have a test suite so I can't validate my work

@mortenlj
Copy link
Contributor

Any chance of this moving forward?

Oracle has an Always Free tier in their cloud offering, which includes enough VMs to build a small cluster. They also offer a free Autonomous database, which would be excellent to use as the datastore for k3s, freeing up a VM which would otherwise be used for mysql or postgresql.

@dereknola
Copy link
Contributor

Is this PR still relevant?

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.

None yet

4 participants