Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zcztc-0001P6-IY for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Sep 2015 17:56:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zcztc-0001PK-4G for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Sep 2015 17:56:28 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zczsx-0008Gy-EI for pgsql-bugs@postgresql.org; Fri, 18 Sep 2015 17:55:47 +0000 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Zczst-00012a-7b for pgsql-bugs@postgresql.org; Fri, 18 Sep 2015 17:55:45 +0000 Received: by wicgb1 with SMTP id gb1so42291272wic.1 for ; Fri, 18 Sep 2015 10:55:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; bh=+XYrc+JiwlEHiOIiZnEnpOUQt/jFL2AC55eK50G56QQ=; b=fhvtZrmx4jLweBiz0jmA2l9t6pV+6hf1e29E4faigZYzR/ZMtw0jvaOcUOH3W2QWhz 5bE2pBYAh63FpQkHGG6xL0cJq92M7laAxzvnGCmOLGSZ73hq0t267BM+Ag7G92KtA0LH chiOZ/FtDY2we9ordXIK1trfYAchqf/Z12bRYkvmj9yEpDTz+Ezr4ZoHyZf8LM8DwP8L cFILaopXIRq7XEDQGIgb+L7seTxEgfoIfjIJjvvdNJ7V7fG7qCzEMKzb9/DROsDvEH+W dQIq8cQOhzdo/pNR+Jl/xRJrGQXQkpbsXMoKua6qq5Loa9oSoCQprD685B4Ci692GSEO 9BWw== X-Received: by 10.180.211.10 with SMTP id my10mr18310409wic.84.1442598941423; Fri, 18 Sep 2015 10:55:41 -0700 (PDT) Received: from [192.168.1.110] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by smtp.gmail.com with ESMTPSA id cx3sm9990354wjc.27.2015.09.18.10.55.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Sep 2015 10:55:40 -0700 (PDT) Message-ID: <55FC501A.5000409@iki.fi> Date: Fri, 18 Sep 2015 20:55:38 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: Michael Paquier , Amit Kapila CC: Oleksandr Shulgin , Tom Lane , Pg Bugs Subject: Re: PQexec() hangs on OOM References: <547480DE.4040408@vmware.com> <5596B924.6020307@iki.fi> <559AB74A.6070602@iki.fi> <559BF7D6.1070906@iki.fi> In-Reply-To: Content-Type: multipart/mixed; boundary="------------000502070604010802070408" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is a multi-part message in MIME format. --------------000502070604010802070408 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit On 09/14/2015 04:36 AM, Michael Paquier wrote: > On Sat, Sep 12, 2015 at 6:11 PM, Amit Kapila wrote: >> On Mon, Sep 7, 2015 at 1:40 PM, Michael Paquier >> wrote: >>> >>> On Sat, Sep 5, 2015 at 9:45 PM, Amit Kapila >>> wrote: >>> >>> Now, to move into the serious things... >>> >>> + /* >>> + * Advance inStart to show that the copy related message has been >>> + * processed. >>> + */ >>> + conn->inStart = conn->inCursor; >>> This change... >>> >>> + /* getCopyStart() moves >>> inStart itself */ >>> conn->asyncStatus = >>> PGASYNC_COPY_IN; >>> - break; >>> + continue; >>> ... And this change are risky for a backpatch. And they actually >>> break the existing replication protocol > > First, many thanks for providing your input! I am really looking > forward into fixing those problems appropriately. > >> Can you please explain how will it break replication protocol? >> I have done the required handling for Copy Both mode as well in attached >> patch similar to what was done for other Copy modes in previous patch. >> Check if you still find it as broken for replication? > > When not enough data has been received from the server, it seems that > we should PQclear the existing result, and leave immediately > pqParseInput3 with the status PGASYNC_BUSY to be able to wait for more > data. Your patch, as-is, is breaking that promise (and this comes from > the first versions of my patches). It seems also that we should not > write an error message on connection in this case to be consistent in > the behavior of back-branches. For the OOM case, we definitely need to > take the error code path though, as your patch is correctly doing, and > what mine legendary failed to do. > > + if (pqGetInt(&result->numAttributes, 2, conn)) > + { > + errmsg = libpq_gettext("extraneous data in COPY start message"); > + goto advance_and_error; > + } > Here an error message is not needed, and this message should have been > formulated as "insufficient data in blah" either way. > >> I have only kept the changes for COPY modes, so that once we settle on >> those, I think similar changes could be done for getParamDescriptions() > > Yeah, I looked into this one as well, resulting in patch 0002 > attached. In this case we have the advantage to only receive data from > the server, so pqPrepareAsyncResult is handling the failure just fine. > Attached as well is the test case I used (similar to previous one, > just extended a bit to report the error message), after getting the > result from PQsendDescribePrepared, PQresultStatus is set correctly on > error and reports "out of memory" to the user. What do you think about > it? Patches 0001 and 0002 look good to me. Two tiny nitpicks: > --- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c > +++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c > @@ -445,6 +445,7 @@ libpqrcv_PQexec(const char *query) > if (PQresultStatus(lastResult) == PGRES_COPY_IN || > PQresultStatus(lastResult) == PGRES_COPY_OUT || > PQresultStatus(lastResult) == PGRES_COPY_BOTH || > + PQresultStatus(lastResult) == PGRES_FATAL_ERROR || > PQstatus(streamConn) == CONNECTION_BAD) > break; > } Is this really needed? AFAICS, the loop will terminate on PGRES_FATAL_ERROR too. Without this patch, it will always return the last result from the query, whether or not it was an error result. With this patch, it will return the first error encountered, or last non-error result if there is no error. In practice, there is no difference because we don't expect multiple results from the server. > @@ -1343,31 +1348,33 @@ getNotify(PGconn *conn) > * parseInput already read the message type and length. > */ > static int > -getCopyStart(PGconn *conn, ExecStatusType copytype) > +getCopyStart(PGconn *conn, ExecStatusType copytype, int msgLength) > { > PGresult *result; > int nfields; > int i; > + const char *errmsg = NULL; > > result = PQmakeEmptyPGresult(conn, copytype); > if (!result) > - goto failure; > + goto advance_and_error; > > if (pqGetc(&conn->copy_is_binary, conn)) > - goto failure; > + goto not_enough_data; > result->binary = conn->copy_is_binary; > + > /* the next two bytes are the number of fields */ > - if (pqGetInt(&(result->numAttributes), 2, conn)) > - goto failure; > + if (pqGetInt(&result->numAttributes, 2, conn)) > + goto not_enough_data; > nfields = result->numAttributes; > > /* allocate space for the attribute descriptors */ > - if (nfields > 0) > + if (result && nfields > 0) 'result' is never NULL here, so the NULL test is still not needed. The 0003 patch also looks OK to me as far as it goes. I feel that some more refactoring would be in order, though. There are still many different styles for handling a command: sometimes it's done inline in the case-statement, sometimes it calls out to a separate function. Sometimes the function moves inStart, sometimes it does not. On error (e.g. short message), sometimes the function returns 'false', sometimes it sets an error message itself. Patches 0001 and 0002 look small enough that we probably could backpatch them, so that would leave 0003 as a optional master-only cleanup. I spent some time writing a regression test for this. This is pretty difficult to test otherwise, and it's a good candidate for automated, exchaustive testing. The only difficulty is injecting the malloc() failures in a cross-platform way. I ended up with a glibc-only solution that uses glibc's malloc() hooks. Other alternatives I considered were Linux-specific LD_PRELOAD, GNU ld specific -wrap option. One cross-platform solution would be to #define malloc() and friends to wrapper functions, and compile a special version of libpq. Anyway, I came up with the attached test program. It hangs without your fixes, and works with the patches applied. Thoughts? - Heikki --------------000502070604010802070408 Content-Type: text/x-diff; name="0001-Initial-version-of-libpq-mallocfail-tester.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Initial-version-of-libpq-mallocfail-tester.patch" From f83b781b86e65263890cbe58347063cc1ceabcde Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 18 Sep 2015 14:17:13 +0300 Subject: [PATCH 1/1] Initial version of libpq mallocfail tester --- src/interfaces/libpq/test/Makefile | 11 +- src/interfaces/libpq/test/mallocfail.c | 83 ++++++++ src/interfaces/libpq/test/mallocfail.h | 23 ++ src/interfaces/libpq/test/oom-test.c | 377 +++++++++++++++++++++++++++++++++ 4 files changed, 493 insertions(+), 1 deletion(-) create mode 100644 src/interfaces/libpq/test/mallocfail.c create mode 100644 src/interfaces/libpq/test/mallocfail.h create mode 100644 src/interfaces/libpq/test/oom-test.c diff --git a/src/interfaces/libpq/test/Makefile b/src/interfaces/libpq/test/Makefile index ab41dc3..92fbf7f 100644 --- a/src/interfaces/libpq/test/Makefile +++ b/src/interfaces/libpq/test/Makefile @@ -9,14 +9,23 @@ endif override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) override LDLIBS := $(libpq_pgport) $(LDLIBS) -PROGS = uri-regress +PROGS = uri-regress oom-test all: $(PROGS) +# The malloc hooks in glibc are marked as deprecated. We want to use them +# anyway, the alternatives are much more complicated, so just silence the +# warnings. +mallocfail.o: CPPFLAGS := -Wno-deprecated-declarations + +oom-test$(X): mallocfail.o + installcheck: all SRCDIR='$(top_srcdir)' SUBDIR='$(subdir)' \ $(PERL) $(top_srcdir)/$(subdir)/regress.pl clean distclean maintainer-clean: rm -f $(PROGS) + rm -f mallocfail.o oom-test.o + rm uri-regress.o rm -f regress.out regress.diff diff --git a/src/interfaces/libpq/test/mallocfail.c b/src/interfaces/libpq/test/mallocfail.c new file mode 100644 index 0000000..e327e9c --- /dev/null +++ b/src/interfaces/libpq/test/mallocfail.c @@ -0,0 +1,83 @@ +/* + * mallocfail.c + * Helper functions for simulating malloc() failures. + * + * This uses glibc-specific malloc hooks to hijack calls to malloc(). + * Call mallocfail_init() to initialize. After that, this module will call + * a function called "mallocfail_callback" on every malloc() call, which must + * be defined elsewhere. If the callback returns 1, we return NULL to the + * caller of malloc(), otherwise we let the allocation to succeed (the libc + * libc malloc() call might still fail if you get a genuine out-of-memory + * error). + * + * Portions Copyright (c) 2015, PostgreSQL Global Development Group + * + * IDENTIFICATION + * src/interfaces/libpq/test/mallocfail.c + */ + +#include +#include +#include +#include + +#include + +#include "mallocfail.h" + +static void *(*orig_malloc) (size_t size, const void *caller); +static void *(*orig_realloc) (void *ptr, size_t size, const void *caller); + +static void *mallocfail_malloc(size_t size, const void *caller); +static void *mallocfail_realloc(void *ptr, size_t size, const void *caller); + +static void * +mallocfail_malloc(size_t size, const void *caller) +{ + void *result; + + if (mallocfail_callback("malloc")) + return NULL; + + /* restore original hooks */ + __malloc_hook = orig_malloc; + __realloc_hook = orig_realloc; + + result = malloc(size); + + /* restore myself */ + __malloc_hook = mallocfail_malloc; + __realloc_hook = mallocfail_realloc; + + return result; +} + +static void * +mallocfail_realloc(void *ptr, size_t size, const void *caller) +{ + void *result; + + if (mallocfail_callback("realloc")) + return NULL; + + /* restore original hooks */ + __malloc_hook = orig_malloc; + __realloc_hook = orig_realloc; + + result = realloc(ptr, size); + + /* restore myself */ + __malloc_hook = mallocfail_malloc; + __realloc_hook = mallocfail_realloc; + + return result; +} + +void +mallocfail_init(void) +{ + orig_malloc = __malloc_hook; + orig_realloc = __realloc_hook; + __malloc_hook = mallocfail_malloc; + __realloc_hook = mallocfail_realloc; +} diff --git a/src/interfaces/libpq/test/mallocfail.h b/src/interfaces/libpq/test/mallocfail.h new file mode 100644 index 0000000..727bf7e --- /dev/null +++ b/src/interfaces/libpq/test/mallocfail.h @@ -0,0 +1,23 @@ +/*------------------------------------------------------------------------- + * + * mallocfail.h + * + * Definitions for malloc() out-of-memory simulation + * + * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/interfaces/libpq/test/mallocfail.h + * + *------------------------------------------------------------------------- + */ +#ifndef MALLOCFAIL_H +#define MALLOCFAIL_H + +/* defined in mallocfail.c */ +extern void mallocfail_init(void); + +/* defined in oomtest.c */ +extern int mallocfail_callback(const char *funcname); + +#endif /* MALLOCFAIL_H */ diff --git a/src/interfaces/libpq/test/oom-test.c b/src/interfaces/libpq/test/oom-test.c new file mode 100644 index 0000000..fd40ee9 --- /dev/null +++ b/src/interfaces/libpq/test/oom-test.c @@ -0,0 +1,377 @@ +/* + * oom-test.c + * A test program for libpq behaviour on out-of-memory + * + * This relies on a mechanism to intercept malloc() calls, see mallocfail.c. + * The intercepter must call our mallocfail_callback() function for every + * intercepted malloc() call, which will decide whether to let the call + * to succeed. + * + * Portions Copyright (c) 2012-2015, PostgreSQL Global Development Group + * + * IDENTIFICATION + * src/interfaces/libpq/test/oom-test.c + */ +#include + +#include "c.h" + +#include "mallocfail.h" + +/* A global variable that counts malloc() calls issued so far */ +static int malloc_counter = 0; +static bool mallocfail_enabled = false; + +/* If non-zero, cause this allocation to fail. */ +static int malloc_fail_at = 0; + +/* + * Checks that a result set looks correct. We know exactly what the result sets + * used in these tests should look like; two rows and two columns: + * + * foo1 foo2 + * bar1 bar2 + */ +static bool +check_result_set(PGresult *res) +{ + /* + * If the result is not correct, print it out to stderr for debugging. + */ + if (PQntuples(res) != 2 || PQnfields(res) != 2 || + strcmp(PQgetvalue(res, 0, 0), "foo1") != 0 || + strcmp(PQgetvalue(res, 0, 1), "foo2") != 0 || + strcmp(PQgetvalue(res, 1, 0), "bar1") != 0 || + strcmp(PQgetvalue(res, 1, 1), "bar2") != 0) + { + int row, + col; + + fprintf(stderr, "unexpected result set with %d rows and %d cols:\n", + PQntuples(res), PQnfields(res)); + for (row = 0; row < PQntuples(res); row++) + { + for (col = 0; col < PQnfields(res); col++) + { + if (col > 0) + fprintf(stderr, "\t"); + fprintf(stderr, "%s", PQgetvalue(res, row, col)); + } + fprintf(stderr, "\n"); + } + return FALSE; + } + else + { + printf("Got correct result set\n"); + return TRUE; + } +} + +/* + * Check that a result indicates an out-of-memory error (and not some + * other kind of error). + */ +static bool +check_error_is_oom(const char *funcname, PGresult *res) +{ + char *errmsg = PQresultErrorMessage(res); + + /* XXX: This won't work with non-English locale. */ + if (strncmp(errmsg, "out of memory", strlen("out of memory")) == 0) + { + /* got "out of memory", that's OK. */ + printf("%s failed with OOM: %s\n", funcname, errmsg); + return TRUE; + } + else + { + /* any other error is not expected */ + fprintf(stderr, "%s returned error: %s\n", funcname, errmsg); + return FALSE; + } +} + +/* + * Test functions. + * + * The test driver, main/run_tests will call these repeatedly, with the + * malloc hook set up to fail at some calls. + */ + +/* Test PQexec() */ +static bool +test_PQexec(PGconn *conn) +{ + PGresult *res; + bool success; + + mallocfail_enabled = true; + res = PQexec(conn, "values ('foo1', 'foo2'), ('bar1', 'bar2')"); + mallocfail_enabled = false; + + /* + * There are two valid outcomes: 1. success 2. Ran out of memory + */ + if (PQresultStatus(res) == PGRES_TUPLES_OK) + success = check_result_set(res); + else if (PQresultStatus(res) == PGRES_FATAL_ERROR) + success = check_error_is_oom("PQexec", res); + else + { + fprintf(stderr, "PQexec returned unexpected result status: %s\n", + PQresStatus(PQresultStatus(res))); + success = FALSE; + } + + PQclear(res); + + return success; +} + + +/* Test PQprepare() + PQdescribePrepared() + PQexec */ +static bool +test_PQprepare(PGconn *conn) +{ + PGresult *res; + bool success = TRUE; + char *param = "foo1"; + + /* 1. Call PQPrepare() to prepare an unnamed statement */ + mallocfail_enabled = true; + res = PQprepare(conn, "", + "values ($1, 'foo2'), ('bar1', 'bar2')", 1, NULL); + mallocfail_enabled = false; + + if (PQresultStatus(res) == PGRES_FATAL_ERROR) + success = check_error_is_oom("PQprepare", res); + else if (PQresultStatus(res) != PGRES_COMMAND_OK) + { + fprintf(stderr, "PQprepare returned unexpected result status: %s\n", + PQresStatus(PQresultStatus(res))); + success = FALSE; + } + PQclear(res); + + if (!success) + return FALSE; + + /* 2. Call PQdescribePrepared */ + mallocfail_enabled = true; + res = PQdescribePrepared(conn, ""); + mallocfail_enabled = false; + + if (PQresultStatus(res) == PGRES_FATAL_ERROR) + success = check_error_is_oom("PQdescribePrepared", res); + else if (PQresultStatus(res) != PGRES_COMMAND_OK) + { + fprintf(stderr, "PQdescribePrepared returned unexpected result status: %s\n", + PQresStatus(PQresultStatus(res))); + success = FALSE; + } + PQclear(res); + + if (!success) + return FALSE; + + + /* 2. Call PQexecPrepared */ + mallocfail_enabled = true; + res = PQexecPrepared(conn, "", 1, (const char *const *) ¶m, NULL, NULL, 0); + mallocfail_enabled = false; + + if (PQresultStatus(res) == PGRES_TUPLES_OK) + success = check_result_set(res); + else if (PQresultStatus(res) == PGRES_FATAL_ERROR) + success = check_error_is_oom("PQexecPrepared", res); + else + { + fprintf(stderr, "PQexecPrepared returned unexpected result status: %s\n", + PQresStatus(PQresultStatus(res))); + success = FALSE; + } + PQclear(res); + + if (!success) + return FALSE; + + + return success; +} + + +/* Test COPY FROM STDIN */ +static bool +test_COPY_FROM(PGconn *conn) +{ + PGresult *res; + bool success; + static bool table_created = false; + char *rowdata[2] = { "foo1\t\foo2\n", "bar1\tbar2\n" }; + int rc; + int i; + + if (!table_created) + { + res = PQexec(conn, "CREATE TEMPORARY TABLE copytest (col1 text, col2 text) ON COMMIT DELETE ROWS"); + if (PQresultStatus(res) != PGRES_COMMAND_OK) + { + fprintf(stderr, "failed to create temporary table: %s", + PQerrorMessage(conn)); + return false; + } + table_created = true; + } + + mallocfail_enabled = true; + res = PQexec(conn, "COPY copytest FROM STDIN"); + mallocfail_enabled = false; + if (PQresultStatus(res) != PGRES_COPY_IN) + { + fprintf(stderr, "unexpected result for COPY FROM STDIN: %s", + PQerrorMessage(conn)); + return false; + } + + mallocfail_enabled = true; + for (i = 0; i < 2; i++) + { + rc = PQputCopyData(conn, rowdata[i], strlen(rowdata[i])); + if (rc == -1) + { + mallocfail_enabled = false; + fprintf(stderr, "PQputCopyData failed: %s\n", PQerrorMessage(conn)); + return false; + } + } + + rc = PQputCopyEnd(conn, NULL); + mallocfail_enabled = false; + if (rc == -1) + { + fprintf(stderr, "PQputCopyEnd failed: %s\n", PQerrorMessage(conn)); + return false; + } + + mallocfail_enabled = true; + res = PQgetResult(conn); + mallocfail_enabled = false; + + /* + * There are two valid outcomes: 1. success 2. Ran out of memory + */ + if (PQresultStatus(res) == PGRES_COMMAND_OK) + success = true; + else if (PQresultStatus(res) == PGRES_FATAL_ERROR) + success = check_error_is_oom("PQexec", res); + else + { + fprintf(stderr, "PQexec returned unexpected result status: %s\n", + PQresStatus(PQresultStatus(res))); + success = false; + } + + PQclear(res); + + return success; +} + +/* + * This function needs to be called for every malloc() call. It decides + * whether the call should be let to succeed, or we should simulate OOM and + * return NULL to the caller. + */ +int +mallocfail_callback(const char *func) +{ + if (!mallocfail_enabled) + return 0; + + malloc_counter++; + if (malloc_counter == malloc_fail_at) + { + printf("%s failing: %d!\n", func, malloc_counter); + return 1; + } + else + { + printf("%s called: %d\n", func, malloc_counter); + return 0; + } +} + +/* + * Run a test function multiple times. In each iteration, cause one malloc() + * call to fail. + */ +static void +run_testfunc(PGconn *conn, const char *testname, bool (*testfunc) (PGconn *conn)) +{ + int i; + int nmallocs; + + /* + * Run the test once without any malloc() failures, to count the number of + * malloc() calls it makes when run normally. + */ + malloc_counter = 0; + malloc_fail_at = 0; + if (!testfunc(conn)) + { + fprintf(stderr, "%s pre-test failed!\n", testname); + return; + } + nmallocs = malloc_counter; + + /* + * If our callback isn't get called at all, the most likely reason is that + * the failure injecting code was not loaded correctly. + */ + if (nmallocs == 0) + { + fprintf(stderr, "malloc() callback was not called in %s test.\n", testname); + return; + } + printf("%s called malloc() %d times\n", testname, nmallocs); + + /* + * Ok, now run the test again several times, causing a different malloc() + * call to fail each time. + */ + for (i = 1; i <= nmallocs; i++) + { + printf("Running %s test, with failure at malloc call %d...\n", testname, i); + malloc_counter = 0; + malloc_fail_at = i; + testfunc(conn); + malloc_fail_at = 0; + } +} + +int +main(int argc, char *argv[]) +{ + PGconn *conn; + + if ((conn = PQconnectdb("")) == NULL) + { + fprintf(stderr, "PQconnectdb failed"); + exit(1); + } + + if (PQstatus(conn) != CONNECTION_OK) + { + fprintf(stderr, "PQconnectdb failed: %s", + PQerrorMessage(conn)); + exit(1); + } + + mallocfail_init(); + + run_testfunc(conn, "PQexec", &test_PQexec); + run_testfunc(conn, "PQprepare", &test_PQprepare); + run_testfunc(conn, "COPY FROM STDIN", &test_COPY_FROM); + + return 0; +} -- 2.1.4 --------------000502070604010802070408 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --------------000502070604010802070408--