aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2006-05-31 11:35:17 +0000
committerBruce Momjian <bruce@momjian.us>2006-05-31 11:35:17 +0000
commitc3c3902611f884bef3f37b95c7a082f6f2b9a238 (patch)
tree15d81db4d1b6261144dd67b0fde0832b43e6932d /doc/src
parenteaca1175e98e937d6b2a9204a53a464fa00d1d56 (diff)
downloadpostgresql-c3c3902611f884bef3f37b95c7a082f6f2b9a238.tar.gz
postgresql-c3c3902611f884bef3f37b95c7a082f6f2b9a238.zip
Support '' for literal ' in psql single-quote strings, documentation update.
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/ref/psql-ref.sgml10
1 files changed, 5 insertions, 5 deletions
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index f00b4c09f6f..13c77595e6b 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.162 2006/05/26 19:51:29 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.163 2006/05/31 11:35:17 momjian Exp $
PostgreSQL documentation
-->
@@ -2262,7 +2262,7 @@ testdb=&gt; <userinput>SELECT * FROM :foo;</userinput>
copy the contents of a file into a table column. First load the file into a
variable and then proceed as above.
<programlisting>
-testdb=&gt; <userinput>\set content '\'' `cat my_file.txt` '\''</userinput>
+testdb=&gt; <userinput>\set content '''' `cat my_file.txt` ''''</userinput>
testdb=&gt; <userinput>INSERT INTO my_table VALUES (:content);</userinput>
</programlisting>
One possible problem with this approach is that <filename>my_file.txt</filename>
@@ -2270,14 +2270,14 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:content);</userinput>
they don't cause a syntax error when the second line is processed. This
could be done with the program <command>sed</command>:
<programlisting>
-testdb=&gt; <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" &lt; my_file.txt` '\''</userinput>
+testdb=&gt; <userinput>\set content '''' `sed -e "s/'/\\\\''/g" &lt; my_file.txt` ''''</userinput>
</programlisting>
Observe the correct number of backslashes (6)! It works
this way: After <application>psql</application> has parsed this
- line, it passes <literal>sed -e "s/'/\\\'/g" &lt; my_file.txt</literal>
+ line, it passes <literal>sed -e "s/'/\\''/g" &lt; my_file.txt</literal>
to the shell. The shell will do its own thing inside the double
quotes and execute <command>sed</command> with the arguments
- <literal>-e</literal> and <literal>s/'/\\'/g</literal>. When
+ <literal>-e</literal> and <literal>s/'/''/g</literal>. When
<command>sed</command> parses this it will replace the two
backslashes with a single one and then do the substitution. Perhaps
at one point you thought it was great that all Unix commands use the