Re: [JDBC] DatabaseMetaData.getCatalogs()

2001-07-08 Thread Tom Lane

[EMAIL PROTECTED] writes:
> Okay here's a context diff against CVS for getting table privileges.

This appears not to be correct for current sources --- the privilege
set has changed since 7.1.

regards, tom lane

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



[JDBC] To do list for DatabaseMetaData

2001-07-08 Thread Peter Eisentraut

Since DatabaseMetaData seems to have been a subject of interest lately I
have composed a list of concrete things that need to be done there.

The spec of DatabaseMetaData is here:
http://java.sun.com/j2se/1.3/docs/api/java/sql/DatabaseMetaData.html

All the functions listed in the spec and not listed below I have recently
checked and updated for correctness and compliance.  Thus, this list is
complete.  Functions marked with '?' I have not checked yet.

If someone wants to tackle some of the getThings() functions, a
description of the system catalogs is in the Developer's Guide.  Also note
that some functions currently incorrectly handle the case of null patterns
vs. "" patterns vs. "%" patterns.

At least two parameters obtained by a DatabaseMetaData method are
user-tunable on the server side.  The only way to get at those numbers
currently is to use SHOW and parse the NOTICE: it sends back (which is
impossible in the days of internationalized messages), so a nice
side-project would be to implement a get_config_variable(text) returns
text (better names possible) function to allow easier access.

Now the list:

allProceduresAreCallable()  not all procedures listed are
callable (triggers, in/out)
allTablesAreSelectable()should this check access
privileges or what?
getSQLKeywords()outdated, could be automated like
keywords.sgml
getNumericFunctions()   decide what exactly is a "numeric function"?
getStringFunctions()ditto
getSystemFunctions()ditto
getTimeDateFunctions()  ditto
getExtraNameCharacters()server allows \200 to \377, how
does this fit in with Unicode?
getMaxColumnNameLength()32 is hard-coded here, maybe query server
getMaxColumnsInIndex()  this should be detected from server
getMaxColumnsInTable()  this limit is probably shaky
getMaxConnections() could query the server for this
(SHOW, see above)
getMaxCursorNameLength()32 hard-coded
getMaxSchemaNameLength()will be 32 when done
getMaxProcedureNameLength() 32 hard-coded
getMaxCatalogNameLength()   should be NAMEDATALEN
doesMaxRowSizeIncludeBlobs()since we don't have blobs, should
this throw an exception?
getMaxStatements()  questionable, see comment there
getMaxTableNameLength() 32 hard-coded
getMaxUserNameLength()  32 hard-coded
getDefaultTransactionIsolation()This is configurable in 7.2.
(SHOW, see above)
getProcedures() missing catalog (database) and
remarks columns
getProcedureColumns()   only dummy implementation
getTables() fails to handle pre-7.1 servers
(relkind 'v')
getSchemas()This should throw an exception.
getTableTypes() ?
getColumns()?
getColumnPrivileges()   not implemented
getTablePrivileges()not implemented
getBestRowIdentifier()  only dummy implementation
getVersionColumns() not implemented
getPrimaryKeys()?
getImportedKeys()   ?
getExportedKeys()   not implemented
getCrossReference() not implemented
getTypeInfo()   ?
getIndexInfo()  ?
getUDTs()   ?


-- 
Peter Eisentraut   [EMAIL PROTECTED]   http://funkturm.homeip.net/~peter


---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl



[JDBC] UpdateableResultSets and concurrency.

2001-07-08 Thread Ola Sundell

On Tue, 26 Jun 2001, Dave Cramer wrote:

> Ola,
> 
> How are you planning on determining if the underlying data has been
> changed by some other process? There is a system column called xmin
> which can be used, however you will have to add it to the select.
> 
> Dave

At first, I will let the backend handle any and all problems that might
occur. I will simply forward any exceptions I get, and let the overlying
code handle the problems. I checked the MySQL driver, and that is how they
are doing it.

I wonder how it works with non-free databases. Does anyone here know?

Ola

-- 
Ola Sundell
[EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED]
http://miranda.org/~ola



