*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.101 2000/09/12 04:49:06 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.102 2000/09/12 05:09:43 momjian Exp $
*
* NOTES
* The PerformAddAttribute() code, like most of the relation
#include "utils/temprel.h"
#include "executor/spi_priv.h"
#include "catalog/pg_index.h"
+#include "catalog/pg_shadow.h"
#include "utils/relcache.h"
#ifdef _DROP_COLUMN_HACK__
+/*
+ * ALTER TABLE OWNER
+ */
+void
+AlterTableOwner(const char *relationName, const char *newOwnerName)
+{
+ Relation class_rel;
+ HeapTuple tuple;
+ int4 newOwnerSysid;
+ Relation idescs[Num_pg_class_indices];
+
+ /*
+ * first check that we are a superuser
+ */
+ if (! superuser() )
+ elog(ERROR, "ALTER TABLE: permission denied");
+
+ /*
+ * look up the new owner in pg_shadow and get the sysid
+ */
+ tuple = SearchSysCacheTuple(SHADOWNAME, PointerGetDatum(newOwnerName),
+ 0, 0, 0);
+ if (!HeapTupleIsValid(tuple))
+ elog(ERROR, "ALTER TABLE: user \"%s\" not found", newOwnerName);
+
+ newOwnerSysid = ((Form_pg_shadow) GETSTRUCT(tuple))->usesysid;
+ heap_freetuple(tuple);
+
+ /*
+ * find the table's entry in pg_class and lock it for writing
+ */
+ class_rel = heap_openr(RelationRelationName, RowExclusiveLock);
+
+ tuple = SearchSysCacheTuple(RELNAME, PointerGetDatum(relationName),
+ 0, 0, 0);
+ if (!HeapTupleIsValid(tuple))
+ elog(ERROR, "ALTER TABLE: relation \"%s\" not found",
+ relationName);
+
+ if (((Form_pg_class) GETSTRUCT(tuple))->relkind != RELKIND_RELATION)
+ elog(ERROR, "ALTER TABLE: relation \"%s\" is not a table",
+ relationName);
+
+ /*
+ * modify the table's entry and write to the heap
+ */
+ ((Form_pg_class) GETSTRUCT(tuple))->relowner = newOwnerSysid;
+
+ heap_update(class_rel, &tuple->t_self, tuple, NULL);
+
+ /* Keep the catalog indices up to date */
+ CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs);
+ CatalogIndexInsert(idescs, Num_pg_class_indices, class_rel, tuple);
+ CatalogCloseIndices(Num_pg_class_indices, idescs);
+
+ /*
+ * unlock everything and return
+ */
+ heap_freetuple(tuple);
+ heap_close(class_rel, RowExclusiveLock);
+
+ return;
+}
+
/*
* ALTER TABLE CREATE TOAST TABLE
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.187 2000/08/26 21:53:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.188 2000/09/12 05:09:44 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
LANCOMPILER, LIMIT, LISTEN, LOAD, LOCATION, LOCK_P,
MAXVALUE, MINVALUE, MODE, MOVE,
NEW, NOCREATEDB, NOCREATEUSER, NONE, NOTHING, NOTIFY, NOTNULL,
- OFFSET, OIDS, OPERATOR, PASSWORD, PROCEDURAL,
+ OFFSET, OIDS, OPERATOR, OWNER, PASSWORD, PROCEDURAL,
REINDEX, RENAME, RESET, RETURNS, ROW, RULE,
SEQUENCE, SERIAL, SETOF, SHARE, SHOW, START, STATEMENT, STDIN, STDOUT, SYSID,
TEMP, TOAST, TRUNCATE, TRUSTED,
n->relname = $3;
$$ = (Node *)n;
}
+
+/* ALTER TABLE <name> OWNER TO UserId */
+ | ALTER TABLE relation_name OWNER TO UserId
+ {
+ AlterTableStmt *n = makeNode(AlterTableStmt);
+ n->subtype = 'U';
+ n->relname = $3;
+ n->name = $6;
+ $$ = (Node *)n;
+ }
;
alter_column_action:
| OIDS { $$ = "oids"; }
| OPERATOR { $$ = "operator"; }
| OPTION { $$ = "option"; }
+ | OWNER { $$ = "owner"; }
| PARTIAL { $$ = "partial"; }
| PASSWORD { $$ = "password"; }
| PENDANT { $$ = "pendant"; }
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.80 2000/08/06 18:05:22 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.81 2000/09/12 05:09:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{"out", OUT},
{"outer", OUTER_P},
{"overlaps", OVERLAPS},
+ {"owner", OWNER},
{"partial", PARTIAL},
{"password", PASSWORD},
{"path", PATH_P},
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.93 2000/09/12 04:49:11 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.94 2000/09/12 05:09:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
case 'E': /* CREATE TOAST TABLE */
AlterTableCreateToastTable(stmt->relname, false);
break;
+ case 'U': /* ALTER OWNER */
+ AlterTableOwner(stmt->relname, stmt->name);
+ break;
default: /* oops */
elog(ERROR, "T_AlterTableStmt: unknown subtype");
break;
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: command.h,v 1.22 2000/07/18 03:57:32 tgl Exp $
+ * $Id: command.h,v 1.23 2000/09/12 05:09:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void AlterTableCreateToastTable(const char *relationName,
bool silent);
+extern void AlterTableOwner(const char *relationName, const char *newOwnerName);
+
/*
* LOCK
*/
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.111 2000/08/11 23:46:54 tgl Exp $
+ * $Id: parsenodes.h,v 1.112 2000/09/12 05:09:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef struct AlterTableStmt
{
NodeTag type;
- char subtype; /* A = add, T = alter, D = drop, C = add
- * constr, X = drop constr */
+ char subtype; /* A = add column, T = alter column, D = drop column,
+ * C = add constraint, X = drop constraint,
+ * E = add toast table,
+ * U = change owner */
char *relname; /* table to work on */
bool inh; /* recursively on children? */
- char *name; /* column or constraint name to act on */
+ char *name; /* column or constraint name to act on, or new owner */
Node *def; /* definition of new column or constraint */
int behavior; /* CASCADE or RESTRICT drop behavior */
} AlterTableStmt;
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.5 2000/09/12 04:58:47 momjian Exp $
+ * $Id: Connection.java,v 1.6 2000/09/12 05:09:54 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
throw new PSQLException("postgresql.con.pass");
this_driver = d;
- this_url = new String(url);
- PG_DATABASE = new String(database);
- PG_PASSWORD = new String(info.getProperty("password"));
- PG_USER = new String(info.getProperty("user"));
+ this_url = url;
+ PG_DATABASE = database;
+ PG_PASSWORD = info.getProperty("password");
+ PG_USER = info.getProperty("user");
PG_PORT = port;
- PG_HOST = new String(host);
+ PG_HOST = host;
PG_STATUS = CONNECTION_BAD;
encoding = info.getProperty("charSet"); // could be null
{
int state = -1;
Properties urlProps = new Properties(defaults);
- String key = new String();
- String value = new String();
+ String key = "";
+ String value = "";
StringTokenizer st = new StringTokenizer(url, ":/;=&?", true);
for (int count = 0; (st.hasMoreTokens()); count++) {
*/
public String getDatabaseProductName() throws SQLException
{
- return new String("PostgreSQL");
+ return "PostgreSQL";
}
/**
*/
public String getDriverName() throws SQLException
{
- return new String("PostgreSQL Native Driver");
+ return "PostgreSQL Native Driver";
}
/**
*/
public String getDriverVersion() throws SQLException
{
- return new String(Integer.toString(connection.this_driver.getMajorVersion())+"."+Integer.toString(connection.this_driver.getMinorVersion()));
+ return Integer.toString(connection.this_driver.getMajorVersion())+"."+Integer.toString(connection.this_driver.getMinorVersion());
}
/**
*/
public String getSQLKeywords() throws SQLException
{
- return new String("abort,acl,add,aggregate,append,archive,arch_store,backward,binary,change,cluster,copy,database,delimiters,do,extend,explain,forward,heavy,index,inherits,isnull,light,listen,load,merge,nothing,notify,notnull,oids,purge,rename,replace,retrieve,returns,rule,recipe,setof,stdin,stdout,store,vacuum,verbose,version");
+ return "abort,acl,add,aggregate,append,archive,arch_store,backward,binary,change,cluster,copy,database,delimiters,do,extend,explain,forward,heavy,index,inherits,isnull,light,listen,load,merge,nothing,notify,notnull,oids,purge,rename,replace,retrieve,returns,rule,recipe,setof,stdin,stdout,store,vacuum,verbose,version";
}
public String getNumericFunctions() throws SQLException
*/
public String getSearchStringEscape() throws SQLException
{
- return new String("\\");
+ return "\\";
}
/**
*/
public String getExtraNameCharacters() throws SQLException
{
- return new String("");
+ return "";
}
/**
*/
public String getSchemaTerm() throws SQLException
{
- return new String("Schema");
+ return "Schema";
}
/**
*/
public String getProcedureTerm() throws SQLException
{
- return new String("Procedure");
+ return "Procedure";
}
/**
*/
public String getCatalogTerm() throws SQLException
{
- return new String("Catalog");
+ return "Catalog";
}
/**
public String getCatalogSeparator() throws SQLException
{
// PM Sep 29 97 - changed from "." as we don't support catalogs.
- return new String("");
+ return "";
}
/**
ResultSet r; // ResultSet for the SQL query that we need to do
Vector v = new Vector(); // The new ResultSet tuple stuff
- f[0] = new Field(connection, new String("PROCEDURE_CAT"), iVarcharOid, 32);
- f[1] = new Field(connection, new String("PROCEDURE_SCHEM"), iVarcharOid, 32);
- f[2] = new Field(connection, new String("PROCEDURE_NAME"), iVarcharOid, 32);
- f[3] = new Field(connection, new String("COLUMN_NAME"), iVarcharOid, 32);
- f[4] = new Field(connection, new String("COLUMN_TYPE"), iInt2Oid, 2);
- f[5] = new Field(connection, new String("DATA_TYPE"), iInt2Oid, 2);
- f[6] = new Field(connection, new String("TYPE_NAME"), iVarcharOid, 32);
- f[7] = new Field(connection, new String("PRECISION"), iInt4Oid, 4);
- f[8] = new Field(connection, new String("LENGTH"), iInt4Oid, 4);
- f[9] = new Field(connection, new String("SCALE"), iInt2Oid, 2);
- f[10] = new Field(connection, new String("RADIX"), iInt2Oid, 2);
- f[11] = new Field(connection, new String("NULLABLE"), iInt2Oid, 2);
- f[12] = new Field(connection, new String("REMARKS"), iVarcharOid, 32);
+ f[0] = new Field(connection, "PROCEDURE_CAT", iVarcharOid, 32);
+ f[1] = new Field(connection, "PROCEDURE_SCHEM", iVarcharOid, 32);
+ f[2] = new Field(connection, "PROCEDURE_NAME", iVarcharOid, 32);
+ f[3] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
+ f[4] = new Field(connection, "COLUMN_TYPE", iInt2Oid, 2);
+ f[5] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
+ f[6] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
+ f[7] = new Field(connection, "PRECISION", iInt4Oid, 4);
+ f[8] = new Field(connection, "LENGTH", iInt4Oid, 4);
+ f[9] = new Field(connection, "SCALE", iInt2Oid, 2);
+ f[10] = new Field(connection, "RADIX", iInt2Oid, 2);
+ f[11] = new Field(connection, "NULLABLE", iInt2Oid, 2);
+ f[12] = new Field(connection, "REMARKS", iVarcharOid, 32);
// add query loop here
java.sql.ResultSet r; // ResultSet for the SQL query that we need to do
Vector v = new Vector(); // The new ResultSet tuple stuff
- f[0] = new Field(connection, new String("TABLE_CAT"), iVarcharOid, 32);
- f[1] = new Field(connection, new String("TABLE_SCHEM"), iVarcharOid, 32);
- f[2] = new Field(connection, new String("TABLE_NAME"), iVarcharOid, 32);
- f[3] = new Field(connection, new String("TABLE_TYPE"), iVarcharOid, 32);
- f[4] = new Field(connection, new String("REMARKS"), iVarcharOid, 32);
+ f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
+ f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
+ f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
+ f[3] = new Field(connection, "TABLE_TYPE", iVarcharOid, 32);
+ f[4] = new Field(connection, "REMARKS", iVarcharOid, 32);
// Now form the query
StringBuffer sql = new StringBuffer("select relname,oid,relkind from pg_class where (");
Field f[] = new Field[1];
Vector v = new Vector();
byte[][] tuple = new byte[1][0];
- f[0] = new Field(connection,new String("TABLE_SCHEM"),iVarcharOid,32);
+ f[0] = new Field(connection,"TABLE_SCHEM",iVarcharOid,32);
tuple[0] = "".getBytes();
v.addElement(tuple);
return new ResultSet(connection,f,v,"OK",1);
Field f[] = new Field[1];
Vector v = new Vector();
byte[][] tuple = new byte[1][0];
- f[0] = new Field(connection,new String("TABLE_CAT"),iVarcharOid,32);
+ f[0] = new Field(connection,"TABLE_CAT",iVarcharOid,32);
tuple[0] = "".getBytes();
v.addElement(tuple);
return new ResultSet(connection,f,v,"OK",1);
java.sql.ResultSet r; // ResultSet for the SQL query that we need to do
Vector v = new Vector(); // The new ResultSet tuple stuff
- f[0] = new Field(connection, new String("TABLE_CAT"), iVarcharOid, 32);
- f[1] = new Field(connection, new String("TABLE_SCHEM"), iVarcharOid, 32);
- f[2] = new Field(connection, new String("TABLE_NAME"), iVarcharOid, 32);
- f[3] = new Field(connection, new String("COLUMN_NAME"), iVarcharOid, 32);
- f[4] = new Field(connection, new String("DATA_TYPE"), iInt2Oid, 2);
- f[5] = new Field(connection, new String("TYPE_NAME"), iVarcharOid, 32);
- f[6] = new Field(connection, new String("COLUMN_SIZE"), iInt4Oid, 4);
- f[7] = new Field(connection, new String("BUFFER_LENGTH"), iVarcharOid, 32);
- f[8] = new Field(connection, new String("DECIMAL_DIGITS"), iInt4Oid, 4);
- f[9] = new Field(connection, new String("NUM_PREC_RADIX"), iInt4Oid, 4);
- f[10] = new Field(connection, new String("NULLABLE"), iInt4Oid, 4);
- f[11] = new Field(connection, new String("REMARKS"), iVarcharOid, 32);
- f[12] = new Field(connection, new String("COLUMN_DEF"), iVarcharOid, 32);
- f[13] = new Field(connection, new String("SQL_DATA_TYPE"), iInt4Oid, 4);
- f[14] = new Field(connection, new String("SQL_DATETIME_SUB"), iInt4Oid, 4);
- f[15] = new Field(connection, new String("CHAR_OCTET_LENGTH"), iVarcharOid, 32);
- f[16] = new Field(connection, new String("ORDINAL_POSITION"), iInt4Oid,4);
- f[17] = new Field(connection, new String("IS_NULLABLE"), iVarcharOid, 32);
+ f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
+ f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
+ f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
+ f[3] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
+ f[4] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
+ f[5] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
+ f[6] = new Field(connection, "COLUMN_SIZE", iInt4Oid, 4);
+ f[7] = new Field(connection, "BUFFER_LENGTH", iVarcharOid, 32);
+ f[8] = new Field(connection, "DECIMAL_DIGITS", iInt4Oid, 4);
+ f[9] = new Field(connection, "NUM_PREC_RADIX", iInt4Oid, 4);
+ f[10] = new Field(connection, "NULLABLE", iInt4Oid, 4);
+ f[11] = new Field(connection, "REMARKS", iVarcharOid, 32);
+ f[12] = new Field(connection, "COLUMN_DEF", iVarcharOid, 32);
+ f[13] = new Field(connection, "SQL_DATA_TYPE", iInt4Oid, 4);
+ f[14] = new Field(connection, "SQL_DATETIME_SUB", iInt4Oid, 4);
+ f[15] = new Field(connection, "CHAR_OCTET_LENGTH", iVarcharOid, 32);
+ f[16] = new Field(connection, "ORDINAL_POSITION", iInt4Oid,4);
+ f[17] = new Field(connection, "IS_NULLABLE", iVarcharOid, 32);
// Added by Stefan Andreasen <stefan@linux.kapow.dk>
// If the pattern are null then set them to %
else
columnNamePattern=columnNamePattern.toLowerCase();
- f[0] = new Field(connection,new String("TABLE_CAT"),iVarcharOid,32);
- f[1] = new Field(connection,new String("TABLE_SCHEM"),iVarcharOid,32);
- f[2] = new Field(connection,new String("TABLE_NAME"),iVarcharOid,32);
- f[3] = new Field(connection,new String("COLUMN_NAME"),iVarcharOid,32);
- f[4] = new Field(connection,new String("GRANTOR"),iVarcharOid,32);
- f[5] = new Field(connection,new String("GRANTEE"),iVarcharOid,32);
- f[6] = new Field(connection,new String("PRIVILEGE"),iVarcharOid,32);
- f[7] = new Field(connection,new String("IS_GRANTABLE"),iVarcharOid,32);
+ f[0] = new Field(connection,"TABLE_CAT",iVarcharOid,32);
+ f[1] = new Field(connection,"TABLE_SCHEM",iVarcharOid,32);
+ f[2] = new Field(connection,"TABLE_NAME",iVarcharOid,32);
+ f[3] = new Field(connection,"COLUMN_NAME",iVarcharOid,32);
+ f[4] = new Field(connection,"GRANTOR",iVarcharOid,32);
+ f[5] = new Field(connection,"GRANTEE",iVarcharOid,32);
+ f[6] = new Field(connection,"PRIVILEGE",iVarcharOid,32);
+ f[7] = new Field(connection,"IS_GRANTABLE",iVarcharOid,32);
// This is taken direct from the psql source
java.sql.ResultSet r = connection.ExecSQL("SELECT relname, relacl FROM pg_class, pg_user WHERE ( relkind = 'r' OR relkind = 'i') and relname !~ '^pg_' and relname !~ '^xin[vx][0-9]+' and usesysid = relowner and relname like '"+table.toLowerCase()+"' ORDER BY relname");
ResultSet r; // ResultSet for the SQL query that we need to do
Vector v = new Vector(); // The new ResultSet tuple stuff
- f[0] = new Field(connection, new String("SCOPE"), iInt2Oid, 2);
- f[1] = new Field(connection, new String("COLUMN_NAME"), iVarcharOid, 32);
- f[2] = new Field(connection, new String("DATA_TYPE"), iInt2Oid, 2);
- f[3] = new Field(connection, new String("TYPE_NAME"), iVarcharOid, 32);
- f[4] = new Field(connection, new String("COLUMN_SIZE"), iInt4Oid, 4);
- f[5] = new Field(connection, new String("BUFFER_LENGTH"), iInt4Oid, 4);
- f[6] = new Field(connection, new String("DECIMAL_DIGITS"), iInt2Oid, 2);
- f[7] = new Field(connection, new String("PSEUDO_COLUMN"), iInt2Oid, 2);
+ f[0] = new Field(connection, "SCOPE", iInt2Oid, 2);
+ f[1] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
+ f[2] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
+ f[3] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
+ f[4] = new Field(connection, "COLUMN_SIZE", iInt4Oid, 4);
+ f[5] = new Field(connection, "BUFFER_LENGTH", iInt4Oid, 4);
+ f[6] = new Field(connection, "DECIMAL_DIGITS", iInt2Oid, 2);
+ f[7] = new Field(connection, "PSEUDO_COLUMN", iInt2Oid, 2);
return new ResultSet(connection, f, v, "OK", 1);
}
ResultSet r; // ResultSet for the SQL query that we need to do
Vector v = new Vector(); // The new ResultSet tuple stuff
- f[0] = new Field(connection, new String("TYPE_NAME"), iVarcharOid, 32);
- f[1] = new Field(connection, new String("DATA_TYPE"), iInt2Oid, 2);
- f[2] = new Field(connection, new String("PRECISION"), iInt4Oid, 4);
- f[3] = new Field(connection, new String("LITERAL_PREFIX"), iVarcharOid, 32);
- f[4] = new Field(connection, new String("LITERAL_SUFFIX"), iVarcharOid, 32);
- f[5] = new Field(connection, new String("CREATE_PARAMS"), iVarcharOid, 32);
- f[6] = new Field(connection, new String("NULLABLE"), iInt2Oid, 2);
- f[7] = new Field(connection, new String("CASE_SENSITIVE"), iBoolOid, 1);
- f[8] = new Field(connection, new String("SEARCHABLE"), iInt2Oid, 2);
- f[9] = new Field(connection, new String("UNSIGNED_ATTRIBUTE"), iBoolOid, 1);
- f[10] = new Field(connection, new String("FIXED_PREC_SCALE"), iBoolOid, 1);
- f[11] = new Field(connection, new String("AUTO_INCREMENT"), iBoolOid, 1);
- f[12] = new Field(connection, new String("LOCAL_TYPE_NAME"), iVarcharOid, 32);
- f[13] = new Field(connection, new String("MINIMUM_SCALE"), iInt2Oid, 2);
- f[14] = new Field(connection, new String("MAXIMUM_SCALE"), iInt2Oid, 2);
- f[15] = new Field(connection, new String("SQL_DATA_TYPE"), iInt4Oid, 4);
- f[16] = new Field(connection, new String("SQL_DATETIME_SUB"), iInt4Oid, 4);
- f[17] = new Field(connection, new String("NUM_PREC_RADIX"), iInt4Oid, 4);
+ f[0] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
+ f[1] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
+ f[2] = new Field(connection, "PRECISION", iInt4Oid, 4);
+ f[3] = new Field(connection, "LITERAL_PREFIX", iVarcharOid, 32);
+ f[4] = new Field(connection, "LITERAL_SUFFIX", iVarcharOid, 32);
+ f[5] = new Field(connection, "CREATE_PARAMS", iVarcharOid, 32);
+ f[6] = new Field(connection, "NULLABLE", iInt2Oid, 2);
+ f[7] = new Field(connection, "CASE_SENSITIVE", iBoolOid, 1);
+ f[8] = new Field(connection, "SEARCHABLE", iInt2Oid, 2);
+ f[9] = new Field(connection, "UNSIGNED_ATTRIBUTE", iBoolOid, 1);
+ f[10] = new Field(connection, "FIXED_PREC_SCALE", iBoolOid, 1);
+ f[11] = new Field(connection, "AUTO_INCREMENT", iBoolOid, 1);
+ f[12] = new Field(connection, "LOCAL_TYPE_NAME", iVarcharOid, 32);
+ f[13] = new Field(connection, "MINIMUM_SCALE", iInt2Oid, 2);
+ f[14] = new Field(connection, "MAXIMUM_SCALE", iInt2Oid, 2);
+ f[15] = new Field(connection, "SQL_DATA_TYPE", iInt4Oid, 4);
+ f[16] = new Field(connection, "SQL_DATETIME_SUB", iInt4Oid, 4);
+ f[17] = new Field(connection, "NUM_PREC_RADIX", iInt4Oid, 4);
// cache some results, this will keep memory useage down, and speed
// things up a little.
ResultSet r; // ResultSet for the SQL query that we need to do
Vector v = new Vector(); // The new ResultSet tuple stuff
- f[0] = new Field(connection, new String("TABLE_CAT"), iVarcharOid, 32);
- f[1] = new Field(connection, new String("TABLE_SCHEM"), iVarcharOid, 32);
- f[2] = new Field(connection, new String("TABLE_NAME"), iVarcharOid, 32);
- f[3] = new Field(connection, new String("NON_UNIQUE"), iBoolOid, 1);
- f[4] = new Field(connection, new String("INDEX_QUALIFIER"), iVarcharOid, 32);
- f[5] = new Field(connection, new String("INDEX_NAME"), iVarcharOid, 32);
- f[6] = new Field(connection, new String("TYPE"), iInt2Oid, 2);
- f[7] = new Field(connection, new String("ORDINAL_POSITION"), iInt2Oid, 2);
- f[8] = new Field(connection, new String("COLUMN_NAME"), iVarcharOid, 32);
- f[9] = new Field(connection, new String("ASC_OR_DESC"), iVarcharOid, 32);
- f[10] = new Field(connection, new String("CARDINALITY"), iInt4Oid, 4);
- f[11] = new Field(connection, new String("PAGES"), iInt4Oid, 4);
- f[12] = new Field(connection, new String("FILTER_CONDITION"), iVarcharOid, 32);
+ f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
+ f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
+ f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
+ f[3] = new Field(connection, "NON_UNIQUE", iBoolOid, 1);
+ f[4] = new Field(connection, "INDEX_QUALIFIER", iVarcharOid, 32);
+ f[5] = new Field(connection, "INDEX_NAME", iVarcharOid, 32);
+ f[6] = new Field(connection, "TYPE", iInt2Oid, 2);
+ f[7] = new Field(connection, "ORDINAL_POSITION", iInt2Oid, 2);
+ f[8] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
+ f[9] = new Field(connection, "ASC_OR_DESC", iVarcharOid, 32);
+ f[10] = new Field(connection, "CARDINALITY", iInt4Oid, 4);
+ f[11] = new Field(connection, "PAGES", iInt4Oid, 4);
+ f[12] = new Field(connection, "FILTER_CONDITION", iVarcharOid, 32);
return new ResultSet(connection, f, v, "OK", 1);
}
*/
public String getDatabaseProductName() throws SQLException
{
- return new String("PostgreSQL");
+ return "PostgreSQL";
}
/**
*/
public String getDriverName() throws SQLException
{
- return new String("PostgreSQL Native Driver");
+ return "PostgreSQL Native Driver";
}
/**
*/
public String getDriverVersion() throws SQLException
{
- return new String(Integer.toString(connection.this_driver.getMajorVersion())+"."+Integer.toString(connection.this_driver.getMinorVersion()));
+ return Integer.toString(connection.this_driver.getMajorVersion())+"."+Integer.toString(connection.this_driver.getMinorVersion());
}
/**
*/
public String getSQLKeywords() throws SQLException
{
- return new String("abort,acl,add,aggregate,append,archive,arch_store,backward,binary,change,cluster,copy,database,delimiters,do,extend,explain,forward,heavy,index,inherits,isnull,light,listen,load,merge,nothing,notify,notnull,oids,purge,rename,replace,retrieve,returns,rule,recipe,setof,stdin,stdout,store,vacuum,verbose,version");
+ return "abort,acl,add,aggregate,append,archive,arch_store,backward,binary,change,cluster,copy,database,delimiters,do,extend,explain,forward,heavy,index,inherits,isnull,light,listen,load,merge,nothing,notify,notnull,oids,purge,rename,replace,retrieve,returns,rule,recipe,setof,stdin,stdout,store,vacuum,verbose,version";
}
public String getNumericFunctions() throws SQLException
*/
public String getSearchStringEscape() throws SQLException
{
- return new String("\\");
+ return "\\";
}
/**
*/
public String getExtraNameCharacters() throws SQLException
{
- return new String("");
+ return "";
}
/**
*/
public String getSchemaTerm() throws SQLException
{
- return new String("Schema");
+ return "Schema";
}
/**
*/
public String getProcedureTerm() throws SQLException
{
- return new String("Procedure");
+ return "Procedure";
}
/**
*/
public String getCatalogTerm() throws SQLException
{
- return new String("Catalog");
+ return "Catalog";
}
/**
public String getCatalogSeparator() throws SQLException
{
// PM Sep 29 97 - changed from "." as we don't support catalogs.
- return new String("");
+ return "";
}
/**
ResultSet r; // ResultSet for the SQL query that we need to do
Vector v = new Vector(); // The new ResultSet tuple stuff
- f[0] = new Field(connection, new String("PROCEDURE_CAT"), iVarcharOid, 32);
- f[1] = new Field(connection, new String("PROCEDURE_SCHEM"), iVarcharOid, 32);
- f[2] = new Field(connection, new String("PROCEDURE_NAME"), iVarcharOid, 32);
- f[3] = new Field(connection, new String("COLUMN_NAME"), iVarcharOid, 32);
- f[4] = new Field(connection, new String("COLUMN_TYPE"), iInt2Oid, 2);
- f[5] = new Field(connection, new String("DATA_TYPE"), iInt2Oid, 2);
- f[6] = new Field(connection, new String("TYPE_NAME"), iVarcharOid, 32);
- f[7] = new Field(connection, new String("PRECISION"), iInt4Oid, 4);
- f[8] = new Field(connection, new String("LENGTH"), iInt4Oid, 4);
- f[9] = new Field(connection, new String("SCALE"), iInt2Oid, 2);
- f[10] = new Field(connection, new String("RADIX"), iInt2Oid, 2);
- f[11] = new Field(connection, new String("NULLABLE"), iInt2Oid, 2);
- f[12] = new Field(connection, new String("REMARKS"), iVarcharOid, 32);
+ f[0] = new Field(connection, "PROCEDURE_CAT", iVarcharOid, 32);
+ f[1] = new Field(connection, "PROCEDURE_SCHEM", iVarcharOid, 32);
+ f[2] = new Field(connection, "PROCEDURE_NAME", iVarcharOid, 32);
+ f[3] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
+ f[4] = new Field(connection, "COLUMN_TYPE", iInt2Oid, 2);
+ f[5] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
+ f[6] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
+ f[7] = new Field(connection, "PRECISION", iInt4Oid, 4);
+ f[8] = new Field(connection, "LENGTH", iInt4Oid, 4);
+ f[9] = new Field(connection, "SCALE", iInt2Oid, 2);
+ f[10] = new Field(connection, "RADIX", iInt2Oid, 2);
+ f[11] = new Field(connection, "NULLABLE", iInt2Oid, 2);
+ f[12] = new Field(connection, "REMARKS", iVarcharOid, 32);
// add query loop here
java.sql.ResultSet r; // ResultSet for the SQL query that we need to do
Vector v = new Vector(); // The new ResultSet tuple stuff
- f[0] = new Field(connection, new String("TABLE_CAT"), iVarcharOid, 32);
- f[1] = new Field(connection, new String("TABLE_SCHEM"), iVarcharOid, 32);
- f[2] = new Field(connection, new String("TABLE_NAME"), iVarcharOid, 32);
- f[3] = new Field(connection, new String("TABLE_TYPE"), iVarcharOid, 32);
- f[4] = new Field(connection, new String("REMARKS"), iVarcharOid, 32);
+ f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
+ f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
+ f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
+ f[3] = new Field(connection, "TABLE_TYPE", iVarcharOid, 32);
+ f[4] = new Field(connection, "REMARKS", iVarcharOid, 32);
// Now form the query
StringBuffer sql = new StringBuffer("select relname,oid,relkind from pg_class where (");
Field f[] = new Field[1];
Vector v = new Vector();
byte[][] tuple = new byte[1][0];
- f[0] = new Field(connection,new String("TABLE_SCHEM"),iVarcharOid,32);
+ f[0] = new Field(connection,"TABLE_SCHEM",iVarcharOid,32);
tuple[0] = "".getBytes();
v.addElement(tuple);
return new ResultSet(connection,f,v,"OK",1);
Field f[] = new Field[1];
Vector v = new Vector();
byte[][] tuple = new byte[1][0];
- f[0] = new Field(connection,new String("TABLE_CAT"),iVarcharOid,32);
+ f[0] = new Field(connection,"TABLE_CAT",iVarcharOid,32);
tuple[0] = "".getBytes();
v.addElement(tuple);
return new ResultSet(connection,f,v,"OK",1);
java.sql.ResultSet r; // ResultSet for the SQL query that we need to do
Vector v = new Vector(); // The new ResultSet tuple stuff
- f[0] = new Field(connection, new String("TABLE_CAT"), iVarcharOid, 32);
- f[1] = new Field(connection, new String("TABLE_SCHEM"), iVarcharOid, 32);
- f[2] = new Field(connection, new String("TABLE_NAME"), iVarcharOid, 32);
- f[3] = new Field(connection, new String("COLUMN_NAME"), iVarcharOid, 32);
- f[4] = new Field(connection, new String("DATA_TYPE"), iInt2Oid, 2);
- f[5] = new Field(connection, new String("TYPE_NAME"), iVarcharOid, 32);
- f[6] = new Field(connection, new String("COLUMN_SIZE"), iInt4Oid, 4);
- f[7] = new Field(connection, new String("BUFFER_LENGTH"), iVarcharOid, 32);
- f[8] = new Field(connection, new String("DECIMAL_DIGITS"), iInt4Oid, 4);
- f[9] = new Field(connection, new String("NUM_PREC_RADIX"), iInt4Oid, 4);
- f[10] = new Field(connection, new String("NULLABLE"), iInt4Oid, 4);
- f[11] = new Field(connection, new String("REMARKS"), iVarcharOid, 32);
- f[12] = new Field(connection, new String("COLUMN_DEF"), iVarcharOid, 32);
- f[13] = new Field(connection, new String("SQL_DATA_TYPE"), iInt4Oid, 4);
- f[14] = new Field(connection, new String("SQL_DATETIME_SUB"), iInt4Oid, 4);
- f[15] = new Field(connection, new String("CHAR_OCTET_LENGTH"), iVarcharOid, 32);
- f[16] = new Field(connection, new String("ORDINAL_POSITION"), iInt4Oid,4);
- f[17] = new Field(connection, new String("IS_NULLABLE"), iVarcharOid, 32);
+ f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
+ f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
+ f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
+ f[3] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
+ f[4] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
+ f[5] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
+ f[6] = new Field(connection, "COLUMN_SIZE", iInt4Oid, 4);
+ f[7] = new Field(connection, "BUFFER_LENGTH", iVarcharOid, 32);
+ f[8] = new Field(connection, "DECIMAL_DIGITS", iInt4Oid, 4);
+ f[9] = new Field(connection, "NUM_PREC_RADIX", iInt4Oid, 4);
+ f[10] = new Field(connection, "NULLABLE", iInt4Oid, 4);
+ f[11] = new Field(connection, "REMARKS", iVarcharOid, 32);
+ f[12] = new Field(connection, "COLUMN_DEF", iVarcharOid, 32);
+ f[13] = new Field(connection, "SQL_DATA_TYPE", iInt4Oid, 4);
+ f[14] = new Field(connection, "SQL_DATETIME_SUB", iInt4Oid, 4);
+ f[15] = new Field(connection, "CHAR_OCTET_LENGTH", iVarcharOid, 32);
+ f[16] = new Field(connection, "ORDINAL_POSITION", iInt4Oid,4);
+ f[17] = new Field(connection, "IS_NULLABLE", iVarcharOid, 32);
// Added by Stefan Andreasen <stefan@linux.kapow.dk>
// If the pattern are null then set them to %
else
columnNamePattern=columnNamePattern.toLowerCase();
- f[0] = new Field(connection,new String("TABLE_CAT"),iVarcharOid,32);
- f[1] = new Field(connection,new String("TABLE_SCHEM"),iVarcharOid,32);
- f[2] = new Field(connection,new String("TABLE_NAME"),iVarcharOid,32);
- f[3] = new Field(connection,new String("COLUMN_NAME"),iVarcharOid,32);
- f[4] = new Field(connection,new String("GRANTOR"),iVarcharOid,32);
- f[5] = new Field(connection,new String("GRANTEE"),iVarcharOid,32);
- f[6] = new Field(connection,new String("PRIVILEGE"),iVarcharOid,32);
- f[7] = new Field(connection,new String("IS_GRANTABLE"),iVarcharOid,32);
+ f[0] = new Field(connection,"TABLE_CAT",iVarcharOid,32);
+ f[1] = new Field(connection,"TABLE_SCHEM",iVarcharOid,32);
+ f[2] = new Field(connection,"TABLE_NAME",iVarcharOid,32);
+ f[3] = new Field(connection,"COLUMN_NAME",iVarcharOid,32);
+ f[4] = new Field(connection,"GRANTOR",iVarcharOid,32);
+ f[5] = new Field(connection,"GRANTEE",iVarcharOid,32);
+ f[6] = new Field(connection,"PRIVILEGE",iVarcharOid,32);
+ f[7] = new Field(connection,"IS_GRANTABLE",iVarcharOid,32);
// This is taken direct from the psql source
java.sql.ResultSet r = connection.ExecSQL("SELECT relname, relacl FROM pg_class, pg_user WHERE ( relkind = 'r' OR relkind = 'i') and relname !~ '^pg_' and relname !~ '^xin[vx][0-9]+' and usesysid = relowner and relname like '"+table.toLowerCase()+"' ORDER BY relname");
ResultSet r; // ResultSet for the SQL query that we need to do
Vector v = new Vector(); // The new ResultSet tuple stuff
- f[0] = new Field(connection, new String("SCOPE"), iInt2Oid, 2);
- f[1] = new Field(connection, new String("COLUMN_NAME"), iVarcharOid, 32);
- f[2] = new Field(connection, new String("DATA_TYPE"), iInt2Oid, 2);
- f[3] = new Field(connection, new String("TYPE_NAME"), iVarcharOid, 32);
- f[4] = new Field(connection, new String("COLUMN_SIZE"), iInt4Oid, 4);
- f[5] = new Field(connection, new String("BUFFER_LENGTH"), iInt4Oid, 4);
- f[6] = new Field(connection, new String("DECIMAL_DIGITS"), iInt2Oid, 2);
- f[7] = new Field(connection, new String("PSEUDO_COLUMN"), iInt2Oid, 2);
+ f[0] = new Field(connection, "SCOPE", iInt2Oid, 2);
+ f[1] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
+ f[2] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
+ f[3] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
+ f[4] = new Field(connection, "COLUMN_SIZE", iInt4Oid, 4);
+ f[5] = new Field(connection, "BUFFER_LENGTH", iInt4Oid, 4);
+ f[6] = new Field(connection, "DECIMAL_DIGITS", iInt2Oid, 2);
+ f[7] = new Field(connection, "PSEUDO_COLUMN", iInt2Oid, 2);
return new ResultSet(connection, f, v, "OK", 1);
}
ResultSet r; // ResultSet for the SQL query that we need to do
Vector v = new Vector(); // The new ResultSet tuple stuff
- f[0] = new Field(connection, new String("TYPE_NAME"), iVarcharOid, 32);
- f[1] = new Field(connection, new String("DATA_TYPE"), iInt2Oid, 2);
- f[2] = new Field(connection, new String("PRECISION"), iInt4Oid, 4);
- f[3] = new Field(connection, new String("LITERAL_PREFIX"), iVarcharOid, 32);
- f[4] = new Field(connection, new String("LITERAL_SUFFIX"), iVarcharOid, 32);
- f[5] = new Field(connection, new String("CREATE_PARAMS"), iVarcharOid, 32);
- f[6] = new Field(connection, new String("NULLABLE"), iInt2Oid, 2);
- f[7] = new Field(connection, new String("CASE_SENSITIVE"), iBoolOid, 1);
- f[8] = new Field(connection, new String("SEARCHABLE"), iInt2Oid, 2);
- f[9] = new Field(connection, new String("UNSIGNED_ATTRIBUTE"), iBoolOid, 1);
- f[10] = new Field(connection, new String("FIXED_PREC_SCALE"), iBoolOid, 1);
- f[11] = new Field(connection, new String("AUTO_INCREMENT"), iBoolOid, 1);
- f[12] = new Field(connection, new String("LOCAL_TYPE_NAME"), iVarcharOid, 32);
- f[13] = new Field(connection, new String("MINIMUM_SCALE"), iInt2Oid, 2);
- f[14] = new Field(connection, new String("MAXIMUM_SCALE"), iInt2Oid, 2);
- f[15] = new Field(connection, new String("SQL_DATA_TYPE"), iInt4Oid, 4);
- f[16] = new Field(connection, new String("SQL_DATETIME_SUB"), iInt4Oid, 4);
- f[17] = new Field(connection, new String("NUM_PREC_RADIX"), iInt4Oid, 4);
+ f[0] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
+ f[1] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
+ f[2] = new Field(connection, "PRECISION", iInt4Oid, 4);
+ f[3] = new Field(connection, "LITERAL_PREFIX", iVarcharOid, 32);
+ f[4] = new Field(connection, "LITERAL_SUFFIX", iVarcharOid, 32);
+ f[5] = new Field(connection, "CREATE_PARAMS", iVarcharOid, 32);
+ f[6] = new Field(connection, "NULLABLE", iInt2Oid, 2);
+ f[7] = new Field(connection, "CASE_SENSITIVE", iBoolOid, 1);
+ f[8] = new Field(connection, "SEARCHABLE", iInt2Oid, 2);
+ f[9] = new Field(connection, "UNSIGNED_ATTRIBUTE", iBoolOid, 1);
+ f[10] = new Field(connection, "FIXED_PREC_SCALE", iBoolOid, 1);
+ f[11] = new Field(connection, "AUTO_INCREMENT", iBoolOid, 1);
+ f[12] = new Field(connection, "LOCAL_TYPE_NAME", iVarcharOid, 32);
+ f[13] = new Field(connection, "MINIMUM_SCALE", iInt2Oid, 2);
+ f[14] = new Field(connection, "MAXIMUM_SCALE", iInt2Oid, 2);
+ f[15] = new Field(connection, "SQL_DATA_TYPE", iInt4Oid, 4);
+ f[16] = new Field(connection, "SQL_DATETIME_SUB", iInt4Oid, 4);
+ f[17] = new Field(connection, "NUM_PREC_RADIX", iInt4Oid, 4);
// cache some results, this will keep memory useage down, and speed
// things up a little.
ResultSet r; // ResultSet for the SQL query that we need to do
Vector v = new Vector(); // The new ResultSet tuple stuff
- f[0] = new Field(connection, new String("TABLE_CAT"), iVarcharOid, 32);
- f[1] = new Field(connection, new String("TABLE_SCHEM"), iVarcharOid, 32);
- f[2] = new Field(connection, new String("TABLE_NAME"), iVarcharOid, 32);
- f[3] = new Field(connection, new String("NON_UNIQUE"), iBoolOid, 1);
- f[4] = new Field(connection, new String("INDEX_QUALIFIER"), iVarcharOid, 32);
- f[5] = new Field(connection, new String("INDEX_NAME"), iVarcharOid, 32);
- f[6] = new Field(connection, new String("TYPE"), iInt2Oid, 2);
- f[7] = new Field(connection, new String("ORDINAL_POSITION"), iInt2Oid, 2);
- f[8] = new Field(connection, new String("COLUMN_NAME"), iVarcharOid, 32);
- f[9] = new Field(connection, new String("ASC_OR_DESC"), iVarcharOid, 32);
- f[10] = new Field(connection, new String("CARDINALITY"), iInt4Oid, 4);
- f[11] = new Field(connection, new String("PAGES"), iInt4Oid, 4);
- f[12] = new Field(connection, new String("FILTER_CONDITION"), iVarcharOid, 32);
+ f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
+ f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
+ f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
+ f[3] = new Field(connection, "NON_UNIQUE", iBoolOid, 1);
+ f[4] = new Field(connection, "INDEX_QUALIFIER", iVarcharOid, 32);
+ f[5] = new Field(connection, "INDEX_NAME", iVarcharOid, 32);
+ f[6] = new Field(connection, "TYPE", iInt2Oid, 2);
+ f[7] = new Field(connection, "ORDINAL_POSITION", iInt2Oid, 2);
+ f[8] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
+ f[9] = new Field(connection, "ASC_OR_DESC", iVarcharOid, 32);
+ f[10] = new Field(connection, "CARDINALITY", iInt4Oid, 4);
+ f[11] = new Field(connection, "PAGES", iInt4Oid, 4);
+ f[12] = new Field(connection, "FILTER_CONDITION", iVarcharOid, 32);
return new ResultSet(connection, f, v, "OK", 1);
}