Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: support DO statement for running running anonymous code blocks #107345

Open
giangpham712 opened this issue Jul 21, 2023 · 4 comments
Open

sql: support DO statement for running running anonymous code blocks #107345

giangpham712 opened this issue Jul 21, 2023 · 4 comments
Labels
A-tools-efcore C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-queries SQL Queries Team X-blathers-triaged blathers was able to find an owner
Projects

Comments

@giangpham712
Copy link

giangpham712 commented Jul 21, 2023

Describe the problem

Running the following SQL

DO $EF$
BEGIN
    IF NOT EXISTS(SELECT 1 FROM pg_namespace WHERE nspname = 'test') THEN
        CREATE SCHEMA test;
    END IF;
END $EF$;

will return error ERROR: at or near "do": syntax error

See the Postgres documentation for more details on the DO statement.

Additional context

What was the impact?

This issue is affecting a number of tests in efcore.pg library

Jira issue: CRDB-30000

@giangpham712 giangpham712 added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Jul 21, 2023
@blathers-crl
Copy link

blathers-crl bot commented Jul 21, 2023

Hello, I am Blathers. I am here to help you get the issue triaged.

Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here.

I have CC'd a few people who may be able to assist you:

  • @cockroachdb/sql-foundations (found keywords: pg_)

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-triaged blathers was able to find an owner labels Jul 21, 2023
@giangpham712 giangpham712 changed the title sql: DO block doesn't work sql: running anonymous code block using DO doesn't work Jul 21, 2023
@rafiss rafiss added A-tools-efcore T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) labels Jul 21, 2023
@blathers-crl blathers-crl bot added this to Triage in SQL Foundations Jul 21, 2023
@rafiss
Copy link
Collaborator

rafiss commented Jul 25, 2023

Tagging the SQL Queries team, as this may be related to ongoing work with plpgsql. (And there may already be a different issue to track this)

@rafiss rafiss added T-sql-queries SQL Queries Team and removed T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) labels Jul 25, 2023
@blathers-crl blathers-crl bot added this to Triage in SQL Queries Jul 25, 2023
@rafiss rafiss removed this from Triage in SQL Foundations Jul 25, 2023
@Enalmada
Copy link

Could we get an update here? Drizzle ORM migrations output DO for duplicate_object checking and I don't believe that is going to change anytime soon. Supporting this would go a long way toward being able to get Drizzle users to seriously consider CockroachDB as a viable option.

DO $$ BEGIN
 CREATE TYPE "status" AS ENUM('ACTIVE', 'COMPLETED');
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;

@mgartner mgartner changed the title sql: running anonymous code block using DO doesn't work sql: support DO statement for running running anonymous code blocks Oct 9, 2023
@mgartner
Copy link
Collaborator

mgartner commented Oct 9, 2023

Thanks for the feedback @Enalmada. In v23.2 we're supporting PLpgSQL functions and procedures for the first time, which brings us a step closer towards supporting anonymous code blocks. We'll keep this issue updated with more information when we have it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tools-efcore C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-queries SQL Queries Team X-blathers-triaged blathers was able to find an owner
Projects
Status: Backlog
SQL Queries
Triage (Old)
Development

No branches or pull requests

4 participants