Commit baed879a authored by IKEDA Soji's avatar IKEDA Soji
Browse files

PostgreSQL: Add a view "dual" to make some SQL statements portable.

parent 27b86fa1
......@@ -61,11 +61,19 @@ sub connect {
# - Configure Postgres to use ISO format dates.
# - Set client encoding to UTF8.
# - Create a temporary view "dual" for portable SQL statements.
# Note: utf8 flagging must be disabled so that we will consistently use
# UTF-8 bytestring as internal format.
# UTF-8 bytestring as internal format.
# Note: PostgreSQL <= 8.0.x didn't support temporary view but >= 7.3.x
# supported CREATE OR REPLACE statement.
$self->__dbh->{pg_enable_utf8} = 0; # For DBD::Pg 3.x
$self->__dbh->do("SET DATESTYLE TO 'ISO';");
$self->__dbh->do("SET NAMES 'utf8'");
defined $self->__dbh->do(
q{CREATE TEMPORARY VIEW dual AS SELECT 'X'::varchar(1) AS dummy;}
) or $self->__dbh->do(
q{CREATE OR REPLACE VIEW dual AS SELECT 'X'::varchar(1) AS dummy;}
);
return 1;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment