// allow NULL values. An empty string means
// nobody knows.
// => pg_attribute.attnotnull
-
+ OUString strDefaultValue = getColExprForDefaultSettingVal(m_pSettings);
Reference< XPreparedStatement > statement = m_origin->prepareStatement(
"SELECT pg_namespace.nspname, " // 1
"pg_class.relname, " // 2
"pg_attribute.attnotnull, " // 6
"pg_type.typdefault, " // 7
"pg_type.typtype, " // 8
- "pg_attrdef.adsrc, " // 9
- "pg_description.description, " // 10
+ + strDefaultValue + // 9
+ ",pg_description.description, " // 10
"pg_type.typbasetype, " // 11
"pg_attribute.attnum " // 12
"FROM pg_class, "
String2StringMap & result,
const Reference< XConnection > & connection,
const OUString &schemaName,
- const OUString & tableName )
+ const OUString & tableName,
+ ConnectionSettings *pConnectionSettings )
{
+ OUString strDefaultValue = getColExprForDefaultSettingVal(pConnectionSettings);
Reference< XPreparedStatement > stmt = connection->prepareStatement(
- "SELECT pg_attribute.attname, pg_attrdef.adsrc "
+ "SELECT pg_attribute.attname, " + strDefaultValue +
"FROM pg_class, pg_namespace, pg_attribute "
"LEFT JOIN pg_attrdef ON pg_attribute.attrelid = pg_attrdef.adrelid AND "
"pg_attribute.attnum = pg_attrdef.adnum "
// LEM TODO: this is weird; why "LIKE" and not "="?
// Most probably gives problems if tableName contains '%'
"pg_class.relname LIKE ? AND "
- "pg_attrdef.adsrc != ''"
+ + strDefaultValue + " != ''"
);
DisposeGuard guard( stmt );
Reference< XParameters > paras( stmt, UNO_QUERY );
{
if( autoValues.begin() == autoValues.end() )
{
- getAutoValues( autoValues, connection, schemaName, tableName );
+ getAutoValues( autoValues, connection, schemaName, tableName, pConnectionSettings );
}
// this could mean, that the column is a default or auto value, check this ...
bool bColumnMatchAutoValue = false;
}
+OUString getColExprForDefaultSettingVal(ConnectionSettings const *settings)
+{
+ return (PQserverVersion( settings->pConnection ) < 80000)?
+ OUString("pg_attrdef.adsrc"):
+ OUString("pg_get_expr(pg_attrdef.adbin, pg_attrdef.adrelid, true)");
+}
+
css::uno::Sequence< sal_Int32 > string2intarray( const OUString & str )
{
css::uno::Sequence< sal_Int32 > ret;
OUString extractTableFromInsert( const OUString & sql );
OString extractSingleTableFromSelect( const std::vector< OString > &vec );
+OUString getColExprForDefaultSettingVal(ConnectionSettings const *settings);
+
void tokenizeSQL( const OString & sql, std::vector< OString > &vec );
void splitSQL( const OString & sql, std::vector< OString > &vec );
std::vector< sal_Int32 > parseIntArray( const OUString & str );