---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl



Re: [JDBC] DatabaseMetaData.getCatalogs()

2001-07-08 Thread Bruce Momjian

I am Cc'ing the jdbc list.

> [[[ Original Message from Bruce Momjian <[EMAIL PROTECTED]> ]]]
> 
> > 
> > Just send over a context diff patch, either against 7.1.2 or CVS.
> 
> Okay here's a context diff against CVS for getting table privileges. I may have more 
>code to add (I noticed getColumnPrivileges() is not completed - could use my routine 
>for parsing pg_class.relacl?).
> 
> Jason Davies
> 
> [EMAIL PROTECTED]

[ Attachment, skipping... ]

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 853-3000
  +  If your life is a hard drive, |  830 Blythe Avenue
  +  Christ can be your backup.|  Drexel Hill, Pennsylvania 19026

---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl



Re: [JDBC] DatabaseMetaData.getCatalogs()

2001-07-08 Thread jason

[[[ Original Message from Bruce Momjian <[EMAIL PROTECTED]> ]]]

> 
> Just send over a context diff patch, either against 7.1.2 or CVS.

Okay here's a context diff against CVS for getting table privileges. I may have more 
code to add (I noticed getColumnPrivileges() is not completed - could use my routine 
for parsing pg_class.relacl?).

Jason Davies

[EMAIL PROTECTED]
 diff


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])



Re: [JDBC] DatabaseMetaData.getCatalogs()

2001-07-08 Thread Bruce Momjian

> [[[ Original Message from Peter Eisentraut <[EMAIL PROTECTED]> ]]]
> 
> > [EMAIL PROTECTED] writes:
> > 
> > > Is there a reason why getCatalogs() is not supported in the JDBC driver? First
> > of all, what is the definition of a catalog? The MySQL JDBC driver simply returns
> > a list of the databases so a simple select datname from pg_database; would do
> > the same thing. However there is probably a reason for this and I would be grateful
> > if you would explain.
> > 
> > It is as of three minutes ago.
> 
> Thanks a lot :) How can I help with coding the JDBC classes? I have some code for 
>getting table privileges etc. which I'd like to add. Do I need a cvs username or 
>should I post the code here?

Just send over a context diff patch, either against 7.1.2 or CVS.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 853-3000
  +  If your life is a hard drive, |  830 Blythe Avenue
  +  Christ can be your backup.|  Drexel Hill, Pennsylvania 19026

---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl



Re: [JDBC] DatabaseMetaData.getCatalogs()

2001-07-08 Thread jason

[[[ Original Message from Peter Eisentraut <[EMAIL PROTECTED]> ]]]

> [EMAIL PROTECTED] writes:
> 
> > Is there a reason why getCatalogs() is not supported in the JDBC driver? First
> of all, what is the definition of a catalog? The MySQL JDBC driver simply returns
> a list of the databases so a simple select datname from pg_database; would do
> the same thing. However there is probably a reason for this and I would be grateful
> if you would explain.
> 
> It is as of three minutes ago.

Thanks a lot :) How can I help with coding the JDBC classes? I have some code for 
getting table privileges etc. which I'd like to add. Do I need a cvs username or 
should I post the code here?

Thanks,
Jason Davies

[EMAIL PROTECTED]

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



[JDBC] [PATCH] Cleanup of JDBC character encoding

2001-07-08 Thread Anders Bengtsson

Hello,

With this patch I've done an attempt to make the handling of character
encoding in the JDBC driver a little clearer.

* Cleans up the logic to select a JVM encoding for a backend encoding.
* Makes the connection setup code easier to read.
* Gathers character encoding and decoding in a single place.
* Adds unit tests for encoding.
* Introduces a new class, org.postgresql.core.Encoding, and the
corresponding unit test class, org.postgresql.test.jdbc2.EncodingTest.

It shouldn't change the external behavior of the driver.

/Anders

_
A n d e r s  B e n g t s s o n   [EMAIL PROTECTED]
Stockholm, Sweden



package org.postgresql.test.jdbc2;

import junit.framework.*;
import org.postgresql.core.Encoding;

