prestogres 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjJjMjIxNzdkNjI5MWVlZjJkNmUzNTUyNWMxMmJmZWZhZmIwZjRkMQ==
4
+ NjQ4NzllNzI0M2I1YTJhZTcyODIzOTlkZDY0YjcyMjI2MWM4MmUxYw==
5
5
  data.tar.gz: !binary |-
6
- MmY0NDlkZjM4N2ZlODg3MjFmNGNiNzcyYmUyMTk2NmQ3NjcxYTlhNQ==
6
+ ODEzZjQzNGE5YTBmOTcxNDhlODlhMmFlNjFmMDJiOTBiMTE1YzZlYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2YyOGIwZjVjNDUwNjFhMzViMjdkYTI5YWIxODhiZTJhZDM2ODA0NjNhNTE1
10
- NTg5YWYzMzE5N2U1ODI2ZTYxOGFjODRmOTQ3OTQ5ZGI0Y2U5YmRmZjhmYWI2
11
- ZTI4Nzk5NDU1MmI5NDc0ZDgwZmJmNjcxYWVhOThlNmM2MzBhMWE=
9
+ OGQwY2I0MDI5NTU3OGFmNzgzZTExM2NhZGNmYjY3YTkzOWU5MDQzM2UzYjZl
10
+ YWE1MTkzOGM1Y2U5MWNhMzhhOGUxN2I4NTA2Njk0YjIzOTdkOTlkNDdmYjM2
11
+ MTAwMTJjMjQ3ZmFiOWRiMjQ5OTVhYzY0YzkyMWU2YjU2OTUwOTQ=
12
12
  data.tar.gz: !binary |-
13
- YzRkOWQ5NjFiNjNlYzg1Y2E5NmQ1ZjE4NzdmYmJhODNjZjVmMTgyMWU0ZjFh
14
- ZmY0YWY0ZmZiZmE0OGM1NzY1YjJmZjMzMDlhZmY2MTc5NzEzMDcwNzQ0YzM1
15
- OGM4MDgwZWNkNzJjMjFlN2ZmY2Q4NmRjZTQwMzkwMTlhODBjYTM=
13
+ ZWVkOWM1MmRkNWU5NjA4ZjZhZTVhYmJlNGZmNmM4N2IzMGMxNzBhYjJkMjNk
14
+ MzJhMGYwZDllMTJhODA4Y2VjOGY2YzJlYzg2YWRjNjkzMTdkNzMyMjMwYjEy
15
+ MmVhMTc1MGEzYjM0NWFiYmU1MTQyMDY2MGI2YjhiNWNhOWYxNWY=
data/ChangeLog CHANGED
@@ -1,4 +1,14 @@
1
1
 
2
+ 2014-06-11 version 0.4.5:
3
+
4
+ * Added prestogres_trust auth method
5
+ * Added support for VARBINARY type introduced by Presto 0.69 by converting it
6
+ to bytea type
7
+ * Added support for date, time and timestamp types with and without time zone
8
+ * Getting table metadata ignores schema, table and column names longer than 63
9
+ (NAMEDATALEN - 1) characters which cause an error in PostgreSQL
10
+
11
+
2
12
  2014-05-12 version 0.4.4:
3
13
 
4
14
  * Send session variable 'timezone' to Presto using X-Presto-Time-Zone HTTP
