From bcaabc5698f6b81a990f1bb7cfa3a6bb9583d03e Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 14 Dec 1999 00:08:21 +0000 Subject: Depending on my interpreting (and programming) skills, this might solve anywhere from zero to two TODO items. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Allow flag to control COPY input/output of NULLs I got this: COPY table .... [ WITH NULL AS 'string' ] which does what you'd expect. The default is \N, otherwise you can use empty strings, etc. On Copy In this acts like a filter: every data item that looks like 'string' becomes a NULL. Pretty straightforward. This also seems to be related to * Make postgres user have a password by default If I recall this discussion correctly, the problem was actually that the default password for the postgres (or any) user is in fact "\N", because of the way copy is used. With this change, the file pg_pwd is copied out with nulls as empty strings, so if someone doesn't have a password, the password is just '', which one would expect from a new account. I don't think anyone really wants a hard-coded default password. Peter Eisentraut Sernanders väg 10:115 --- doc/src/sgml/ref/copy.sgml | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml index 3653ae9ef60..adbaa4c8e91 100644 --- a/doc/src/sgml/ref/copy.sgml +++ b/doc/src/sgml/ref/copy.sgml @@ -1,5 +1,5 @@ @@ -20,15 +20,17 @@ Postgres documentation - 1999-07-20 + 1999-12-11 COPY [ BINARY ] table [ WITH OIDS ] FROM { 'filename' | stdin } [ [USING] DELIMITERS 'delimiter' ] + [ WITH NULL AS 'null string' ] COPY [ BINARY ] table [ WITH OIDS ] TO { 'filename' | stdout } [ [USING] DELIMITERS 'delimiter' ] + [ WITH NULL AS 'null string' ] @@ -104,6 +106,25 @@ COPY [ BINARY ] table [ WITH OIDS ] + + + null print + + + A string to represent NULL values. The default is + \N (backslash-N), for historical + reasons. You might prefer an empty string, for example. + + + + On a copy in, any data item that matches this string will be stored as + a NULL value, so you should make sure that you use the same string + as you used on copy out. + + + + + @@ -287,15 +308,16 @@ ERROR: reason encountered before this special end-of-file pattern is found. - The backslash character has other special meanings. NULL attributes are - represented as "\N". A literal backslash character is represented as two + The backslash character has other special meanings. A literal backslash + character is represented as two consecutive backslashes ("\\"). A literal tab character is represented as a backslash and a tab. A literal newline character is represented as a backslash and a newline. When loading text data not generated by Postgres, you will need to convert backslash characters ("\") to double-backslashes ("\\") to ensure that they are loaded - properly. + properly. (The sequence "\N" will always be interpreted as a backslash and + an "N", for compatibility. The more general solution is "\\N".) -- cgit v1.2.3