Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit ba2c9ef

Browse files
committed
Disable pushdown if no extension
Pushdowns require functions defined in the extension.
1 parent 80a4f14 commit ba2c9ef

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkg/pgmodel/migrate.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const (
2727
metadataUpdateNoExtension = "INSERT INTO _timescaledb_catalog.metadata(key, value, include_in_telemetry) VALUES ($1, $2, $3) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, include_in_telemetry = EXCLUDED.include_in_telemetry"
2828
)
2929

30+
var ExtensionIsInstalled = false
31+
3032
type mySrc struct {
3133
source.Driver
3234
}
@@ -137,7 +139,10 @@ func Migrate(db *sql.DB, versionInfo VersionInfo) (err error) {
137139

138140
_, extErr := db.Exec(fmt.Sprintf(extensionInstall, extSchema))
139141
if extErr != nil {
142+
ExtensionIsInstalled = false
140143
log.Warn("msg", "timescale_prometheus_extra extension not installed", "cause", extErr)
144+
} else {
145+
ExtensionIsInstalled = true
141146
}
142147

143148
// Insert metadata.

pkg/pgmodel/query_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func (t *queryFinalizer) Finalize() (string, []interface{}, error) {
296296

297297
/* The path is the list if ancestors (direct parent last) returned node is the last node processed by the pushdown */
298298
func getQueryFinalizer(otherClauses string, values []interface{}, hints *storage.SelectHints, path []parser.Node) (*queryFinalizer, parser.Node, error) {
299-
if path != nil && hints != nil && len(path) >= 2 && !partOfSubquery(path) {
299+
if ExtensionIsInstalled && path != nil && hints != nil && len(path) >= 2 && !partOfSubquery(path) {
300300
var topNode parser.Node
301301

302302
node := path[len(path)-2]

0 commit comments

Comments
 (0)