Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fYzT0-0004gO-RS for pgsql-general@arkaria.postgresql.org; Fri, 29 Jun 2018 19:54:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fYzSx-0000gJ-ND for pgsql-general@arkaria.postgresql.org; Fri, 29 Jun 2018 19:53:59 +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.89) (envelope-from ) id 1fYzSv-0000gC-SV for pgsql-general@lists.postgresql.org; Fri, 29 Jun 2018 19:53:59 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fYzSs-0005Vj-09 for pgsql-general@lists.postgresql.org; Fri, 29 Jun 2018 19:53:56 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 45DCA24C; Fri, 29 Jun 2018 15:53:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 29 Jun 2018 15:53:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=MwxbAj0MQdW1B/WsDXIx4lrC1Afqc NwR/HYmsdaKLV0=; b=OaBKETkk5D0mUoEZa4swOvUIrsa28KgumW6C+/VmPo00T P1032LPv+GKOuXfyzBzjo1kAQQs4nppbK7/lKGkOEatRIYdSIF7JhFZCabsGl33+ fVd1OnR0wP+koqfbq6G2RTp0v7aVweE47YJfoy+N6NYql+n49OGqtG/L1FNEojlz DhH7gU+sokBaaJIhDoIXoaNh28/5zTZhNkGFs07wWviegKGdoKYE1kv2tF6ZF26H KNQjR9N3QlQiAANC+EV27eho2UEkdhgPv2raG6bb7Z0Ja31v+Wzi5CM6uh0s06C9 atB7l3DcwT1hcnbc+PRQbvramdpTWZhq5YiW4obQQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=MwxbAj 0MQdW1B/WsDXIx4lrC1AfqcNwR/HYmsdaKLV0=; b=GOlWgKjS1OxTdLDT4v3mYR 6kz+I0K+wCRcp6BaJpMZS6FG7jTeAzmgGZjItCC4RTdFV3klG7oCjOnh4KIqjQLn CJaSI7Sc5lM5Cd/g8HrrulbjKEga4lJYQbSrH9IU3DPwJzs4dKE7Xg4aIA/mLRBe 8ZWDapYJxPWWso/3AVe4K/e4dGEJ2jKETLV6aAPaCgf5k996cXNtZNnXR2/Jz4K4 mM4WE6LUeF2/Ftizoydxv2JRHy2u5k/sKj47w+GZ0Pfk0Y0OL2t1hdTOvRcr0veK O1rvxSBJAb6EIX1a0cS3Yp9SMM1CjkOm+Mfwy1tjdErD1KjahA20HcQnafoW6H7w == X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.159.209]) by mail.messagingengine.com (Postfix) with ESMTPA id 0884910261; Fri, 29 Jun 2018 15:53:50 -0400 (EDT) Subject: Re: CSV export bug? To: Tracy Babiasz , "pgsql-general@lists.postgresql.org" References: <6a107213f40c4c56a4b67c7232057e30@TOWNMBX2.townofchapelhill.org> From: Adrian Klaver Message-ID: Date: Fri, 29 Jun 2018 12:53:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 06/29/2018 09:29 AM, Tracy Babiasz wrote: > Hi Adrian. Thanks for the response. I'm not sure how else to explain it. The report executes fine in the query tool and gives me about 300 lines in data output. It even appears to export fine. I click on the download button and open in Excel, but I get the statements I copied below. The statement is slightly different if I remove the comment statements within the script. If, instead of opening in Excel, I save the file and give it a name, I have a csv file to open. But the file is only 1KB, and if you open it, you see the statements I copied below, rather than the results of the report. > > Does that make sense? > Well I can replicate it so, yes. Using pgAdmin4 3.1. My 'report': DROP TABLE IF EXISTS tmp_test; CREATE table tmp_test(id integer, fld_1 varchar); select * from cell_per; The error I get when doing the export: postgres-2018-06-29 12:39:16.349 PDT-0ERROR: syntax error at or near "DROP" at character 55 postgres-2018-06-29 12:39:16.349 PDT-0STATEMENT: DECLARE "CURSOR:CONN:8564986" CURSOR WITHOUT HOLD FOR DROP TABLE IF EXISTS tmp_test; CREATE table tmp_test(id integer, fld_1 varchar); select * from cell_per; Looks like pgAdmin4 is running all the queries using a declared cursor(https://www.postgresql.org/docs/10/static/sql-declare.html). This fails because the CURSOR can only take a SELECT or VALUES as the query. The DROP TABLE will not work with a CURSOR. To me it looks like a bug. I would file an issue here: https://redmine.postgresql.org/projects/pgadmin4 You will need a Postgres community account to access the issue tracker. If you do not have one there will be instructions on how to set one up when you click on the link above. For now what seems to work is to open another tab and then open another Query Tool. In that Tool do the DROP TABLE/CREATE TABLE and then in the other Tool do the SELECT and export from there. > Tracy Babiasz > Acquisitions and Collections Manager > Chapel Hill Public Library > 100 Library Drive Chapel Hill, NC 27514 > Phone: 919-969-2032 |Fax: 919-968-2838 > tbabiasz@townofchapelhill.org > Sparking Curiosity. Inspiring Learning. Creating Connections. > -- Adrian Klaver adrian.klaver@aklaver.com