Index: doc/src/sgml/ref/psql-ref.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v
retrieving revision 1.162
diff -c -c -r1.162 psql-ref.sgml
*** doc/src/sgml/ref/psql-ref.sgml 26 May 2006 19:51:29 -0000 1.162
--- doc/src/sgml/ref/psql-ref.sgml 29 May 2006 17:49:43 -0000
***************
*** 2262,2268 ****
copy the contents of a file into a table column. First load the file into a
variable and then proceed as above.
! testdb=> \set content '\'' `cat my_file.txt` '\''
testdb=> INSERT INTO my_table VALUES (:content);
One possible problem with this approach is that my_file.txt
--- 2262,2268 ----
copy the contents of a file into a table column. First load the file into a
variable and then proceed as above.
! testdb=> \set content '''' `cat my_file.txt` ''''
testdb=> INSERT INTO my_table VALUES (:content);
One possible problem with this approach is that my_file.txt
***************
*** 2270,2283 ****
they don't cause a syntax error when the second line is processed. This
could be done with the program sed:
! testdb=> \set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\''
Observe the correct number of backslashes (6)! It works
this way: After psql has parsed this
! line, it passes sed -e "s/'/\\\'/g" < my_file.txt
to the shell. The shell will do its own thing inside the double
quotes and execute sed with the arguments
! -e and s/'/\\'/g. When
sed 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
--- 2270,2283 ----
they don't cause a syntax error when the second line is processed. This
could be done with the program sed:
! testdb=> \set content '''' `sed -e "s/'/\\\\''/g" < my_file.txt` ''''
Observe the correct number of backslashes (6)! It works
this way: After psql has parsed this
! line, it passes sed -e "s/'/\\''/g" < my_file.txt
to the shell. The shell will do its own thing inside the double
quotes and execute sed with the arguments
! -e and s/'/''/g. When
sed 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
Index: src/bin/psql/psqlscan.l
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/psqlscan.l,v
retrieving revision 1.18
diff -c -c -r1.18 psqlscan.l
*** src/bin/psql/psqlscan.l 11 May 2006 19:15:35 -0000 1.18
--- src/bin/psql/psqlscan.l 29 May 2006 17:49:50 -0000
***************
*** 861,866 ****
--- 861,868 ----
{quote} { return LEXRES_OK; }
+ {xqdouble} { emit("'", 1); }
+
"\\n" { appendPQExpBufferChar(output_buf, '\n'); }
"\\t" { appendPQExpBufferChar(output_buf, '\t'); }
"\\b" { appendPQExpBufferChar(output_buf, '\b'); }