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

doc_update/updating-doc-related-to-dsnexec-commnds-for-DDL-queries #188

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion dsnexec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ Commands:

args: An array of arguments to the SQL command. The args are parsed with
the golang text/template package with the sources map as the
template context.
template context.
(Note - If you intent to fire DDL queries, then put full go template expressions in the command.
As unlike for DML queries, underlying prepare statement does not consider arguments passed when the query is DDL.)

10 changes: 8 additions & 2 deletions dsnexec/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ configs:
driver: hotload
dsn: fsnotify://postgres/path/to/myfile.txt
commands:
- command: ALTER SERVER myserver OPTIONS (SET host=?);
- command: INSERT INTO table1 values ($1, $2);
args:
- '{{ index . "test/source.json" "host" }}'
- '{{ index . "test/source.json" "host" }}'
- '{{ index . "test/source.json" "port" }}'

# As the below query is DDL, unlike insert (DML) written above, we can not pass arguments here.
# We need to put full go template expressions in the command itself
- command: ALTER SERVER myserver OPTIONS (SET host '{{ index . "test/source.json" "host" }}' );
args: []
Loading