[postgis-users] PostGis introduction doc code block seems wrong....

Bo Victor Thomsen bo.victor.thomsen at gmail.com
Thu Apr 21 12:53:25 PDT 2022


It might have something to do with implicit transactional behaviour, ( 
START TRANSACTION;/commands/; COMMIT).

Anyway, another little tidbit to remember

Med venlig hilsen / Kind regards

Bo Victor Thomsen

Den 21-04-2022 kl. 17:32 skrev Paul Ramsey:
> Well now that you mention it, it does seem funky, and I have no idea what the expected behavour is...
>
> create table foo (old text, new text);
>
> insert into foo (old) values ('1234');
>
> update foo set old = left(old, 2), new = old
> where old = '1234';
>
> select * from foo;
>
> I'm going to go out on a limb and suggest that maybe the values on the right-hand side of the assignment are actually always implicitly from the original record, so in trigger terms, the assignments look like NEW.colname = OLD.colname.
>
> P
>
>
>> On Apr 21, 2022, at 2:12 AM, Bo Victor Thomsen<bo.victor.thomsen at gmail.com>  wrote:
>>
>> Am I the only one that get "semantic itch" looking at the UPDATE expression? I would prefer it like this:
>>
>> UPDATE nyc_neighborhoods
>>    SET geom_invalid = geom,
>>        geom = ST_MakeValid(geom)
>>    WHERE NOT ST_IsValid(geom);
>> where you save the original "geom" value into another column "geom_invalid" before rectifying it and saving it into the original column.
>>
>> Disclaimer: I have no clue about the internal methods of the SQL interpreter and how and in which order it assigns values.
>>
>> Med venlig hilsen / Kind regards
>>
>> Bo Victor Thomsen
>>
>> Den 20-04-2022 kl. 16:59 skrev Regina Obe:
>>> Thanks for the errata.  Corrected now.
>>>   
>>> From: postgis-users [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Jian He
>>> Sent: Wednesday, April 20, 2022 5:12 AM
>>> To: PostGIS Users Discussion<postgis-users at lists.osgeo.org>
>>> Subject: [postgis-users] PostGis introduction doc code block seems wrong....
>>>   
>>>   
>>> 23. Validity — Introduction to PostGIS
>>> last code block,
>>> -- Fix invalid and save the original
>>> UPDATE nyc_neighborhoods
>>>    SET geom = ST_MakeValid(geom),
>>>        invalid_geom = geom
>>>    WHERE NOT ST_IsValid(geom);
>>>   
>>> I think it should be:
>>> -- Fix invalid and save the original
>>> UPDATE nyc_neighborhoods
>>>    SET geom = ST_MakeValid(geom),
>>>        geom_invalid = geom
>>>
>>>    
>>> WHERE NOT ST_IsValid(geom);
>>>   
>>>
>>>
>>> _______________________________________________
>>> postgis-users mailing list
>>>
>>> postgis-users at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20220421/952ae22f/attachment.html>


More information about the postgis-users mailing list