Skip to content

Commit a56c8ce

Browse files
committed
Release v1.7.0
1 parent 9abbc6d commit a56c8ce

8 files changed

Lines changed: 31 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ SELECT * FROM [TABLE] WHERE [JSON_COLUMN]->>'[JSON_KEY]' = '[JSON_VALUE]';
317317
- [x] DBeaver
318318
- [x] pgAdmin
319319
- [x] Grafana
320+
- [x] Retool
320321
- [ ] Jupyter notebooks ([#27](https://github.com/BemiHQ/BemiDB/issues/27))
321322
- [x] Data syncing from other sources
322323
- [x] Amplitude (incremental)

src/common/common_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package common
22

33
const (
4-
VERSION = "1.6.0"
4+
VERSION = "1.7.0"
55

66
ENV_LOG_LEVEL = "BEMIDB_LOG_LEVEL"
77
ENV_DISABLE_ANONYMOUS_ANALYTICS = "BEMIDB_DISABLE_ANONYMOUS_ANALYTICS"

src/server/parser_function.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (parser *ParserFunction) FirstArgumentToString(functionCall *pgQuery.FuncCa
3131
// n from (FUNCTION()).n
3232
func (parser *ParserFunction) IndirectionName(targetNode *pgQuery.Node) string {
3333
indirection := targetNode.GetResTarget().Val.GetAIndirection()
34-
if indirection != nil {
34+
if indirection != nil && len(indirection.Indirection) == 1 && indirection.Indirection[0].GetString_() != nil {
3535
return indirection.Indirection[0].GetString_().Sval
3636
}
3737

src/server/parser_table.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ func (parser *ParserTable) MakeIcebergTableNode(queryToIcebergTable QueryToIcebe
5555
if permissions == nil {
5656
query = "SELECT * FROM iceberg_scan('" + queryToIcebergTable.IcebergTablePath + "')"
5757
} else if columnNames, allowed := (*permissions)[queryToIcebergTable.QuerySchemaTable.ToIcebergSchemaTable().ToArg()]; allowed {
58-
query = "SELECT " + strings.Join(columnNames, ", ") + " FROM iceberg_scan('" + queryToIcebergTable.IcebergTablePath + "')"
58+
quotedColumnNames := make([]string, len(columnNames))
59+
for i, columnName := range columnNames {
60+
quotedColumnNames[i] = "\"" + columnName + "\""
61+
}
62+
query = "SELECT " + strings.Join(quotedColumnNames, ", ") + " FROM iceberg_scan('" + queryToIcebergTable.IcebergTablePath + "')"
5963
} else {
6064
query = "SELECT NULL WHERE FALSE"
6165
}

src/server/postgres_server.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,13 @@ func (server *PostgresServer) handleExtendedQuery(queryHandler *QueryHandler, pa
174174
case *pgproto3.Parse:
175175
server.handleExtendedQuery(queryHandler, message) // self-recursion
176176
return nil
177+
case *pgproto3.Flush:
178+
// Ignore Flush messages, as we are sending responses immediately.
179+
case *pgproto3.Close:
180+
common.LogDebug(server.config.CommonConfig, "Closing prepared statement", message.Name)
181+
server.writeMessages(&pgproto3.CloseComplete{})
177182
default:
183+
common.LogError(server.config.CommonConfig, fmt.Sprintf("Received unexpected message type from client: %T", message))
178184
return fmt.Errorf("received unexpected message type from client: %T", message)
179185
}
180186
}

src/server/query_handler_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ func TestHandleQuery(t *testing.T) {
8383
"types": {uint32ToString(pgtype.Int4OID)},
8484
"values": {"0"},
8585
},
86+
"SELECT pg_cancel_backend(12345) AS pg_cancel_backend": {
87+
"description": {"pg_cancel_backend"},
88+
"types": {uint32ToString(pgtype.BoolOID)},
89+
"values": {"t"},
90+
},
8691
"SELECT * from pg_is_in_recovery()": {
8792
"description": {"pg_is_in_recovery"},
8893
"types": {uint32ToString(pgtype.BoolOID)},
@@ -400,6 +405,11 @@ func TestHandleQuery(t *testing.T) {
400405
"types": {uint32ToString(pgtype.OIDOID)},
401406
"values": {"25"},
402407
},
408+
"SELECT DISTINCT ON(typlen) oid FROM pg_type ORDER BY oid LIMIT 1": {
409+
"description": {"oid"},
410+
"types": {uint32ToString(pgtype.OIDOID)},
411+
"values": {"16"},
412+
},
403413
})
404414
})
405415

src/server/query_remapper.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,12 @@ func (remapper *QueryRemapper) remapSelect(selectStatement *pgQuery.SelectStmt,
509509
}
510510
}
511511

512+
// DISTINCT ON (column)
513+
distinctClauses := selectStatement.GetDistinctClause()
514+
for i, distinctNode := range distinctClauses {
515+
distinctClauses[i] = remapper.remappedExpressions(distinctNode, remappedColumnRefs, permissions, indentLevel) // recursion
516+
}
517+
512518
return remappedColumnRefs
513519
}
514520

src/server/query_remapper_function.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func CreatePgCatalogMacroQueries(config *Config) []string {
1717
"CREATE MACRO aclexplode(aclitem_array) AS json(aclitem_array)",
1818
"CREATE MACRO current_setting(setting_name) AS '', (setting_name, missing_ok) AS ''",
1919
"CREATE MACRO pg_backend_pid() AS 0",
20+
"CREATE MACRO pg_cancel_backend(pid) AS true",
2021
"CREATE MACRO pg_encoding_to_char(encoding_int) AS 'UTF8'",
2122
"CREATE MACRO pg_get_expr(pg_node_tree, relation_oid) AS pg_catalog.pg_get_expr(pg_node_tree, relation_oid), (pg_node_tree, relation_oid, pretty_bool) AS pg_catalog.pg_get_expr(pg_node_tree, relation_oid)",
2223
"CREATE MACRO pg_get_function_identity_arguments(func_oid) AS ''",

0 commit comments

Comments
 (0)