Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EE5B1200C2A for ; Wed, 15 Feb 2017 03:20:23 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id ED238160B6A; Wed, 15 Feb 2017 02:20:23 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3F6CC160B5F for ; Wed, 15 Feb 2017 03:20:23 +0100 (CET) Received: (qmail 80499 invoked by uid 500); 15 Feb 2017 02:20:22 -0000 Mailing-List: contact commits-help@hawq.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hawq.incubator.apache.org Delivered-To: mailing list commits@hawq.incubator.apache.org Received: (qmail 80490 invoked by uid 99); 15 Feb 2017 02:20:22 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Feb 2017 02:20:22 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id D1CE0C05E9 for ; Wed, 15 Feb 2017 02:20:21 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id STJTl45EwD4w for ; Wed, 15 Feb 2017 02:20:20 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 086D15FB0F for ; Wed, 15 Feb 2017 02:20:19 +0000 (UTC) Received: (qmail 80487 invoked by uid 99); 15 Feb 2017 02:20:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Feb 2017 02:20:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 05910DFAB2; Wed, 15 Feb 2017 02:20:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: odiachenko@apache.org To: commits@hawq.incubator.apache.org Message-Id: <66f5185baf4048c48474235ee550a0c6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-hawq git commit: HAWQ-1314. Added upgrade for function pxf_get_item_fields. Date: Wed, 15 Feb 2017 02:20:19 +0000 (UTC) archived-at: Wed, 15 Feb 2017 02:20:24 -0000 Repository: incubator-hawq Updated Branches: refs/heads/master 9a86ed8c9 -> 103373b7f HAWQ-1314. Added upgrade for function pxf_get_item_fields. Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/103373b7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/103373b7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/103373b7 Branch: refs/heads/master Commit: 103373b7f7cfabef181bd624a6ceb4d6e5095954 Parents: 9a86ed8 Author: Oleksandr Diachenko Authored: Tue Feb 14 18:20:02 2017 -0800 Committer: Oleksandr Diachenko Committed: Tue Feb 14 18:20:16 2017 -0800 ---------------------------------------------------------------------- tools/bin/hawqupgrade | 48 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/103373b7/tools/bin/hawqupgrade ---------------------------------------------------------------------- diff --git a/tools/bin/hawqupgrade b/tools/bin/hawqupgrade index a71f4d6..0352018 100755 --- a/tools/bin/hawqupgrade +++ b/tools/bin/hawqupgrade @@ -89,12 +89,52 @@ def register_func(options, args): except pg.DatabaseError as e: logger.error('%s', e) logger.info('Hawq Upgrade Failed.') - return 1 + sys.exit(1) except pg.InternalError: logger.error('Fail to connect to database, this script can only be run when database is up.') logger.info('Hawq Upgrade Failed.') - return 1 - logger.info('Hawq Upgrade Succeed.') + sys.exit(1) + +def pxf_get_item_fields_func(options, args): + # connect db + try: + url = dbconn.DbURL(hostname=options.host, port=options.port, + dbname="template1", username=options.user) + utility_conn = pg.connect(dbname=url.pgdb, host=url.pghost, port=url.pgport, + user=url.pguser, passwd=url.pgpass, opt='-c gp_session_role=utility') + + + # update function for template1 + update_func_query = """ + SET allow_system_table_mods = 'dml'; + UPDATE pg_proc + SET proallargtypes = '{25,25,25,25,25,25,25}', proargmodes = '{i,i,o,o,o,o,o}', proargnames = '{profile,pattern,path,itemname,fieldname,fieldtype,sourcefieldtype}' + WHERE proname = 'pxf_get_item_fields'; + """ + + utility_conn.query(update_func_query) + logger.info('Function pxf_get_item_fields successfully updated into database template1.') + # pxf_get_item_fields function for other databases + query = """select datname from pg_database;""" + dbs = utility_conn.query(query).dictresult() + for cur_db in dbs: + if cur_db['datname'] not in ['template1', 'template0', 'hcatalog']: + url = dbconn.DbURL(hostname=options.host, port=options.port, + dbname=cur_db['datname'], username=options.user) + existed_db_conn = pg.connect(dbname=cur_db['datname'], host=url.pghost, + port=url.pgport, user=url.pguser, passwd=url.pgpass) + existed_db_conn.query(update_func_query); + logger.info('Function pxf_get_item_fields successfully updated in database %s.',cur_db['datname']) + existed_db_conn.close() + utility_conn.close() + except pg.DatabaseError as e: + logger.error('%s', e) + logger.info('Hawq Upgrade Failed.') + sys.exit(1) + except pg.InternalError: + logger.error('Fail to connect to database, this script can only be run when database is up.') + logger.info('Hawq Upgrade Failed.') + sys.exit(1) if __name__ == '__main__': parser = option_parser() @@ -103,3 +143,5 @@ if __name__ == '__main__': parser.print_help(sys.stderr) sys.exit(1) register_func(options, args) + pxf_get_item_fields_func(options, args) + logger.info('Hawq Upgrade Succeed.') \ No newline at end of file