[LRUG] Reasons for Postgres

Sam Stokes webstuff-lrug at samstokes.co.uk
Mon Nov 16 17:39:21 PST 2009


Jocke Selin wrote:
> Those commands create and run the SQL for you.

Thanks Jocke, createdb and createuser do look a lot easier to get 
started with!

Mark Blackman wrote:
» ...
> I'd say the key thing about Postgres for me is that it feels very 
> predictable, where MySQL always seemed to surprise me with what felt
> like very odd behaviours and it's never seemed slow. The only genuine
> drawback to Postgres that I've ever found, was more replication 
> technology options for MySQL

Here's one example I'd heard about before, and just tried.

CREATE TABLE badger(foo INT);
INSERT INTO badger(foo) VALUES('2a');
INSERT INTO badger(foo) VALUES('2.5');

In PostgreSQL, both INSERTs fail with "ERROR: invalid input syntax for 
integer".

In MySQL, the first INSERT succeeds with a warning, with foo = 2 (i.e. 
dropping the unparsed input).  The second INSERT succeeds without any 
warning, with foo = 3 (i.e. *rounding* the input).

Silent type coercion?  What is this, Javascript?

More scarily,

CREATE TABLE mushroom(bar VARCHAR(1));
INSERT INTO mushroom(bar) VALUES(10);

PostgreSQL refuses to do the insert.  MySQL does it with a warning... 
setting bar = "1"!

Another annoyance I've had with MySQL is that its TIMESTAMP type 
silently truncates down to 1-second precision.

-- 
Sam



More information about the Chat mailing list