Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package mysql-xml-to-csv for
openSUSE:Factory checked in at 2024-09-18 15:27:12
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/mysql-xml-to-csv (Old)
and /work/SRC/openSUSE:Factory/.mysql-xml-to-csv.new.29891 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "mysql-xml-to-csv"
Wed Sep 18 15:27:12 2024 rev:2 rq:1201663 version:1.0.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/mysql-xml-to-csv/mysql-xml-to-csv.changes
2021-11-22 23:05:37.897640590 +0100
+++
/work/SRC/openSUSE:Factory/.mysql-xml-to-csv.new.29891/mysql-xml-to-csv.changes
2024-09-18 15:27:55.295437486 +0200
@@ -1,0 +2,8 @@
+Tue Sep 17 17:05:18 UTC 2024 - Archie Cobbs <[email protected]>
+
+- Update to release 1.0.1.
+ + Added "-s" flag to specify alternate column separator
+ + Added "-E" flag to specify output if there are zero rows
+ + Added "-n" flag to specify alternate value for NULL columns
+
+-------------------------------------------------------------------
Old:
----
mysql-xml-to-csv-1.0.0.obscpio
New:
----
mysql-xml-to-csv-1.0.1.obscpio
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ mysql-xml-to-csv.spec ++++++
--- /var/tmp/diff_new_pack.NKodU4/_old 2024-09-18 15:27:56.387482992 +0200
+++ /var/tmp/diff_new_pack.NKodU4/_new 2024-09-18 15:27:56.387482992 +0200
@@ -1,7 +1,7 @@
#
# spec file for package mysql-xml-to-csv
#
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
Name: mysql-xml-to-csv
-Version: 1.0.0
+Version: 1.0.1
Release: 0
Summary: Convert MySQL XML output to CSV
License: Apache-2.0
++++++ _service ++++++
--- /var/tmp/diff_new_pack.NKodU4/_old 2024-09-18 15:27:56.419484325 +0200
+++ /var/tmp/diff_new_pack.NKodU4/_new 2024-09-18 15:27:56.423484492 +0200
@@ -2,8 +2,8 @@
<service mode="localonly" name="obs_scm">
<param name="scm">git</param>
<param
name="url">https://github.com/archiecobbs/mysql-xml-to-csv</param>
- <param name="versionformat">1.0.0</param>
- <param name="revision">1.0.0</param>
+ <param name="versionformat">1.0.1</param>
+ <param name="revision">1.0.1</param>
<param name="filename">mysql-xml-to-csv</param>
</service>
<service mode="buildtime" name="tar"/>
++++++ mysql-xml-to-csv-1.0.0.obscpio -> mysql-xml-to-csv-1.0.1.obscpio ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/mysql-xml-to-csv-1.0.0/CHANGES
new/mysql-xml-to-csv-1.0.1/CHANGES
--- old/mysql-xml-to-csv-1.0.0/CHANGES 2021-09-02 18:54:11.000000000 +0200
+++ new/mysql-xml-to-csv-1.0.1/CHANGES 2024-09-17 18:43:34.000000000 +0200
@@ -1,3 +1,9 @@
+Version 1.0.1 Released September 17, 2024
+
+ - Added "-s" flag to specify alternate column separator
+ - Added "-E" flag to specify output if there are zero rows
+ - Added "-n" flag to specify alternate value for NULL columns
+
Version 1.0.0 Released September 2, 2021
- Initial release
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/mysql-xml-to-csv-1.0.0/Makefile.am
new/mysql-xml-to-csv-1.0.1/Makefile.am
--- old/mysql-xml-to-csv-1.0.0/Makefile.am 2021-09-02 18:54:11.000000000
+0200
+++ new/mysql-xml-to-csv-1.0.1/Makefile.am 2024-09-17 18:43:34.000000000
+0200
@@ -1,7 +1,7 @@
#
# mysql-xml-to-csv - Convert MySQL XML output to CSV
#
-# Copyright (C) 2010-2011 Archie L. Cobbs. All rights reserved.
+# Copyright (C) 2021 Archie L. Cobbs. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@
doc_DATA= CHANGES LICENSE README.md INSTALL AUTHORS
-EXTRA_DIST= CHANGES README.md
+EXTRA_DIST= CHANGES LICENSE README.md
mysql_xml_to_csv_SOURCES= main.c \
gitrev.c
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/mysql-xml-to-csv-1.0.0/README.md
new/mysql-xml-to-csv-1.0.1/README.md
--- old/mysql-xml-to-csv-1.0.0/README.md 2021-09-02 18:54:11.000000000
+0200
+++ new/mysql-xml-to-csv-1.0.1/README.md 2024-09-17 18:43:34.000000000
+0200
@@ -1,2 +1,54 @@
-# mysql-xml-to-csv
-Convert MySQL XML output to CSV
+```
+MYSQL-XML-TO-CSV(1) BSD General Commands Manual
MYSQL-XML-TO-CSV(1)
+
+NAME
+ mysql-xml-to-csv -- Convert MySQL XML output to CSV
+
+SYNOPSIS
+ mysql-xml-to-csv [-E line] [-n value] [-N] [-s separator] [input.xml]
+
+DESCRIPTION
+ mysql-xml-to-csv converts MySQL XML query results (i.e., produced using
the
+ mysql(1) command when given the --xml flag) into a CSV file.
+
+ The XML input is read from input.xml, if specified, otherwise standard
input.
+ The CSV output is written to standard output.
+
+ The first row of the CSV output contains column names unless the -N flag
is
+ given.
+
+ If the query result set contains zero rows, then by default nothing is
output;
+ this behavior can be altered using the -E flag.
+
+ By default NULL column values are converted into the empty string; this
behav-
+ ior can be altered using the -n flag.
+
+ The character encoding used for the CVS output is UTF-8.
+
+OPTIONS
+ -E If the result set contains zero rows, output line followed by a
new-
+ line character instead of outputting nothing. No validation of
line
+ is performed.
+
+ -n Output value instead of the empty string for NULL values.
+
+ -N Do not output the column names in the first row of the output
file.
+
+ -s Specify an alternate column separator (default is comma).
+
+RETURN VALUES
+ mysql-xml-to-csv exits with one of the following values:
+
+ 0 Input was successfully processed.
+
+ 1 An error occurred.
+
+SEE ALSO
+ mysql-xml-to-csv: Convert MySQL XML output to CSV,
+ https://github.com/archiecobbs/mysql-xml-to-csv.
+
+AUTHOR
+ Archie L. Cobbs <[email protected]>
+
+BSD September 16, 2024
BSD
+```
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/mysql-xml-to-csv-1.0.0/configure.ac
new/mysql-xml-to-csv-1.0.1/configure.ac
--- old/mysql-xml-to-csv-1.0.0/configure.ac 2021-09-02 18:54:11.000000000
+0200
+++ new/mysql-xml-to-csv-1.0.1/configure.ac 2024-09-17 18:43:34.000000000
+0200
@@ -16,7 +16,7 @@
# limitations under the License.
#
-AC_INIT([mysql-xml-to-csv Convert MySQL XML output to CSV], [1.0.0],
[https://github.com/archiecobbs/mysql-xml-to-csv/], [mysql-xml-to-csv])
+AC_INIT([mysql-xml-to-csv Convert MySQL XML output to CSV], [1.0.1],
[https://github.com/archiecobbs/mysql-xml-to-csv/], [mysql-xml-to-csv])
AC_CONFIG_AUX_DIR(scripts)
AM_INIT_AUTOMAKE
dnl AM_MAINTAINER_MODE
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/mysql-xml-to-csv-1.0.0/main.c
new/mysql-xml-to-csv-1.0.1/main.c
--- old/mysql-xml-to-csv-1.0.0/main.c 2021-09-02 18:54:11.000000000 +0200
+++ new/mysql-xml-to-csv-1.0.1/main.c 2024-09-17 18:43:34.000000000 +0200
@@ -28,7 +28,8 @@
</resultset>
*/
-#define BUFFER_SIZE (1 << 16)
+#define BUFFER_SIZE (1 << 16)
+#define DEFAULT_COLUMN_SEPARATOR ","
// Version string
extern const char *const mysql_xml_to_csv_version;
@@ -39,20 +40,27 @@
static XML_Char **first_row_values;
static size_t num_first_row_values;
+// Column separator
+static const char *column_separator = DEFAULT_COLUMN_SEPARATOR;
+
// This accumulates one column's value
static XML_Char *elem_text; // note: not nul-terminated
static size_t elem_text_len;
// Flags
-static int first_column;
-static int reading_value;
+static int first_column; // the current column is the
first column
+static int reading_value; // we are reading the current
column's value
+static int num_rows_seen; // the number of rows we have
seen so far
+static int value_is_null; // the current column value is
null
+static const char *null_value; // string to output for null
values (default empty)
// Expat callback functions
-static void handle_elem_start(void *data, const XML_Char *el, const XML_Char
**attr);
-static void handle_elem_text(void *userData, const XML_Char *s, int len);
+static void handle_elem_start(void *data, const XML_Char *el, const XML_Char
**attrs);
+static void handle_elem_text(void *data, const XML_Char *s, int len);
static void handle_elem_end(void *data, const XML_Char *el);
// Helper functions
+static const XML_Char *find_attribute(const XML_Char **const attrs, const char
*name);
static void output_csv_row(XML_Char **values, size_t num);
static void output_csv_text(const char *s, size_t len);
static void add_string(XML_Char ***arrayp, size_t *lengthp, const XML_Char
*string, size_t len);
@@ -65,21 +73,33 @@
main(int argc, char **argv)
{
char buf[BUFFER_SIZE];
- int want_column_names = 1;
+ int want_column_names = 1; // output column names as the
first CSV row
+ const char *empty_output = NULL; // what to print if there are
zero rows
XML_Parser p;
FILE *fp;
size_t r;
int i;
// Parse command line
- while ((i = getopt(argc, argv, "hNv")) != -1) {
+ while ((i = getopt(argc, argv, "E:hn:Ns:v")) != -1) {
switch (i) {
+ case 'E':
+ empty_output = optarg;
+ break;
+ case 'n':
+ null_value = optarg;
+ break;
case 'N':
want_column_names = 0;
break;
case 'h':
usage();
exit(0);
+ case 's':
+ if (*optarg == '\0' || *optarg == '"')
+ errx(1, "invalid separator: %s", optarg);
+ column_separator = optarg;
+ break;
case 'v':
fprintf(stderr, "mysql-xml-to-csv %s\n", mysql_xml_to_csv_version);
fprintf(stderr, "Copyright %s Archie L. Cobbs. All rights
reserved.\n", COPYRIGHT);
@@ -131,6 +151,10 @@
break;
}
+ // Any rows encountered?
+ if (num_rows_seen == 0 && empty_output != NULL)
+ printf("%s\n", empty_output);
+
// Clean up
XML_ParserFree(p);
fclose(fp);
@@ -140,31 +164,56 @@
}
static void
-handle_elem_start(void *data, const XML_Char *name, const XML_Char **attr)
+handle_elem_start(void *data, const XML_Char *name, const XML_Char **attrs)
{
- if (strcmp(name, "row") == 0)
+ const XML_Char *field_name;
+ const XML_Char *nil_status;
+
+ if (strcmp(name, "row") == 0) {
first_column = 1;
- else if (strcmp(name, "field") == 0) {
+ num_rows_seen++;
+ } else if (strcmp(name, "field") == 0) {
if (column_names != NULL) {
- while (*attr != NULL && strcmp(*attr, "name") != 0)
- attr += 2;
- if (*attr == NULL)
- errx(1, "\"field\" element is missing \"name\" attribute");
- add_string(&column_names, &num_column_names, attr[1],
xml_strlen(attr[1]));
+ if ((field_name = find_attribute(attrs, "name")) == NULL)
+ errx(1, "row %d: \"%s\" element is missing \"%s\" attribute",
num_rows_seen, "field", "name");
+ add_string(&column_names, &num_column_names, field_name,
xml_strlen(field_name));
} else {
if (!first_column)
- putchar(',');
+ fputs(column_separator, stdout);
putchar('"');
}
+ value_is_null = (nil_status = find_attribute(attrs, "xsi:nil")) !=
NULL && strcmp(nil_status, "true") == 0;
reading_value = 1;
}
}
+static const XML_Char *
+find_attribute(const XML_Char **attrs, const char *target)
+{
+ const XML_Char *name;
+ const XML_Char *value;
+
+ while (*attrs != NULL) {
+ name = attrs[0];
+ value = attrs[1];
+ if (strcmp(name, target) == 0)
+ return value;
+ attrs += 2;
+ }
+ return NULL;
+}
+
static void
-handle_elem_text(void *userData, const XML_Char *s, int len)
+handle_elem_text(void *data, const XML_Char *s, int len)
{
if (!reading_value)
return;
+ if (value_is_null) {
+// if (len > 0)
+// errx(1, "row %d: non-empty value for field with
xsi:nil=\"true\"", num_rows_seen);
+ if (null_value != NULL)
+ return;
+ }
if (column_names != NULL)
add_chars(&elem_text, &elem_text_len, s, len);
else
@@ -183,6 +232,10 @@
} else
putchar('\n');
} else if (strcmp(name, "field") == 0) {
+ if (value_is_null && null_value != NULL) { // pretend
"null_value" was the text content
+ value_is_null = 0;
+ handle_elem_text(data, null_value, strlen(null_value));
+ }
if (column_names != NULL) {
add_string(&first_row_values, &num_first_row_values, elem_text,
elem_text_len);
free(elem_text);
@@ -202,7 +255,7 @@
for (i = 0; i < num_columns; i++) {
if (i > 0)
- putchar(',');
+ fputs(column_separator, stdout);
putchar('"');
output_csv_text(values[i], xml_strlen(values[i]));
putchar('"');
@@ -273,7 +326,10 @@
{
fprintf(stderr, "Usage: mysql-xml-to-csv [options] [file.xml]\n");
fprintf(stderr, "Options:\n");
- fprintf(stderr, " -N\tDo not output column names as the first row\n");
- fprintf(stderr, " -h\tShow this usage info\n");
- fprintf(stderr, " -v\tShow program version\n");
+ fprintf(stderr, " -E line\tOutput \"line\" if result has zero rows
(default output nothing)\n");
+ fprintf(stderr, " -n value\tOutput \"value\" for NULL values (default
empty string)\n");
+ fprintf(stderr, " -N\t\tDo not output column names as the first CSV
row\n");
+ fprintf(stderr, " -s char\tSpecify column separator (default \"%s\")\n",
DEFAULT_COLUMN_SEPARATOR);
+ fprintf(stderr, " -h\t\tShow this usage info\n");
+ fprintf(stderr, " -v\t\tShow program version\n");
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/mysql-xml-to-csv-1.0.0/mysql-xml-to-csv.1.in
new/mysql-xml-to-csv-1.0.1/mysql-xml-to-csv.1.in
--- old/mysql-xml-to-csv-1.0.0/mysql-xml-to-csv.1.in 2021-09-02
18:54:11.000000000 +0200
+++ new/mysql-xml-to-csv-1.0.1/mysql-xml-to-csv.1.in 2024-09-17
18:43:34.000000000 +0200
@@ -1,6 +1,6 @@
.\" -*- nroff -*-
.\"
-.\" mysql-xml-to-csv - Convers MySQL XML output to CSV
+.\" mysql-xml-to-csv - Convert MySQL XML output to CSV
.\"
.\" Copyright (C) 2021 Archie L. Cobbs. All rights reserved.
.\"
@@ -16,7 +16,7 @@
.\" See the License for the specific language governing permissions and
.\" limitations under the License.
.\"
-.Dd September 2, 2021
+.Dd September 16, 2024
.Dt MYSQL-XML-TO-CSV 1
.Os
.Sh NAME
@@ -24,7 +24,10 @@
.Nd Convert MySQL XML output to CSV
.Sh SYNOPSIS
.Nm mysql-xml-to-csv
+.Op Fl E Ar line
+.Op Fl n Ar value
.Op Fl N
+.Op Fl s Ar separator
.Op Ar input.xml
.Bk -words
.Ek
@@ -45,13 +48,34 @@
.Fl N
flag is given.
.Pp
-Any null values are converted into the empty string.
+If the query result set contains zero rows, then by default nothing is output;
+this behavior can be altered using the
+.Fl E
+flag.
+.Pp
+By default NULL column values are converted into the empty string;
+this behavior can be altered using the
+.Fl n
+flag.
.Pp
The character encoding used for the CVS output is UTF-8.
.Sh OPTIONS
.Bl -tag -width Ds
+.It Fl E
+If the result set contains zero rows, output
+.Ar line
+followed by a newline character instead of outputting nothing.
+No validation of
+.Ar line
+is performed.
+.It Fl n
+Output
+.Ar value
+instead of the empty string for NULL values.
.It Fl N
Do not output the column names in the first row of the output file.
+.It Fl s
+Specify an alternate column separator (default is comma).
.El
.Sh RETURN VALUES
.Nm
++++++ mysql-xml-to-csv.obsinfo ++++++
--- /var/tmp/diff_new_pack.NKodU4/_old 2024-09-18 15:27:56.531488993 +0200
+++ /var/tmp/diff_new_pack.NKodU4/_new 2024-09-18 15:27:56.535489159 +0200
@@ -1,6 +1,5 @@
name: mysql-xml-to-csv
-version: 1.0.0
-mtime: 1630601651
-commit: 51a62e9ff450a4935889df4062d3f1d8e7d45de3
-
+version: 1.0.1
+mtime: 1726591414
+commit: cf85fb504657c7a29663401935aecc2c574074b8