120c120
< 	my($dbh) = @_;		# XXX add qualification
---
> 	my($dbh, $catalog, $schema, $table, $type) = @_;
121a122,128
> 	if ($#_ == 1) {
> 	    my $attrs = $_[1];
> 	    $catalog = $attrs->{TABLE_CAT};
> 	    $schema = $attrs->{TABLE_SCHEM};
> 	    $table = $attrs->{TABLE_NAME};
> 	    $type = $attrs->{TABLE_TYPE};
> 	}
123a131,134
>         $catalog = "" if (!$catalog);
>         $schema = "" if (!$schema);
>         $table = "" if (!$table);
>         $type = "" if (!$type);
125,126c136
< 	# XXX use qualification(s) (qual, schema, etc?) here...
< 	DBD::ODBC::st::_tables($dbh,$sth, "")
---
> 	DBD::ODBC::st::_tables($dbh,$sth, $catalog, $schema, $table, $type)
130a141,153
>     sub primary_key_info {
> 	my ($dbh, $catalog, $schema, $table ) = @_;
> 
> 	# create a "blank" statement handle
> 	my $sth = DBI::_new_sth($dbh, { 'Statement' => "SQLPrimaryKeys" });
> 
> 	$catalog = "" if (!$catalog);
> 	$schema = "" if (!$schema);
> 	$table = "" if (!$table);
> 	DBD::ODBC::st::_primary_keys($dbh,$sth, $catalog, $schema, $table )
> 		or return undef;
> 	$sth;
>     }
27c27
< _tables(dbh, sth, qualifier)

---
> _tables(dbh, sth, catalog, schema, table, type)

30c30,33
< 	char *	qualifier

---
> 	char *	catalog

> 	char *	schema

> 	char *  table

> 	char *	type

33c36,46
< 	ST(0) = dbd_st_tables(dbh, sth, qualifier, 0) ? &sv_yes : &sv_no;

---
> 	ST(0) = dbd_st_tables(dbh, sth, catalog, schema, table, type) ? &sv_yes : &sv_no;

> 

> void

> _primary_keys(dbh, sth, catalog, schema, table)

> 	SV * 	dbh

> 	SV *	sth

> 	char *	catalog

> 	char *	schema

> 	char *	table

> 	CODE:

> 	ST(0) = dbd_st_primary_keys(dbh, sth, catalog, schema, table) ? &sv_yes : &sv_no;

16c16,17
< static const char *cSqlTables = "SQLTables(%s)";
---
> static const char *cSqlTables = "SQLTables(%s,%s,%s,%s)";
> static const char *cSqlPrimaryKeys = "SQLPrimaryKeys(%s,%s,%s)";
595c596
<    dbd_st_tables(dbh, sth, qualifier, table_type)
---
>    dbd_st_tables(dbh, sth, catalog, schema, table, table_type)
598c599,601
< char *qualifier;
---
> char *catalog;
> char *schema;
> char *table;
620,621c623,629
<     imp_sth->statement = (char *)safemalloc(strlen(cSqlTables)+strlen(qualifier)+1);
<     sprintf(imp_sth->statement, cSqlTables, qualifier);
---
>     imp_sth->statement = (char *)safemalloc(strlen(cSqlTables)+
>                                             strlen(XXSAFECHAR(catalog)) +
>                                             strlen(XXSAFECHAR(schema)) +
>                                             strlen(XXSAFECHAR(table)) +
>                                             strlen(XXSAFECHAR(table_type))+1);
>     sprintf(imp_sth->statement, cSqlTables, XXSAFECHAR(catalog),
>             XXSAFECHAR(schema), XXSAFECHAR(table), XXSAFECHAR(table_type));
624,626c632,634
< 		   0, SQL_NTS,			/* qualifier */
< 		   0, SQL_NTS,			/* schema/user */
< 		   0, SQL_NTS,			/* table name */
---
> 		   (catalog && *catalog) ? catalog : 0, SQL_NTS,
>                    (schema && *schema) ? schema : 0, SQL_NTS,
>                    (table && *table) ? table : 0, SQL_NTS,
634a643,694
>     if (!SQL_ok(rc)) {
> 	SQLFreeStmt(imp_sth->hstmt, SQL_DROP);
> 	imp_sth->hstmt = SQL_NULL_HSTMT;
> 	return 0;
>     }
> 
>     return build_results(sth);
> }
> 
> int
>    dbd_st_primary_keys(dbh, sth, catalog, schema, table)
>    SV *dbh;
> SV *sth;
> char *catalog;
> char *schema;
> char *table;
> {
>     dTHR;
>     D_imp_dbh(dbh);
>     D_imp_sth(sth);
>     RETCODE rc;
>     imp_sth->henv = imp_dbh->henv;	/* needed for dbd_error */
>     imp_sth->hdbc = imp_dbh->hdbc;
> 
>     imp_sth->done_desc = 0;
>     rc = SQLAllocStmt(imp_dbh->hdbc, &imp_sth->hstmt);
>     if (rc != SQL_SUCCESS) {
> 	dbd_error(sth, rc, "odbc_db_primary_key_info/SQLAllocStmt");
> 	return 0;
>     }
> 
>     /* just for sanity, later.  Any internals that may rely on this (including */
>     /* debugging) will have valid data */
>     imp_sth->statement = (char *)safemalloc(strlen(cSqlColumns)+
> 					    strlen(XXSAFECHAR(catalog))+
> 					    strlen(XXSAFECHAR(schema))+
> 					    strlen(XXSAFECHAR(table))+1);
> 
>     sprintf(imp_sth->statement,
> 	    cSqlPrimaryKeys, XXSAFECHAR(catalog), XXSAFECHAR(schema),
> 	    XXSAFECHAR(table));
> 
>     rc = SQLPrimaryKeys(imp_sth->hstmt,
>                         (catalog && *catalog) ? catalog : 0, SQL_NTS,
>                         (schema && *schema) ? schema : 0, SQL_NTS,
>                         (table && *table) ? table : 0, SQL_NTS);
> 
>     if (DBIS->debug >= 2)
> 	PerlIO_printf(DBILOGFP, "SQLPrimaryKeys call: cat = %s, schema = %s, table = %s\n",
> 		      XXSAFECHAR(catalog), XXSAFECHAR(schema), XXSAFECHAR(table));
>     dbd_error(sth, rc, "st_primary_key_info/SQLPrimaryKeys");
> 
