Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmGxW-0000Tr-Ot for pgadmin-hackers@arkaria.postgresql.org; Tue, 20 Sep 2016 09:03: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 1bmGxW-0002nl-C4 for pgadmin-hackers@arkaria.postgresql.org; Tue, 20 Sep 2016 09:03:22 +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 1bmGxV-0002nd-UI for pgadmin-hackers@postgresql.org; Tue, 20 Sep 2016 09:03:22 +0000 Received: from mail-it0-x22b.google.com ([2607:f8b0:4001:c0b::22b]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bmGxQ-0001yw-QC for pgadmin-hackers@postgresql.org; Tue, 20 Sep 2016 09:03:21 +0000 Received: by mail-it0-x22b.google.com with SMTP id n143so12707908ita.1 for ; Tue, 20 Sep 2016 02:03:16 -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=HEEykkhDQpl63vOUmC1bsjiN3m6XVoVrkY673hjOoSY=; b=LkaBI/eTF/B0uMSKbbmLzfje4mDVO4cIst+mBP8Eg5T7tYEQqTLE1KRYgVUVc6oLcY iPBU8bdI0z/txlNOIj/gmyi7u0uzhZXUhalZOm3nPK99AYB3CQl522uRBLtzKGvKBFWc gREyhejrzZ0q2bwjskeLY5p5johbhYs9BkK2XpH8/fyKRdJcQ55CcCDgr8peD4Ed6vQJ SeoJ96MMjuZFUMfonDvhesXSJGy5pyxSq2yI9GTLe8tz5GlB7DKUPXIvtrMUtCQ7/rcw s3zg7F9OZSd0Jebq/9j2MzhJ7Uadse2n8kOq2AWd1J6O4tHM+u8HIMX75iISfRpnQTv/ lfAg== 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=HEEykkhDQpl63vOUmC1bsjiN3m6XVoVrkY673hjOoSY=; b=jkUlLojzdqxhOD1m8qjHUqG8wvm7oRE/PrTFUr+FzOSPU6W+oU7xN7wVEItxFJwDhC CibIm6MlIGOh9Mshki7IFpzlDHEgEDR1SRNhP3oVepo9XY9X8W9CME07u0zTDD7+FhHy E98nKFEiRqkmQ+aGU/tjKVXXJW0CAStFcesCnW9raz+YUxEBI46bxLkMBLi4RvU4iXOm Kvqk+79vHqpeAQlyYr3R0ispyt8Ws4sGv2BfvZIglI2boMx9Q4yPXQFSpzItMuxUefFF 80WkIrH0hgnbR99BR3Mxtl6VsTQ7oicohgbWPPwGvnK7/Hz0Si0MaIjkvtC0TOIzuAi0 1XpQ== X-Gm-Message-State: AE9vXwMTFZ5LqlY0g1KdsPlmJ/yxcuZRRhGAmFsNvg66w0cC9/lC+kMs31bzuYKl6LccctuDylqNCZWPcE3MXA== X-Received: by 10.36.127.87 with SMTP id r84mr2790686itc.4.1474362194826; Tue, 20 Sep 2016 02:03:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.1.203 with HTTP; Tue, 20 Sep 2016 02:03:14 -0700 (PDT) In-Reply-To: References: From: Dave Page Date: Tue, 20 Sep 2016 10:03:14 +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 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. -- 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