data/README.md CHANGED
@@ -188,7 +188,7 @@ See [sample pool_hba.conf file](https://github.com/treasure-data/prestogres/blob
188
188
 
189
189
  ```conf
190
190
  # TYPE DATABASE USER CIDR-ADDRESS METHOD OPTIONS
191
- host postgres pg 127.0.0.1/32 trust pg_database:postgres,pg_user:pg
191
+ host postgres pg 127.0.0.1/32 prestogres_trust pg_database:postgres,pg_user:pg
192
192
  host postgres pg 127.0.0.1/32,192.168.0.0/16 prestogres_md5 pg_database:postgres,pg_user:pg
193
193
  host altdb pg 0.0.0.0/0 prestogres_md5 pg_database:postgres,pg_user:pg,server:localhost:8190,
194
194
  host all all 0.0.0.0/0 prestogres_external pg_database:postgres,pg_user:pg,auth_prog:/opt/prestogres/auth.py
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.4
1
+ 0.4.5
@@ -39,20 +39,17 @@ socket_dir = '<%= @config[:unix_socket_directory] %>'
39
39
 
40
40
  # - Presto Settings -
41
41
  presto_server = 'localhost:8080'
42
- # Address of Presto server.
43
- # You can overwrite this parameter depending
44
- # on user, database, or client address using
45
- # pool_hba.conf.
46
- presto_catalog = 'native'
47
- # Catalog name of Presto.
48
- # You can overwrite this parameter depending
49
- # on user, database, or client address using
50
- # pool_hba.conf.
42
+ # Address of the Presto server.
43
+ # You can overwrite this parameter per user,
44
+ # database, or client address in pool_hba.conf.
45
+ presto_catalog = 'tpch'
46
+ # Catalog name of Presto to query.
47
+ # You can overwrite this parameter per user,
48
+ # database, or client address in pool_hba.conf.
51
49
  presto_schema = 'default'
52
50
  # Default schema name of Presto.
53
- # You can overwrite this parameter depending
54
- # on user, database, or client address using
55
- # pool_hba.conf.
51
+ # You can overwrite this parameter per user,
52
+ # database, or client address in pool_hba.conf.
56
53
 
57
54
  # - pgpool Communication Manager Connection Settings -
58
55
 
@@ -60,20 +60,20 @@
60
60
  # TYPE DATABASE USER CIDR-ADDRESS METHOD OPTIONS
61
61
 
62
62
  # "local" is for Unix domain socket connections only
63
- local all all trust
63
+ local all all prestogres_trust pg_database:postgres
64
64
 
65
65
  # IPv4 local connections:
66
- host all all 127.0.0.1/32 trust
66
+ host all all 127.0.0.1/32 prestogres_trust pg_database:postgres
67
67
 
68
68
 
69
69
  # Examples
70
70
  # ----------------------------------
71
71
  #
72
72
  ## Trust all connection from localhost:
73
- #host all all 127.0.0.1/32 trust
73
+ #host all all 127.0.0.1/32 prestogres_trust pg_database:postgres
74
74
  #
75
75
  ## MD5 authorization using pool_passwd file:
76
- #host all all 0.0.0.0/0 prestogres_md5
76
+ #host all all 0.0.0.0/0 prestogres_md5 pg_database:postgres
77
77
  #
78
78
  ## MD5 authorization and overwrites presto_server and
79
79
  ## presto_catalog parameters in pgpool.config:
@@ -77,6 +77,7 @@ const char* presto_external_auth_prog = NULL;
77
77
 
78
78
  static bool prestogres_hba_set_session_info(POOL_CONNECTION *frontend, const char* key, const char* value);
79
79
  static void prestogres_hba_parse_arg(POOL_CONNECTION *frontend, const char* arg);
80
+ static POOL_STATUS pool_prestogres_hba_auth_trust(POOL_CONNECTION *frontend);
80
81
  static POOL_STATUS pool_prestogres_hba_auth_md5(POOL_CONNECTION *frontend);
81
82
  static POOL_STATUS pool_prestogres_hba_auth_external(POOL_CONNECTION *frontend);
82
83
 
@@ -252,6 +253,9 @@ void ClientAuthentication(POOL_CONNECTION *frontend)
252
253
  status = CheckPAMAuth(frontend, frontend->username, "");
253
254
  break;
254
255
  #endif /* USE_PAM */
256
+ case uaPrestogresTrust:
257
+ status = pool_prestogres_hba_auth_trust(frontend);
258
+ break;
255
259
  case uaPrestogresMD5:
256
260
  status = pool_prestogres_hba_auth_md5(frontend);
257
261
  break;
@@ -430,6 +434,11 @@ static void auth_failed(POOL_CONNECTION *frontend)
430
434
  frontend->username);
431
435
  break;
432
436
  #endif /* USE_PAM */
437
+ case uaPrestogresTrust:
438
+ snprintf(errmessage, messagelen,
439
+ "\"trust\" authentication with pgpool failed for user \"%s\"",
440
+ frontend->username);
441
+ break;
433
442
  case uaPrestogresMD5:
434
443
  snprintf(errmessage, messagelen,
435
444
  "\"MD5\" authentication with pgpool failed for user \"%s\"",
@@ -840,6 +849,8 @@ static void parse_hba_auth(ListCell **line_item, UserAuth *userauth_p,
840
849
  else if (strcmp(token, "pam") == 0)
841
850
  *userauth_p = uaPAM;
842
851
  #endif /* USE_PAM */
852
+ else if (strcmp(token, "prestogres_trust") == 0)
853
+ *userauth_p = uaPrestogresTrust;
843
854
  else if (strcmp(token, "prestogres_md5") == 0)
844
855
  *userauth_p = uaPrestogresMD5;
845
856
  else if (strcmp(token, "prestogres_external") == 0)
@@ -1551,6 +1562,13 @@ static void prestogres_hba_parse_arg(POOL_CONNECTION *frontend, const char* arg)
1551
1562
  }
1552
1563
  }
1553
1564
 
1565
+ static POOL_STATUS pool_prestogres_hba_auth_trust(POOL_CONNECTION *frontend)
1566
+ {
1567
+ prestogres_hba_parse_arg(frontend, frontend->auth_arg);
1568
+
1569
+ return POOL_CONTINUE;
1570
+ }
1571
+
1554
1572
  static POOL_STATUS pool_prestogres_hba_auth_md5(POOL_CONNECTION *frontend)
1555
1573
  {
1556
1574
  char *pool_passwd = NULL;
@@ -152,6 +152,7 @@ typedef enum UserAuth
152
152
  #ifdef USE_PAM
153
153
  ,uaPAM
154
154
  #endif /* USE_PAM */
155
+ ,uaPrestogresTrust
155
156
  ,uaPrestogresMD5
156
157
  ,uaPrestogresExternal
157
158
  }
@@ -3,31 +3,33 @@ import presto_client
3
3
  from collections import namedtuple
4
4
  import time
5
5
 
6
- # convert Presto query result type to PostgreSQL type
6
+ # Maximum length for identifiers (e.g. table names, column names, function names)
7
+ # defined in pg_config_manual.h
8
+ PG_NAMEDATALEN = 64
9
+
10
+ # convert Presto query result field types to PostgreSQL types
7
11
  def _pg_result_type(presto_type):
8
12
  if presto_type == "varchar":
9
13
  return "varchar(255)"
10
- elif presto_type == "bigint":
11
- return "bigint"
12
- elif presto_type == "boolean":
13
- return "boolean"
14
+ if presto_type == "varbinary":
15
+ return "bytea"
14
16
  elif presto_type == "double":
15
17
  return "double precision"
16
18
  else:
17
- raise Exception, "unknown result column type: " + plpy.quote_ident(presto_type)
19
+ # assuming Presto and PostgreSQL use the same SQL standard name
20
+ return presto_type
18
21
 
19
- # convert Presto type to PostgreSQL type
22
+ # convert Presto table column types to PostgreSQL types
20
23
  def _pg_table_type(presto_type):
21
24
  if presto_type == "varchar":
22
25
  return "varchar(255)"
23
- elif presto_type == "bigint":
24
- return "bigint"
25
- elif presto_type == "boolean":
26
- return "boolean"
26
+ if presto_type == "varbinary":
27
+ return "bytea"
27
28
  elif presto_type == "double":
28
29
  return "double precision"
29
30
  else:
30
- raise Exception("unknown table column type: " + plpy.quote_ident(presto_type))
31
+ # assuming Presto and PostgreSQL use the same SQL standard name
32
+ return presto_type
31
33
 
32
34
  # build CREATE TEMPORARY TABLE statement
33
35
  def _build_create_temp_table_sql(table_name, column_names, column_types):
@@ -238,8 +240,26 @@ def run_system_catalog_as_temp_table(server, user, catalog, schema, result_table
238
240
  is_nullable = row[3]
239
241
  column_type = row[4]
240
242
 
243
+ if len(schema_name) > PG_NAMEDATALEN - 1:
244
+ plpy.warning("Schema %s is skipped because its name is longer than %d characters" % \
245
+ (plpy.quote_ident(schema_name), PG_NAMEDATALEN - 1))
246
+ continue
247
+
241
248
  tables = schemas.setdefault(schema_name, {})
249
+
250
+ if len(table_name) > PG_NAMEDATALEN - 1:
251
+ plpy.warning("Table %s.%s is skipped because its name is longer than %d characters" % \
252
+ (plpy.quote_ident(schema_name), plpy.quote_ident(table_name), PG_NAMEDATALEN - 1))
253
+ continue
254
+
242
255
  columns = tables.setdefault(table_name, [])
256
+
257
+ if len(column_name) > PG_NAMEDATALEN - 1:
258
+ plpy.warning("Column %s.%s.%s is skipped because its name is longer than %d characters" % \
259
+ (plpy.quote_ident(schema_name), plpy.quote_ident(table_name), \
260
+ plpy.quote_ident(column_name), PG_NAMEDATALEN - 1))
261
+ continue
262
+
243
263
  columns.append(Column(column_name, column_type, is_nullable))
244
264
 
245
265
  # generate SQL statements
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prestogres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-12 00:00:00.000000000 Z
11
+ date: 2014-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler