"PATTERSON,JEFF (A-Sonoma,ex1)" <jeff_patterson@agilent.com> writes:
> I have done an exhaustive (and exhausting) search of the documentation, the
> pg_tables and the Internet and have discovered to my great dismay that there
> appears to be no way of extracting the x and y coordinates from a geometric
> point. If true, this seems to be a singularity surprisingly close to the
> origin for a project as mature as postgreSQL.
Documentation deficiencies are par for the course around here,
particularly in obscure features originally invented at Berkeley :-(.
But a point is a 2-item float8 array, so:
regression=# \d point_tbl
Table "point_tbl"
Column | Type | Modifiers
--------+-------+-----------
f1 | point |
regression=# select f1, f1[0], f1[1] from point_tbl;
f1 | f1 | f1
------------+-----+------
(0,0) | 0 | 0
(-10,0) | -10 | 0
(-3,4) | -3 | 4
(5.1,34.5) | 5.1 | 34.5
(-5,-12) | -5 | -12
(10,10) | 10 | 10
(6 rows)
regression=# update point_tbl set f1[1] = f1[1] + 1;
UPDATE 6
regression=# select f1, f1[0], f1[1] from point_tbl;
f1 | f1 | f1
------------+-----+------
(0,1) | 0 | 1
(-10,1) | -10 | 1
(-3,5) | -3 | 5
(5.1,35.5) | 5.1 | 35.5
(-5,-11) | -5 | -11
(10,11) | 10 | 11
(6 rows)
regression=#
(Note array origin zero, not 1, for historical reasons ...)
regards, tom lane