mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Backport #69584 to 24.8: Fix inserting into FixedString column in PostgreSQL engine
This commit is contained in:
parent
fa3d99b00a
commit
462c2cc55b
@ -3,6 +3,7 @@
|
|||||||
#if USE_LIBPQXX
|
#if USE_LIBPQXX
|
||||||
#include <Columns/ColumnNullable.h>
|
#include <Columns/ColumnNullable.h>
|
||||||
#include <Columns/ColumnString.h>
|
#include <Columns/ColumnString.h>
|
||||||
|
#include <Columns/ColumnFixedString.h>
|
||||||
#include <Columns/ColumnArray.h>
|
#include <Columns/ColumnArray.h>
|
||||||
#include <Columns/ColumnsNumber.h>
|
#include <Columns/ColumnsNumber.h>
|
||||||
#include <Columns/ColumnDecimal.h>
|
#include <Columns/ColumnDecimal.h>
|
||||||
@ -82,6 +83,8 @@ void insertPostgreSQLValue(
|
|||||||
case ExternalResultDescription::ValueType::vtEnum8:
|
case ExternalResultDescription::ValueType::vtEnum8:
|
||||||
case ExternalResultDescription::ValueType::vtEnum16:
|
case ExternalResultDescription::ValueType::vtEnum16:
|
||||||
case ExternalResultDescription::ValueType::vtFixedString:
|
case ExternalResultDescription::ValueType::vtFixedString:
|
||||||
|
assert_cast<ColumnFixedString &>(column).insertData(value.data(), value.size());
|
||||||
|
break;
|
||||||
case ExternalResultDescription::ValueType::vtString:
|
case ExternalResultDescription::ValueType::vtString:
|
||||||
assert_cast<ColumnString &>(column).insertData(value.data(), value.size());
|
assert_cast<ColumnString &>(column).insertData(value.data(), value.size());
|
||||||
break;
|
break;
|
||||||
|
@ -526,6 +526,7 @@ def test_postgres_distributed(started_cluster):
|
|||||||
result = node2.query("SELECT DISTINCT(name) FROM test_shards ORDER BY name")
|
result = node2.query("SELECT DISTINCT(name) FROM test_shards ORDER BY name")
|
||||||
started_cluster.unpause_container("postgres1")
|
started_cluster.unpause_container("postgres1")
|
||||||
assert result == "host2\nhost4\n" or result == "host3\nhost4\n"
|
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_shards")
|
||||||
node2.query("DROP TABLE test_replicas")
|
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
|
# Connection from python + pg_stat table also has a connection at the moment of current query
|
||||||
assert count == 2
|
assert count == 2
|
||||||
|
|
||||||
|
node2.query("DROP TABLE test.stat")
|
||||||
|
node2.query("DROP TABLE test.test_table")
|
||||||
|
|
||||||
|
|
||||||
def test_literal_escaping(started_cluster):
|
def test_literal_escaping(started_cluster):
|
||||||
cursor = started_cluster.postgres_conn.cursor()
|
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%
|
||||||
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")
|
cursor.execute(f"DROP TABLE escaping")
|
||||||
|
node1.query("DROP TABLE default.escaping")
|
||||||
|
|
||||||
|
|
||||||
def test_filter_pushdown(started_cluster):
|
def test_filter_pushdown(started_cluster):
|
||||||
@ -886,6 +891,28 @@ def test_filter_pushdown(started_cluster):
|
|||||||
)
|
)
|
||||||
|
|
||||||
cursor.execute("DROP SCHEMA test_filter_pushdown CASCADE")
|
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__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user