parameters: (connection, table)
return_statement: return 0
docstring: Reverse engineers the indices for the given table.
docstring_summary: Reverse engineers the indices for the given table.
docstring_tokens: Reverse engineers the indices for the given table .
function: def reverseEngineerTableIndices(connection, table):
      """Reverse engineers the indices for the given table."""
  
      schema = table.owner
      catalog = schema.owner
      
      if len(table.columns) == 0:
          grt.send_error('Sybase reverseEngineerTableIndices', 'Reverse engineer of table %s.%s was attempted but the table has no columns attribute' % (schema.name, table.name) )
          return 1    # Table must have columns reverse engineered before we can rev eng its indices
  
      execute_query(connection, 'USE %s' % catalog.name)
  
      query = """SELECT INDEX_NAME = A.name,
  IS_CLUSTERED = CASE
                  WHEN ((A.status&16) = 16 OR (A.status2&512) = 512) THEN 1
                  ELSE 0
                 END,
  IS_PRIMARY = CASE
                  WHEN ((A.status&0x800) = 0x800) THEN 1
                  ELSE 0
               END,
  IS_UNIQUE = CASE
                  WHEN ((A.status&2) = 2) THEN 1
                  ELSE 0
              END,
  IGNORE_DUP = CASE
                  WHEN ((A.status&4) = 4) THEN 1
                  ELSE 0
               END,
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 1),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 2),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 3),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 4),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 5),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 6),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 7),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 8),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 9),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 10),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 11),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 12),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 13),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 14),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 15),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 16),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 17),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 18),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 19),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 20),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 21),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 22),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 23),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 24),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 25),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 26),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 27),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 28),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 29),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 30),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 31)
  FROM sysindexes A,  sysobjects B
  WHERE A.indid > 0 AND A.indid < 255 AND A.status2 & 2 != 2 AND
  B.id = A.id AND B.type = 'U' AND
  USER_NAME(B.uid) = ? AND B.name=? ORDER BY 1, 2, 3"""
  
      for index_row in execute_query(connection, query, schema.name, table.name):
          index = grt.classes.db_sybase_Index()
          index.name = index_row[0]
          index.clustered = index_row[1]
          index.isPrimary = index_row[2]
          index.unique = index_row[3]
          index.indexType = 'UNIQUE' if index.unique else 'INDEX'
          index.ignoreDuplicateRows = index_row[4]
          table.addIndex(index)
  
          # Get the columns for the index:
          index_column_names = [colname for colname in index_row[5:] if colname is not None]
          for column_name in index_column_names:
              column = find_object_with_name(table.columns, column_name)
              if column:
                  index_column = grt.classes.db_sybase_IndexColumn()
                  index_column.name = index.name + '.' + column_name
                  index_column.referencedColumn = column
                  index.columns.append(index_column)
      return 0
function_tokens: def reverseEngineerTableIndices ( connection , table ) : schema = table . owner catalog = schema . owner if len ( table . columns ) == 0 : grt . send_error ( 'Sybase reverseEngineerTableIndices' , 'Reverse engineer of table %s.%s was attempted but the table has no columns attribute' % ( schema . name , table . name ) ) return 1 # Table must have columns reverse engineered before we can rev eng its indices execute_query ( connection , 'USE %s' % catalog . name ) query = """SELECT INDEX_NAME = A.name,
  IS_CLUSTERED = CASE
                  WHEN ((A.status&16) = 16 OR (A.status2&512) = 512) THEN 1
                  ELSE 0
                 END,
  IS_PRIMARY = CASE
                  WHEN ((A.status&0x800) = 0x800) THEN 1
                  ELSE 0
               END,
  IS_UNIQUE = CASE
                  WHEN ((A.status&2) = 2) THEN 1
                  ELSE 0
              END,
  IGNORE_DUP = CASE
                  WHEN ((A.status&4) = 4) THEN 1
                  ELSE 0
               END,
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 1),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 2),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 3),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 4),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 5),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 6),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 7),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 8),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 9),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 10),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 11),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 12),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 13),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 14),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 15),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 16),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 17),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 18),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 19),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 20),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 21),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 22),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 23),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 24),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 25),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 26),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 27),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 28),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 29),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 30),
  INDEX_COL(USER_NAME(B.uid) + '.' + B.name, indid, 31)
  FROM sysindexes A,  sysobjects B
  WHERE A.indid > 0 AND A.indid < 255 AND A.status2 & 2 != 2 AND
  B.id = A.id AND B.type = 'U' AND
  USER_NAME(B.uid) = ? AND B.name=? ORDER BY 1, 2, 3""" for index_row in execute_query ( connection , query , schema . name , table . name ) : index = grt . classes . db_sybase_Index ( ) index . name = index_row [ 0 ] index . clustered = index_row [ 1 ] index . isPrimary = index_row [ 2 ] index . unique = index_row [ 3 ] index . indexType = 'UNIQUE' if index . unique else 'INDEX' index . ignoreDuplicateRows = index_row [ 4 ] table . addIndex ( index ) # Get the columns for the index: index_column_names = [ colname for colname in index_row [ 5 : ] if colname is not None ] for column_name in index_column_names : column = find_object_with_name ( table . columns , column_name ) if column : index_column = grt . classes . db_sybase_IndexColumn ( ) index_column . name = index . name + '.' + column_name index_column . referencedColumn = column index . columns . append ( index_column ) return 0