[libgda: 4/7] PostgreSQL: Improving CREATE INDEX
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda: 4/7] PostgreSQL: Improving CREATE INDEX
- Date: Thu, 19 Mar 2020 14:56:36 +0000 (UTC)
commit c32b9f6e07da6b586ce2ff942c433a79c3f3ed52
Author: Pavlo Solntsev <p sun fun gmail com>
Date: Sat Mar 7 23:48:10 2020 -0600
PostgreSQL: Improving CREATE INDEX
IFNOTEXISTS, COLLATE, and SORTORDER added
providers/postgres/gda-postgres-ddl.c | 20 +++++++++++++++++++-
.../postgres/postgres_specs_create_index.xml.in | 19 +++++++++++++++++++
2 files changed, 38 insertions(+), 1 deletion(-)
---
diff --git a/providers/postgres/gda-postgres-ddl.c b/providers/postgres/gda-postgres-ddl.c
index 2ffb94244..c55453adc 100644
--- a/providers/postgres/gda-postgres-ddl.c
+++ b/providers/postgres/gda-postgres-ddl.c
@@ -207,7 +207,7 @@ gda_postgres_render_CREATE_TABLE (GdaServerProvider *provider, GdaConnection *cn
g_string_append (string, " DEFAULT ");
const gchar* valtmp = g_value_get_string (value1);
if (!g_ascii_strcasecmp (valtmp,"string") ||
- !g_ascii_strcasecmp (valtmp,"gchararray")) {
+ !g_ascii_strcasecmp (valtmp,"varchar")) {
g_string_append_c (string,'\'');
g_string_append (string, str);
g_string_append_c (string,'\'');
@@ -678,6 +678,24 @@ gda_postgres_render_CREATE_INDEX (GdaServerProvider *provider, GdaConnection *cn
g_string_append (string, ", ");
g_string_append (string, tmp);
g_free (tmp);
+
+ value = gda_server_operation_get_value_at (op, "/INDEX_FIELDS_S/%d/INDEX_COLLATE", i);
+ if (value && G_VALUE_HOLDS (value, G_TYPE_STRING)) {
+ const gchar *str = g_value_get_string (value);
+ if (str && *str) {
+ g_string_append (string, " COLLATE ");
+ g_string_append (string, str);
+ }
+ }
+
+ value = gda_server_operation_get_value_at (op, "/INDEX_FIELDS_S/%d/INDEX_SORT_ORDER",
i);
+ if (value && G_VALUE_HOLDS (value, G_TYPE_STRING)) {
+ const gchar *str = g_value_get_string (value);
+ if (str && *str) {
+ g_string_append_c (string, ' ');
+ g_string_append (string, str);
+ }
+ }
}
else {
g_string_free (string, TRUE);
diff --git a/providers/postgres/postgres_specs_create_index.xml.in
b/providers/postgres/postgres_specs_create_index.xml.in
index 070e98663..434b02a6b 100644
--- a/providers/postgres/postgres_specs_create_index.xml.in
+++ b/providers/postgres/postgres_specs_create_index.xml.in
@@ -9,6 +9,9 @@
<parameter id="INDEX_METHOD" _name="Method" gdatype="gchararray" nullok="TRUE" source="method:0"/>
<parameter id="INDEX_TABLESPACE" _name="Tablespace" gdatype="gchararray" nullok="TRUE"/>
<parameter id="INDEX_PREDICATE" _name="Predicate" _descr="Constraint expression for a partial index"
gdatype="gchararray" nullok="TRUE"/>
+ <parameter id="INDEX_IFNOTEXISTS" _name="Only if it does not yet exist" _descr="Create index only if it
does not yet exist" gdatype="gboolean" nullok="TRUE">
+ <gda_value>FALSE</gda_value>
+ </parameter>
</parameters>
<!-- Index fields -->
@@ -16,6 +19,8 @@
<parameter id="INDEX_FIELD" _name="Indexed field or expression" gdatype="gchararray" nullok="FALSE"
source="_INDEX_ON_TABLE/DICT_FIELDS_">
<gda_value>indexed_field</gda_value>
</parameter>
+ <parameter id="INDEX_COLLATE" _name="Compare method" _descr="Collation name" gdatype="gchararray"
nullok="TRUE"/>
+ <parameter id="INDEX_SORT_ORDER" _name="Sort type" gdatype="gchararray" nullok="TRUE" source="sort:0"/>
</sequence>
<!-- Sources -->
@@ -57,5 +62,19 @@
</gda_array_row>
</gda_array_data>
</gda_array>
+ <gda_array name="sort">
+ <gda_array_field name="id" gdatype="gchararray" nullok="FALSE"/>
+ <gda_array_field name="text" gdatype="gchararray" nullok="FALSE"/>
+ <gda_array_data>
+ <gda_array_row>
+ <gda_value>ASC</gda_value>
+ <gda_value>Ascending</gda_value>
+ </gda_array_row>
+ <gda_array_row>
+ <gda_value>DESC</gda_value>
+ <gda_value>Descending</gda_value>
+ </gda_array_row>
+ </gda_array_data>
+ </gda_array>
</sources>
</serv_op>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]