def tablespace_alter(name, user=None, host=None, port=None, maintenance_db=None, password=None, new_name=None, new_owner=None, set_option=None, reset_option=None, runas=None):
 if (not any([new_name, new_owner, set_option, reset_option])):
  return True
 queries = []
 if new_name:
  queries.append('ALTER TABLESPACE "{0}" RENAME TO "{1}"'.format(name, new_name))
 if new_owner:
  queries.append('ALTER TABLESPACE "{0}" OWNER TO "{1}"'.format(name, new_owner))
 if set_option:
  queries.append('ALTER TABLESPACE "{0}" SET ({1} = {2})'.format(name, set_option.keys()[0], set_option.values()[0]))
 if reset_option:
  queries.append('ALTER TABLESPACE "{0}" RESET ({1})'.format(name, reset_option))
 for query in queries:
  ret = _psql_prepare_and_run(['-c', query], user=user, host=host, port=port, maintenance_db=maintenance_db, password=password, runas=runas)
  if (ret['retcode'] != 0):
   return False
 return True

def tablespace_alter ( name , user = None , host = None , port = None , maintenance_db = None , password = None , new_name = None , new_owner = None , set_option = None , reset_option = None , runas = None ) : if ( not any ( [ new_name , new_owner , set_option , reset_option ] ) ) : return True queries = [ ] if new_name : queries . append ( 'ALTER TABLESPACE "{0}" RENAME TO "{1}"' . format ( name , new_name ) ) if new_owner : queries . append ( 'ALTER TABLESPACE "{0}" OWNER TO "{1}"' . format ( name , new_owner ) ) if set_option : queries . append ( 'ALTER TABLESPACE "{0}" SET ({1} = {2})' . format ( name , set_option . keys ( ) [ 0 ] , set_option . values ( ) [ 0 ] ) ) if reset_option : queries . append ( 'ALTER TABLESPACE "{0}" RESET ({1})' . format ( name , reset_option ) ) for query in queries : ret = _psql_prepare_and_run ( [ '-c' , query ] , user = user , host = host , port = port , maintenance_db = maintenance_db , password = password , runas = runas ) if ( ret [ 'retcode' ] != 0 ) : return False return True
change tablespace name .