[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] PostGis introduction doc code block seems wrong....
From:       Bo Victor Thomsen <bo.victor.thomsen () gmail ! com>
Date:       2022-04-21 19:53:25
Message-ID: 5b7fa4e1-2627-4b74-24c5-71081bbf4009 () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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@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@lists.osgeo.org] On Behalf Of \
> > >                 Jian He
> > > Sent: Wednesday, April 20, 2022 5:12 AM
> > > To: PostGIS Users Discussion<postgis-users@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@lists.osgeo.org
> > > https://lists.osgeo.org/mailman/listinfo/postgis-users
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users@lists.osgeo.org
> > https://lists.osgeo.org/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> postgis-users@lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users


[Attachment #5 (text/html)]

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>It might have something to do with implicit transactional
      behaviour, ( START TRANSACTION;<i> commands</i>; COMMIT).</p>
    <p>Anyway, another little tidbit to remember   <br>
    </p>
    <pre class="moz-signature" cols="72">Med venlig hilsen / Kind regards

Bo Victor Thomsen</pre>
    <div class="moz-cite-prefix">Den 21-04-2022 kl. 17:32 skrev Paul
      Ramsey:<br>
    </div>
    <blockquote type="cite"
      cite="mid:3DA049FF-B46E-41E4-8553-13EC0DE7CD65@cleverelephant.ca">
      <pre class="moz-quote-pre" wrap="">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


</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">On Apr 21, 2022, at 2:12 AM, Bo Victor \
Thomsen <a class="moz-txt-link-rfc2396E" \
href="mailto:bo.victor.thomsen@gmail.com">&lt;bo.victor.thomsen@gmail.com&gt;</a> \
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:
</pre>
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">Thanks for the errata.  Corrected now.
 
From: postgis-users [<a class="moz-txt-link-freetext" \
href="mailto:postgis-users-bounces@lists.osgeo.org">mailto:postgis-users-bounces@lists.osgeo.org</a>] \
                On Behalf Of Jian He
Sent: Wednesday, April 20, 2022 5:12 AM
To: PostGIS Users Discussion <a class="moz-txt-link-rfc2396E" \
                href="mailto:postgis-users@lists.osgeo.org">&lt;postgis-users@lists.osgeo.org&gt;</a>
                
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

<a class="moz-txt-link-abbreviated" \
href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a> <a \
class="moz-txt-link-freetext" \
href="https://lists.osgeo.org/mailman/listinfo/postgis-users">https://lists.osgeo.org/mailman/listinfo/postgis-users</a>
 </pre>
        </blockquote>
        <pre class="moz-quote-pre" \
wrap="">_______________________________________________ postgis-users mailing list
<a class="moz-txt-link-abbreviated" \
href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a> <a \
class="moz-txt-link-freetext" \
href="https://lists.osgeo.org/mailman/listinfo/postgis-users">https://lists.osgeo.org/mailman/listinfo/postgis-users</a>
 </pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" \
href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a> <a \
class="moz-txt-link-freetext" \
href="https://lists.osgeo.org/mailman/listinfo/postgis-users">https://lists.osgeo.org/mailman/listinfo/postgis-users</a>
 </pre>
    </blockquote>
  </body>
</html>



_______________________________________________
postgis-users mailing list
postgis-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic