Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: deprecate Fastpath API #903

Merged
merged 4 commits into from May 4, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+24 −33
Diff settings

Always

Just for now

@@ -83,14 +83,14 @@ public Object fastpath(int fnId, boolean resultType, FastpathArg[] args) throws
}

/**
* Send a function call to the PostgreSQL backend
* Sends a function call to the PostgreSQL backend
*
* @param fnId Function id
* @param args FastpathArguments to pass to fastpath
* @return null if no data, byte[] otherwise
* @throws SQLException if a database-access error occurs.
*/
public byte[] fastpath(int fnId, FastpathArg[] args) throws SQLException {
public byte[] fastpath(int fnId, FastpathArg... args) throws SQLException {

This comment has been minimized.

Copy link
@vlsi

vlsi Aug 3, 2017

Member

I think this was somewhat deprecated API.

This comment has been minimized.

Copy link
@AlexElin

AlexElin Aug 4, 2017

Author Contributor

marked as deprecated

// Turn fastpath array into a parameter list.
ParameterList params = executor.createFastpathParameters(args.length);
for (int i = 0; i < args.length; ++i) {
@@ -121,7 +121,7 @@ public Object fastpath(String name, boolean resulttype, FastpathArg[] args) thro
}

/**
* Send a function call to the PostgreSQL backend by name.
* Sends a function call to the PostgreSQL backend by name.
*
* Note: the mapping for the procedure name to function id needs to exist, usually to an earlier
* call to addfunction().
@@ -137,7 +137,7 @@ public Object fastpath(String name, boolean resulttype, FastpathArg[] args) thro
* @throws SQLException if name is unknown or if a database-access error occurs.
* @see org.postgresql.largeobject.LargeObject
*/
public byte[] fastpath(String name, FastpathArg[] args) throws SQLException {
public byte[] fastpath(String name, FastpathArg... args) throws SQLException {
connection.getLogger().log(Level.FINEST, "Fastpath: calling {0}", name);
return fastpath(getID(name), args);
}
@@ -150,7 +150,7 @@ public Object fastpath(String name, boolean resulttype, FastpathArg[] args) thro
* @return integer result
* @throws SQLException if a database-access error occurs or no result
*/
public int getInteger(String name, FastpathArg[] args) throws SQLException {
public int getInteger(String name, FastpathArg... args) throws SQLException {
byte[] returnValue = fastpath(name, args);
if (returnValue == null) {
throw new PSQLException(
@@ -175,7 +175,7 @@ public int getInteger(String name, FastpathArg[] args) throws SQLException {
* @return long result
* @throws SQLException if a database-access error occurs or no result
*/
public long getLong(String name, FastpathArg[] args) throws SQLException {
public long getLong(String name, FastpathArg... args) throws SQLException {
byte[] returnValue = fastpath(name, args);
if (returnValue == null) {
throw new PSQLException(
@@ -201,7 +201,7 @@ public long getLong(String name, FastpathArg[] args) throws SQLException {
* @return oid of the given call
* @throws SQLException if a database-access error occurs or no result
*/
public long getOID(String name, FastpathArg[] args) throws SQLException {
public long getOID(String name, FastpathArg... args) throws SQLException {
long oid = getInteger(name, args);
if (oid < 0) {
oid += NUM_OIDS;
@@ -217,12 +217,12 @@ public long getOID(String name, FastpathArg[] args) throws SQLException {
* @return byte[] array containing result
* @throws SQLException if a database-access error occurs or no result
*/
public byte[] getData(String name, FastpathArg[] args) throws SQLException {
public byte[] getData(String name, FastpathArg... args) throws SQLException {
return fastpath(name, args);
}

/**
* This adds a function to our lookup table.
* Adds a function to our lookup table.
*
* <p>
* User code should use the addFunctions method, which is based upon a query, rather than hard
@@ -278,7 +278,7 @@ public void addFunctions(ResultSet rs) throws SQLException {
}

/**
* This returns the function id associated by its name.
* Returns the function id associated by its name.
*
* <p>
* If addFunction() or addFunctions() have not been called for this name, then an SQLException is
@@ -137,6 +137,7 @@ public LargeObject copy() throws SQLException {
* @return the OID of this LargeObject
* @deprecated As of 8.3, replaced by {@link #getLongOID()}
*/
@Deprecated
public int getOID() {
return (int) oid;
}
@@ -168,9 +169,7 @@ public void close() throws SQLException {
}

// finally close
FastpathArg[] args = new FastpathArg[1];
args[0] = new FastpathArg(fd);
fp.fastpath("lo_close", args); // true here as we dont care!!
fp.fastpath("lo_close", new FastpathArg(fd)); // true here as we dont care!!
closed = true;
if (this.commitOnClose) {
this.conn.commit();
@@ -293,19 +292,15 @@ public void seek(int pos) throws SQLException {
* @throws SQLException if a database-access error occurs.
*/
public int tell() throws SQLException {
FastpathArg[] args = new FastpathArg[1];
args[0] = new FastpathArg(fd);
return fp.getInteger("lo_tell", args);
return fp.getInteger("lo_tell", new FastpathArg(fd));
}

/**
* @return the current position within the object
* @throws SQLException if a database-access error occurs.
*/
public long tell64() throws SQLException {
FastpathArg[] args = new FastpathArg[1];
args[0] = new FastpathArg(fd);
return fp.getLong("lo_tell64", args);
return fp.getLong("lo_tell64", new FastpathArg(fd));
}

/**
@@ -266,7 +266,7 @@ public LargeObject open(long oid, int mode, boolean commitOnClose) throws SQLExc
}

/**
* This creates a large object, returning its OID.
* Creates a large object, returning its OID.
*
* <p>
* It defaults to READWRITE for the new object's attributes.
@@ -281,7 +281,7 @@ public int create() throws SQLException {
}

/**
* This creates a large object, returning its OID.
* Creates a large object, returning its OID.
*
* <p>
* It defaults to READWRITE for the new object's attributes.
@@ -294,7 +294,7 @@ public long createLO() throws SQLException {
}

/**
* This creates a large object, returning its OID
* Creates a large object, returning its OID
*
* @param mode a bitmask describing different attributes of the new object
* @return oid of new object
@@ -305,13 +305,11 @@ public long createLO(int mode) throws SQLException {
throw new PSQLException(GT.tr("Large Objects may not be used in auto-commit mode."),
PSQLState.NO_ACTIVE_SQL_TRANSACTION);
}
FastpathArg[] args = new FastpathArg[1];
args[0] = new FastpathArg(mode);
return fp.getOID("lo_creat", args);
return fp.getOID("lo_creat", new FastpathArg(mode));
}

/**
* This creates a large object, returning its OID
* Creates a large object, returning its OID
*
* @param mode a bitmask describing different attributes of the new object
* @return oid of new object
@@ -325,19 +323,17 @@ public int create(int mode) throws SQLException {
}

/**
* This deletes a large object.
* Deletes a large object.
*
* @param oid describing object to delete
* @throws SQLException on error
*/
public void delete(long oid) throws SQLException {
FastpathArg[] args = new FastpathArg[1];
args[0] = Fastpath.createOIDArg(oid);
fp.fastpath("lo_unlink", args);
fp.fastpath("lo_unlink", Fastpath.createOIDArg(oid));
}

/**
* This deletes a large object.
* Deletes a large object.
*
* <p>
* It is identical to the delete method, and is supplied as the C API uses unlink.
@@ -352,7 +348,7 @@ public void unlink(int oid) throws SQLException {
}

/**
* This deletes a large object.
* Deletes a large object.
*
* <p>
* It is identical to the delete method, and is supplied as the C API uses unlink.
@@ -365,7 +361,7 @@ public void unlink(long oid) throws SQLException {
}

/**
* This deletes a large object.
* Deletes a large object.
*
* @param oid describing object to delete
* @throws SQLException on error
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.