mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
psql: Add command to use extended query protocol
This adds a new psql command \bind that sets query parameters and
causes the next query to be sent using the extended query protocol.
Example:
SELECT $1, $2 \bind 'foo' 'bar' \g
This may be useful for psql scripting, but one of the main purposes is
also to be able to test various aspects of the extended query protocol
from psql and to write tests more easily.
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/e8dd1cd5-0e04-3598-0518-a605159fe314@enterprisedb.com
This commit is contained in:
@@ -45,6 +45,20 @@ SELECT 1 as one, 2 as two \g (format=csv csv_fieldsep='\t')
|
||||
SELECT 1 as one, 2 as two \gx (title='foo bar')
|
||||
\g
|
||||
|
||||
-- \bind (extended query protocol)
|
||||
|
||||
SELECT 1 \bind \g
|
||||
SELECT $1 \bind 'foo' \g
|
||||
SELECT $1, $2 \bind 'foo' 'bar' \g
|
||||
|
||||
-- errors
|
||||
-- parse error
|
||||
SELECT foo \bind \g
|
||||
-- tcop error
|
||||
SELECT 1 \; SELECT 2 \bind \g
|
||||
-- bind error
|
||||
SELECT $1, $2 \bind 'foo' \g
|
||||
|
||||
-- \gset
|
||||
|
||||
select 10 as test01, 20 as test02, 'Hello' as test03 \gset pref01_
|
||||
|
||||
Reference in New Issue
Block a user