This commit is contained in:
Kruglov Pavel 2024-09-18 19:37:18 +00:00 committed by GitHub
commit 98a6b04b4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#if USE_LIBPQXX
#include <Columns/ColumnNullable.h>
#include <Columns/ColumnString.h>
#include <Columns/ColumnFixedString.h>
#include <Columns/ColumnArray.h>
#include <Columns/ColumnsNumber.h>
#include <Columns/ColumnDecimal.h>
@ -82,6 +83,8 @@ void insertPostgreSQLValue(
case ExternalResultDescription::ValueType::vtEnum8:
case ExternalResultDescription::ValueType::vtEnum16:
case ExternalResultDescription::ValueType::vtFixedString:
assert_cast<ColumnFixedString &>(column).insertData(value.data(), value.size());
break;
case ExternalResultDescription::ValueType::vtString:
assert_cast<ColumnString &>(column).insertData(value.data(), value.size());
break;

View File

@ -526,6 +526,7 @@ def test_postgres_distributed(started_cluster):
result = node2.query("SELECT DISTINCT(name) FROM test_shards ORDER BY name")
started_cluster.unpause_container("postgres1")
assert result == "host2\nhost4\n" or result == "host3\nhost4\n"
node2.query("DROP TABLE test_shards2")
node2.query("DROP TABLE test_shards")
node2.query("DROP TABLE test_replicas")
@ -817,6 +818,9 @@ def test_auto_close_connection(started_cluster):
# Connection from python + pg_stat table also has a connection at the moment of current query
assert count == 2
node2.query("DROP TABLE test.stat")
node2.query("DROP TABLE test.test_table")
def test_literal_escaping(started_cluster):
cursor = started_cluster.postgres_conn.cursor()
@ -832,6 +836,7 @@ def test_literal_escaping(started_cluster):
node1.query("SELECT * FROM escaping WHERE text like '%a''a%'") # %a'a% -> %a''a%
node1.query("SELECT * FROM escaping WHERE text like '%a\\'a%'") # %a'a% -> %a''a%
cursor.execute(f"DROP TABLE escaping")
node1.query("DROP TABLE default.escaping")
def test_filter_pushdown(started_cluster):
@ -886,6 +891,30 @@ def test_filter_pushdown(started_cluster):
)
cursor.execute("DROP SCHEMA test_filter_pushdown CASCADE")
node1.query("DROP TABLE test_filter_pushdown_local_table")
node1.query("DROP TABLE test_filter_pushdown_pg_table")
def test_fixed_string_type(started_cluster):
cursor = started_cluster.postgres_conn.cursor()
cursor.execute("DROP TABLE IF EXISTS test_fixed_string")
cursor.execute(
"CREATE TABLE test_fixed_string (contact_id numeric NULL, email varchar NULL)"
)
cursor.execute("INSERT INTO test_fixed_string values (1, 'abc')")
node1.query("DROP TABLE IF EXISTS test_fixed_string")
node1.query(
"CREATE TABLE test_fixed_string(contact_id Int64, email Nullable(FixedString(3))) ENGINE = PostgreSQL('postgres1:5432', 'postgres', 'test_fixed_string', 'postgres', 'mysecretpassword')"
)
result = node1.query("SELECT * FROM test_fixed_string format TSV")
assert result.strip() == "1\tabc"
node1.query("DROP TABLE test_fixed_string")
if __name__ == "__main__":