"=" or ":=" ?

Started by BERTRAND Joëlabout 18 years ago5 messagesgeneral
Jump to latest
#1BERTRAND Joël
joel.bertrand@systella.fr

Hello,

I'm trying to optimize assign_vertex_id() function provided by
pgRouting/PostGIS. In this function, I can see :

DECLARE
points record;
i record;
source_id int;
target_id int;
pre varchar;
post varchar;

srid integer;

BEGIN

BEGIN
DROP TABLE vertices_tmp;
EXCEPTION
WHEN UNDEFINED_TABLE THEN
END;

EXECUTE 'CREATE TABLE vertices_tmp (id serial)';

FOR i IN EXECUTE 'SELECT srid FROM geometry_columns WHERE
f_table_name='''|| quote_ident(geom_table)||'''' LOOP
END LOOP;

srid := i.srid;

EXECUTE 'SELECT addGeometryColumn(''vertices_tmp'', ''the_geom'',
'||srid||', ''POINT'', 2)';

CREATE INDEX vertices_tmp_idx ON vertices_tmp USING
GIST (the_geom);

pre = '';
post = '';

I don't understand last assignations. In pgsql documentation, ther is
written that all assignations have to be written with ":=", not with
"=". What is the difference between "=" and ":=" ? I don't find any
information about "=".

Regards,

JKB

#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: BERTRAND Joël (#1)
Re: "=" or ":=" ?

BERTRAND Jo�l wrote:

I don't understand last assignations. In pgsql documentation, ther is
written that all assignations have to be written with ":=", not with
"=". What is the difference between "=" and ":=" ? I don't find any
information about "=".

It's exactly the same. := is the documented way, but = is also
accepted and behaves identically.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: BERTRAND Joël (#1)
Re: "=" or ":=" ?

=?ISO-8859-1?Q?BERTRAND_Jo=EBl?= <joel.bertrand@systella.fr> writes:

What is the difference between "=" and ":=" ?

None; plpgsql accepts either for assignment.

regards, tom lane

#4BERTRAND Joël
joel.bertrand@systella.fr
In reply to: Tom Lane (#3)
Re: "=" or ":=" ?

Tom Lane wrote:

=?ISO-8859-1?Q?BERTRAND_Jo=EBl?= <joel.bertrand@systella.fr> writes:

What is the difference between "=" and ":=" ?

None; plpgsql accepts either for assignment.

Thank you for your answer. I suggest to add a note in documentation ;-)

Regards,

JKB

#5Jeff Davis
pgsql@j-davis.com
In reply to: BERTRAND Joël (#4)
Re: "=" or ":=" ?

On Thu, 2008-02-28 at 20:11 +0100, BERTRAND Joël wrote:

Tom Lane wrote:

=?ISO-8859-1?Q?BERTRAND_Jo=EBl?= <joel.bertrand@systella.fr> writes:

What is the difference between "=" and ":=" ?

None; plpgsql accepts either for assignment.

Thank you for your answer. I suggest to add a note in documentation ;-)

I think that it is undocumented on purpose.

"=" in SQL is generally for testing equality, and having one operator
mean two completely different things can be confusing. Therefore, ":="
is encouraged.

Regards,
Jeff Davis