string escaping in tutorial/syscat.source

Lists: pgsql-hackers
From: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: string escaping in tutorial/syscat.source
Date: 2012-10-15 03:53:51
Message-ID: CAK3UJREtO1QEi3uRWaaJBg8giOaX8fFCv7vaQoQ5RLhYTOKx5w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi all,
It seems the queries in ./src/tutorial/syscat.source use string
escaping with the assumption that standard_conforming_strings is off,
and thus give wrong results with modern versions. A simple fix is
attached.
Josh

Attachment Content-Type Size
syscat.source_escaping.diff application/octet-stream 3.6 KB

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: string escaping in tutorial/syscat.source
Date: 2013-01-16 01:35:15
Message-ID: CAMkU=1zz8gG=_CK+BU3+NDzTyZ9qwkO4c5kJqkUmz6Z7jBvdmA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Oct 14, 2012 at 8:53 PM, Josh Kupershmidt
<schmiddy(at)gmail(dot)com<javascript:;>>
wrote:
> Hi all,
> It seems the queries in ./src/tutorial/syscat.source use string
> escaping with the assumption that standard_conforming_strings is off,
> and thus give wrong results with modern versions. A simple fix is
> attached.

Hi Josh,

Do you propose back-patching this? You could argue that this is a bug in
9.1 and 9.2. Before that, they generate deprecation warnings, but do not
give the wrong answer.

If it is only to be applied to HEAD, or only to 9.1, 9.2, and HEAD, then
this part seems to be unnecessary and I think should be removed (setting a
value to its default is more likely to cause confusion than remove
confusion):

SET standard_conforming_strings TO on;

and the corresponding reset as well.

Other than that, it does what it says (fix a broken example), does it
cleanly, we want this, and I have no other concerns.

I guess the src/tutorial directory could participate in regression tests,
in which case this problem would have been detected when introduced, but I
don't think I can demand that you invent regression tests for a feature you
are just fixing rather than creating.

Thanks for the patch,

Jeff


From: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: string escaping in tutorial/syscat.source
Date: 2013-01-16 04:54:56
Message-ID: CAK3UJRF9ER2SZbronQ49334TB55QWkjbcf0u2WrJHYacu4Zczw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Jan 15, 2013 at 6:35 PM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:

> Do you propose back-patching this? You could argue that this is a bug in
> 9.1 and 9.2. Before that, they generate deprecation warnings, but do not
> give the wrong answer.

I think that backpatching to 9.1 would be reasonable, though I won't
complain if the fix is only applied to HEAD.

> If it is only to be applied to HEAD, or only to 9.1, 9.2, and HEAD, then
> this part seems to be unnecessary and I think should be removed (setting a
> value to its default is more likely to cause confusion than remove
> confusion):
>
> SET standard_conforming_strings TO on;
>
> and the corresponding reset as well.

Well, it may be unnecessary for people who use the modern default
standard_conforming_strings. But some people have kept
standard_conforming_strings=off in recent versions because they have
old code which depends on this. And besides, it seems prudent to make
the dependency explicit, rather than just hoping the user has the
correct setting, and silently giving wrong results if not. Plus being
able to work with old server versions.

> Other than that, it does what it says (fix a broken example), does it
> cleanly, we want this, and I have no other concerns.
>
> I guess the src/tutorial directory could participate in regression tests, in
> which case this problem would have been detected when introduced, but I
> don't think I can demand that you invent regression tests for a feature you
> are just fixing rather than creating.

Yeah, I don't think tying into the regression tests is warranted here.

Josh


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: string escaping in tutorial/syscat.source
Date: 2013-01-17 01:20:37
Message-ID: CAMkU=1y+9Zks8VPbaA_nmbD6n7xN4Kdx6dGiLDCz7_s3eMxh=A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tuesday, January 15, 2013, Josh Kupershmidt wrote:

> On Tue, Jan 15, 2013 at 6:35 PM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com<javascript:;>>
> wrote:
>
> > Do you propose back-patching this? You could argue that this is a bug in
> > 9.1 and 9.2. Before that, they generate deprecation warnings, but do
> not
> > give the wrong answer.
>
> I think that backpatching to 9.1 would be reasonable, though I won't
> complain if the fix is only applied to HEAD.
>
> > If it is only to be applied to HEAD, or only to 9.1, 9.2, and HEAD, then
> > this part seems to be unnecessary and I think should be removed (setting
> a
> > value to its default is more likely to cause confusion than remove
> > confusion):
> >
> > SET standard_conforming_strings TO on;
> >
> > and the corresponding reset as well.
>
> Well, it may be unnecessary for people who use the modern default
> standard_conforming_strings. But some people have kept
> standard_conforming_strings=off in recent versions because they have
> old code which depends on this.

OK, I didn't anticipate them doing that in their default (i.e.
postgresql.conf) but of course they might do that.

I've marked it ready for committer.

Thanks,

Jeff


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: string escaping in tutorial/syscat.source
Date: 2013-01-19 22:23:19
Message-ID: 2163.1358634199@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Josh Kupershmidt <schmiddy(at)gmail(dot)com> writes:
> It seems the queries in ./src/tutorial/syscat.source use string
> escaping with the assumption that standard_conforming_strings is off,
> and thus give wrong results with modern versions. A simple fix is
> attached.

I tweaked the comments a little bit and committed this as far back
as 9.1. Thanks!

regards, tom lane