From 6e4a3e216584a22a0ff3218edd85e30902ad9e2e Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Mon, 20 Jan 2014 17:19:41 +0100 Subject: [PATCH] Fix parsing COPY error message without column information, see issue #22. --- src/pgsql/pgsql.lisp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pgsql/pgsql.lisp b/src/pgsql/pgsql.lisp index b6b9b5c..f6977be 100644 --- a/src/pgsql/pgsql.lisp +++ b/src/pgsql/pgsql.lisp @@ -233,15 +233,14 @@ details about the format, and format specs." ;;; batching splitting in case of errors. ;;; ;;; CONTEXT: COPY errors, line 1, column b: "2006-13-11" +;;; CONTEXT: COPY byte, line 1: "hello\0world" ;;; (defun parse-copy-error-context (context) "Given a COPY command CONTEXT error message, return the batch position where the error comes from." - (let* ((fields (sq:split-sequence #\, context)) - (linepart (second fields)) - (linestr (second (sq:split-sequence #\Space linepart :start 1)))) - ;; COPY command counts from 1 where we index our batch from 0 - (1- (parse-integer linestr)))) + (cl-ppcre:register-groups-bind ((#'parse-integer n)) + ("line (\\d+)" context :sharedp t) + (1- n))) ;;; ;;; The main retry batch function.