Index: src/bin/psql/input.c =================================================================== RCS file: /cvsroot/pgsql/src/bin/psql/input.c,v retrieving revision 1.47 diff -c -c -r1.47 input.c *** src/bin/psql/input.c 11 Feb 2006 21:55:35 -0000 1.47 --- src/bin/psql/input.c 12 Feb 2006 05:21:55 -0000 *************** *** 26,31 **** --- 26,40 ---- static bool useHistory; char *psql_history; + /* + * Preserve newlines in saved queries by mapping '\n' to NL_IN_HISTORY + * + * It is assumed NL_IN_HISTORY will never be entered by the user + * nor appear inside a multi-byte string. 0x00 is not properly + * handled by the readline routines so it can not be used + * for this purpose. + */ + #define NL_IN_HISTORY 0x01 enum histcontrol { *************** *** 213,219 **** cur_hist; cur_hist = next_history()) for (cur_ptr = cur_hist->line; *cur_ptr; cur_ptr++) if (*cur_ptr == '\n') ! *cur_ptr = '\0'; } static void decode_history() --- 222,228 ---- cur_hist; cur_hist = next_history()) for (cur_ptr = cur_hist->line; *cur_ptr; cur_ptr++) if (*cur_ptr == '\n') ! *cur_ptr = NL_IN_HISTORY; } static void decode_history() *************** *** 224,230 **** for (history_set_pos(0), cur_hist = current_history(); cur_hist; cur_hist = next_history()) for (cur_ptr = cur_hist->line; *cur_ptr; cur_ptr++) ! if (*cur_ptr == '\0') *cur_ptr = '\n'; } --- 233,239 ---- for (history_set_pos(0), cur_hist = current_history(); cur_hist; cur_hist = next_history()) for (cur_ptr = cur_hist->line; *cur_ptr; cur_ptr++) ! if (*cur_ptr == NL_IN_HISTORY) *cur_ptr = '\n'; }