Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmIko-0005F5-7d for pgadmin-hackers@arkaria.postgresql.org; Tue, 20 Sep 2016 10:58:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bmIkn-0003BS-RR for pgadmin-hackers@arkaria.postgresql.org; Tue, 20 Sep 2016 10:58:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bmIkZ-0002kD-4x for pgadmin-hackers@postgresql.org; Tue, 20 Sep 2016 10:58:07 +0000 Received: from mail-it0-x233.google.com ([2607:f8b0:4001:c0b::233]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bmIkV-0004CO-Q9 for pgadmin-hackers@postgresql.org; Tue, 20 Sep 2016 10:58:06 +0000 Received: by mail-it0-x233.google.com with SMTP id o3so94126535ita.1 for ; Tue, 20 Sep 2016 03:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgadmin-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=P/nW6lFJxiQf8BBFkCEuh64MBtigdvI/2DMJ4KcB558=; b=ekx1GxObT9p/6syuKmdXLcRvp5USBj520cjzbm9vGM17ArWlGDrejQ/9dq1R1ewyHs cvnllXLrvuosp5/yXPD1pJBRuOlUmO+rRYvy26KqPFvWpgwAo+4A+Z7ZufoGps516N11 JhT54kyJQqTL97/9C2CS8heJrP9ATD/Hn5zTjNaQ82yOyh4pn4QLTejOD2pKyR5Xwofa YVuITqRDelZEvD4/zyC6kRbr7KCX80MO4Yf8Z9IDO4k0kpR889CmHLnNBQi2fp6igKpK 60PMqdLrkKhMr/ML9YWPFhnHmsAXyyQ5SbMCLo4yrY0j8rov36L9megYwPmkGLGKYZgV SRYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=P/nW6lFJxiQf8BBFkCEuh64MBtigdvI/2DMJ4KcB558=; b=enclu3adir/auIJSrSZiiQIV/UzZ1zX4YU0SwNZYOdxR/AdUVzGusZ/oasH2b77o4c OMaud1ooCxpUFs5qK6ZXQAmIkAYTZU1IUHjlySoJ9QkyOyyQhvW2Yw0MZF6Ti12u5+wd QuNTRlc4bcSk18OaxxqswBFsvmBTLyJxJv+kwUfhyQJhemnyKLP9Hd/e74tLQPdK6juZ X2vemNFo+btn/pxgF0TAeJvFp2hCr8+G5/WHnrIXpg6alH2fmUEoNoS2mU2q/1J8yzCw DUSWfetOuzWUYUWzBDqNGKvFTkD4UF/PwhP02uF24odTBEriLCEIxOApZVKUA2r5EpqI AgWg== X-Gm-Message-State: AE9vXwNwhCxsCyiL6rlOxJVgc9KgmqrNrm/OzxHitRZdO8TL0dd09gAuA2cXQkVwG0mDB6saOFrCFjZrIR+BKg== X-Received: by 10.36.254.140 with SMTP id w134mr3075645ith.108.1474369082100; Tue, 20 Sep 2016 03:58:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.1.203 with HTTP; Tue, 20 Sep 2016 03:58:01 -0700 (PDT) In-Reply-To: References: From: Dave Page Date: Tue, 20 Sep 2016 11:58:01 +0100 Message-ID: Subject: Re: [pgAdmin4][Patch]: RM1592 - Download as CSV should be supported for DDL To: Surinder Kumar Cc: pgadmin-hackers Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgadmin-hackers Precedence: bulk Sender: pgadmin-hackers-owner@postgresql.org Thanks, applied. On Tue, Sep 20, 2016 at 11:39 AM, Surinder Kumar wrote: > Please find updated patch with suggested changes and inline comments. > > Also, Incase if user tries to download csv on queries other than select, we > are catching that exception and write into 'csv' with name 'error.csv'. > > On Tue, Sep 20, 2016 at 2:33 PM, Dave Page wrote: >> >> On Tue, Sep 20, 2016 at 6:43 AM, Surinder Kumar >> wrote: >> > >> > On Mon, Sep 19, 2016 at 8:59 PM, Surinder Kumar >> > wrote: >> >> >> >> On Mon, Sep 19, 2016 at 8:48 PM, Dave Page wrote: >> >>> >> >>> Hi >> >>> >> >>> On Mon, Sep 19, 2016 at 3:03 PM, Surinder Kumar >> >>> wrote: >> >>> > Hi >> >>> > >> >>> > Please find attached patch with fix. >> >>> >> >> >>> >> Download as CSV >> >>> >> button should be enabled only for SELECT queries. >> >>> >> >>> I'm not sure there's a way to do this without parsing the query. >> >>> Simply matching on ^select certainly won't work reliably - for >> >>> example, there could be multiple statements in the script, or it could >> >>> be PERFORM ... or UPDATE ... RETURNING ... >> >> >> >> I wasn't aware of such cases. >> >>> >> >>> >> >>> I think we need to leave the button enabled, but give the user a >> >>> message if no data is returned, e.g. >> >> >> >> ok. sure. >> > >> > I discussed the issue with Harshal and this is how download csv works: >> > We just hit the url to download csv, and let the browser handle the >> > response >> > from the server side. we don't have access to response data to check if >> > no >> > data is returned. >> >> Hmm, yeah that's true. >> >> > The other approach is to hit the same query twice. First time an ajax >> > query >> > to check if data is returned or not. if returned, fire another query to >> > download csv otherwise set message in message panel. >> > But the limitation with this approach is that we are just increasing >> > load >> > over server by hitting same query twice, incase returned data rows in >> > billions. >> > Thoughts ? >> >> Yeah, we can't do that. >> >> The only thing I can think of right now is to simply write the error >> message to the CSV file, e.g. >> >> "The query executed did not return any data." >> >> (with the quotes, so it's valid CSV). That way at least the user will >> always get a file downloaded, and will see the error when they open >> it. > > Thats' done. >> >> >> -- >> Dave Page >> Blog: http://pgsnake.blogspot.com >> Twitter: @pgsnake >> >> EnterpriseDB UK: http://www.enterprisedb.com >> The Enterprise PostgreSQL Company > > -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers