[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - 2 commits - connectivity/source
Lionel Elie Mamane
lionel at mamane.lu
Mon Mar 7 12:44:32 UTC 2016
connectivity/source/drivers/postgresql/pq_databasemetadata.cxx | 81 +++++++++-
1 file changed, 77 insertions(+), 4 deletions(-)
New commits:
commit 43bca025961c4d78082e18efb95f9212b27f964b
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Fri Mar 4 12:38:47 2016 +0100
tdf#92538 pgsql-sdbc make a reasonable sorting of types
Change-Id: I74283234834b5057857620ed2466068e88628585
Reviewed-on: https://gerrit.libreoffice.org/22896
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Stahl <mstahl at redhat.com>
diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
index 2b349db..fcd4847 100644
--- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
@@ -2143,11 +2143,84 @@ struct TypeInfoByDataTypeSorter
OUString nameB;
a[0 /*TYPE_NAME*/] >>= nameA;
b[0 /*TYPE_NAME*/] >>= nameB;
- if( nameA.startsWith( "int4" ) )
+ OUString nsA, tnA, nsB, tnB;
+
+ // parse typename into schema and typename
+ sal_Int32 nIndex=0;
+ nsA = nameA.getToken(0, '.', nIndex);
+ if (nIndex<0)
+ {
+ tnA = nsA;
+ nsA.clear();
+ }
+ else
+ {
+ tnA = nameA.getToken(0, '.', nIndex);
+ assert(nIndex < 0);
+ }
+
+ nIndex=0;
+ nsB = nameB.getToken(0, '.', nIndex);
+ if (nIndex<0)
+ {
+ tnB = nsB;
+ nsB.clear();
+ }
+ else
+ {
+ tnB = nameB.getToken(0, '.', nIndex);
+ assert(nIndex < 0);
+ }
+
+ // sort no schema first, then "public", then normal schemas, then internal schemas
+ if(nsA == nsB)
+ {
+ if(nsA.isEmpty())
+ {
+ assert(nsB.isEmpty());
+ // within each type category, sort privileged choice first
+ if( tnA == "int4" || tnA == "varchar" || tnA == "char" || tnA == "text")
+ return true;
+ if( tnB == "int4" || tnB == "varchar" || tnB == "char" || tnB == "text")
+ return false;
+ }
+ return nameA.compareTo( nameB ) < 0;
+ }
+ else if (nsA.isEmpty())
+ {
+ assert(!nsB.isEmpty());
return true;
- if( nameB.startsWith( "int4" ) )
+ }
+ else if (nsB.isEmpty())
+ {
+ assert(!nsA.isEmpty());
+ return false;
+ }
+ else if(nsA == "public")
+ {
+ assert(nsB != "public");
+ return true;
+ }
+ else if(nsB == "public")
+ {
+ assert(nsA != "public");
return false;
- return nameA.compareTo( nameB ) < 0;
+ }
+ else if(nsA.startsWith("pg_"))
+ {
+ if(nsB.startsWith("pg_"))
+ return nsA.compareTo(nsB) < 0;
+ else
+ return false;
+ }
+ else if(nsB.startsWith("pg_"))
+ {
+ return true;
+ }
+ else
+ {
+ return nsA.compareTo(nsB) < 0;
+ }
}
return valueA.toInt32() < valueB.toInt32();
commit f80bc900eecf2268587e7b7ced5f392a6b1c1c62
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Fri Mar 4 13:22:57 2016 +0100
When not changing the value of a string parameter, use const OUString&,
Change-Id: Id82a62bb437e09137a643c191ad56745daea0e38
Reviewed-on: https://gerrit.libreoffice.org/22895
Reviewed-by: Michael Stahl <mstahl at redhat.com>
Tested-by: Michael Stahl <mstahl at redhat.com>
diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
index 14cb74e..2b349db 100644
--- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
@@ -2194,7 +2194,7 @@ static sal_Int32 getMaxScale( sal_Int32 dataType )
namespace
{
- OUString construct_full_typename(OUString ns, OUString tn)
+ OUString construct_full_typename(const OUString &ns, const OUString &tn)
{
if(ns.isEmpty() || ns == "pg_catalog")
return tn;
More information about the Libreoffice-commits
mailing list