From 7cf8e3361f76dcc177d2bb8f0d37ab09ecf6d159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Tue, 28 May 2024 11:00:52 +0200 Subject: [PATCH] chore: update psql samples --- samples/snippets/psql-snippets/add_column.sh | 6 +++--- samples/snippets/psql-snippets/create_connection.sh | 6 +++--- samples/snippets/psql-snippets/create_tables.sh | 6 +++--- samples/snippets/psql-snippets/data_boost.sh | 6 +++--- samples/snippets/psql-snippets/ddl_batch.sh | 6 +++--- samples/snippets/psql-snippets/partitioned_dml.sh | 6 +++--- samples/snippets/psql-snippets/query_data.sh | 6 +++--- .../snippets/psql-snippets/query_data_with_new_column.sh | 9 +++++++++ .../snippets/psql-snippets/query_data_with_parameter.sh | 6 +++--- samples/snippets/psql-snippets/read_only_transaction.sh | 6 +++--- samples/snippets/psql-snippets/statement_timeout.sh | 6 +++--- samples/snippets/psql-snippets/tags.sh | 6 +++--- samples/snippets/psql-snippets/update_data_with_copy.sh | 6 +++--- .../psql-snippets/update_data_with_transaction.sh | 6 +++--- samples/snippets/psql-snippets/write_data_with_copy.sh | 6 +++--- samples/snippets/psql-snippets/write_data_with_dml.sh | 6 +++--- .../snippets/psql-snippets/write_data_with_dml_batch.sh | 6 +++--- 17 files changed, 57 insertions(+), 48 deletions(-) mode change 100644 => 100755 samples/snippets/psql-snippets/add_column.sh mode change 100644 => 100755 samples/snippets/psql-snippets/create_connection.sh mode change 100644 => 100755 samples/snippets/psql-snippets/create_tables.sh mode change 100644 => 100755 samples/snippets/psql-snippets/data_boost.sh mode change 100644 => 100755 samples/snippets/psql-snippets/ddl_batch.sh mode change 100644 => 100755 samples/snippets/psql-snippets/partitioned_dml.sh mode change 100644 => 100755 samples/snippets/psql-snippets/query_data.sh create mode 100755 samples/snippets/psql-snippets/query_data_with_new_column.sh mode change 100644 => 100755 samples/snippets/psql-snippets/query_data_with_parameter.sh mode change 100644 => 100755 samples/snippets/psql-snippets/read_only_transaction.sh mode change 100644 => 100755 samples/snippets/psql-snippets/statement_timeout.sh mode change 100644 => 100755 samples/snippets/psql-snippets/tags.sh mode change 100644 => 100755 samples/snippets/psql-snippets/update_data_with_copy.sh mode change 100644 => 100755 samples/snippets/psql-snippets/update_data_with_transaction.sh mode change 100644 => 100755 samples/snippets/psql-snippets/write_data_with_copy.sh mode change 100644 => 100755 samples/snippets/psql-snippets/write_data_with_dml.sh mode change 100644 => 100755 samples/snippets/psql-snippets/write_data_with_dml_batch.sh diff --git a/samples/snippets/psql-snippets/add_column.sh b/samples/snippets/psql-snippets/add_column.sh old mode 100644 new mode 100755 index 080d314ae..acfff9e10 --- a/samples/snippets/psql-snippets/add_column.sh +++ b/samples/snippets/psql-snippets/add_column.sh @@ -1,7 +1,7 @@ #!/bin/bash -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" psql -c "ALTER TABLE albums ADD COLUMN marketing_budget bigint" diff --git a/samples/snippets/psql-snippets/create_connection.sh b/samples/snippets/psql-snippets/create_connection.sh old mode 100644 new mode 100755 index 0182937a7..8210b891c --- a/samples/snippets/psql-snippets/create_connection.sh +++ b/samples/snippets/psql-snippets/create_connection.sh @@ -3,9 +3,9 @@ # Set the connection variables for psql. # The following statements use the existing value of the variable if it has # already been set, and otherwise assigns a default value. -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" # Connect to Cloud Spanner using psql through PGAdapter # and execute a simple query. diff --git a/samples/snippets/psql-snippets/create_tables.sh b/samples/snippets/psql-snippets/create_tables.sh old mode 100644 new mode 100755 index 020dfc6e0..e60ac6b56 --- a/samples/snippets/psql-snippets/create_tables.sh +++ b/samples/snippets/psql-snippets/create_tables.sh @@ -3,9 +3,9 @@ # Set the connection variables for psql. # The following statements use the existing value of the variable if it has # already been set, and otherwise assigns a default value. -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" # Create two tables in one batch. psql << SQL diff --git a/samples/snippets/psql-snippets/data_boost.sh b/samples/snippets/psql-snippets/data_boost.sh old mode 100644 new mode 100755 index 6062ff2e8..87ffb8687 --- a/samples/snippets/psql-snippets/data_boost.sh +++ b/samples/snippets/psql-snippets/data_boost.sh @@ -1,8 +1,8 @@ #!/bin/bash -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" # 'set spanner.data_boost_enabled=true' enables Data Boost for # all partitioned queries on this connection. diff --git a/samples/snippets/psql-snippets/ddl_batch.sh b/samples/snippets/psql-snippets/ddl_batch.sh old mode 100644 new mode 100755 index b83df784b..519718086 --- a/samples/snippets/psql-snippets/ddl_batch.sh +++ b/samples/snippets/psql-snippets/ddl_batch.sh @@ -1,8 +1,8 @@ #!/bin/bash -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" # Use a single SQL command to batch multiple statements together. # Executing multiple DDL statements as one batch is more efficient diff --git a/samples/snippets/psql-snippets/partitioned_dml.sh b/samples/snippets/psql-snippets/partitioned_dml.sh old mode 100644 new mode 100755 index b0feb8803..6e3ebc056 --- a/samples/snippets/psql-snippets/partitioned_dml.sh +++ b/samples/snippets/psql-snippets/partitioned_dml.sh @@ -1,8 +1,8 @@ #!/bin/bash -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" # Change the DML mode that is used by this connection to Partitioned # DML. Partitioned DML is designed for bulk updates and deletes. diff --git a/samples/snippets/psql-snippets/query_data.sh b/samples/snippets/psql-snippets/query_data.sh old mode 100644 new mode 100755 index 14ff290f2..8ba8a5408 --- a/samples/snippets/psql-snippets/query_data.sh +++ b/samples/snippets/psql-snippets/query_data.sh @@ -1,8 +1,8 @@ #!/bin/bash -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" psql -c "SELECT singer_id, album_id, album_title FROM albums" diff --git a/samples/snippets/psql-snippets/query_data_with_new_column.sh b/samples/snippets/psql-snippets/query_data_with_new_column.sh new file mode 100755 index 000000000..e9904777b --- /dev/null +++ b/samples/snippets/psql-snippets/query_data_with_new_column.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" + +psql -c "SELECT singer_id, album_id, marketing_budget + FROM albums + ORDER BY singer_id, album_id" diff --git a/samples/snippets/psql-snippets/query_data_with_parameter.sh b/samples/snippets/psql-snippets/query_data_with_parameter.sh old mode 100644 new mode 100755 index 81e0d8baf..d853aa6ac --- a/samples/snippets/psql-snippets/query_data_with_parameter.sh +++ b/samples/snippets/psql-snippets/query_data_with_parameter.sh @@ -1,8 +1,8 @@ #!/bin/bash -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" # Create a prepared statement to use a query parameter. # Using a prepared statement for executing the same SQL string multiple diff --git a/samples/snippets/psql-snippets/read_only_transaction.sh b/samples/snippets/psql-snippets/read_only_transaction.sh old mode 100644 new mode 100755 index 5ad5af8f1..306967d52 --- a/samples/snippets/psql-snippets/read_only_transaction.sh +++ b/samples/snippets/psql-snippets/read_only_transaction.sh @@ -1,8 +1,8 @@ #!/bin/bash -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" psql << SQL -- Begin a transaction. diff --git a/samples/snippets/psql-snippets/statement_timeout.sh b/samples/snippets/psql-snippets/statement_timeout.sh old mode 100644 new mode 100755 index b2a88ec81..1d690af54 --- a/samples/snippets/psql-snippets/statement_timeout.sh +++ b/samples/snippets/psql-snippets/statement_timeout.sh @@ -1,8 +1,8 @@ #!/bin/bash -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" # Set the statement timeout that should be used for all statements # on this connection to 5 seconds. diff --git a/samples/snippets/psql-snippets/tags.sh b/samples/snippets/psql-snippets/tags.sh old mode 100644 new mode 100755 index 60e84099b..f97b4fea7 --- a/samples/snippets/psql-snippets/tags.sh +++ b/samples/snippets/psql-snippets/tags.sh @@ -1,8 +1,8 @@ #!/bin/bash -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" psql << SQL -- Start a transaction. diff --git a/samples/snippets/psql-snippets/update_data_with_copy.sh b/samples/snippets/psql-snippets/update_data_with_copy.sh old mode 100644 new mode 100755 index b2126c919..7455b78db --- a/samples/snippets/psql-snippets/update_data_with_copy.sh +++ b/samples/snippets/psql-snippets/update_data_with_copy.sh @@ -1,8 +1,8 @@ #!/bin/bash -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" # Instruct PGAdapter to use insert-or-update for COPY statements. # This enables us to use COPY to update data. diff --git a/samples/snippets/psql-snippets/update_data_with_transaction.sh b/samples/snippets/psql-snippets/update_data_with_transaction.sh old mode 100644 new mode 100755 index eaff993d6..2fb040e9d --- a/samples/snippets/psql-snippets/update_data_with_transaction.sh +++ b/samples/snippets/psql-snippets/update_data_with_transaction.sh @@ -1,8 +1,8 @@ #!/bin/bash -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" psql << SQL -- Transfer marketing budget from one album to another. diff --git a/samples/snippets/psql-snippets/write_data_with_copy.sh b/samples/snippets/psql-snippets/write_data_with_copy.sh old mode 100644 new mode 100755 index 6d2c65aea..730277b1a --- a/samples/snippets/psql-snippets/write_data_with_copy.sh +++ b/samples/snippets/psql-snippets/write_data_with_copy.sh @@ -3,9 +3,9 @@ # Get the source directory of this script. directory=${BASH_SOURCE%/*}/ -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" # Copy data to Spanner from a tab-separated text file using the COPY command. psql -c "COPY singers (singer_id, first_name, last_name) FROM STDIN" \ diff --git a/samples/snippets/psql-snippets/write_data_with_dml.sh b/samples/snippets/psql-snippets/write_data_with_dml.sh old mode 100644 new mode 100755 index 13c4506f0..38e6a4350 --- a/samples/snippets/psql-snippets/write_data_with_dml.sh +++ b/samples/snippets/psql-snippets/write_data_with_dml.sh @@ -1,8 +1,8 @@ #!/bin/bash -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" psql -c "INSERT INTO singers (singer_id, first_name, last_name) VALUES (12, 'Melissa', 'Garcia'), diff --git a/samples/snippets/psql-snippets/write_data_with_dml_batch.sh b/samples/snippets/psql-snippets/write_data_with_dml_batch.sh old mode 100644 new mode 100755 index f08f36147..2c44f17c7 --- a/samples/snippets/psql-snippets/write_data_with_dml_batch.sh +++ b/samples/snippets/psql-snippets/write_data_with_dml_batch.sh @@ -1,8 +1,8 @@ #!/bin/bash -PGHOST="${PGHOST:-localhost}" -PGPORT="${PGPORT:-5432}" -PGDATABASE="${PGDATABASE:-example-db}" +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGDATABASE="${PGDATABASE:-example-db}" # Create a prepared insert statement and execute this prepared # insert statement three times in one SQL string. The single