-
Notifications
You must be signed in to change notification settings - Fork 964
Support for cockroach db #8662
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
base: master
Are you sure you want to change the base?
Support for cockroach db #8662
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -244,10 +244,10 @@ static struct migration dbmigrations[] = { | |
| {SQL("UPDATE invoices SET pay_index=id WHERE state=1;"), | ||
| NULL}, /* only paid invoice */ | ||
| /* Create next_pay_index variable (highest pay_index). */ | ||
| {SQL("INSERT INTO vars(name, val)" | ||
| {SQL("INSERT INTO vars(name, val)" | ||
| " VALUES('next_pay_index', " | ||
| " COALESCE((SELECT MAX(pay_index) FROM invoices WHERE state=1), 0) " | ||
| "+ 1" | ||
| " CAST(COALESCE((SELECT MAX(pay_index) FROM invoices WHERE state=1), 0) " | ||
| "+ 1 AS TEXT)" | ||
| " );"), | ||
| NULL}, | ||
| /* Create first_block field; initialize from channel id if any. | ||
|
|
@@ -943,7 +943,7 @@ static struct migration dbmigrations[] = { | |
| " in_channel_scid" | ||
| ", COALESCE(" | ||
| " (SELECT channel_htlc_id FROM channel_htlcs WHERE id = forwarded_payments.in_htlc_id)," | ||
| " -_ROWID_" | ||
| " -row_number() OVER ()" | ||
|
Comment on lines
-939
to
+946
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I think you missed the translation layer? See devtools/sql-rewrite.py...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It gets run over all db source files to map anything in a SQL() macro. These get looked up at runtime. |
||
| " )" | ||
| ", out_channel_scid" | ||
| ", (SELECT channel_htlc_id FROM channel_htlcs WHERE id = forwarded_payments.out_htlc_id)" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's super-annoying. Postgres was actually checking our types are correct here (sqlite3 is YOLO), so loosening it is not great.
I wonder if it's best to support a cockroachdb:// db URL, which shares everything except has a different column_int function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a better way to do this, without introducing the specific cockroachdb url.
Using OID, see d584cb9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I really like that you currently have to set a BIGINT for u64 accesses, and be consistent.
Better is to have a separate db/db_cockroachdb.c and share almost all the functions with the postgres one. Hell, you could even put it in the same file.