? GNUmakefile ? config.log ? config.status ? diff.patch ? src/Makefile.global ? src/backend/postgres ? src/backend/catalog/postgres.bki ? src/backend/catalog/postgres.description ? src/backend/utils/mb/conversion_procs/conversion_create.sql ? src/backend/utils/mb/conversion_procs/ascii_and_mic/libascii_and_mic.so.0.0 ? src/backend/utils/mb/conversion_procs/cyrillic_and_mic/libcyrillic_and_mic.so.0.0 ? src/backend/utils/mb/conversion_procs/euc_cn_and_mic/libeuc_cn_and_mic.so.0.0 ? src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/libeuc_jp_and_sjis.so.0.0 ? src/backend/utils/mb/conversion_procs/euc_kr_and_mic/libeuc_kr_and_mic.so.0.0 ? src/backend/utils/mb/conversion_procs/euc_tw_and_big5/libeuc_tw_and_big5.so.0.0 ? src/backend/utils/mb/conversion_procs/latin2_and_win1250/liblatin2_and_win1250.so.0.0 ? src/backend/utils/mb/conversion_procs/latin_and_mic/liblatin_and_mic.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_ascii/libutf8_and_ascii.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_big5/libutf8_and_big5.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/libutf8_and_cyrillic.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/libutf8_and_euc_cn.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/libutf8_and_euc_jp.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/libutf8_and_euc_kr.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/libutf8_and_euc_tw.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_gb18030/libutf8_and_gb18030.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_gbk/libutf8_and_gbk.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_iso8859/libutf8_and_iso8859.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/libutf8_and_iso8859_1.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_johab/libutf8_and_johab.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_sjis/libutf8_and_sjis.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_tcvn/libutf8_and_tcvn.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_uhc/libutf8_and_uhc.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_win1250/libutf8_and_win1250.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_win1256/libutf8_and_win1256.so.0.0 ? src/backend/utils/mb/conversion_procs/utf8_and_win874/libutf8_and_win874.so.0.0 ? src/bin/initdb/initdb ? src/bin/initlocation/initlocation ? src/bin/ipcclean/ipcclean ? src/bin/pg_ctl/pg_ctl ? src/include/pg_config.h ? src/include/stamp-h ? src/interfaces/jdbc.b4cvs ? src/interfaces/jdbc.tar.bz2 ? src/interfaces/ecpg/compatlib/libecpg_compat.so.1.0.0 ? src/interfaces/ecpg/ecpglib/libecpg.so.4.0.0 ? src/interfaces/ecpg/pgtypeslib/libpgtypes.so.1.0.0 ? src/interfaces/ecpg/preproc/ecpg ? src/interfaces/jdbc/diff.patch ? src/interfaces/jdbc/example/metadata-testver.java ? src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.class ? src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.class ? src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.class ? src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.class ? src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.class ? src/interfaces/libpq/libpq.so.3.1 Index: doc/src/sgml/release.sgml =================================================================== RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/release.sgml,v retrieving revision 1.208 diff -c -r1.208 release.sgml *** doc/src/sgml/release.sgml 20 Sep 2003 20:12:05 -0000 1.208 --- doc/src/sgml/release.sgml 24 Sep 2003 05:39:40 -0000 *************** *** 839,844 **** --- 839,845 ---- JDBC + Allow JDBC to enable sql logging by adding ?logtype=X to the connection Allow JDBC to compile with JDK 1.4 (Dave) Add JDBC 3 support (Barry) Allows JDBC to set loglevel by adding ?loglevel=X to the connection URL (Barry) Index: src/interfaces/jdbc/org/postgresql/Driver.java.in =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/Driver.java.in,v retrieving revision 1.36 diff -c -r1.36 Driver.java.in *** src/interfaces/jdbc/org/postgresql/Driver.java.in 13 Sep 2003 04:02:12 -0000 1.36 --- src/interfaces/jdbc/org/postgresql/Driver.java.in 24 Sep 2003 05:39:46 -0000 *************** *** 41,46 **** --- 41,59 ---- public class Driver implements java.sql.Driver { + // SQL statement types. Should be provided as arguments to [enable|disable]SQLLogType() + + public static final int SQL_ALL = 0; + + public static boolean logSQLAll = false; + + // Maximum length for variables (prepared and called statements) + // after which they should be cut off in the log. This variable + // should not be altered directly. Please use the + // setMaxSQLLogVarLen() function. + + public static int MAX_SQL_LOG_VAR_LEN = 32; + // make these public so they can be used in setLogLevel below public static final int DEBUG = 2; *************** *** 422,428 **** { return new PSQLException("postgresql.unimplemented", PSQLState.NOT_IMPLEMENTED); } ! /** * used to turn logging on to a certain level, can be called * by specifying fully qualified class ie org.postgresql.Driver.setLogLevel() --- 435,499 ---- { return new PSQLException("postgresql.unimplemented", PSQLState.NOT_IMPLEMENTED); } ! /** ! * used to enable logging for specific SQL statement ! * types. SQL logging is automatically turned on if any of the sql ! * statement types are set for logging. ! * @param statementType Sets the type of SQL statements to log. It can be one of (currently only 1..): ! * SQL_ALL ! */ ! public static void enableSQLLogType(int statementType) ! { ! if (statementType == SQL_ALL) ! { ! logSQLAll = true; ! } ! else ! { ! // Else do nothing. ! } ! } ! /** ! * used to disable logging for specific SQL statement ! * types. SQL logging is automatically turned off if none of the sql ! * statement types are set for logging. ! * @param statementType Sets the type of SQL statements to log. It can be one of (currently only 1..): ! * SQL_ALL ! */ ! public static void disableSQLLogType(int statementType) ! { ! if (statementType == SQL_ALL) ! { ! logSQLAll = false; ! } ! else ! { ! // Else do nothing. ! } ! } ! /** ! * Sets the maximum length for variables (in prepared and callable ! * statements) after which they are cut off in the log. If the ! * given length is less than 0 it is reset ! * back to the default (32). If its greater than 256, it is set to 256. ! * ! * @param maxLen The maximum length of the variable. ! */ ! public static void setMaxSQLLogVarLen (int maxLen) ! { ! if (maxLen < 0) ! { ! MAX_SQL_LOG_VAR_LEN = 32; ! } ! else if (maxLen > 256) ! { ! MAX_SQL_LOG_VAR_LEN = 256; ! } ! else ! { ! MAX_SQL_LOG_VAR_LEN = maxLen; ! } ! } /** * used to turn logging on to a certain level, can be called * by specifying fully qualified class ie org.postgresql.Driver.setLogLevel() *************** *** 485,491 **** } } } ! public static void makeSSL(org.postgresql.core.PGStream p_stream) throws IOException { @SSL@ if (logDebug) --- 556,572 ---- } } } ! /** ! * SQL Query logger. Only selected message types are logged. ! * @param sql The statement to log. ! */ ! public static void logSQL(String sql) ! { ! if (logSQLAll) ! { ! DriverManager.println(sql); ! } ! } public static void makeSSL(org.postgresql.core.PGStream p_stream) throws IOException { @SSL@ if (logDebug) Index: src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java,v retrieving revision 1.27 diff -c -r1.27 QueryExecutor.java *** src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java 17 Sep 2003 08:21:36 -0000 1.27 --- src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java 24 Sep 2003 05:39:48 -0000 *************** *** 315,320 **** --- 315,321 ---- } try { + StringBuffer logBuffer = new StringBuffer(); byte[][] l_parts = new byte[(m_binds.length*2)+1][]; int j = 0; int l_msgSize = 4; *************** *** 322,327 **** --- 323,340 ---- pgStream.SendChar('Q'); for (int i = 0 ; i < m_binds.length ; ++i) { + // Log the fragment and its binding + logBuffer.append(m_sqlFrags[i]); + if (org.postgresql.Driver.MAX_SQL_LOG_VAR_LEN > m_binds[i].toString().length()) + { + logBuffer.append(m_binds[i].toString()); + } + else + { + logBuffer.append(m_binds[i].toString().substring(0, org.postgresql.Driver.MAX_SQL_LOG_VAR_LEN)); + logBuffer.append("..."); + } + l_parts[j] = l_encoding.encode(m_sqlFrags[i]); l_msgSize += l_parts[j].length; j++; *************** *** 329,334 **** --- 342,352 ---- l_msgSize += l_parts[j].length; j++; } + + // Get the last item and write to log + logBuffer.append(m_sqlFrags[m_binds.length]); + org.postgresql.Driver.logSQL(logBuffer.toString()); + l_parts[j] = l_encoding.encode(m_sqlFrags[m_binds.length]); l_msgSize += l_parts[j].length; pgStream.SendInteger(l_msgSize+1,4); *************** *** 356,367 **** --- 374,403 ---- } try { + StringBuffer logBuffer = new StringBuffer(); pgStream.SendChar('Q'); for (int i = 0 ; i < m_binds.length ; ++i) { + // Log the fragment and its binding + + logBuffer.append(m_sqlFrags[i]); + if (org.postgresql.Driver.MAX_SQL_LOG_VAR_LEN > m_binds[i].toString().length()) + { + logBuffer.append(m_binds[i].toString()); + } + else + { + logBuffer.append(m_binds[i].toString().substring(0, org.postgresql.Driver.MAX_SQL_LOG_VAR_LEN)); + logBuffer.append("..."); + } + pgStream.Send(connection.getEncoding().encode(m_sqlFrags[i])); pgStream.Send(connection.getEncoding().encode(m_binds[i].toString())); } + + // Get the last item and write to log + logBuffer.append(m_sqlFrags[m_binds.length]); + org.postgresql.Driver.logSQL(logBuffer.toString()); pgStream.Send(connection.getEncoding().encode(m_sqlFrags[m_binds.length])); pgStream.SendChar(0); Index: src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java,v retrieving revision 1.26 diff -c -r1.26 AbstractJdbc1Connection.java *** src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java 13 Sep 2003 04:02:15 -0000 1.26 --- src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java 24 Sep 2003 05:39:51 -0000 *************** *** 182,187 **** --- 182,212 ---- enableDriverManagerLogging(); } + // Read logtypes arg and determine what needs to be logged + + String l_logTypeProp = info.getProperty("logtype", "0"); + + try { + StringTokenizer stok = new StringTokenizer(l_logTypeProp, ","); + + while (stok.hasMoreTokens()) + { + if (((String) stok.nextElement()).equals("all")) + { + Driver.enableSQLLogType(Driver.SQL_ALL); + enableDriverManagerLogging(); + } + else + { + // Else nothing.. + } + } + } + catch (Exception lt_e) + { + // Ignore + } + //Print out the driver version number if (Driver.logInfo) Driver.info(Driver.getVersion()); *************** *** 189,194 **** --- 214,220 ---- Driver.debug(" ssl = " + useSSL); Driver.debug(" compatible = " + compatible); Driver.debug(" loglevel = " + l_logLevel); + Driver.debug(" sqllogtypes = " + l_logTypeProp); } // Now make the initial connection