CREATE EXTENSION fails with Azure Cosmos DB for PostgreSQL #4

Open
opened 2026-02-16 05:16:02 -05:00 by yindo · 1 comment
Owner

Originally created by @joshuasundance-swca on GitHub (Apr 23, 2024).

The SQL for enabling the vector extension is hardcoded at https://github.com/langchain-ai/langchain-postgres/blob/07053067c7013b4b57c035f6caa94b2b63bfe404/langchain_postgres/vectorstores.py#L344

But when using Azure Cosmos DB for PostgreSQL, it's necessary to use SELECT create_extension('vector');

From relevant docs:

If CREATE EXTENSION fails with a permission denied error, try the create_extension() function instead. For instance:

SELECT create_extension('postgis');

To remove an extension installed this way, use drop_extension().

The same applies to pgvector in the same context.

I might propose a parameter that allows the user to define the create extension statement, or choose from a list of predefined options if that approach seems better. Currently, of course, the user can create the extension first and then use create_extension=False.

Originally created by @joshuasundance-swca on GitHub (Apr 23, 2024). The SQL for enabling the `vector` extension is hardcoded at https://github.com/langchain-ai/langchain-postgres/blob/07053067c7013b4b57c035f6caa94b2b63bfe404/langchain_postgres/vectorstores.py#L344 But when using Azure Cosmos DB for PostgreSQL, it's necessary to use `SELECT create_extension('vector');` From [relevant docs](https://learn.microsoft.com/en-us/azure/cosmos-db/postgresql/reference-extensions): ``` If CREATE EXTENSION fails with a permission denied error, try the create_extension() function instead. For instance: SELECT create_extension('postgis'); To remove an extension installed this way, use drop_extension(). ``` The same applies to [pgvector in the same context](https://learn.microsoft.com/en-us/azure/cosmos-db/postgresql/howto-use-pgvector). I might propose a parameter that allows the user to define the create extension statement, or choose from a list of predefined options if that approach seems better. Currently, of course, the user can create the extension first and then use `create_extension=False`.
Author
Owner

@eyurtsev commented on GitHub (Apr 23, 2024):

Feel free to open a PR to try to parameterize

@eyurtsev commented on GitHub (Apr 23, 2024): Feel free to open a PR to try to parameterize
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#4