Readit News logoReadit News
postgressomethi commented on An unordered list of things I miss in Go   kokada.capivaras.dev/blog... · Posted by u/todsacerdoti
kbolino · a year ago
Being unable to access struct fields a.b.c without risking a panic sucks (and which caused the panic: a.b or b.c?). There's no remotely ergonomic solution to the problem, because there's no nil-safe struct member operator, there's no ternary operator, and if-statements can't be used as expressions.

This wouldn't be such a problem, since of course you can just "choose" to not use pointer- or interface-typed fields in "your" structs, but as soon as serialization, databases, or other people's APIs are involved, you don't have that "choice" anymore.

In the same vein, being unable to write e.g. &true or &"foo" is annoying too. If I can write &struct{...} why can't I write &true?

postgressomethi · a year ago
I always thought there should be a two-arg overload of new, so you could write new(bool, true) or new(int, 20). Would solve the problem without any trickery.
postgressomethi commented on Nintendo blitzes GitHub with over 8k emulator-related DMCA takedowns   engadget.com/nintendo-bli... · Posted by u/mikhael
dannyw · a year ago
It’s not hardware, it’s encryption and decryption systems.
postgressomethi · a year ago
A Nintendo Switch is a non-hardware decryption system?
postgressomethi commented on Nintendo blitzes GitHub with over 8k emulator-related DMCA takedowns   engadget.com/nintendo-bli... · Posted by u/mikhael
pprotas · a year ago
You are right, it says it right there:

No person shall circumvent a technological measure that effectively controls access to a work protected under this title.

https://www.law.cornell.edu/uscode/text/17/1201

Can the emulators remove the circumvention code to avoid the DMCA takedown?

postgressomethi · a year ago
Could "effectively controls access" be attacked here? The purpose of the hardware is not to control access.
postgressomethi commented on Common DB schema change mistakes in Postgres   postgres.ai/blog/20220525... · Posted by u/thunderbong
hot_gril · a year ago
The most surprising thing about Postgres indexes as a beginner was how UNIQUE indexes can affect the outcomes of concurrent queries because of the additional locking they add. Something like

  INSERT INTO foo (bar) (SELECT max(bar) + 1 FROM foo);
can insert duplicate `bar` values when run concurrently using the default mode, since one xact might not see the new max value created by the other. You might think adding a UNIQUE index would cause the "losing" xact to get constraint errors, but instead both xacts succeed and no longer have a race condition.

postgressomethi · a year ago
> You might think adding a UNIQUE index would cause the "losing" xact to get constraint errors, but instead both xacts succeed and no longer have a race condition.

This is not true. What happens is that the (sub)transaction that loses the race to the index is aborted:

  =# INSERT INTO foo (bar) (SELECT max(bar) + 1 FROM foo);
  ERROR:  duplicate key value violates unique constraint "foo_bar_idx"
  DETAIL:  Key (bar)=(2) already exists.

postgressomethi commented on There has never been a better time to game on Linux   tildes.net/~games/1dcj/th... · Posted by u/PaulHoule
hospitalJail · 2 years ago
I shutter at the idea of using another Windows Operating system.

Imagine booting your computer and having to give an email to login offline.

Then you click on a link and it auto opens through edge, "DO YOU WANT TO IMPORT AND GIVE US YOUR PRIVACY?"

Or imagine you try to uninstall some microsoft app, it doesn't let you, you try to remove it thorugh the registry but the top 10 results on google are outdated with a different windows.

2 hours later, your computer reboots automatically during a windows update. Everything is turned off, you are dealing with autosaves, you re-open your browser and tons of tabs open slowly.

Finally you save some files in your local documents pictures folder, and start getting nagged about not having enough space in OneDrive. No big deal I don't use that. Lets delete OneDrive. Oh my god I lost all of my files.

postgressomethi · 2 years ago
> Imagine booting your computer and having to give an email to login offline.

As much as I hate what modern Windows has become, this is not actually true. If you know the correct sequence of clicks you can avoid this. Not defending this bullshit, though.

postgressomethi commented on How I destroyed the company's DB (a stupid SQL mistake)   zaidesanton.substack.com/... · Posted by u/AntonZ234
postgressomethi · 2 years ago
I'm sorry, I wasn't being clear. Any column meaning "this row is to be ignored for most applications" is an annoying pattern.
postgressomethi · 2 years ago
Ah, now I see I responded to the wrong message.
postgressomethi commented on How I destroyed the company's DB (a stupid SQL mistake)   zaidesanton.substack.com/... · Posted by u/AntonZ234
Karellen · 2 years ago
How does using a timestamp column make querying the database more annoying than using a boolean column? Aren't the places you have to use filters exactly the same either way?
postgressomethi · 2 years ago
I'm sorry, I wasn't being clear. Any column meaning "this row is to be ignored for most applications" is an annoying pattern.
postgressomethi commented on How I destroyed the company's DB (a stupid SQL mistake)   zaidesanton.substack.com/... · Posted by u/AntonZ234
OscarCunningham · 2 years ago
I can't find the original post now, but there's a good suggestion that booleans should usually be timestamps:

UPDATE orders SET deletion_timestamp = CURRENT_TIMESTAMP() WHERE deletion_timestamp IS NULL

postgressomethi · 2 years ago
While that's kind of convenient in a lot of ways, it also makes querying the database really annoying, since you have to remember to add the filtering to every single query or you're screwed. Personally, I wish there was a database-implementation-acknowledged "deleted" flag, which could even expose a "history table"-like interface.
postgressomethi commented on Ways to capture changes in Postgres   blog.sequin.io/all-the-wa... · Posted by u/chuckhend
_acco · 2 years ago
Author here. Good point. For those that are curious, parent is referring to the following situation:

1. Transaction A starts, its before trigger fires, Row 1 has its updated_at timestamp set to 2023-09-22 12:00:01.

2. Transaction B starts a moment later, its before trigger fires, Row 2 has its updated_at timestamp set to 2023-09-22 12:00:02.

3. Transaction B commits successfully.

4. Polling query runs, sees Row 2 as the latest change, and updates its cursor to 2023-09-22 12:00:02.

5. Transaction A then commits successfully.

A simple way to avoid this issue is to not poll close to real-time, as the order is eventually consistent.

Perhaps a more robust suggestion would be to use a sequence? Imagine a new column, `updated_at_idx`, that incremented every time a row was changed.

postgressomethi · 2 years ago
Sequences kind of have the same issue, because you don't know if a gap is because of a rollback or an uncommitted transaction. Though with some logic you can do a pretty good job at this with sequences. And then you're not in the realm of "simple" anymore, at all.
postgressomethi commented on Ways to capture changes in Postgres   blog.sequin.io/all-the-wa... · Posted by u/chuckhend
postgressomethi · 2 years ago
Polling an updated_at column is not robust in its most simple form, as transactions are not guaranteed to commit in that order.

u/postgressomethi

KarmaCake day52April 2, 2021View Original