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

Parser refuses AFTER CREATE SCHEMA DO #1062

Closed
3 of 4 tasks
mrj0 opened this issue Dec 18, 2019 · 4 comments
Closed
3 of 4 tasks

Parser refuses AFTER CREATE SCHEMA DO #1062

mrj0 opened this issue Dec 18, 2019 · 4 comments

Comments

@mrj0
Copy link

mrj0 commented Dec 18, 2019

  • pgloader --version

pgloader version "3.6.1"
compiled with SBCL 1.4.15.debian
```

  • did you test a fresh compile from the source tree?

No, compilation failed (reported in #1005)

  • did you search for other similar issues?

Yes

LOAD DATABASE
    FROM      mysql://
    INTO postgresql://

  WITH max parallel create index = 4, prefetch rows = 2500, on error resume next, workers = 8, concurrency = 8

  set timezone to 'PST8PDT'

  SET PostgreSQL PARAMETERS
        maintenance_work_mem to '128MB',
        work_mem to '12MB',
        search_path to 'staging, public, "$user"'

  SET MySQL PARAMETERS
        net_read_timeout  = '120',
        net_write_timeout = '120'

  CAST
     type datetime to timestamptz using zero-dates-to-null,
     type datetime when default '0000-00-00 00:00:00' to timestamptz using zero-dates-to-null,
     type datetime to timestamptz drop default drop not null using zero-dates-to-null,

     type date when default '0000-00-00' to date using zero-dates-to-null,
     type date to date drop not null drop default using zero-dates-to-null

INCLUDING ONLY TABLE NAMES MATCHING 'user'

BEFORE LOAD DO
    $$ drop schema if exists staging cascade ; $$,
    $$ create schema staging;     $$,
    $$ alter database pgsandbox set search_path to staging, public; $$;

AFTER CREATE SCHEMA DO
    $$ alter table "user" alter column last_login_at drop not null; $$,
    $$ alter table "user" alter column banned_at drop not null; $$;
  • pgloader output you obtain
2019-12-18T16:55:05.013000Z LOG pgloader version "3.6.1"
KABOOM!
FATAL error: At 

  
  AFTER CREATE SCHEMA DO
  
  ^ (Line 34, Column 0, Position 1174)

In context COMMANDS:

While parsing COMMANDS. Expected:

     the character Tab
  or the character Newline
  or the character Return
  or the character Space
  or the string "--"
  or the string "/*"
  or the string "load"
An unhandled error condition has been signalled: At

  
  AFTER CREATE SCHEMA DO
  
  ^ (Line 34, Column 0, Position 1174)

In context COMMANDS:

While parsing COMMANDS. Expected:

     the character Tab
  or the character Newline
  or the character Return
  or the character Space
  or the string "--"
  or the string "/*"
  or the string "load"




What I am doing here?

At

  
  AFTER CREATE SCHEMA DO
  
  ^ (Line 34, Column 0, Position 1174)

In context COMMANDS:

While parsing COMMANDS. Expected:

     the character Tab
  or the character Newline
  or the character Return
  or the character Space
  or the string "--"
  or the string "/*"
  or the string "load"

Apologies if I have misunderstood the format but I wasn't able to locate an example of how to use this command.

Thanks!
Mike

@auspex
Copy link

auspex commented Dec 20, 2019

I'm certain that's the documented format, Mike. I had the same problem.

@dimitri
Copy link
Owner

dimitri commented Feb 11, 2020

Your command had a problem with an extra semi-colon (terminating the command) before the last section. That said that was not your problem, it's just that I didn't expose the new facility to all the sources parsers. I have now added MySQL source as supported for this clause.

@auspex
Copy link

auspex commented Feb 12, 2020

I didn't actually find anything in the documentation about that semicolon—I spent hours comparing a non-working configuration to working ones before I realized there had to be one.

@dimitri
Copy link
Owner

dimitri commented Feb 29, 2020

Yeah documentation kind of makes sense mostly if you know how it works already. I realise that it's quite difficult for me to document my own code in a way that makes sense for people who are discovering the whole thing for the first time. Help needed, documentation Pull Requests welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants