Become a fan of Slashdot on Facebook


Forgot your password?

Comment Re:I'm somewhat (Score 1) 105

Many RDBMSes allow more than one statement per batch - so you can execute two or more statements in a single round trip. For example you could do 'if exists (blah) ...', assuming your dialect of SQL supports it, in just one round trip, or even separate 'insert where not exists... update...' or whatever technique you want to use. (I am not saying that these techniques are a foolproof alternative to merge or upsert, they are not, but that is for another discussion.) If you have multiple rows, you can still prepare a statement handle and handle them in the same number of round trips it would require for a single insert, or at most one extra round trip for the whole batch. Essentially - the checking for an existing row, even without a merge / update builtin, can usually be done in SQL rather than clunkily by the client app.

Comment Re:I'm curious (Score 1) 105

There is no exact equivalent in traditional SQL. As others have pointed out, you can check exists and then insert, but that introduces a race condition; wrapping it in an explicit transaction might help depending on the locking model, but might still introduce failures that have to be introduced by client code.

That said, if you can make some assumptions about what else is writing to the table then you can get fairly close. One technique I often use is like this:

-- Insert the row if none with the same PK exists.
-- As a single SQL statement, this executes atomically
-- in all but the most braindead DBMSes.
insert into mytable (keycol, datacol)
select 1, 'a'
where not exists (
select 0
from mytable
where keycol = 1

-- OK, now there is definitely a row there with keycol=1.
-- Update the row which exists.
-- This is redundant work if we just inserted it above, but do it anyway.
update mytable
set datacol = 'a'
where keycol = 1

This is clearly not safe in general. If there are others accessing the table and doing general delete, or test-and-set, it can lose data. However, if you know that code like the above is the only code accessing the table, or if you restrict it to the above plus simple inserts, then you have a safe way to insert-or-update a row that doesn't involve holding locks for a period of time and doesn't require an explicit transaction.

Comment Re: Use a larger monitor. (Score 1) 197

It depends on the monitor. Some will let you run at a resolution of exactly half and scale crisply, so that each pixel from the computer becomes a neat square of four pixels on the monitor. Sadly there are too many monitors which generate a blurry mess even when doing an exact integer scaling like this. (From my limited experience older monitors are better than newer in this respect.) Scaling in the video hardware is the same. It's from a misapplied idea that fancy scaling like bicubic is superior to the naive nearest-neighbour. That is true for photographs, but not for input images which are intended to have exact pixel boundaries. My first resort would be to set a font scaling of 200% in the operating system. If running Windows it may help to turn off Aero, so that (as above) you get clean pixel scaling and not blurring.

Comment Re:Voting - how to ensure a secret ballot? (Score 1) 69

You logging into the voting machine is recorded when you vote. Information about who you voted for is not recorded.

And how can you be certain that when the votes are counted, your vote is being included? Having something recorded on the blockchain (or any other public record) doesn't help at all with that; you still have to trust the people counting the votes to count them fairly. Or if the votes are counted by machine, you have to trust those who built and operate the machine. If somebody queries the totals after the election, they can't use the blockchain records to check that the total is correct; conversely it's possible for a malicious actor to stuff ballots without ever recording it in the blockchain.

There are proposals for cryptographic voting systems that work properly. When you vote, your vote is recorded so that you can check that it was counted (and anyone can check that the count includes all votes cast); but you cannot find out or demonstrate what the vote was. This is an interesting area of research but it is a lot more complicated than just saying 'add something to the blockchain'. Doing that by itself adds nothing.

Comment Re:Voting - how to ensure a secret ballot? (Score 1) 69

Having an accurate count that *shows how everybody voted* is not how elections are done. You vote in secret, and nobody else can find out for sure how you voted, not even if you want to show it to them. If all votes are recorded publicly then there is no longer a secret ballot. That's unrelated to having an accurate count of votes, which is obviously important.

Comment Re:Voting - how to ensure a secret ballot? (Score 1) 69

If you had bothered, you'd know that you can sign a message using your private key that proves indeed, that you did something on the blockchain, whether its voting or whatever.

Right. But how do you do that while ensuring a secret ballot? In other words so you *cannot* prove, whether you want to or not, who you voted for?

There are suggested protocols for having a verifiable yet secret ballot, but they are not completely straightforward. Unless the secret ballot part is sorted out properly, recording all votes in a public ledger (be it the blockchain or anything else) doesn't give a free and fair election.

Comment Voting - how to ensure a secret ballot? (Score 2) 69

A lot of electronic voting proposals fail to ensure a secret ballot - which means you *cannot* prove how you voted, whether you want to or not. If votes are published in the blockchain it's hard to see how this would be achieved; although there are cryptographic proposals for voting systems that would let you make sure your vote (and every vote) has been counted without being able to prove which way any individual voted. So for elections I don't think blockchain voting is really going to fly. It would work for situations where the ballot is not secret, like votes in most countries' legislative assemblies, where you can see all the votes cast by each representative. But there, only the true tinfoil hat brigade would see the need for the tamper-proof Bitcoin log, given that the assembly's proceedings are surely part of the public record anyway.
United Kingdom

Huge Ritual Arena Discovered Near Stonehenge 126

New submitter pabloApicco writes: A row of 90 megalithic stones has been found buried beneath a grassy bank only two miles from the world-famous site of Stonehenge in Wiltshire, England. Believed to have been a huge ritual monument, the long line of megalithic stones lies 3 feet underground, and was found using sophisticated radar equipment. “What we are starting to see is the largest surviving stone monument, preserved underneath a bank, that has ever been discovered in Britain and possibly in Europe,” said Vince Gaffney, an archaeologist at Bradford University who leads the Stonehenge Hidden Landscape project. “This is archeology on steroids.” Here's a satellite map of the new site.

Slashdot Top Deals

A method of solution is perfect if we can forsee from the start, and even prove, that following that method we shall attain our aim. -- Leibnitz