/**
 * Tests for the Encoding class.
 *
 * $Id$
 */


public class EncodingTest extends TestCase {

public EncodingTest(String name) {
super(name);
}

public void testCreation() throws Exception {
Encoding encoding;
encoding = Encoding.forDatabaseEncoding("UNICODE");
assertEquals("UTF", encoding.name().substring(0, 3).toUpperCase());
encoding = Encoding.forDatabaseEncoding("SQL_ASCII");
assert(encoding.name().toUpperCase().indexOf("ASCII") != -1);
encoding = Encoding.forDatabaseEncoding("X-UNIT-TESTS");
assertEquals("ascii", encoding.name());
}

public void testTransformations() throws Exception {
Encoding encoding = Encoding.forDatabaseEncoding("UNICODE");
assertEquals("ab", encoding.decode(new byte[] { 97, 98 }));

assertEquals(2, encoding.encode("ab").length);
assertEquals(97, encoding.encode("a")[0]);
assertEquals(98, encoding.encode("b")[0]);

encoding = Encoding.defaultEncoding();
assertEquals("a".getBytes()[0], encoding.encode("a")[0]);
assertEquals(new String(new byte[] { 97 }),
 encoding.decode(new byte[] { 97 }));
}
}


package org.postgresql.core;

import java.io.UnsupportedEncodingException;
import java.util.*;
import java.sql.SQLException;
import org.postgresql.util.*;

/**
 * Converts to and from the character encoding used by the backend.
 *
 * $Id$
 */

public class Encoding {

private static final Encoding DEFAULT_ENCODING = new Encoding(null);

/**
 * Preferred JVM encodings for backend encodings.
 */
private static final Hashtable encodings = new Hashtable();

static {
encodings.put("SQL_ASCII", new String[] { "ASCII", "us-ascii" });
encodings.put("UNICODE", new String[] { "UTF-8", "UTF8" });
encodings.put("LATIN1", new String[] { "ISO8859_1" });
encodings.put("LATIN2", new String[] { "ISO8859_2" });
encodings.put("LATIN3", new String[] { "ISO8859_3" });
encodings.put("LATIN4", new String[] { "ISO8859_4" });
encodings.put("LATIN5", new String[] { "ISO8859_5" });
encodings.put("LATIN6", new String[] { "ISO8859_6" });
encodings.put("LATIN7", new String[] { "ISO8859_7" });
encodings.put("LATIN8", new String[] { "ISO8859_8" });
encodings.put("LATIN9", new String[] { "ISO8859_9" });
encodings.put("EUC_JP", new String[] { "EUC_JP" });
encodings.put("EUC_CN", new String[] { "EUC_CN" });
encodings.put("EUC_KR", new String[] { "EUC_KR" });
encodings.put("EUC_TW", new String[] { "EUC_TW" });
encodings.put("WIN", new String[] { "Cp1252" });
// We prefer KOI8-U, since it is a superset of KOI8-R
encodings.put("KOI8", new String[] { "KOI8_U", "KOI8_R" });
// Database is not encoding-aware, so we'll settle with the default encoding
encodings.put("UNKNOWN", new String[0]);
// Data for unit tests
encodings.put("X-UNIT-TESTS", new String[] { "dummy1", "dummy2", "ascii" });
}

private final String encoding;

public Encoding(String encoding) {
this.encoding = encoding;
}

/**
 * Get an Encoding matching the given database encoding.
 */
public static Encoding forDatabaseEncoding(String databaseEncoding) {
// If the backend encoding is known and there is a suitable
// encoding in the JVM we use that. Otherwise we fall back
// to the default encoding of the JVM.

if (encodings.containsKey(databaseEncoding)) {
String[] candidates = (String[]) encodings.get(databaseEncoding);
for (int i = 0; i < candidates.length; i++) {
if (isAvailable(candidates[i])) {
return new Encoding(candidates[i]);
}
}
}
return defaultEncoding();
}

/**
 * Name of the (JVM) encoding used.
 */
public String name() {
return encoding;
}

/**
 * Encode a str