Hello community, here is the log from the commit of package perl-DBD-Pg for openSUSE:Factory checked in at 2014-08-25 11:04:03 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-DBD-Pg (Old) and /work/SRC/openSUSE:Factory/.perl-DBD-Pg.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-DBD-Pg" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-DBD-Pg/perl-DBD-Pg.changes 2014-06-04 18:39:52.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.perl-DBD-Pg.new/perl-DBD-Pg.changes 2014-08-25 11:05:12.000000000 +0200 @@ -1,0 +2,33 @@ +Thu Aug 21 11:40:23 UTC 2014 - [email protected] + +- Update to version 3.4.1 from 3.4.0 + Change from upstream: + - Allow '%' again for the type in table_info() and thus tables() + It's not documented or tested in DBI, but it used to work until + DBD::Pg 3.4.0, and the change broke DBIx::Class::Schema::Loader, which + uses type='%'. + +------------------------------------------------------------------- +Mon Aug 18 12:18:56 UTC 2014 - [email protected] + +- update to version 3.4.0 from 3.3.0 + Upstream changes: + - Cleanup and improve table_info() + table_info() type searching now supports TABLE, VIEW, SYSTEM TABLE, + SYSTEM VIEW, and LOCAL TEMPORARY + + table_info() object searching fully supports the above types. + + table_info() object searching no longer ignores invalid types - a filter + of 'NOSUCH' will return no rows, and 'NOSUCH,LOCAL TEMPORARY' will + return only temp objects. + + tableinfo() type filters are strictly matched now ... previously a + search for SYSTEM TABLE would have fetched plain TABLE objects. + + table_info() now treats temporary tables and temporary views as LOCAL + TEMPORARY + + - Make sure column_info() and table_info() can handle materialized views. + +------------------------------------------------------------------- Old: ---- DBD-Pg-3.3.0.tar.gz New: ---- DBD-Pg-3.4.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-DBD-Pg.spec ++++++ --- /var/tmp/diff_new_pack.lMyXg9/_old 2014-08-25 11:05:13.000000000 +0200 +++ /var/tmp/diff_new_pack.lMyXg9/_new 2014-08-25 11:05:13.000000000 +0200 @@ -21,7 +21,7 @@ Summary: PostgreSQL database driver for the DBI module License: GPL-1.0+ or Artistic-1.0 Group: Development/Libraries/Perl -Version: 3.3.0 +Version: 3.4.1 Release: 0 Url: http://search.cpan.org/dist/DBD-Pg/ Source: http://www.cpan.org/authors/id/T/TU/TURNSTEP/DBD-Pg-%{version}.tar.gz ++++++ DBD-Pg-3.3.0.tar.gz -> DBD-Pg-3.4.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DBD-Pg-3.3.0/Changes new/DBD-Pg-3.4.1/Changes --- old/DBD-Pg-3.3.0/Changes 2014-05-31 20:48:02.000000000 +0200 +++ new/DBD-Pg-3.4.1/Changes 2014-08-20 22:36:20.000000000 +0200 @@ -1,6 +1,38 @@ 'GSM' is Greg Sabino Mullane, [email protected] +Version 3.4.1 Released August 20, 2014 (git commit cfd146effde09c493ac7573408ac29d6d9cbed47) + + - Allow '%' again for the type in table_info() and thus tables() + It's not documented or tested in DBI, but it used to work until + DBD::Pg 3.4.0, and the change broke DBIx::Class::Schema::Loader, which + uses type='%'. + [Dagfinn Ilmari Mannsåker <[email protected]>] + + +Version 3.4.0 Released August 16, 2014 (git commit 7a5da12d84b4c2e9879f90fb6168f56c095071fa) + + - Cleanup and improve table_info() + [Mike Pomraning <[email protected]>] (github issue #7) + + table_info() type searching now supports TABLE, VIEW, SYSTEM TABLE, + SYSTEM VIEW, and LOCAL TEMPORARY + + table_info() object searching fully supports the above types. + + table_info() object searching no longer ignores invalid types - a filter + of 'NOSUCH' will return no rows, and 'NOSUCH,LOCAL TEMPORARY' will + return only temp objects. + + tableinfo() type filters are strictly matched now ... previously a + search for SYSTEM TABLE would have fetched plain TABLE objects. + + table_info() now treats temporary tables and temporary views as LOCAL TEMPORARY + + - Make sure column_info() and table_info() can handle materialized views. + [Greg Sabino Mullane] (CPAN bug #97032) + + Version 3.3.0 Released May 31, 2014 (git commit 055f788cf96b380b9fe0e80b6cedb88f8d1799b8) - Major cleanup of UTF-8 support: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DBD-Pg-3.3.0/META.yml new/DBD-Pg-3.4.1/META.yml --- old/DBD-Pg-3.3.0/META.yml 2014-05-21 18:20:48.000000000 +0200 +++ new/DBD-Pg-3.4.1/META.yml 2014-08-20 01:55:43.000000000 +0200 @@ -1,6 +1,6 @@ --- #YAML:1.0 name : DBD-Pg -version : 3.3.0 +version : 3.4.1 abstract : DBI PostgreSQL interface author: - Greg Sabino Mullane <[email protected]> @@ -30,10 +30,10 @@ provides: DBD::Pg: file : Pg.pm - version : 3.3.0 + version : 3.4.1 Bundle::DBD::Pg: file : lib/Bundle/DBD/Pg.pm - version : 3.3.0 + version : 3.4.1 keywords: - Postgres diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DBD-Pg-3.3.0/Makefile.PL new/DBD-Pg-3.4.1/Makefile.PL --- old/DBD-Pg-3.3.0/Makefile.PL 2014-05-21 18:21:02.000000000 +0200 +++ new/DBD-Pg-3.4.1/Makefile.PL 2014-08-20 01:55:49.000000000 +0200 @@ -5,7 +5,7 @@ use 5.008001; ## No version.pm for this one, as the prereqs are not loaded yet. -my $VERSION = '3.3.0'; +my $VERSION = '3.4.1'; ## App::Info is stored inside t/lib ## Create a proper path so we can use it below diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DBD-Pg-3.3.0/Pg.pm new/DBD-Pg-3.4.1/Pg.pm --- old/DBD-Pg-3.3.0/Pg.pm 2014-05-31 20:45:27.000000000 +0200 +++ new/DBD-Pg-3.4.1/Pg.pm 2014-08-20 01:55:59.000000000 +0200 @@ -16,7 +16,7 @@ { package DBD::Pg; - use version; our $VERSION = qv('3.3.0'); + use version; our $VERSION = qv('3.4.1'); use DBI (); use DynaLoader (); @@ -485,7 +485,7 @@ $schemajoin WHERE a.attnum >= 0 - AND c.relkind IN ('r','v') + AND c.relkind IN ('r','v','m') $whereclause ORDER BY "TABLE_SCHEM", "TABLE_NAME", "ORDINAL_POSITION" !; @@ -1044,190 +1044,220 @@ and (defined $table and $table eq '') and (defined $type and $type eq '%') ) { - $tbl_sql = qq{ - SELECT - NULL::text AS "TABLE_CAT" - , NULL::text AS "TABLE_SCHEM" - , NULL::text AS "TABLE_NAME" - , 'TABLE' AS "TABLE_TYPE" - , 'relkind: r' AS "REMARKS" $extracols - UNION - SELECT - NULL::text AS "TABLE_CAT" - , NULL::text AS "TABLE_SCHEM" - , NULL::text AS "TABLE_NAME" - , 'VIEW' AS "TABLE_TYPE" - , 'relkind: v' AS "REMARKS" $extracols + $tbl_sql = q{ + SELECT "TABLE_CAT" + , "TABLE_SCHEM" + , "TABLE_NAME" + , "TABLE_TYPE" + , "REMARKS" + FROM + (SELECT NULL::text AS "TABLE_CAT" + , NULL::text AS "TABLE_SCHEM" + , NULL::text AS "TABLE_NAME") dummy_cols + CROSS JOIN + (SELECT 'TABLE' AS "TABLE_TYPE" + , 'relkind: r' AS "REMARKS" + UNION + SELECT 'SYSTEM TABLE' + , 'relkind: r; nspname ~ ^pg_(catalog|toast)$' + UNION + SELECT 'VIEW' + , 'relkind: v' + UNION + SELECT 'SYSTEM VIEW' + , 'relkind: v; nspname ~ ^pg_(catalog|toast)$' + UNION + SELECT 'MATERIALIZED VIEW' + , 'relkind: m' + UNION + SELECT 'SYSTEM MATERIALIZED VIEW' + , 'relkind: m; nspname ~ ^pg_(catalog|toast)$' + UNION + SELECT 'LOCAL TEMPORARY' + , 'relkind: r; nspname ~ ^pg_(toast_)?temp') type_info + ORDER BY "TABLE_TYPE" ASC }; - } - else { - # Default SQL - $extracols = q{,n.nspname AS pg_schema, c.relname AS pg_table}; - my @search; - my $showtablespace = ', quote_ident(t.spcname) AS "pg_tablespace_name", quote_ident(t.spclocation) AS "pg_tablespace_location"'; - if ($dbh->{private_dbdpg}{version} >= 90200) { - $showtablespace = ', quote_ident(t.spcname) AS "pg_tablespace_name", quote_ident(pg_tablespace_location(t.oid)) AS "pg_tablespace_location"'; - } - - ## If the schema or table has an underscore or a %, use a LIKE comparison - if (defined $schema and length $schema) { - push @search, 'n.nspname ' . ($schema =~ /[_%]/ ? 'LIKE ' : '= ') . $dbh->quote($schema); - } - if (defined $table and length $table) { - push @search, 'c.relname ' . ($table =~ /[_%]/ ? 'LIKE ' : '= ') . $dbh->quote($table); - } - ## All we can see is "table" or "view". Default is both - my $typesearch = q{IN ('r','v')}; - if (defined $type and length $type) { - if ($type =~ /\btable\b/i and $type !~ /\bview\b/i) { - $typesearch = q{= 'r'}; - } - elsif ($type =~ /\bview\b/i and $type !~ /\btable\b/i) { - $typesearch = q{= 'v'}; - } - } - push @search, "c.relkind $typesearch"; - - my $TSJOIN = 'pg_catalog.pg_tablespace t ON (t.oid = c.reltablespace)'; - if ($dbh->{private_dbdpg}{version} < 80000) { - $TSJOIN = '(SELECT 0 AS oid, 0 AS spcname, 0 AS spclocation LIMIT 0) AS t ON (t.oid=1)'; - } - my $whereclause = join "\n\t\t\t\t\t AND " => @search; - $tbl_sql = qq{ + } + else { + # Default SQL + $extracols = q{,n.nspname AS pg_schema, c.relname AS pg_table}; + my @search = (q|c.relkind IN ('r', 'v', 'm')|, # No sequences, etc. for now + q|NOT (quote_ident(n.nspname) ~ '^pg_(toast_)?temp_' AND NOT has_schema_privilege(n.nspname, 'USAGE'))|); # No others' temp objects + my $showtablespace = ', quote_ident(t.spcname) AS "pg_tablespace_name", quote_ident(t.spclocation) AS "pg_tablespace_location"'; + if ($dbh->{private_dbdpg}{version} >= 90200) { + $showtablespace = ', quote_ident(t.spcname) AS "pg_tablespace_name", quote_ident(pg_tablespace_location(t.oid)) AS "pg_tablespace_location"'; + } + + ## If the schema or table has an underscore or a %, use a LIKE comparison + if (defined $schema and length $schema) { + push @search, 'n.nspname ' . ($schema =~ /[_%]/ ? 'LIKE ' : '= ') . $dbh->quote($schema); + } + if (defined $table and length $table) { + push @search, 'c.relname ' . ($table =~ /[_%]/ ? 'LIKE ' : '= ') . $dbh->quote($table); + } + + my $TSJOIN = 'pg_catalog.pg_tablespace t ON (t.oid = c.reltablespace)'; + if ($dbh->{private_dbdpg}{version} < 80000) { + $TSJOIN = '(SELECT 0 AS oid, 0 AS spcname, 0 AS spclocation LIMIT 0) AS t ON (t.oid=1)'; + } + my $whereclause = join "\n\t\t\t\t\t AND " => @search; + $tbl_sql = qq{ SELECT NULL::text AS "TABLE_CAT" , quote_ident(n.nspname) AS "TABLE_SCHEM" , quote_ident(c.relname) AS "TABLE_NAME" - , CASE - WHEN c.relkind = 'v' THEN - CASE WHEN quote_ident(n.nspname) ~ '^pg_' THEN 'SYSTEM VIEW' ELSE 'VIEW' END - ELSE - CASE WHEN quote_ident(n.nspname) ~ '^pg_' THEN 'SYSTEM TABLE' ELSE 'TABLE' END - END AS "TABLE_TYPE" + -- any temp table or temp view is LOCAL TEMPORARY for us + , CASE WHEN quote_ident(n.nspname) ~ '^pg_(toast_)?temp_' THEN + 'LOCAL TEMPORARY' + WHEN c.relkind = 'r' THEN + CASE WHEN quote_ident(n.nspname) ~ '^pg_' THEN + 'SYSTEM TABLE' + ELSE 'TABLE' + END + WHEN c.relkind = 'v' THEN + CASE WHEN quote_ident(n.nspname) ~ '^pg_' THEN + 'SYSTEM VIEW' + ELSE 'VIEW' + END + WHEN c.relkind = 'm' THEN + CASE WHEN quote_ident(n.nspname) ~ '^pg_' THEN + 'SYSTEM MATERIALIZED VIEW' + ELSE 'MATERIALIZED VIEW' + END + ELSE 'UNKNOWN' + END AS "TABLE_TYPE" , d.description AS "REMARKS" $showtablespace $extracols - FROM pg_catalog.pg_class AS c - LEFT JOIN pg_catalog.pg_description AS d - ON (c.oid = d.objoid AND c.tableoid = d.classoid AND d.objsubid = 0) - LEFT JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) - LEFT JOIN $TSJOIN - WHERE $whereclause - ORDER BY "TABLE_TYPE", "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME" + FROM pg_catalog.pg_class AS c + LEFT JOIN pg_catalog.pg_description AS d + ON (c.oid = d.objoid AND c.tableoid = d.classoid AND d.objsubid = 0) + LEFT JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) + LEFT JOIN $TSJOIN + WHERE $whereclause + ORDER BY "TABLE_TYPE", "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME" }; - } - my $sth = $dbh->prepare( $tbl_sql ) or return undef; - $sth->execute(); - - return $sth; - } - - sub tables { - my ($dbh, @args) = @_; - my $attr = $args[4]; - my $sth = $dbh->table_info(@args) or return; - my $tables = $sth->fetchall_arrayref() or return; - my @tables = map { (! (ref $attr eq 'HASH' and $attr->{pg_noprefix})) ? - "$_->[1].$_->[2]" : $_->[2] } @$tables; - return @tables; - } - sub table_attributes { - my ($dbh, $table) = @_; + if (defined($type) and length($type) and $type ne '%') { + my $type_restrict = join ', ' => + map { $dbh->quote($_) unless /^'/ } + grep {length} + split(',', $type); + $tbl_sql = qq{SELECT * FROM ($tbl_sql) ti WHERE "TABLE_TYPE" IN ($type_restrict)}; + } + } + my $sth = $dbh->prepare( $tbl_sql ) or return undef; + $sth->execute(); - my $sth = $dbh->column_info(undef,undef,$table,undef); + return $sth; + } - my %convert = ( - COLUMN_NAME => 'NAME', - DATA_TYPE => 'TYPE', - COLUMN_SIZE => 'SIZE', - NULLABLE => 'NOTNULL', - REMARKS => 'REMARKS', - COLUMN_DEF => 'DEFAULT', - pg_constraint => 'CONSTRAINT', - ); + sub tables { + my ($dbh, @args) = @_; + my $attr = $args[4]; + my $sth = $dbh->table_info(@args) or return; + my $tables = $sth->fetchall_arrayref() or return; + my @tables = map { (! (ref $attr eq 'HASH' and $attr->{pg_noprefix})) ? + "$_->[1].$_->[2]" : $_->[2] } @$tables; + return @tables; + } - my $attrs = $sth->fetchall_arrayref(\%convert); + sub table_attributes { + my ($dbh, $table) = @_; - for my $row (@$attrs) { - # switch the column names - for my $name (keys %$row) { - $row->{ $convert{$name} } = $row->{$name}; + my $sth = $dbh->column_info(undef,undef,$table,undef); - ## Keep some original columns - delete $row->{$name} unless ($name eq 'REMARKS' or $name eq 'NULLABLE'); + my %convert = ( + COLUMN_NAME => 'NAME', + DATA_TYPE => 'TYPE', + COLUMN_SIZE => 'SIZE', + NULLABLE => 'NOTNULL', + REMARKS => 'REMARKS', + COLUMN_DEF => 'DEFAULT', + pg_constraint => 'CONSTRAINT', + ); + + my $attrs = $sth->fetchall_arrayref(\%convert); + + for my $row (@$attrs) { + # switch the column names + for my $name (keys %$row) { + $row->{ $convert{$name} } = $row->{$name}; + + ## Keep some original columns + delete $row->{$name} unless ($name eq 'REMARKS' or $name eq 'NULLABLE'); + + } + # Moved check outside of loop as it was inverting the NOTNULL value for + # attribute. + # NOTNULL inverts the sense of NULLABLE + $row->{NOTNULL} = ($row->{NOTNULL} ? 0 : 1); + + my @pri_keys = $dbh->primary_key( undef, undef, $table ); + $row->{PRIMARY_KEY} = scalar(grep { /^$row->{NAME}$/i } @pri_keys) ? 1 : 0; + } - } - # Moved check outside of loop as it was inverting the NOTNULL value for - # attribute. - # NOTNULL inverts the sense of NULLABLE - $row->{NOTNULL} = ($row->{NOTNULL} ? 0 : 1); + return $attrs; - my @pri_keys = $dbh->primary_key( undef, undef, $table ); - $row->{PRIMARY_KEY} = scalar(grep { /^$row->{NAME}$/i } @pri_keys) ? 1 : 0; - } - - return $attrs; - - } + } - sub _calc_col_size { + sub _calc_col_size { - my $mod = shift; - my $size = shift; + my $mod = shift; + my $size = shift; - if ((defined $size) and ($size > 0)) { - return $size; - } elsif ($mod > 0xffff) { - my $prec = ($mod & 0xffff) - 4; - $mod >>= 16; - my $dig = $mod; - return "$prec,$dig"; - } elsif ($mod >= 4) { - return $mod - 4; - } # else { - # $rtn = $mod; - # $rtn = undef; - # } + if ((defined $size) and ($size > 0)) { + return $size; + } elsif ($mod > 0xffff) { + my $prec = ($mod & 0xffff) - 4; + $mod >>= 16; + my $dig = $mod; + return "$prec,$dig"; + } elsif ($mod >= 4) { + return $mod - 4; + } # else { + # $rtn = $mod; + # $rtn = undef; + # } - return; - } + return; + } - sub type_info_all { - my ($dbh) = @_; + sub type_info_all { + my ($dbh) = @_; - my $names = - { - TYPE_NAME => 0, - DATA_TYPE => 1, - COLUMN_SIZE => 2, - LITERAL_PREFIX => 3, - LITERAL_SUFFIX => 4, - CREATE_PARAMS => 5, - NULLABLE => 6, - CASE_SENSITIVE => 7, - SEARCHABLE => 8, - UNSIGNED_ATTRIBUTE => 9, - FIXED_PREC_SCALE => 10, - AUTO_UNIQUE_VALUE => 11, - LOCAL_TYPE_NAME => 12, - MINIMUM_SCALE => 13, - MAXIMUM_SCALE => 14, - SQL_DATA_TYPE => 15, - SQL_DATETIME_SUB => 16, - NUM_PREC_RADIX => 17, - INTERVAL_PRECISION => 18, - }; - - ## This list is derived from dbi_sql.h in DBI, from types.c and types.h, and from the PG docs - - ## Aids to make the list more readable: - my $GIG = 1073741824; - my $PS = 'precision/scale'; - my $LEN = 'length'; - my $UN; - my $ti = - [ - $names, + my $names = + { + TYPE_NAME => 0, + DATA_TYPE => 1, + COLUMN_SIZE => 2, + LITERAL_PREFIX => 3, + LITERAL_SUFFIX => 4, + CREATE_PARAMS => 5, + NULLABLE => 6, + CASE_SENSITIVE => 7, + SEARCHABLE => 8, + UNSIGNED_ATTRIBUTE => 9, + FIXED_PREC_SCALE => 10, + AUTO_UNIQUE_VALUE => 11, + LOCAL_TYPE_NAME => 12, + MINIMUM_SCALE => 13, + MAXIMUM_SCALE => 14, + SQL_DATA_TYPE => 15, + SQL_DATETIME_SUB => 16, + NUM_PREC_RADIX => 17, + INTERVAL_PRECISION => 18, + }; + + ## This list is derived from dbi_sql.h in DBI, from types.c and types.h, and from the PG docs + + ## Aids to make the list more readable: + my $GIG = 1073741824; + my $PS = 'precision/scale'; + my $LEN = 'length'; + my $UN; + my $ti = + [ + $names, # name sql_type size pfx/sfx crt n/c/s +-/P/I local min max sub rdx itvl ['unknown', SQL_UNKNOWN_TYPE, 0, $UN,$UN, $UN, 1,0,0, $UN,0,0, 'UNKNOWN', $UN,$UN, @@ -1274,31 +1304,31 @@ ['timestamptz',SQL_TYPE_TIMESTAMP_WITH_TIMEZONE, 29, q{'},q{'}, $UN, 1,0,2, $UN,0,0, 'TIMESTAMPTZ',0,6, SQL_TYPE_TIMESTAMP_WITH_TIMEZONE, $UN, $UN, $UN ], - # - # intentionally omitted: char, all geometric types, internal types - ]; - return $ti; - } + # + # intentionally omitted: char, all geometric types, internal types + ]; + return $ti; + } - # Characters that need to be escaped by quote(). - my %esc = ( - q{'} => '\\047', # '\\' . sprintf("%03o", ord("'")), # ISO SQL 2 - '\\' => '\\134', # '\\' . sprintf("%03o", ord("\\")), - ); + # Characters that need to be escaped by quote(). + my %esc = ( + q{'} => '\\047', # '\\' . sprintf("%03o", ord("'")), # ISO SQL 2 + '\\' => '\\134', # '\\' . sprintf("%03o", ord("\\")), + ); - # Set up lookup for SQL types we don't want to escape. - my %no_escape = map { $_ => 1 } - DBI::SQL_INTEGER, DBI::SQL_SMALLINT, DBI::SQL_BIGINT, DBI::SQL_DECIMAL, - DBI::SQL_FLOAT, DBI::SQL_REAL, DBI::SQL_DOUBLE, DBI::SQL_NUMERIC; + # Set up lookup for SQL types we don't want to escape. + my %no_escape = map { $_ => 1 } + DBI::SQL_INTEGER, DBI::SQL_SMALLINT, DBI::SQL_BIGINT, DBI::SQL_DECIMAL, + DBI::SQL_FLOAT, DBI::SQL_REAL, DBI::SQL_DOUBLE, DBI::SQL_NUMERIC; - sub get_info { + sub get_info { - my ($dbh,$type) = @_; + my ($dbh,$type) = @_; - return undef unless defined $type and length $type; + return undef unless defined $type and length $type; - my %type = ( + my %type = ( ## Driver information: @@ -1312,7 +1342,7 @@ 4 => ['SQL_DRIVER_HENV', 0 ], ## not applicable 76 => ['SQL_DRIVER_HLIB', 0 ], ## not applicable 5 => ['SQL_DRIVER_HSTMT', 0 ], ## not applicable - ## Not clear what should go here. Some things suggest 'Pg', others 'Pg.pm'. We'll use DBD::Pg for now + ## Not clear what should go here. Some things suggest 'Pg', others 'Pg.pm'. We'll use DBD::Pg for now 6 => ['SQL_DRIVER_NAME', 'DBD::Pg' ], 77 => ['SQL_DRIVER_ODBC_VERSION', '03.00' ], 7 => ['SQL_DRIVER_VER', 'DBDVERSION' ], ## magic word @@ -1480,146 +1510,146 @@ 125 => ['SQL_CONVERT_WLONGVARCHAR', 0 ], 126 => ['SQL_CONVERT_WVARCHAR', 0 ], - ); ## end of %type + ); ## end of %type - ## Put both numbers and names into a hash - my %t; - for (keys %type) { - $t{$_} = $type{$_}->[1]; - $t{$type{$_}->[0]} = $type{$_}->[1]; - } - - return undef unless exists $t{$type}; - - my $ans = $t{$type}; - - if ($ans eq 'NAMEDATALEN') { - return $dbh->selectall_arrayref('SHOW max_identifier_length')->[0][0]; - } - elsif ($ans eq 'ODBCVERSION') { - my $version = $dbh->{private_dbdpg}{version}; - return '00.00.0000' unless $version =~ /^(\d\d?)(\d\d)(\d\d)$/o; - return sprintf '%02d.%02d.%.2d00', $1,$2,$3; - } - elsif ($ans eq 'DBDVERSION') { - my $simpleversion = $DBD::Pg::VERSION; - $simpleversion =~ s/_/./g; - return sprintf '%02d.%02d.%1d%1d%1d%1d', split (/\./, "$simpleversion.0.0.0.0.0.0"); - } - elsif ($ans eq 'MAXCONNECTIONS') { - return $dbh->selectall_arrayref('SHOW max_connections')->[0][0]; - } - elsif ($ans eq 'ENCODING') { - return $dbh->selectall_arrayref('SHOW server_encoding')->[0][0]; - } - elsif ($ans eq 'KEYWORDS') { - ## http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html - ## Basically, we want ones that are 'reserved' for PostgreSQL but not 'reserved' in SQL:2003 - ## - return join ',' => (qw(ANALYSE ANALYZE ASC DEFERRABLE DESC DO FREEZE ILIKE INITIALLY ISNULL LIMIT NOTNULL OFF OFFSET PLACING RETURNING VERBOSE)); - } - elsif ($ans eq 'CURRENTDB') { - return $dbh->selectall_arrayref('SELECT pg_catalog.current_database()')->[0][0]; - } - elsif ($ans eq 'READONLY') { - my $SQL = q{SELECT CASE WHEN setting = 'on' THEN 'Y' ELSE 'N' END FROM pg_settings WHERE name = 'transaction_read_only'}; - my $info = $dbh->selectall_arrayref($SQL); - return defined $info->[0] ? $info->[0][0] : 'N'; - } - elsif ($ans eq 'DEFAULTTXN') { - my $SQL = q{SELECT CASE WHEN setting = 'read committed' THEN 2 ELSE 8 END FROM pg_settings WHERE name = 'default_transaction_isolation'}; - my $info = $dbh->selectall_arrayref($SQL); - return defined $info->[0] ? $info->[0][0] : 2; - } - - return $ans; - } # end of get_info - - sub private_attribute_info { - return { - pg_async_status => undef, - pg_bool_tf => undef, - pg_db => undef, - pg_default_port => undef, - pg_enable_utf8 => undef, - pg_utf8_flag => undef, - pg_errorlevel => undef, - pg_expand_array => undef, - pg_host => undef, - pg_INV_READ => undef, - pg_INV_WRITE => undef, - pg_lib_version => undef, - pg_options => undef, - pg_pass => undef, - pg_pid => undef, - pg_placeholder_dollaronly => undef, - pg_placeholder_nocolons => undef, - pg_port => undef, - pg_prepare_now => undef, - pg_protocol => undef, - pg_server_prepare => undef, - pg_server_version => undef, - pg_socket => undef, - pg_standard_conforming_strings => undef, - pg_switch_prepared => undef, - pg_user => undef, - }; - } + ## Put both numbers and names into a hash + my %t; + for (keys %type) { + $t{$_} = $type{$_}->[1]; + $t{$type{$_}->[0]} = $type{$_}->[1]; + } + + return undef unless exists $t{$type}; + + my $ans = $t{$type}; + + if ($ans eq 'NAMEDATALEN') { + return $dbh->selectall_arrayref('SHOW max_identifier_length')->[0][0]; + } + elsif ($ans eq 'ODBCVERSION') { + my $version = $dbh->{private_dbdpg}{version}; + return '00.00.0000' unless $version =~ /^(\d\d?)(\d\d)(\d\d)$/o; + return sprintf '%02d.%02d.%.2d00', $1,$2,$3; + } + elsif ($ans eq 'DBDVERSION') { + my $simpleversion = $DBD::Pg::VERSION; + $simpleversion =~ s/_/./g; + return sprintf '%02d.%02d.%1d%1d%1d%1d', split (/\./, "$simpleversion.0.0.0.0.0.0"); + } + elsif ($ans eq 'MAXCONNECTIONS') { + return $dbh->selectall_arrayref('SHOW max_connections')->[0][0]; + } + elsif ($ans eq 'ENCODING') { + return $dbh->selectall_arrayref('SHOW server_encoding')->[0][0]; + } + elsif ($ans eq 'KEYWORDS') { + ## http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html + ## Basically, we want ones that are 'reserved' for PostgreSQL but not 'reserved' in SQL:2003 + ## + return join ',' => (qw(ANALYSE ANALYZE ASC DEFERRABLE DESC DO FREEZE ILIKE INITIALLY ISNULL LIMIT NOTNULL OFF OFFSET PLACING RETURNING VERBOSE)); + } + elsif ($ans eq 'CURRENTDB') { + return $dbh->selectall_arrayref('SELECT pg_catalog.current_database()')->[0][0]; + } + elsif ($ans eq 'READONLY') { + my $SQL = q{SELECT CASE WHEN setting = 'on' THEN 'Y' ELSE 'N' END FROM pg_settings WHERE name = 'transaction_read_only'}; + my $info = $dbh->selectall_arrayref($SQL); + return defined $info->[0] ? $info->[0][0] : 'N'; + } + elsif ($ans eq 'DEFAULTTXN') { + my $SQL = q{SELECT CASE WHEN setting = 'read committed' THEN 2 ELSE 8 END FROM pg_settings WHERE name = 'default_transaction_isolation'}; + my $info = $dbh->selectall_arrayref($SQL); + return defined $info->[0] ? $info->[0][0] : 2; + } + + return $ans; + } # end of get_info + + sub private_attribute_info { + return { + pg_async_status => undef, + pg_bool_tf => undef, + pg_db => undef, + pg_default_port => undef, + pg_enable_utf8 => undef, + pg_utf8_flag => undef, + pg_errorlevel => undef, + pg_expand_array => undef, + pg_host => undef, + pg_INV_READ => undef, + pg_INV_WRITE => undef, + pg_lib_version => undef, + pg_options => undef, + pg_pass => undef, + pg_pid => undef, + pg_placeholder_dollaronly => undef, + pg_placeholder_nocolons => undef, + pg_port => undef, + pg_prepare_now => undef, + pg_protocol => undef, + pg_server_prepare => undef, + pg_server_version => undef, + pg_socket => undef, + pg_standard_conforming_strings => undef, + pg_switch_prepared => undef, + pg_user => undef, + }; + } } { - package DBD::Pg::st; - - sub parse_trace_flag { - my ($h, $flag) = @_; - return DBD::Pg->parse_trace_flag($flag); - } - - sub bind_param_array { - - ## Binds an array of data to a specific placeholder in a statement - ## The DBI version is broken, so we implement a near-copy here + package DBD::Pg::st; - my $sth = shift; - my ($p_id, $value_array, $attr) = @_; - - ## Bail if the second arg is not undef or an arrayref - return $sth->set_err(1, "Value for parameter $p_id must be a scalar or an arrayref, not a ".ref($value_array)) - if defined $value_array and ref $value_array and ref $value_array ne 'ARRAY'; - - ## Bail if the first arg is not a number - return $sth->set_err(1, q{Can't use named placeholders for non-driver supported bind_param_array}) - unless DBI::looks_like_number($p_id); # because we rely on execute(@ary) here + sub parse_trace_flag { + my ($h, $flag) = @_; + return DBD::Pg->parse_trace_flag($flag); + } - ## Store the list of items in the hash (will be undef or an arrayref) - $sth->{ParamArrays}{$p_id} = $value_array; + sub bind_param_array { - ## If any attribs were passed in, we need to call bind_param - return $sth->bind_param($p_id, '', $attr) if $attr; ## This is the big change so -w does not complain + ## Binds an array of data to a specific placeholder in a statement + ## The DBI version is broken, so we implement a near-copy here - return 1; - } ## end bind_param_array + my $sth = shift; + my ($p_id, $value_array, $attr) = @_; - sub private_attribute_info { - return { - pg_async => undef, - pg_bound => undef, - pg_current_row => undef, - pg_direct => undef, - pg_numbound => undef, - pg_cmd_status => undef, - pg_oid_status => undef, - pg_placeholder_dollaronly => undef, - pg_placeholder_nocolons => undef, - pg_prepare_name => undef, - pg_prepare_now => undef, - pg_segments => undef, - pg_server_prepare => undef, - pg_size => undef, - pg_switch_prepared => undef, - pg_type => undef, - }; + ## Bail if the second arg is not undef or an arrayref + return $sth->set_err(1, "Value for parameter $p_id must be a scalar or an arrayref, not a ".ref($value_array)) + if defined $value_array and ref $value_array and ref $value_array ne 'ARRAY'; + + ## Bail if the first arg is not a number + return $sth->set_err(1, q{Can't use named placeholders for non-driver supported bind_param_array}) + unless DBI::looks_like_number($p_id); # because we rely on execute(@ary) here + + ## Store the list of items in the hash (will be undef or an arrayref) + $sth->{ParamArrays}{$p_id} = $value_array; + + ## If any attribs were passed in, we need to call bind_param + return $sth->bind_param($p_id, '', $attr) if $attr; ## This is the big change so -w does not complain + + return 1; + } ## end bind_param_array + + sub private_attribute_info { + return { + pg_async => undef, + pg_bound => undef, + pg_current_row => undef, + pg_direct => undef, + pg_numbound => undef, + pg_cmd_status => undef, + pg_oid_status => undef, + pg_placeholder_dollaronly => undef, + pg_placeholder_nocolons => undef, + pg_prepare_name => undef, + pg_prepare_now => undef, + pg_segments => undef, + pg_server_prepare => undef, + pg_size => undef, + pg_switch_prepared => undef, + pg_type => undef, + }; } } ## end st section @@ -1652,7 +1682,7 @@ =head1 VERSION -This documents version 3.3.0 of the DBD::Pg module +This documents version 3.4.1 of the DBD::Pg module =head1 DESCRIPTION @@ -2751,11 +2781,14 @@ $sth = $dbh->table_info(undef, $schema, $table, $type); -Returns all tables and views visible to the current user. -The schema and table arguments will do a C<LIKE> search if a percent sign (C<%>) or an -underscore (C<_>) is detected in the argument. The C<$type> argument accepts a value of either -"TABLE" or "VIEW" (using both is the default action). Note that a statement handle is returned, -and not a direct list of tables. See the examples below for ways to handle this. +Returns all tables and views visible to the current user. The schema and table +arguments will do a C<LIKE> search if a percent sign (C<%>) or an underscore +(C<_>) is detected in the argument. The C<$type> argument accepts any +comma-separated combination of "TABLE", "VIEW", "SYSTEM TABLE", "SYSTEM VIEW", +"MATERIALIZED VIEW", "SYSTEM MATERIALIZED VIEW", or "LOCAL TEMPORARY". (Using all is the default action.) + +Note that a statement handle is returned, and not a direct list of tables. See +the examples below for ways to handle this. The following fields are returned: @@ -2765,8 +2798,9 @@ B<TABLE_NAME>: The name of the table or view. -B<TABLE_TYPE>: The type of object returned. Will be one of "TABLE", "VIEW", -or "SYSTEM TABLE". +B<TABLE_TYPE>: The type of object returned. Will be one of "TABLE", "VIEW", +"MATERIALIZED VIEW", "SYSTEM VIEW", "SYSTEM MATERIALIZED VIEW", "SYSTEM TABLE", +or "LOCAL TEMPORARY". The TABLE_SCHEM and TABLE_NAME will be quoted via C<quote_ident()>. @@ -2783,7 +2817,7 @@ B<pg_tablespace_location>: the location of the tablespace the table is in -Tables that have not been assigned to a particular tablespace (or views) +Tables that have not been assigned to a particular tablespace (or views) will return NULL (C<undef>) for both of the above field. Rows are returned alphabetically, with all tables first, and then all views. @@ -2929,7 +2963,7 @@ @names = $dbh->tables( undef, $schema, $table, $type, \%attr ); Supported by this driver as proposed by DBI. This method returns all tables -and/or views which are visible to the current user: see L</table_info> +and/or views (including materialized views) which are visible to the current user: see L</table_info> for more information about the arguments. The name of the schema appears before the table or view name. This can be turned off by adding in the C<pg_noprefix> attribute: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DBD-Pg-3.3.0/README new/DBD-Pg-3.4.1/README --- old/DBD-Pg-3.3.0/README 2014-05-21 19:01:35.000000000 +0200 +++ new/DBD-Pg-3.4.1/README 2014-08-20 01:55:46.000000000 +0200 @@ -5,7 +5,7 @@ DESCRIPTION: ------------ -This is version 3.3.0 of DBD::Pg, the Perl interface to Postgres using DBI. +This is version 3.4.1 of DBD::Pg, the Perl interface to Postgres using DBI. The web site for this interface, and the latest version, can be found at: http://search.cpan.org/dist/DBD-Pg/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DBD-Pg-3.3.0/README.dev new/DBD-Pg-3.4.1/README.dev --- old/DBD-Pg-3.3.0/README.dev 2014-05-25 20:29:14.000000000 +0200 +++ new/DBD-Pg-3.4.1/README.dev 2014-08-19 16:51:42.000000000 +0200 @@ -575,6 +575,10 @@ * Test on variety of versions (see ** Heavy Testing), including the optional tests. +* Test modules that depend on DBD::Pg, in particular DBIx::Class and DBIx::Class::Schema::Loader + +* Consider a pre-release announcement to [email protected] + * Make sure everything is up to date in git (git status) * Update the versions (see ** Version Numbers) in README, Pg.pm (2 places!), Makefile.PL, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DBD-Pg-3.3.0/SIGNATURE new/DBD-Pg-3.4.1/SIGNATURE --- old/DBD-Pg-3.3.0/SIGNATURE 2014-05-31 20:48:14.000000000 +0200 +++ new/DBD-Pg-3.4.1/SIGNATURE 2014-08-20 22:37:16.000000000 +0200 @@ -15,24 +15,24 @@ Hash: RIPEMD160 SHA1 6f4143600430e0bc949c17b05ac34844e5fb3ee4 .perlcriticrc -SHA1 f9fe28efe2f182f9b6419052b9451267fdfd6db2 Changes +SHA1 81f729ce60e2eb4163382cbf6e7f45c7a1dcf830 Changes SHA1 21bc5f3c797d4d5b72285198ffeb1e4e1f0a2902 LICENSES/artistic.txt SHA1 06877624ea5c77efe3b7e39b0f909eda6e25a4ec LICENSES/gpl-2.0.txt SHA1 9c2b33069c9ceb7cd57ea0aeb7b8de144ab75672 MANIFEST SHA1 8d2857ee9a6326c08507d8552f86709dd068fbe5 MANIFEST.SKIP -SHA1 4c03569f25f2f959bc73db064c364f21a37da51d META.yml -SHA1 bd6fe25d5cfc5edfe86093ee7ea0b559fc40bf28 Makefile.PL +SHA1 258f6108b4b95af46a88be3089ad3ac55f062dd2 META.yml +SHA1 328948695a097c9cf75ef55cd58896cdcfc23afc Makefile.PL SHA1 8d7577d85e3a6299c1af5a12ac5faa3af6d11b18 Pg.h -SHA1 7aff4f57004ef698425be76eeb7666119ee8b3d6 Pg.pm +SHA1 4d33d116054d6a56e0ce3f1119eafdd8e90ecd2e Pg.pm SHA1 595b26f97c7708f82bd5c2c60e4f59724958c2bc Pg.xs -SHA1 83ded291b86dd613be134481caef357ff3204ffe README -SHA1 34036e0b0dc15d899f561e8177227661eaaef2f1 README.dev +SHA1 6cbb661c34938b85c9009694f738c039282149ae README +SHA1 0332ac652afae7e53181e075ca446b88b8631ac6 README.dev SHA1 7e213bf90f513595b59c0a2c4ef94fea1592efcf README.win32 -SHA1 3aac8fa93676046f9fa31d8fd05914bf638b6c1f TODO +SHA1 15c20ab7888be67fa0c6f98aa81f2c4e20bd3f66 TODO SHA1 74f0a441f0593fd6902d57ab5922cf799ac57d44 dbdimp.c SHA1 886c53b8dcc360f46077bd5cfbf905d7ac530243 dbdimp.h SHA1 6c33bcf138e577722283bef02fceb8cbce4d100d dbivport.h -SHA1 55d966a55fa3fa7a2ce6d644b6d825943eb781b3 lib/Bundle/DBD/Pg.pm +SHA1 79c0e361486f73e883391bb1ec4d287979d897ac lib/Bundle/DBD/Pg.pm SHA1 cd0b9dfa8153734b147c5689abe81ec2196bf364 quote.c SHA1 931179894b8b48de407547a38ce0e034f75baaaa quote.h SHA1 93aa7e8cae0a361d1e6163dea0281ebff41f3c5f t/00_signature.t @@ -40,7 +40,7 @@ SHA1 1f50adea4f2c7a5110eca34dc8b6d5dc9d4121ed t/01connect.t SHA1 42b566f777c15a3d07e41d4bca55be435349376c t/01constants.t SHA1 c9473410e196cc020902cf92ff52de8ebbf00420 t/02attribs.t -SHA1 2c1c174d17ebd672cff3f0bf918d573816642ab5 t/03dbmethod.t +SHA1 31b673055dd68c5879bbd7547ea8bd656c3f89d7 t/03dbmethod.t SHA1 4e16959f7f2e68667a42c86c3d35e8d317034b23 t/03smethod.t SHA1 dd47bd1ac55072177a57f856daca98904939112c t/04misc.t SHA1 9113f062bf144a5768e9e4e98a0f140f498caee1 t/06bytea.t @@ -51,7 +51,7 @@ SHA1 81558ca5c783ea6792fd103444a04df615a8d127 t/20savepoints.t SHA1 da1f8f9a51dc99735f8463fea3c881fa7071036d t/30unicode.t SHA1 b1e1d98917296def69afa730d963a3d16c23def1 t/99cleanup.t -SHA1 28b835a7aefed7dc7167867c40f5c4e293bfb33b t/dbdpg_test_setup.pl +SHA1 f54d43ab863df1f1cf8b55c7e46a8bec7b6a48af t/dbdpg_test_setup.pl SHA1 0e196509e83b3ca603478d994a0837edd51b841d t/lib/App/Info.pm SHA1 e02b0b5206c37280f9259e6a02839cbfc10be53f t/lib/App/Info/Handler.pm SHA1 cc5d256a57f1fe0ddc587685a0cd64f812bb1ce9 t/lib/App/Info/Handler/Print.pm @@ -66,7 +66,7 @@ SHA1 f07cd5ecaeb854c81ceb9206364979cf607e6546 win32.mak -----BEGIN PGP SIGNATURE----- -iEYEAREDAAYFAlOKI+4ACgkQvJuQZxSWSsgd6ACeJ1azhxlkodHcRyggQRTmmhch -JVcAnRwvPFbx4qsxjgEm3+ytN34TIxza -=gg2h +iEYEAREDAAYFAlP1BvwACgkQvJuQZxSWSsiUtQCfUgc76Xdq8wZ4dWAeuZpXAILE +VXoAoPDynlupQMAbMIkUa30xao0DkPvE +=7rvk -----END PGP SIGNATURE----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DBD-Pg-3.3.0/TODO new/DBD-Pg-3.4.1/TODO --- old/DBD-Pg-3.3.0/TODO 2014-05-19 17:42:46.000000000 +0200 +++ new/DBD-Pg-3.4.1/TODO 2014-08-12 16:21:01.000000000 +0200 @@ -7,6 +7,9 @@ https://github.com/bucardo/dbdpg (although we prefer using cpan.org) +- Enable native JSON decoding, similar to arrays, perhaps with JSON::PP +- Allow partial result sets, either via PQsetSingleRowMode or something better +- Hack libpq to make user-defined number of rows returned - Map hstore to hashes ala array/array mapping - Fix ping problem: http://www.cpantesters.org/cpan/report/53c5cc72-6d39-11e1-8b9d-82c3d2d9ea9f - Use WITH HOLD for cursor work diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DBD-Pg-3.3.0/lib/Bundle/DBD/Pg.pm new/DBD-Pg-3.4.1/lib/Bundle/DBD/Pg.pm --- old/DBD-Pg-3.3.0/lib/Bundle/DBD/Pg.pm 2014-05-21 18:20:29.000000000 +0200 +++ new/DBD-Pg-3.4.1/lib/Bundle/DBD/Pg.pm 2014-08-20 01:55:39.000000000 +0200 @@ -4,7 +4,7 @@ use strict; use warnings; -$VERSION = '3.3.0'; +$VERSION = '3.4.1'; 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DBD-Pg-3.3.0/t/03dbmethod.t new/DBD-Pg-3.4.1/t/03dbmethod.t --- old/DBD-Pg-3.3.0/t/03dbmethod.t 2014-05-21 17:25:10.000000000 +0200 +++ new/DBD-Pg-3.4.1/t/03dbmethod.t 2014-08-20 01:49:26.000000000 +0200 @@ -26,7 +26,7 @@ if (! $dbh) { plan skip_all => 'Connection to database failed, cannot continue testing'; } -plan tests => 538; +plan tests => 547; isnt ($dbh, undef, 'Connect to database for database handle method testing'); @@ -483,11 +483,16 @@ # Test of the "table_info" database handle method # -$t='DB handle method "table_info" works when called with undef arguments'; +$t='DB handle method "table_info" works when called with empty arguments'; $sth = $dbh->table_info('', '', 'dbd_pg_test', ''); my $number = $sth->rows(); ok ($number, $t); +$t='DB handle method "table_info" works when called with \'%\' arguments'; +$sth = $dbh->table_info('%', '%', 'dbd_pg_test', '%'); +$number = $sth->rows(); +ok ($number, $t); + # Check required minimum fields $t='DB handle method "table_info" returns fields required by DBI'; $result = $sth->fetchall_arrayref({}); @@ -511,10 +516,15 @@ $number = $sth->rows(); cmp_ok ($number, '>', 1, $t); -$t='DB handle method "table_info" returns correct number of rows when given an invalid type argument'; +$t=q{DB handle method "table_info" returns correct number of rows when given a 'TABLE,VIEW,SYSTEM TABLE,SYSTEM VIEW' type argument}; +$sth = $dbh->table_info(undef,undef,undef,'TABLE,VIEW,SYSTEM TABLE,SYSTEM VIEW'); +$number = $sth->rows(); +cmp_ok ($number, '>', 1, $t); + +$t='DB handle method "table_info" returns zero rows when given an invalid type argument'; $sth = $dbh->table_info(undef,undef,undef,'DUMMY'); $rows = $sth->rows(); -is ($rows, $number, $t); +is ($rows, 0, $t); $t=q{DB handle method "table_info" returns correct number of rows when given a 'VIEW' type argument}; $sth = $dbh->table_info(undef,undef,undef,'VIEW'); @@ -526,6 +536,30 @@ $rows = $sth->rows(); cmp_ok ($rows, '<', $number, $t); +$dbh->do('CREATE TEMP TABLE dbd_pg_local_temp (i INT)'); + +$t=q{DB handle method "table_info" returns correct number of rows when given a 'LOCAL TEMPORARY' type argument}; +$sth = $dbh->table_info(undef,undef,undef,'LOCAL TEMPORARY'); +$rows = $sth->rows(); +cmp_ok ($rows, '<', $number, $t); +cmp_ok ($rows, '>', 0, $t); + +$t=q{DB handle method "table_info" returns correct number of rows when given a 'MATERIALIZED VIEW' type argument}; +$sth = $dbh->table_info(undef,undef,undef,'MATERIALIZED VIEW'); +$rows = $sth->rows(); +is ($rows, 0, $t); + +SKIP: { + if ($pgversion < 90300) { + skip 'Postgres version 9.3 or better required to create materialized views', 1; + } + $dbh->do('CREATE MATERIALIZED VIEW dbd_pg_matview (a) AS SELECT count(*) FROM pg_class'); + $t=q{DB handle method "table_info" returns correct number of rows when given a 'MATERIALIZED VIEW' type argument}; + $sth = $dbh->table_info(undef,undef,undef,'MATERIALIZED VIEW'); + $rows = $sth->rows(); + is ($rows, 1, $t); +} + # Test listing catalog names $t='DB handle method "table_info" works when called with a catalog of %'; $sth = $dbh->table_info('%', '', ''); @@ -536,10 +570,35 @@ $sth = $dbh->table_info('', '%', ''); ok ($sth, $t); -# Test listing table types +{ # Test listing table types + +my @expected = ('LOCAL TEMPORARY', + 'SYSTEM TABLE', + 'SYSTEM VIEW', + 'MATERIALIZED VIEW', + 'SYSTEM MATERIALIZED VIEW', + 'TABLE', + 'VIEW',); + $t='DB handle method "table_info" works when called with a type of %'; $sth = $dbh->table_info('', '', '', '%'); -ok ($sth, $t); +ok($sth, $t); + +$t='DB handle method "table_info" type list returns all expected types'; +my %advertised = map { $_->[0] => 1 } @{ $sth->fetchall_arrayref([3]) }; +is_deeply([sort keys %advertised], [sort @expected], $t); + +$t='DB handle method "table_info" object list returns no unadvertised types'; +$sth = $dbh->table_info('', '', '%'); +my %surprises = map { $_->[0] => 1 } + grep { ! $advertised{$_->[0]} } + @{ $sth->fetchall_arrayref([3]) }; + +is_deeply([keys %surprises], [], $t) + or diag("Objects of unexpected type(s) found: " + . join(', ', sort keys %surprises)); + +} # END test listing table types # # Test of the "column_info" database handle method @@ -1125,6 +1184,10 @@ @result = $dbh->tables('', '', 'dbd_pg_test', '', {pg_noprefix => 1}); is ($result[0], 'dbd_pg_test', $t); +$t='DB handle method "tables" works with type=\'%\''; +@result = $dbh->tables('', '', 'dbd_pg_test', '%'); +like ($result[0], qr/dbd_pg_test/, $t); + # # Test of the "type_info_all" database handle method # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DBD-Pg-3.3.0/t/dbdpg_test_setup.pl new/DBD-Pg-3.4.1/t/dbdpg_test_setup.pl --- old/DBD-Pg-3.3.0/t/dbdpg_test_setup.pl 2014-05-19 17:43:22.000000000 +0200 +++ new/DBD-Pg-3.4.1/t/dbdpg_test_setup.pl 2014-07-27 07:30:40.000000000 +0200 @@ -17,6 +17,11 @@ Test::More->builder->todo_output($testfh); } +my @matviews = + ( + 'dbd_pg_matview', + ); + my @schemas = ( 'dbd_pg_testschema', @@ -796,6 +801,12 @@ $dbh->rollback() if ! $dbh->{AutoCommit}; + for my $name (@matviews) { + my $schema = ($name =~ s/(.+)\.(.+)/$2/) ? $1 : $S; + next if ! relation_exists($dbh,$schema,$name); + $dbh->do("DROP MATERIALIZED VIEW $schema.$name"); + } + for my $name (@tables) { my $schema = ($name =~ s/(.+)\.(.+)/$2/) ? $1 : $S; next if ! relation_exists($dbh,$schema,$name); -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
