Skip to content

Commit a977802

Browse files
committed
Conditionally query scylla_tables for table metadata
When using scylladb/gocql with upstream Cassandra, the driver queries system_schema.tables to get table metadata. When using scylladb/gocql with ScyllaDB, the driver should also query system_schema.scylla_tables. Closes #579
1 parent 7fe8106 commit a977802

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

metadata_scylla.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,8 @@ func getKeyspaceMetadata(session *Session, keyspaceName string) (*KeyspaceMetada
808808
return keyspace, nil
809809
}
810810

811-
// query for table metadata in the system_schema.tables and system_schema.scylla_tables
811+
// query for table metadata in the system_schema.tables, and system_schema.scylla_tables
812+
// if connected to ScyllaDB
812813
func getTableMetadata(session *Session, keyspaceName string) ([]TableMetadata, error) {
813814
if !session.useSystemSchema {
814815
return nil, nil
@@ -845,6 +846,10 @@ func getTableMetadata(session *Session, keyspaceName string) ([]TableMetadata, e
845846
return nil, fmt.Errorf("error querying table schema: %v", err)
846847
}
847848

849+
if session.getConn() != nil && !session.getConn().isScyllaConn() {
850+
return tables, nil
851+
}
852+
848853
stmt = `SELECT * FROM system_schema.scylla_tables WHERE keyspace_name = ? AND table_name = ?`
849854
for i, t := range tables {
850855
iter := session.control.querySystem(stmt, keyspaceName, t.Name)

0 commit comments

Comments
 (0)