pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: bubthegreat@gmail.com
Subject: BUG #15474: Special character escape sequences need better documentation, or more easily found documentation
Date: Wed, 31 Oct 2018 16:25:06 +0000
Message-ID: <15474-a10e03c9efe552f3@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15474
Logged by:          Micheal Taylor
Email address:      bubthegreat@gmail.com
PostgreSQL version: 11.0
Operating system:   Any
Description:        

When looking for postgresql documentation on characters that need to be
escaped, and how to escape them, I consistently get to this page:

https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-SPECIAL-CHARS

That page goes over high levels of escaping numerous things, but in the
special characters and operators, it doesn't clearly show how to escape the
operators or special characters within a more complicated query structure. 
For example, if I have the following table:

            CREATE TABLE IF NOT EXISTS {tablename}
            (
                time        TIMESTAMP,
                case_number VARCHAR(25),
                jira        VARCHAR(25),
                status      VARCHAR(25),
                fqdn        VARCHAR(255),
                subject     TEXT,
                description TEXT,
                comment     TEXT
            )

And the following insertion information:

    INSERT INTO orphans(time, case_number, fqdn, status, subject,
description)
    SELECT '{timestamp}', '{case_number}', '{fqdn}', 'new', '{subject}',
'{description}'
    WHERE
        NOT EXISTS (
            SELECT case_number, status FROM orphans
            WHERE case_number = '{case_number}'
        )

Where all columns inputs are strings, if any of those inputs have special
characters like % or ', it is not clear by quick inspection of the
documentation how to escape those characters.  A simple table elaborating on
the escapes for each special character would be incredibly helpful at
determining how to translate those escapes for cleaning strings prior to
insertion so those of us using postgresql can quickly write cleaning
functions for data.



view thread (8+ messages)  latest in thread

Message-ID: <15474-a10e03c9efe552f3@postgresql.org>
Permalink:  ../15474-a10e03c9efe552f3@postgresql.org/
Also on:    postgresql.org/message-id/15474-a10e03c9efe552f3@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, bubthegreat@gmail.com
  Subject: Re: BUG #15474: Special character escape sequences need better documentation, or more easily found documentation
  In-Reply-To: <15474-a10e03c9efe552f3@postgresql.org>
  References: <15474-a10e03c9efe552f3@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox