Re: PostgreSQL Indexing versus MySQL

From: Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my>
To: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
Cc: Chris Fossenier <chris(at)engenuit(dot)com>, "'Jan Wieck'" <JanWieck(at)Yahoo(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL Indexing versus MySQL
Date: 2004-02-18 18:31:47
Message-ID: 5.2.1.1.1.20040219022122.0277da80@mbox.jaring.my
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 10:35 AM 2/18/2004 -0700, scott.marlowe wrote:
>It works, I just like writing things in the most self documenting manner
>possible, since one day somebody else may look at:
>
>select * from test where id='456'
>
>and go, "hey, that's just an int, no need for the quotes" and take them
>out not knowing what they do. cast(456 as int8) is pretty obvious, '456'
>is much more subtle.

Well whenever I see:

select * from test where id=$var

I think "possible SQL injection".

I'd rather see bind variables be used or something similar, and when you
use those, the quotes are automatic.

With your method if the table is altered to int4 or something else, it
won't use the index (unless a postgresql dev adds stuff).

'456'::int8 seems to work too. But I suppose that's a Postgresql-ism.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lee Harr 2004-02-18 19:24:13 cannot use createlang after removing public schema
Previous Message Fernando Alonso Renault 2004-02-18 17:44:03 Re: Adding Functionality